mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-27 11:05:06 +00:00
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.
10 lines
198 B
Rust
10 lines
198 B
Rust
pub fn main() {
|
|
const x: i32 = 4;
|
|
let x: i32 = 3;
|
|
//~^ ERROR refutable pattern in local binding
|
|
|
|
const y: i32 = 3;
|
|
let y = 4;
|
|
//~^ ERROR refutable pattern in local binding
|
|
}
|