-
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.
Rollup merge of #108971 - Ezrashaw:E0532-better-binding-names, r=Waff…
…leLapkin error-msg: impl better suggestion for `E0532` Fixes #106862 No test as there is already a test which is nearly identical to the example in the linked issue.
- Loading branch information
Showing
5 changed files
with
169 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
use Foo::{FooB, FooA}; | ||
|
||
enum Foo { | ||
FooA { opt_x: Option<i32>, y: i32 }, | ||
FooB { x: i32, y: i32 } | ||
} | ||
|
||
fn main() { | ||
let f = FooB { x: 3, y: 4 }; | ||
|
||
match f { | ||
FooB { x: a, y: b } => println!("{} {}", a, b), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooB { x, y } => println!("{} {}", x, y), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooA { opt_x: Some(x), y } => println!("{} {}", x, y), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooA` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooB { x: a, y: _ } => println!("{}", a), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooB { x, y } => (), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
} |
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,44 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
use Foo::{FooB, FooA}; | ||
|
||
enum Foo { | ||
FooA { opt_x: Option<i32>, y: i32 }, | ||
FooB { x: i32, y: i32 } | ||
} | ||
|
||
fn main() { | ||
let f = FooB { x: 3, y: 4 }; | ||
|
||
match f { | ||
FooB(a, b) => println!("{} {}", a, b), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooB(x, y) => println!("{} {}", x, y), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooA(Some(x), y) => println!("{} {}", x, y), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooA` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooB(a, _, _) => println!("{}", a), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
|
||
match f { | ||
FooB() => (), | ||
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB` | ||
_ => (), | ||
} | ||
} |
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,48 @@ | ||
error[E0532]: expected tuple struct or tuple variant, found variant `FooB` | ||
--> $DIR/issue-106862.rs:16:9 | ||
| | ||
LL | FooB { x: i32, y: i32 } | ||
| ----------------------- `FooB` defined here | ||
... | ||
LL | FooB(a, b) => println!("{} {}", a, b), | ||
| ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` | ||
|
||
error[E0532]: expected tuple struct or tuple variant, found variant `FooB` | ||
--> $DIR/issue-106862.rs:22:9 | ||
| | ||
LL | FooB { x: i32, y: i32 } | ||
| ----------------------- `FooB` defined here | ||
... | ||
LL | FooB(x, y) => println!("{} {}", x, y), | ||
| ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` | ||
|
||
error[E0532]: expected tuple struct or tuple variant, found variant `FooA` | ||
--> $DIR/issue-106862.rs:28:9 | ||
| | ||
LL | FooA { opt_x: Option<i32>, y: i32 }, | ||
| ----------------------------------- `FooA` defined here | ||
... | ||
LL | FooA(Some(x), y) => println!("{} {}", x, y), | ||
| ^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooA { opt_x: Some(x), y }` | ||
|
||
error[E0532]: expected tuple struct or tuple variant, found variant `FooB` | ||
--> $DIR/issue-106862.rs:34:9 | ||
| | ||
LL | FooB { x: i32, y: i32 } | ||
| ----------------------- `FooB` defined here | ||
... | ||
LL | FooB(a, _, _) => println!("{}", a), | ||
| ^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: _ }` | ||
|
||
error[E0532]: expected tuple struct or tuple variant, found variant `FooB` | ||
--> $DIR/issue-106862.rs:40:9 | ||
| | ||
LL | FooB { x: i32, y: i32 } | ||
| ----------------------- `FooB` defined here | ||
... | ||
LL | FooB() => (), | ||
| ^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0532`. |