Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing shadowing diagnostic with "@" in pattern-match #27033

Closed
eefriedman opened this issue Jul 14, 2015 · 2 comments
Closed

Missing shadowing diagnostic with "@" in pattern-match #27033

eefriedman opened this issue Jul 14, 2015 · 2 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@eefriedman
Copy link
Contributor

fn main() {
  match Some(1) { None @ _ => { } };
  //let None = 1;
}
<anon>:2:19: 2:27 warning: unused variable: `None`, #[warn(unused_variables)] on by default
<anon>:2   match Some(1) { None @ _ => { } };
                           ^~~~~~~~

This is accepted, but probably shouldn't be. (A normal declaration of a variable named None is rejected.)

@eefriedman
Copy link
Contributor Author

Related testcase:

fn main() {
    const C: u8 = 1;
    match 1 {
        C @ 2 => { println!("{}", C); }
        _ => {}
    };
}
<anon>:4:9: 4:14 warning: unused variable: `C`, #[warn(unused_variables)] on by default
<anon>:4         C @ 2 => { println!("{}", C); }
                 ^~~~~
Switch constants must all be same type as switch value!
  switch i32 %3, label %match_else [
    i8 1, label %match_case
  ]
LLVM ERROR: Broken function found, compilation aborted!
playpen: application terminated with error code 1

@steveklabnik steveklabnik added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Jul 16, 2015
@Aatch
Copy link
Contributor

Aatch commented Jul 17, 2015

That second case is unrelated. (And really weird, I'm not even sure how that's happening!)

arielb1 pushed a commit to arielb1/rust that referenced this issue Jul 28, 2015
as this breaks code that worked under some conditions, this is a
[breaking-change]

Fixes rust-lang#27033
Fixes rust-lang#27077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants