Skip to content

Commit 028dc58

Browse files
committed
auto merge of #5963 : alexcrichton/rust/fix-ice, r=pcwalton
I ran across this when working on some other changes, and it looked like it wasn't too hard to "fix". I'm not very familiar with this code, but it looks like if an error was already generated there's no need to generate and ICE as well when parts of the program can just be ignored for more incorrectness.
2 parents ce4f73a + 93e13e0 commit 028dc58

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,9 @@ fn constrain_derefs(rcx: @mut Rcx,
413413

414414
match ty::deref(tcx, derefd_ty, true) {
415415
Some(mt) => derefd_ty = mt.ty,
416-
None => {
417-
tcx.sess.span_bug(
418-
deref_expr.span,
419-
fmt!("%?'th deref is of a non-deref'able type `%s`",
420-
i, rcx.fcx.infcx().ty_to_str(derefd_ty)));
421-
}
416+
/* if this type can't be dereferenced, then there's already an error
417+
in the session saying so. Just bail out for now */
418+
None => break
422419
}
423420
}
424421
}

src/test/compile-fail/deref-non-pointer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:cannot be dereferenced
1211
fn main() {
13-
match *1 {
12+
match *1 { //~ ERROR: cannot be dereferenced
1413
_ => { fail!(); }
1514
}
1615
}

0 commit comments

Comments
 (0)