We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9dc8dad + 99a595e commit 017a682Copy full SHA for 017a682
src/librustc_errors/diagnostic_builder.rs
@@ -136,12 +136,11 @@ impl<'a> DiagnosticBuilder<'a> {
136
137
let handler = self.0.handler;
138
139
- // We need to use `ptr::read` because `DiagnosticBuilder` implements `Drop`.
140
- let diagnostic;
141
- unsafe {
142
- diagnostic = std::ptr::read(&self.0.diagnostic);
143
- std::mem::forget(self);
144
- };
+ // 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);
+
145
// Logging here is useful to help track down where in logs an error was
146
// actually emitted.
147
debug!("buffer: diagnostic={:?}", diagnostic);
0 commit comments