Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoerister
Make `Ty::builtin_deref` just return a `Ty` Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
This commit is contained in:
commit
9a9ec90567
43 changed files with 92 additions and 116 deletions
|
@ -78,13 +78,9 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
}
|
||||
let answer = match *elem {
|
||||
ProjectionElem::Deref => {
|
||||
let ty = self
|
||||
.ty
|
||||
.builtin_deref(true)
|
||||
.unwrap_or_else(|| {
|
||||
bug!("deref projection of non-dereferenceable ty {:?}", self)
|
||||
})
|
||||
.ty;
|
||||
let ty = self.ty.builtin_deref(true).unwrap_or_else(|| {
|
||||
bug!("deref projection of non-dereferenceable ty {:?}", self)
|
||||
});
|
||||
PlaceTy::from_ty(ty)
|
||||
}
|
||||
ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {
|
||||
|
|
|
@ -2164,13 +2164,11 @@ impl<'tcx> Ty<'tcx> {
|
|||
///
|
||||
/// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
|
||||
match self.kind() {
|
||||
Adt(def, _) if def.is_box() => {
|
||||
Some(TypeAndMut { ty: self.boxed_ty(), mutbl: hir::Mutability::Not })
|
||||
}
|
||||
Ref(_, ty, mutbl) => Some(TypeAndMut { ty: *ty, mutbl: *mutbl }),
|
||||
RawPtr(ty, mutbl) if explicit => Some(TypeAndMut { ty: *ty, mutbl: *mutbl }),
|
||||
pub fn builtin_deref(self, explicit: bool) -> Option<Ty<'tcx>> {
|
||||
match *self.kind() {
|
||||
Adt(def, _) if def.is_box() => Some(self.boxed_ty()),
|
||||
Ref(_, ty, _) => Some(ty),
|
||||
RawPtr(ty, _) if explicit => Some(ty),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue