提交 f3f9db13 编写于 作者: P Philipp Brüschweiler

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).
上级 c786b68d
...@@ -3042,15 +3042,17 @@ pub fn adjust_ty(cx: ctxt, ...@@ -3042,15 +3042,17 @@ pub fn adjust_ty(cx: ctxt,
Some(@AutoDerefRef(ref adj)) => { Some(@AutoDerefRef(ref adj)) => {
let mut adjusted_ty = unadjusted_ty; let mut adjusted_ty = unadjusted_ty;
for uint::range(0, adj.autoderefs) |i| { if (!ty::type_is_error(adjusted_ty)) {
match ty::deref(cx, adjusted_ty, true) { for uint::range(0, adj.autoderefs) |i| {
Some(mt) => { adjusted_ty = mt.ty; } match ty::deref(cx, adjusted_ty, true) {
None => { Some(mt) => { adjusted_ty = mt.ty; }
cx.sess.span_bug( None => {
span, cx.sess.span_bug(
fmt!("The %uth autoderef failed: %s", span,
i, ty_to_str(cx, fmt!("The %uth autoderef failed: %s",
adjusted_ty))); i, ty_to_str(cx,
adjusted_ty)));
}
} }
} }
} }
......
...@@ -1108,6 +1108,12 @@ fn apply_autoderefs( ...@@ -1108,6 +1108,12 @@ fn apply_autoderefs(
-> ExprCategorizationType { -> ExprCategorizationType {
let mut ct = ct; let mut ct = ct;
let tcx = rcx.fcx.ccx.tcx; let tcx = rcx.fcx.ccx.tcx;
if (ty::type_is_error(ct.ty)) {
ct.cat.pointer = NotPointer;
return ct;
}
for uint::range(0, autoderefs) |_| { for uint::range(0, autoderefs) |_| {
ct.cat.guarantor = guarantor_of_deref(&ct.cat); ct.cat.guarantor = guarantor_of_deref(&ct.cat);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册