Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
359bfa901b9d8eddbed7b88b6716dbb77b7bfb95
rust/tests/ui/mir/issue-112269.rs

10 lines
198 B
Rust
Raw Normal View History

Show note for type ascription interpreted as a constant pattern, not a new variable 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.
2023-06-04 20:33:33 +08:00
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
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 1562ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API