Rollup merge of #33406 - Manishearth:diag-improve-const-let, r=GuillaumeGomez
Improve diagnostics for constants being used in irrefutable patterns It's pretty confusing and this error triggers in resolve only when "shadowing" a const, so let's make that clearer. r? @steveklabnik
This commit is contained in:
commit
deb97fef21
4 changed files with 71 additions and 9 deletions
|
|
@ -19,10 +19,10 @@ use foo::d; //~ NOTE constant imported here
|
|||
const a: u8 = 2; //~ NOTE constant defined here
|
||||
|
||||
fn main() {
|
||||
let a = 4; //~ ERROR only irrefutable
|
||||
let a = 4; //~ ERROR variable bindings cannot
|
||||
//~^ NOTE there already is a constant in scope
|
||||
let c = 4; //~ ERROR only irrefutable
|
||||
let c = 4; //~ ERROR variable bindings cannot
|
||||
//~^ NOTE there already is a constant in scope
|
||||
let d = 4; //~ ERROR only irrefutable
|
||||
let d = 4; //~ ERROR variable bindings cannot
|
||||
//~^ NOTE there already is a constant in scope
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
};
|
||||
const C: u8 = 1;
|
||||
match 1 {
|
||||
C @ 2 => { //~ ERROR only irrefutable patterns allowed here
|
||||
C @ 2 => { //~ ERROR variable bindings cannot shadow constants
|
||||
println!("{}", C);
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue