mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
55b4549602
Given the code ```rust pub fn main() { const y: i32 = 4; let y: i32 = 3; } ``` `y` in the let binding is actually interpreted as a constant pattern and is not a new variable, causing confusing diagnostics about refutable patterns in local binding. This commit extends the note for type ascription as a constant pattern to `AscribeUserType` patterns as well.
32 lines
1.4 KiB
Plaintext
32 lines
1.4 KiB
Plaintext
error[E0005]: refutable pattern in local binding
|
|
--> $DIR/issue-112269.rs:3:9
|
|
|
|
|
LL | let x: i32 = 3;
|
|
| ^
|
|
| |
|
|
| patterns `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered
|
|
| missing patterns are not covered because `x` is interpreted as a constant pattern, not a new variable
|
|
| help: introduce a variable instead: `x_var`
|
|
|
|
|
= 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 `i32`
|
|
|
|
error[E0005]: refutable pattern in local binding
|
|
--> $DIR/issue-112269.rs:7:9
|
|
|
|
|
LL | let y = 4;
|
|
| ^
|
|
| |
|
|
| patterns `i32::MIN..=2_i32` and `4_i32..=i32::MAX` not covered
|
|
| missing patterns are not covered because `y` is interpreted as a constant pattern, not a new variable
|
|
| help: introduce a variable instead: `y_var`
|
|
|
|
|
= 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 `i32`
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0005`.
|