1
Fork 0

Use Session::diagnostic in more places.

This commit is contained in:
Nicholas Nethercote 2023-12-01 13:45:29 +11:00
parent a179a53565
commit 31ac4efb31
7 changed files with 33 additions and 40 deletions

View file

@ -444,11 +444,7 @@ impl<'a> Parser<'a> {
None
};
if let Some(err) = err {
Err(err.into_diagnostic(&self.sess.span_diagnostic))
} else {
Ok(())
}
if let Some(err) = err { Err(err.into_diagnostic(self.diagnostic())) } else { Ok(()) }
}
fn parse_item_builtin(&mut self) -> PResult<'a, Option<ItemInfo>> {
@ -1382,8 +1378,7 @@ impl<'a> Parser<'a> {
let span = self.prev_token.span.shrink_to_hi();
let err: DiagnosticBuilder<'_, ErrorGuaranteed> =
errors::MissingConstType { span, colon, kind }
.into_diagnostic(&self.sess.span_diagnostic);
errors::MissingConstType { span, colon, kind }.into_diagnostic(self.diagnostic());
err.stash(span, StashKey::ItemNoType);
// The user intended that the type be inferred,
@ -1400,7 +1395,7 @@ impl<'a> Parser<'a> {
self.bump();
self.sess.emit_err(err);
} else {
return Err(err.into_diagnostic(&self.sess.span_diagnostic));
return Err(err.into_diagnostic(self.diagnostic()));
}
}
@ -1600,7 +1595,7 @@ impl<'a> Parser<'a> {
} else {
let err =
errors::UnexpectedTokenAfterStructName::new(self.token.span, self.token.clone());
return Err(err.into_diagnostic(&self.sess.span_diagnostic));
return Err(err.into_diagnostic(self.diagnostic()));
};
Ok((class_name, ItemKind::Struct(vdata, generics)))
@ -1796,7 +1791,7 @@ impl<'a> Parser<'a> {
let sp = previous_span.shrink_to_hi();
err.missing_comma = Some(sp);
}
return Err(err.into_diagnostic(&self.sess.span_diagnostic));
return Err(err.into_diagnostic(self.diagnostic()));
}
}
_ => {
@ -1846,7 +1841,7 @@ impl<'a> Parser<'a> {
// Make sure an error was emitted (either by recovering an angle bracket,
// or by finding an identifier as the next token), since we're
// going to continue parsing
assert!(self.sess.span_diagnostic.has_errors().is_some());
assert!(self.diagnostic().has_errors().is_some());
} else {
return Err(err);
}