/// Cancel the diagnostic (a structured diagnostic must either be emitted or
/// canceled or it will panic when dropped).
- /// BEWARE: if this DiagnosticBuilder is an error, then creating it will
- /// bump the error count on the Handler and canceling it won't undo that.
- /// If you want to decrement the error count you should use `Handler::cancel`.
pub fn cancel(&mut self) {
self.level = Level::Cancelled;
}
return;
}
- let is_error = match self.level {
+ self.handler.emit_db(&self);
+ self.cancel();
+ }
+
+ pub fn is_error(&self) -> bool {
+ match self.level {
Level::Bug |
Level::Fatal |
Level::PhaseFatal |
Level::Cancelled => {
false
}
- };
-
- self.handler.emit_db(&self);
- self.cancel();
-
- if is_error {
- self.handler.bump_err_count();
}
-
- // if self.is_fatal() {
- // panic!(FatalError);
- // }
}
/// Convenience function for internal use, clients should use one of the
// one:
if self.emitted_diagnostics.borrow_mut().insert(diagnostic_hash) {
self.emitter.borrow_mut().emit(db);
+ if db.is_error() {
+ self.bump_err_count();
+ }
}
}
}
35 | #[rustc_deprecated = "1500"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 9 previous errors
+error: aborting due to 8 previous errors
35 | #[stable = "1300"] impl S { }
| ^^^^^^^^^^^^^^^^^^
-error: aborting due to 9 previous errors
+error: aborting due to 8 previous errors
35 | #[unstable = "1200"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 9 previous errors
+error: aborting due to 8 previous errors
14 | }
| - immutable borrow ends here
-error: aborting due to 2 previous errors
+error: aborting due to previous error
20 | m!(MyTrait<>); //~ ERROR generic arguments in macro path
| ^^
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors