Skip to content

Commit cc40f41

Browse files
committed
Instead of ICEing on incorrect pattern, use delay_span_bug
1 parent 33cde4a commit cc40f41

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/librustc/middle/mem_categorization.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
13001300
}
13011301
}
13021302
def => {
1303-
span_bug!(pat.span, "tuple struct pattern didn't resolve \
1304-
to variant or struct {:?}", def);
1303+
debug!(
1304+
"tuple struct pattern didn't resolve to variant or struct {:?} at {:?}",
1305+
def,
1306+
pat.span,
1307+
);
1308+
self.tcx.sess.delay_span_bug(pat.span, &format!(
1309+
"tuple struct pattern didn't resolve to variant or struct {:?}",
1310+
def,
1311+
));
1312+
return Err(());
13051313
}
13061314
};
13071315

src/test/ui/fn-in-pat.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
struct A {}
2+
3+
impl A {
4+
fn new() {}
5+
}
6+
7+
fn hof<F>(_: F) where F: FnMut(()) {}
8+
9+
fn ice() {
10+
hof(|c| match c {
11+
A::new() => (), //~ ERROR expected tuple struct/variant, found method
12+
_ => ()
13+
})
14+
}
15+
16+
fn main() {}

src/test/ui/fn-in-pat.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0164]: expected tuple struct/variant, found method `<A>::new`
2+
--> $DIR/fn-in-pat.rs:11:9
3+
|
4+
LL | A::new() => (),
5+
| ^^^^^^^^ not a tuple variant or struct
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0164`.

0 commit comments

Comments
 (0)