Recover extra trailing angle brackets in struct definition
This commit applies the existing 'extra angle bracket recovery' logic when parsing fields in struct definitions. This allows us to continue parsing the struct's fields, avoiding spurious 'missing field' errors in code that tries to use the struct.
This commit is contained in:
parent
7750c3d46b
commit
765bd47fa0
6 changed files with 66 additions and 8 deletions
14
src/test/ui/parser/recover-field-extra-angle-brackets.rs
Normal file
14
src/test/ui/parser/recover-field-extra-angle-brackets.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Tests that we recover from extra trailing angle brackets
|
||||
// in a struct field
|
||||
|
||||
struct BadStruct {
|
||||
first: Vec<u8>>, //~ ERROR unmatched angle bracket
|
||||
second: bool
|
||||
}
|
||||
|
||||
fn bar(val: BadStruct) {
|
||||
val.first;
|
||||
val.second;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: unmatched angle bracket
|
||||
--> $DIR/recover-field-extra-angle-brackets.rs:5:19
|
||||
|
|
||||
LL | first: Vec<u8>>,
|
||||
| ^ help: remove extra angle bracket
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue