-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect suggestion for uninitialize binding in destructuring pa…
…ttern
- Loading branch information
Showing
3 changed files
with
60 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,16 @@ | ||
// regression test for #120634 | ||
|
||
struct A(u8); | ||
struct B { d: u8 } | ||
|
||
fn main() { | ||
let (a, ); | ||
let [b, ]; | ||
let A(c); | ||
let B { d }; | ||
let _: (u8, u8, u8, u8) = (a, b, c, d); | ||
//~^ ERROR used binding `a` | ||
//~| ERROR used binding `b` | ||
//~| ERROR used binding `c` | ||
//~| ERROR used binding `d` | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/ui/borrowck/borrowck-uninit-binding-suggestion.stderr
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,38 @@ | ||
error[E0381]: used binding `a` isn't initialized | ||
--> $DIR/borrowck-uninit-binding-suggestion.rs:11:32 | ||
| | ||
LL | let (a, ); | ||
| - binding declared here but left uninitialized | ||
... | ||
LL | let _: (u8, u8, u8, u8) = (a, b, c, d); | ||
| ^ `a` used here but it isn't initialized | ||
|
||
error[E0381]: used binding `b` isn't initialized | ||
--> $DIR/borrowck-uninit-binding-suggestion.rs:11:35 | ||
| | ||
LL | let [b, ]; | ||
| - binding declared here but left uninitialized | ||
... | ||
LL | let _: (u8, u8, u8, u8) = (a, b, c, d); | ||
| ^ `b` used here but it isn't initialized | ||
|
||
error[E0381]: used binding `c` isn't initialized | ||
--> $DIR/borrowck-uninit-binding-suggestion.rs:11:38 | ||
| | ||
LL | let A(c); | ||
| - binding declared here but left uninitialized | ||
LL | let B { d }; | ||
LL | let _: (u8, u8, u8, u8) = (a, b, c, d); | ||
| ^ `c` used here but it isn't initialized | ||
|
||
error[E0381]: used binding `d` isn't initialized | ||
--> $DIR/borrowck-uninit-binding-suggestion.rs:11:41 | ||
| | ||
LL | let B { d }; | ||
| - binding declared here but left uninitialized | ||
LL | let _: (u8, u8, u8, u8) = (a, b, c, d); | ||
| ^ `d` used here but it isn't initialized | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0381`. |