Instead of ICEing on incorrect pattern, use delay_span_bug
This commit is contained in:
parent
33cde4aac2
commit
cc40f41ee5
@ -1300,8 +1300,16 @@ fn cat_pattern_<F>(&self, mut cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F) -> McR
|
||||
}
|
||||
}
|
||||
def => {
|
||||
span_bug!(pat.span, "tuple struct pattern didn't resolve \
|
||||
to variant or struct {:?}", def);
|
||||
debug!(
|
||||
"tuple struct pattern didn't resolve to variant or struct {:?} at {:?}",
|
||||
def,
|
||||
pat.span,
|
||||
);
|
||||
self.tcx.sess.delay_span_bug(pat.span, &format!(
|
||||
"tuple struct pattern didn't resolve to variant or struct {:?}",
|
||||
def,
|
||||
));
|
||||
return Err(());
|
||||
}
|
||||
};
|
||||
|
||||
|
16
src/test/ui/fn-in-pat.rs
Normal file
16
src/test/ui/fn-in-pat.rs
Normal file
@ -0,0 +1,16 @@
|
||||
struct A {}
|
||||
|
||||
impl A {
|
||||
fn new() {}
|
||||
}
|
||||
|
||||
fn hof<F>(_: F) where F: FnMut(()) {}
|
||||
|
||||
fn ice() {
|
||||
hof(|c| match c {
|
||||
A::new() => (), //~ ERROR expected tuple struct/variant, found method
|
||||
_ => ()
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {}
|
9
src/test/ui/fn-in-pat.stderr
Normal file
9
src/test/ui/fn-in-pat.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error[E0164]: expected tuple struct/variant, found method `<A>::new`
|
||||
--> $DIR/fn-in-pat.rs:11:9
|
||||
|
|
||||
LL | A::new() => (),
|
||||
| ^^^^^^^^ not a tuple variant or struct
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0164`.
|
Loading…
Reference in New Issue
Block a user