Skip to content

Commit ccc892f

Browse files
committed
HACK: avoid an existing ICE
1 parent 12f29ba commit ccc892f

File tree

1 file changed

+7
-3
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+7
-3
lines changed

compiler/rustc_middle/src/mir/tcx.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ impl<'tcx> PlaceTy<'tcx> {
114114
}
115115
let answer = match *elem {
116116
ProjectionElem::Deref => {
117-
let ty = self.ty.builtin_deref(true).unwrap_or_else(|| {
118-
bug!("deref projection of non-dereferenceable ty {:?}", self)
119-
});
117+
let pointee_ty = self.ty;
118+
let ty = pointee_ty
119+
.builtin_deref(true)
120+
.or_else(|| Some(Ty::new_error(tcx, pointee_ty.error_reported().err()?)))
121+
.unwrap_or_else(|| {
122+
bug!("deref projection of non-dereferenceable ty {:?}", self)
123+
});
120124
PlaceTy::from_ty(ty)
121125
}
122126
ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {

0 commit comments

Comments
 (0)