forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The suggestion to use `let else` with an uninitialized refutable `let` statement was erroneous: `let else` cannot be used with deferred initialization.
- Loading branch information
Showing
6 changed files
with
22 additions
and
48 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
8 changes: 8 additions & 0 deletions
8
tests/ui/let-else/uninitialized-refutable-let-issue-123844.rs
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,8 @@ | ||
// https://github.com/rust-lang/rust/issues/123844 | ||
// An uninitialized refutable let should not suggest `let else`, as it can't be used with deferred | ||
// initialization. | ||
|
||
fn main() { | ||
let Some(x); //~ ERROR refutable pattern in local binding | ||
x = 1; | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/ui/let-else/uninitialized-refutable-let-issue-123844.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,13 @@ | ||
error[E0005]: refutable pattern in local binding | ||
--> $DIR/uninitialized-refutable-let-issue-123844.rs:6:9 | ||
| | ||
LL | let Some(x); | ||
| ^^^^^^^ pattern `None` not covered | ||
| | ||
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant | ||
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html | ||
= note: the matched value is of type `Option<i32>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0005`. |
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