Represent the raw pointer for a array length check as a new kind of fake borrow
This commit is contained in:
parent
057313b7a6
commit
eeecb56b73
26 changed files with 199 additions and 89 deletions
|
@ -192,7 +192,7 @@ enum AggregateTy<'tcx> {
|
|||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
enum AddressKind {
|
||||
Ref(BorrowKind),
|
||||
Address(Mutability),
|
||||
Address(RawPtrKind),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -504,7 +504,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
mplace.layout.ty,
|
||||
bk.to_mutbl_lossy(),
|
||||
),
|
||||
AddressKind::Address(mutbl) => Ty::new_ptr(self.tcx, mplace.layout.ty, mutbl),
|
||||
AddressKind::Address(mutbl) => {
|
||||
Ty::new_ptr(self.tcx, mplace.layout.ty, mutbl.to_mutbl_lossy())
|
||||
}
|
||||
};
|
||||
let layout = self.ecx.layout_of(ty).ok()?;
|
||||
ImmTy::from_immediate(pointer, layout).into()
|
||||
|
|
|
@ -125,7 +125,7 @@ impl<'tcx> crate::MirPass<'tcx> for EnumSizeOpt {
|
|||
source_info,
|
||||
kind: StatementKind::Assign(Box::new((
|
||||
dst,
|
||||
Rvalue::RawPtr(Mutability::Mut, *lhs),
|
||||
Rvalue::RawPtr(RawPtrKind::Mut, *lhs),
|
||||
))),
|
||||
};
|
||||
|
||||
|
@ -146,7 +146,7 @@ impl<'tcx> crate::MirPass<'tcx> for EnumSizeOpt {
|
|||
source_info,
|
||||
kind: StatementKind::Assign(Box::new((
|
||||
src,
|
||||
Rvalue::RawPtr(Mutability::Not, *rhs),
|
||||
Rvalue::RawPtr(RawPtrKind::Const, *rhs),
|
||||
))),
|
||||
};
|
||||
|
||||
|
|
|
@ -2,17 +2,11 @@ use std::iter;
|
|||
|
||||
use itertools::Itertools;
|
||||
use rustc_abi::{FieldIdx, VariantIdx};
|
||||
use rustc_ast::Mutability;
|
||||
use rustc_const_eval::interpret;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_index::{Idx, IndexVec};
|
||||
use rustc_middle::mir::{
|
||||
BasicBlock, BasicBlockData, Body, CallSource, CastKind, CoercionSource, Const, ConstOperand,
|
||||
ConstValue, Local, LocalDecl, MirSource, Operand, Place, PlaceElem, RETURN_PLACE, Rvalue,
|
||||
SourceInfo, Statement, StatementKind, Terminator, TerminatorKind, UnwindAction,
|
||||
UnwindTerminateReason,
|
||||
};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
use rustc_middle::ty::util::{AsyncDropGlueMorphology, Discr};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
@ -345,7 +339,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> {
|
|||
.tcx
|
||||
.mk_place_elems(&[PlaceElem::Deref, PlaceElem::Field(field, field_ty)]),
|
||||
};
|
||||
self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place))
|
||||
self.put_temp_rvalue(Rvalue::RawPtr(RawPtrKind::Mut, place))
|
||||
}
|
||||
|
||||
/// If given Self is an enum puts `to_drop: *mut FieldTy` on top of
|
||||
|
@ -365,7 +359,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> {
|
|||
PlaceElem::Field(field, field_ty),
|
||||
]),
|
||||
};
|
||||
self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place))
|
||||
self.put_temp_rvalue(Rvalue::RawPtr(RawPtrKind::Mut, place))
|
||||
}
|
||||
|
||||
/// If given Self is an enum puts `to_drop: *mut FieldTy` on top of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue