diff options
| author | Philipp Brüschweiler <blei42@gmail.com> | 2013-06-07 18:08:06 +0200 |
|---|---|---|
| committer | Philipp Brüschweiler <blei42@gmail.com> | 2013-06-08 09:34:32 +0200 |
| commit | f3f9db133aae35956f2fb91ce4d017260f5f7828 (patch) | |
| tree | 52bca838cd1e0c860a23f27f11535f735a56f31e /src | |
| parent | c786b68dd3ecf96e202f50ba600292f54b35f2ee (diff) | |
rustc: Fix an ICE "Autoderef but type not derefable"
Related to #5062 (same error message), but that test case causes a different ICE than mentioned there (even without this fix).
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/ty.rs | 20 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/check/regionck.rs | 6 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 8e2691c8a27..f32df13ad2a 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3042,15 +3042,17 @@ pub fn adjust_ty(cx: ctxt, Some(@AutoDerefRef(ref adj)) => { let mut adjusted_ty = unadjusted_ty; - for uint::range(0, adj.autoderefs) |i| { - match ty::deref(cx, adjusted_ty, true) { - Some(mt) => { adjusted_ty = mt.ty; } - None => { - cx.sess.span_bug( - span, - fmt!("The %uth autoderef failed: %s", - i, ty_to_str(cx, - adjusted_ty))); + if (!ty::type_is_error(adjusted_ty)) { + for uint::range(0, adj.autoderefs) |i| { + match ty::deref(cx, adjusted_ty, true) { + Some(mt) => { adjusted_ty = mt.ty; } + None => { + cx.sess.span_bug( + span, + fmt!("The %uth autoderef failed: %s", + i, ty_to_str(cx, + adjusted_ty))); + } } } } diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 58749b92ddc..2eb646a0b9b 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -1108,6 +1108,12 @@ pub mod guarantor { -> ExprCategorizationType { let mut ct = ct; let tcx = rcx.fcx.ccx.tcx; + + if (ty::type_is_error(ct.ty)) { + ct.cat.pointer = NotPointer; + return ct; + } + for uint::range(0, autoderefs) |_| { ct.cat.guarantor = guarantor_of_deref(&ct.cat); |
