1
Fork 0

rustc_errors: take self by value in DiagnosticBuilder::cancel.

This commit is contained in:
Eduard-Mihai Burtescu 2022-01-26 03:39:14 +00:00
parent 8562d6b752
commit 0b9d70cf6d
31 changed files with 176 additions and 146 deletions

View file

@ -1114,7 +1114,7 @@ impl<'a> Parser<'a> {
// Only try to recover if this is implementing a trait for a type
let mut impl_info = match self.parse_item_impl(attrs, defaultness) {
Ok(impl_info) => impl_info,
Err(mut recovery_error) => {
Err(recovery_error) => {
// Recovery failed, raise the "expected identifier" error
recovery_error.cancel();
return Err(err);
@ -1476,7 +1476,9 @@ impl<'a> Parser<'a> {
// after the comma
self.eat(&token::Comma);
// `check_trailing_angle_brackets` already emitted a nicer error
err.cancel();
// NOTE(eddyb) this was `.cancel()`, but `err`
// gets returned, so we can't fully defuse it.
err.downgrade_to_delayed_bug();
}
}
}
@ -2073,7 +2075,7 @@ impl<'a> Parser<'a> {
if let Ok(snippet) = self.span_to_snippet(sp) {
let current_vis = match self.parse_visibility(FollowedByType::No) {
Ok(v) => v,
Err(mut d) => {
Err(d) => {
d.cancel();
return Err(err);
}
@ -2216,7 +2218,7 @@ impl<'a> Parser<'a> {
// If this is a C-variadic argument and we hit an error, return the error.
Err(err) if this.token == token::DotDotDot => return Err(err),
// Recover from attempting to parse the argument as a type without pattern.
Err(mut err) => {
Err(err) => {
err.cancel();
*this = parser_snapshot_before_ty;
this.recover_arg_parse()?
@ -2358,7 +2360,7 @@ impl<'a> Parser<'a> {
match self
.parse_outer_attributes()
.and_then(|_| self.parse_self_param())
.map_err(|mut e| e.cancel())
.map_err(|e| e.cancel())
{
Ok(Some(_)) => "method",
_ => "function",