rustc_error: make ErrorReported impossible to construct

There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.
This commit is contained in:
mark 2022-01-22 18:49:12 -06:00
parent 461e807801
commit bb8d4307eb
104 changed files with 705 additions and 550 deletions

View file

@ -16,7 +16,7 @@ pub(crate) fn parse_lazy_static(
($method:ident $(,)* $($arg:expr),* $(,)*) => {
match parser.$method($($arg,)*) {
Ok(val) => {
if parser.sess.span_diagnostic.has_errors() {
if parser.sess.span_diagnostic.has_errors().is_some() {
parser.sess.span_diagnostic.reset_err_count();
return None;
} else {

View file

@ -28,7 +28,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
let mut cloned_parser = (*parser).clone();
match $parser(&mut cloned_parser) {
Ok(x) => {
if parser.sess.span_diagnostic.has_errors() {
if parser.sess.span_diagnostic.has_errors().is_some() {
parser.sess.span_diagnostic.reset_err_count();
} else {
// Parsing succeeded.

View file

@ -235,7 +235,7 @@ impl ParseSess {
}
pub(super) fn has_errors(&self) -> bool {
self.parse_sess.span_diagnostic.has_errors()
self.parse_sess.span_diagnostic.has_errors().is_some()
}
pub(super) fn reset_errors(&self) {