Improve span handling in parse_expr_bottom.
`parse_expr_bottom` stores `this.token.span` in `lo`, but then fails to use it in many places where it could. This commit fixes that, and likewise (to a smaller extent) in `parse_ty_common`.
This commit is contained in:
@@ -274,7 +274,6 @@ impl<'a> Parser<'a> {
|
||||
// Function pointer type
|
||||
self.parse_ty_bare_fn(lo, ThinVec::new(), None, recover_return_sign)?
|
||||
} else if self.check_keyword(kw::For) {
|
||||
let for_span = self.token.span;
|
||||
// Function pointer type or bound list (trait object type) starting with a poly-trait.
|
||||
// `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
|
||||
// `for<'lt> Trait1<'lt> + Trait2 + 'a`
|
||||
@@ -302,7 +301,7 @@ impl<'a> Parser<'a> {
|
||||
kw: kw.name.as_str(),
|
||||
sugg: errors::TransposeDynOrImplSugg {
|
||||
removal_span,
|
||||
insertion_span: for_span.shrink_to_lo(),
|
||||
insertion_span: lo.shrink_to_lo(),
|
||||
kw: kw.name.as_str(),
|
||||
},
|
||||
});
|
||||
@@ -345,16 +344,14 @@ impl<'a> Parser<'a> {
|
||||
// FIXME(c_variadic): Should we just allow `...` syntactically
|
||||
// anywhere in a type and use semantic restrictions instead?
|
||||
// NOTE: This may regress certain MBE calls if done incorrectly.
|
||||
let guar = self
|
||||
.dcx()
|
||||
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
|
||||
let guar = self.dcx().emit_err(NestedCVariadicType { span: lo });
|
||||
TyKind::Err(guar)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let msg = format!("expected type, found {}", super::token_descr(&self.token));
|
||||
let mut err = self.dcx().struct_span_err(self.token.span, msg);
|
||||
err.span_label(self.token.span, "expected type");
|
||||
let mut err = self.dcx().struct_span_err(lo, msg);
|
||||
err.span_label(lo, "expected type");
|
||||
return Err(err);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user