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).
This commit is contained in:
Philipp Brüschweiler 2013-06-07 18:08:06 +02:00
parent c786b68dd3
commit f3f9db133a
2 changed files with 17 additions and 9 deletions

View File

@ -3042,6 +3042,7 @@ pub fn adjust_ty(cx: ctxt,
Some(@AutoDerefRef(ref adj)) => {
let mut adjusted_ty = unadjusted_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; }
@ -3054,6 +3055,7 @@ pub fn adjust_ty(cx: ctxt,
}
}
}
}
match adj.autoref {
None => adjusted_ty,

View File

@ -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);