delay the bug once again, generalize turbofish suggestion
This commit is contained in:
parent
a090bb1dea
commit
37bed05986
@ -731,28 +731,22 @@ impl<'a> Parser<'a> {
|
|||||||
match x {
|
match x {
|
||||||
Ok((_, _, false)) => {
|
Ok((_, _, false)) => {
|
||||||
if self.eat(&token::Gt) {
|
if self.eat(&token::Gt) {
|
||||||
let turbo_err = e.span_suggestion_verbose(
|
e.span_suggestion_verbose(
|
||||||
binop.span.shrink_to_lo(),
|
binop.span.shrink_to_lo(),
|
||||||
TURBOFISH_SUGGESTION_STR,
|
TURBOFISH_SUGGESTION_STR,
|
||||||
"::".to_string(),
|
"::".to_string(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
)
|
||||||
if matches!(self.token.kind, token::Semi | token::CloseDelim(_)) {
|
.emit();
|
||||||
turbo_err.emit();
|
match self.parse_expr() {
|
||||||
*expr = self.mk_expr_err(expr.span);
|
Ok(_) => {
|
||||||
return Ok(());
|
*expr =
|
||||||
} else {
|
self.mk_expr_err(expr.span.to(self.prev_token.span));
|
||||||
match self.parse_expr() {
|
return Ok(());
|
||||||
Ok(_) => {
|
}
|
||||||
turbo_err.emit();
|
Err(mut err) => {
|
||||||
*expr = self
|
*expr = self.mk_expr_err(expr.span);
|
||||||
.mk_expr_err(expr.span.to(self.prev_token.span));
|
err.cancel();
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
Err(mut err) => {
|
|
||||||
turbo_err.cancel();
|
|
||||||
err.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1448,8 +1448,6 @@ impl<'a> Parser<'a> {
|
|||||||
let lo = label.ident.span;
|
let lo = label.ident.span;
|
||||||
let label = Some(label);
|
let label = Some(label);
|
||||||
let ate_colon = self.eat(&token::Colon);
|
let ate_colon = self.eat(&token::Colon);
|
||||||
let msg = "expected `while`, `for`, `loop` or `{` after a label";
|
|
||||||
|
|
||||||
let expr = if self.eat_keyword(kw::While) {
|
let expr = if self.eat_keyword(kw::While) {
|
||||||
self.parse_while_expr(label, lo, attrs)
|
self.parse_while_expr(label, lo, attrs)
|
||||||
} else if self.eat_keyword(kw::For) {
|
} else if self.eat_keyword(kw::For) {
|
||||||
@ -1459,12 +1457,13 @@ impl<'a> Parser<'a> {
|
|||||||
} else if self.check(&token::OpenDelim(token::Brace)) || self.token.is_whole_block() {
|
} else if self.check(&token::OpenDelim(token::Brace)) || self.token.is_whole_block() {
|
||||||
self.parse_block_expr(label, lo, BlockCheckMode::Default, attrs)
|
self.parse_block_expr(label, lo, BlockCheckMode::Default, attrs)
|
||||||
} else if !ate_colon && (self.check(&TokenKind::Comma) || self.check(&TokenKind::Gt)) {
|
} else if !ate_colon && (self.check(&TokenKind::Comma) || self.check(&TokenKind::Gt)) {
|
||||||
self.struct_span_err(self.token.span, msg).span_label(self.token.span, msg).emit();
|
|
||||||
// We're probably inside of a `Path<'a>` that needs a turbofish, so suppress the
|
// We're probably inside of a `Path<'a>` that needs a turbofish, so suppress the
|
||||||
// "must be followed by a colon" error.
|
// "must be followed by a colon" error, and the "expected one of" error.
|
||||||
|
self.diagnostic().delay_span_bug(lo, "this label wasn't parsed correctly");
|
||||||
consume_colon = false;
|
consume_colon = false;
|
||||||
Ok(self.mk_expr_err(lo))
|
Ok(self.mk_expr_err(lo))
|
||||||
} else {
|
} else {
|
||||||
|
let msg = "expected `while`, `for`, `loop` or `{` after a label";
|
||||||
self.struct_span_err(self.token.span, msg).span_label(self.token.span, msg).emit();
|
self.struct_span_err(self.token.span, msg).span_label(self.token.span, msg).emit();
|
||||||
// Continue as an expression in an effort to recover on `'label: non_block_expr`.
|
// Continue as an expression in an effort to recover on `'label: non_block_expr`.
|
||||||
self.parse_expr()
|
self.parse_expr()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
f<'a,>
|
f<'a,>
|
||||||
//~^ ERROR expected
|
//~^ ERROR expected
|
||||||
//~| ERROR expected
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
error: expected `while`, `for`, `loop` or `{` after a label
|
|
||||||
--> $DIR/issue-93282.rs:2:9
|
|
||||||
|
|
|
||||||
LL | f<'a,>
|
|
||||||
| ^ expected `while`, `for`, `loop` or `{` after a label
|
|
||||||
|
|
||||||
error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `{`, `}`, or an operator, found `,`
|
error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `{`, `}`, or an operator, found `,`
|
||||||
--> $DIR/issue-93282.rs:2:9
|
--> $DIR/issue-93282.rs:2:9
|
||||||
|
|
|
|
||||||
@ -15,5 +9,5 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum
|
|||||||
LL | f::<'a,>
|
LL | f::<'a,>
|
||||||
| ++
|
| ++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -21,12 +21,10 @@ fn main() {
|
|||||||
|
|
||||||
let _ = f<'_, i8>();
|
let _ = f<'_, i8>();
|
||||||
//~^ ERROR expected one of
|
//~^ ERROR expected one of
|
||||||
//~| ERROR expected
|
|
||||||
//~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
//~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
||||||
|
|
||||||
f<'_>();
|
f<'_>();
|
||||||
//~^ comparison operators cannot be chained
|
//~^ comparison operators cannot be chained
|
||||||
//~| ERROR expected
|
|
||||||
//~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
//~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
||||||
|
|
||||||
let _ = f<u8>;
|
let _ = f<u8>;
|
||||||
|
@ -53,12 +53,6 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum
|
|||||||
LL | let _ = f::<u8, i8>();
|
LL | let _ = f::<u8, i8>();
|
||||||
| ++
|
| ++
|
||||||
|
|
||||||
error: expected `while`, `for`, `loop` or `{` after a label
|
|
||||||
--> $DIR/require-parens-for-chained-comparison.rs:22:17
|
|
||||||
|
|
|
||||||
LL | let _ = f<'_, i8>();
|
|
||||||
| ^ expected `while`, `for`, `loop` or `{` after a label
|
|
||||||
|
|
||||||
error: expected one of `.`, `:`, `;`, `?`, `else`, `for`, `loop`, `while`, `{`, or an operator, found `,`
|
error: expected one of `.`, `:`, `;`, `?`, `else`, `for`, `loop`, `while`, `{`, or an operator, found `,`
|
||||||
--> $DIR/require-parens-for-chained-comparison.rs:22:17
|
--> $DIR/require-parens-for-chained-comparison.rs:22:17
|
||||||
|
|
|
|
||||||
@ -70,14 +64,8 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum
|
|||||||
LL | let _ = f::<'_, i8>();
|
LL | let _ = f::<'_, i8>();
|
||||||
| ++
|
| ++
|
||||||
|
|
||||||
error: expected `while`, `for`, `loop` or `{` after a label
|
|
||||||
--> $DIR/require-parens-for-chained-comparison.rs:27:9
|
|
||||||
|
|
|
||||||
LL | f<'_>();
|
|
||||||
| ^ expected `while`, `for`, `loop` or `{` after a label
|
|
||||||
|
|
||||||
error: comparison operators cannot be chained
|
error: comparison operators cannot be chained
|
||||||
--> $DIR/require-parens-for-chained-comparison.rs:27:6
|
--> $DIR/require-parens-for-chained-comparison.rs:26:6
|
||||||
|
|
|
|
||||||
LL | f<'_>();
|
LL | f<'_>();
|
||||||
| ^ ^
|
| ^ ^
|
||||||
@ -88,7 +76,7 @@ LL | f::<'_>();
|
|||||||
| ++
|
| ++
|
||||||
|
|
||||||
error: comparison operators cannot be chained
|
error: comparison operators cannot be chained
|
||||||
--> $DIR/require-parens-for-chained-comparison.rs:32:14
|
--> $DIR/require-parens-for-chained-comparison.rs:30:14
|
||||||
|
|
|
|
||||||
LL | let _ = f<u8>;
|
LL | let _ = f<u8>;
|
||||||
| ^ ^
|
| ^ ^
|
||||||
@ -96,5 +84,5 @@ LL | let _ = f<u8>;
|
|||||||
= help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
= help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
||||||
= help: or use `(...)` if you meant to specify fn arguments
|
= help: or use `(...)` if you meant to specify fn arguments
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user