Rollup merge of #35297 - saml:e0001-label, r=jonathandturner
Set label for unreachable pattern Part of #35233 Fixes #35190 r? @jonathandturner
This commit is contained in:
commit
8038c17da5
@ -335,6 +335,7 @@ fn check_arms(cx: &MatchCheckCtxt,
|
||||
hir::MatchSource::Normal => {
|
||||
let mut err = struct_span_err!(cx.tcx.sess, pat.span, E0001,
|
||||
"unreachable pattern");
|
||||
err.span_label(pat.span, &format!("this is an unreachable pattern"));
|
||||
// if we had a catchall pattern, hint at that
|
||||
for row in &seen.0 {
|
||||
if pat_is_catchall(&cx.tcx.def_map.borrow(), row[0].0) {
|
||||
|
@ -22,6 +22,7 @@ fn main() {
|
||||
//~^ NOTE this pattern matches any value
|
||||
Var2 => (),
|
||||
//~^ ERROR unreachable pattern
|
||||
//~^^ NOTE this is an unreachable pattern
|
||||
};
|
||||
match &s {
|
||||
&Var1 => (),
|
||||
@ -29,6 +30,7 @@ fn main() {
|
||||
//~^ NOTE this pattern matches any value
|
||||
&Var2 => (),
|
||||
//~^ ERROR unreachable pattern
|
||||
//~^^ NOTE this is an unreachable pattern
|
||||
};
|
||||
let t = (Var1, Var1);
|
||||
match t {
|
||||
@ -37,6 +39,7 @@ fn main() {
|
||||
//~^ NOTE this pattern matches any value
|
||||
anything => ()
|
||||
//~^ ERROR unreachable pattern
|
||||
//~^^ NOTE this is an unreachable pattern
|
||||
};
|
||||
// `_` need not emit a note, it is pretty obvious already.
|
||||
let t = (Var1, Var1);
|
||||
@ -45,5 +48,6 @@ fn main() {
|
||||
_ => (),
|
||||
anything => ()
|
||||
//~^ ERROR unreachable pattern
|
||||
//~^^ NOTE this is an unreachable pattern
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user