Skip to content

Commit

Permalink
Instead of ICEing on incorrect pattern, use delay_span_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed May 8, 2019
1 parent 33cde4a commit cc40f41
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -1300,8 +1300,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
} }
} }
def => { def => {
span_bug!(pat.span, "tuple struct pattern didn't resolve \ debug!(
to variant or struct {:?}", def); "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(());
} }
}; };


Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/fn-in-pat.rs
@@ -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 changes: 9 additions & 0 deletions src/test/ui/fn-in-pat.stderr
@@ -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`.

0 comments on commit cc40f41

Please sign in to comment.