fix ice in suggesting
This commit is contained in:
parent
20e6e6a493
commit
a7fc32ceaf
3 changed files with 29 additions and 7 deletions
|
@ -405,13 +405,20 @@ impl<'a> Parser<'a> {
|
||||||
let prev_span = self.prev_token.span.shrink_to_lo();
|
let prev_span = self.prev_token.span.shrink_to_lo();
|
||||||
let snapshot = self.create_snapshot_for_diagnostic();
|
let snapshot = self.create_snapshot_for_diagnostic();
|
||||||
self.bump();
|
self.bump();
|
||||||
if self.parse_ty().is_ok() && self.token == token::Eq {
|
match self.parse_ty() {
|
||||||
err.span_suggestion_verbose(
|
Ok(_) => {
|
||||||
prev_span,
|
if self.token == token::Eq {
|
||||||
"you might have meant to introduce a new binding",
|
err.span_suggestion_verbose(
|
||||||
"let ".to_string(),
|
prev_span,
|
||||||
Applicability::MaybeIncorrect,
|
"you might have meant to introduce a new binding",
|
||||||
);
|
"let ".to_string(),
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
err.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.restore_snapshot(snapshot);
|
self.restore_snapshot(snapshot);
|
||||||
}
|
}
|
||||||
|
|
5
tests/ui/type/missing-let-in-binding-3.rs
Normal file
5
tests/ui/type/missing-let-in-binding-3.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
struct A {
|
||||||
|
: :u8, //~ ERROR expected identifier, found `:`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
10
tests/ui/type/missing-let-in-binding-3.stderr
Normal file
10
tests/ui/type/missing-let-in-binding-3.stderr
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
error: expected identifier, found `:`
|
||||||
|
--> $DIR/missing-let-in-binding-3.rs:2:5
|
||||||
|
|
|
||||||
|
LL | struct A {
|
||||||
|
| - while parsing this struct
|
||||||
|
LL | : :u8,
|
||||||
|
| ^ expected identifier
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue