Skip to content

Commit ae35912

Browse files
estebankpietroalbini
authored andcommitted
Instead of ICEing on incorrect pattern, use delay_span_bug
1 parent 6599770 commit ae35912

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
@@ -1294,8 +1294,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
12941294
}
12951295
}
12961296
def => {
1297-
span_bug!(pat.span, "tuple struct pattern didn't resolve \
1298-
to variant or struct {:?}", def);
1297+
debug!(
1298+
"tuple struct pattern didn't resolve to variant or struct {:?} at {:?}",
1299+
def,
1300+
pat.span,
1301+
);
1302+
self.tcx.sess.delay_span_bug(pat.span, &format!(
1303+
"tuple struct pattern didn't resolve to variant or struct {:?}",
1304+
def,
1305+
));
1306+
return Err(());
12991307
}
13001308
};
13011309

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)