-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #47242 - estebank:issue-15980, r=petrochenkov
`struct` pattern parsing and diagnostic tweaks - Recover from struct parse error on match and point out missing match body. - Point at struct when finding non-identifier while parsing its fields. - Add label to "expected identifier, found {}" error. Fix #15980.
- Loading branch information
Showing
8 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use std::io; | ||
|
||
fn main(){ | ||
let x: io::IoResult<()> = Ok(()); | ||
//~^ ERROR cannot find type `IoResult` in module `io` | ||
//~| NOTE did you mean `Result`? | ||
match x { | ||
Err(ref e) if e.kind == io::EndOfFile { | ||
//~^ NOTE while parsing this struct | ||
return | ||
//~^ ERROR expected identifier, found keyword `return` | ||
//~| NOTE expected identifier, found keyword | ||
} | ||
//~^ NOTE expected one of `.`, `=>`, `?`, or an operator here | ||
_ => {} | ||
//~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found `_` | ||
//~| NOTE unexpected token | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: expected identifier, found keyword `return` | ||
--> $DIR/issue-15980.rs:20:13 | ||
| | ||
18 | Err(ref e) if e.kind == io::EndOfFile { | ||
| ------------- while parsing this struct | ||
19 | //~^ NOTE while parsing this struct | ||
20 | return | ||
| ^^^^^^ expected identifier, found keyword | ||
|
||
error: expected one of `.`, `=>`, `?`, or an operator, found `_` | ||
--> $DIR/issue-15980.rs:25:9 | ||
| | ||
23 | } | ||
| - expected one of `.`, `=>`, `?`, or an operator here | ||
24 | //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here | ||
25 | _ => {} | ||
| ^ unexpected token | ||
|
||
error[E0412]: cannot find type `IoResult` in module `io` | ||
--> $DIR/issue-15980.rs:14:16 | ||
| | ||
14 | let x: io::IoResult<()> = Ok(()); | ||
| ^^^^^^^^ did you mean `Result`? | ||
|
||
error: aborting due to 3 previous errors | ||
|