We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
DiagnosticBuilder::into_diagnostic
1 parent 4e1c5f0 commit fff19a0Copy full SHA for fff19a0
src/librustc_errors/diagnostic_builder.rs
@@ -132,12 +132,11 @@ impl<'a> DiagnosticBuilder<'a> {
132
133
let handler = self.0.handler;
134
135
- // We need to use `ptr::read` because `DiagnosticBuilder` implements `Drop`.
136
- let diagnostic;
137
- unsafe {
138
- diagnostic = std::ptr::read(&self.0.diagnostic);
139
- std::mem::forget(self);
140
- };
+ // We must use `Level::Cancelled` for `dummy` to avoid an ICE about an
+ // unused diagnostic.
+ let dummy = Diagnostic::new(Level::Cancelled, "");
+ let diagnostic = std::mem::replace(&mut self.0.diagnostic, dummy);
+
141
// Logging here is useful to help track down where in logs an error was
142
// actually emitted.
143
debug!("buffer: diagnostic={:?}", diagnostic);
0 commit comments