Skip to content
Permalink
Browse files

Instead of ICEing on incorrect pattern, use delay_span_bug

  • Loading branch information...
estebank committed May 8, 2019
1 parent 33cde4a commit cc40f41ee5baefa0dc1845dd9d794abe90511161
Showing with 35 additions and 2 deletions.
  1. +10 −2 src/librustc/middle/mem_categorization.rs
  2. +16 −0 src/test/ui/fn-in-pat.rs
  3. +9 −0 src/test/ui/fn-in-pat.stderr
@@ -1300,8 +1300,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
}
}
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(());
}
};

@@ -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() {}
@@ -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.
You can’t perform that action at this time.