-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better diagnostics for '..' pattern fragment not in the last position
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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. | ||
|
||
// Test for #49257: | ||
// emits good diagnostics for `..` pattern fragments not in the last position. | ||
|
||
#![allow(unused)] | ||
|
||
struct Point { x: u8, y: u8 } | ||
|
||
fn main() { | ||
let p = Point { x: 0, y: 0 }; | ||
let Point { .., y } = p; //~ ERROR expected `}`, found `,` | ||
//~^ pattern does not mention field `x` | ||
//~^^ pattern does not mention field `y` | ||
} |
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,21 @@ | ||
error: expected `}`, found `,` | ||
--> $DIR/issue-49257.rs:20:19 | ||
| | ||
LL | let Point { .., y } = p; //~ ERROR expected `}`, found `,` | ||
| ^ `..` must be in the last position, and cannot have a trailing comma | ||
|
||
error[E0027]: pattern does not mention field `x` | ||
--> $DIR/issue-49257.rs:20:9 | ||
| | ||
LL | let Point { .., y } = p; //~ ERROR expected `}`, found `,` | ||
| ^^^^^^^^^^^^^^^ missing field `x` | ||
|
||
error[E0027]: pattern does not mention field `y` | ||
--> $DIR/issue-49257.rs:20:9 | ||
| | ||
LL | let Point { .., y } = p; //~ ERROR expected `}`, found `,` | ||
| ^^^^^^^^^^^^^^^ missing field `y` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0027`. |