1
Fork 0

Remove ParseSess methods that duplicate DiagCtxt methods.

Also add missing `#[track_caller]` attributes to `DiagCtxt` methods as
necessary to keep tests working.
This commit is contained in:
Nicholas Nethercote 2023-12-18 21:14:02 +11:00
parent ec9af0d6cb
commit d51db05d7e
22 changed files with 256 additions and 308 deletions

View file

@ -176,7 +176,7 @@ impl<'a> Parser<'a> {
if this.eat_keyword_noexpect(kw::SelfUpper) {
// `Self` as a generic param is invalid. Here we emit the diagnostic and continue parsing
// as if `Self` never existed.
this.sess.emit_err(UnexpectedSelfInGenericParameters {
this.dcx().emit_err(UnexpectedSelfInGenericParameters {
span: this.prev_token.span,
});
@ -200,7 +200,7 @@ impl<'a> Parser<'a> {
this.bump(); // `=`
this.bump(); // `'lifetime`
let span = lo.to(this.prev_token.span);
this.sess.emit_err(
this.dcx().emit_err(
UnexpectedDefaultValueForLifetimeInGenericParameters { span },
);
}
@ -225,7 +225,7 @@ impl<'a> Parser<'a> {
let snapshot = this.create_snapshot_for_diagnostic();
match this.parse_ty_where_predicate() {
Ok(where_predicate) => {
this.sess.emit_err(errors::BadAssocTypeBounds {
this.dcx().emit_err(errors::BadAssocTypeBounds {
span: where_predicate.span(),
});
// FIXME - try to continue parsing other generics?
@ -242,10 +242,10 @@ impl<'a> Parser<'a> {
// Check for trailing attributes and stop parsing.
if !attrs.is_empty() {
if !params.is_empty() {
this.sess
this.dcx()
.emit_err(errors::AttrAfterGeneric { span: attrs[0].span });
} else {
this.sess
this.dcx()
.emit_err(errors::AttrWithoutGenerics { span: attrs[0].span });
}
}
@ -334,7 +334,7 @@ impl<'a> Parser<'a> {
// change we parse those generics now, but report an error.
if self.choose_generics_over_qpath(0) {
let generics = self.parse_generics()?;
self.sess.emit_err(errors::WhereOnGenerics { span: generics.span });
self.dcx().emit_err(errors::WhereOnGenerics { span: generics.span });
}
loop {
@ -370,7 +370,7 @@ impl<'a> Parser<'a> {
let ate_comma = self.eat(&token::Comma);
if self.eat_keyword_noexpect(kw::Where) {
self.sess.emit_err(MultipleWhereClauses {
self.dcx().emit_err(MultipleWhereClauses {
span: self.token.span,
previous: pred_lo,
between: prev_token.shrink_to_hi().to(self.prev_token.span),
@ -422,7 +422,7 @@ impl<'a> Parser<'a> {
let body_sp = pred_lo.to(snapshot.prev_token.span);
let map = self.sess.source_map();
self.sess.emit_err(WhereClauseBeforeTupleStructBody {
self.dcx().emit_err(WhereClauseBeforeTupleStructBody {
span: where_sp,
name: struct_name.span,
body: body_sp,