Place::ty_from takes local by value
This commit is contained in:
parent
b5b6be0ab7
commit
22a4827dcb
@ -114,7 +114,7 @@ pub fn projection_ty_core<V, T>(
|
||||
|
||||
impl<'tcx> Place<'tcx> {
|
||||
pub fn ty_from<D>(
|
||||
local: &Local,
|
||||
local: Local,
|
||||
projection: &[PlaceElem<'tcx>],
|
||||
local_decls: &D,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
@ -124,7 +124,7 @@ pub fn ty_from<D>(
|
||||
{
|
||||
projection
|
||||
.iter()
|
||||
.fold(PlaceTy::from_ty(local_decls.local_decls()[*local].ty), |place_ty, elem| {
|
||||
.fold(PlaceTy::from_ty(local_decls.local_decls()[local].ty), |place_ty, elem| {
|
||||
place_ty.projection_ty(tcx, elem)
|
||||
})
|
||||
}
|
||||
@ -133,7 +133,7 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
Place::ty_from(&self.local, &self.projection, local_decls, tcx)
|
||||
Place::ty_from(self.local, &self.projection, local_decls, tcx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ fn process_place(
|
||||
};
|
||||
if is_consume {
|
||||
let base_ty =
|
||||
mir::Place::ty_from(&place_ref.local, proj_base, *self.fx.mir, cx.tcx());
|
||||
mir::Place::ty_from(place_ref.local, proj_base, *self.fx.mir, cx.tcx());
|
||||
let base_ty = self.fx.monomorphize(&base_ty);
|
||||
|
||||
// ZSTs don't require any actual memory access.
|
||||
|
@ -499,7 +499,7 @@ pub fn codegen_place(
|
||||
|
||||
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> {
|
||||
let tcx = self.cx.tcx();
|
||||
let place_ty = mir::Place::ty_from(&place_ref.local, place_ref.projection, *self.mir, tcx);
|
||||
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
|
||||
self.monomorphize(&place_ty.ty)
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ pub(in crate::borrow_check) fn report_use_of_moved_or_uninitialized(
|
||||
}
|
||||
|
||||
let ty =
|
||||
Place::ty_from(&used_place.local, used_place.projection, *self.body, self.infcx.tcx)
|
||||
Place::ty_from(used_place.local, used_place.projection, *self.body, self.infcx.tcx)
|
||||
.ty;
|
||||
let needs_note = match ty.kind {
|
||||
ty::Closure(id, _) => {
|
||||
@ -604,7 +604,7 @@ pub(in crate::borrow_check) fn describe_place_for_conflicting_borrow(
|
||||
cursor = proj_base;
|
||||
|
||||
match elem {
|
||||
ProjectionElem::Field(field, _) if union_ty(local, proj_base).is_some() => {
|
||||
ProjectionElem::Field(field, _) if union_ty(*local, proj_base).is_some() => {
|
||||
return Some((PlaceRef { local: *local, projection: proj_base }, field));
|
||||
}
|
||||
_ => {}
|
||||
@ -622,7 +622,7 @@ pub(in crate::borrow_check) fn describe_place_for_conflicting_borrow(
|
||||
cursor = proj_base;
|
||||
|
||||
if let ProjectionElem::Field(field, _) = elem {
|
||||
if let Some(union_ty) = union_ty(local, proj_base) {
|
||||
if let Some(union_ty) = union_ty(*local, proj_base) {
|
||||
if field != target_field
|
||||
&& *local == target_base.local
|
||||
&& proj_base == target_base.projection
|
||||
@ -1513,7 +1513,7 @@ fn classify_drop_access_kind(&self, place: PlaceRef<'cx, 'tcx>) -> StorageDeadOr
|
||||
StorageDeadOrDrop::LocalStorageDead
|
||||
| StorageDeadOrDrop::BoxedStorageDead => {
|
||||
assert!(
|
||||
Place::ty_from(&place.local, proj_base, *self.body, tcx)
|
||||
Place::ty_from(place.local, proj_base, *self.body, tcx)
|
||||
.ty
|
||||
.is_box(),
|
||||
"Drop of value behind a reference or raw pointer"
|
||||
@ -1523,7 +1523,7 @@ fn classify_drop_access_kind(&self, place: PlaceRef<'cx, 'tcx>) -> StorageDeadOr
|
||||
StorageDeadOrDrop::Destructor(_) => base_access,
|
||||
},
|
||||
ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
|
||||
let base_ty = Place::ty_from(&place.local, proj_base, *self.body, tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, proj_base, *self.body, tcx).ty;
|
||||
match base_ty.kind {
|
||||
ty::Adt(def, _) if def.has_dtor(tcx) => {
|
||||
// Report the outermost adt with a destructor
|
||||
|
@ -316,7 +316,7 @@ fn describe_field(&self, place: PlaceRef<'cx, 'tcx>, field: Field) -> String {
|
||||
}
|
||||
ProjectionElem::Downcast(_, variant_index) => {
|
||||
let base_ty =
|
||||
Place::ty_from(&place.local, place.projection, *self.body, self.infcx.tcx)
|
||||
Place::ty_from(place.local, place.projection, *self.body, self.infcx.tcx)
|
||||
.ty;
|
||||
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
|
||||
}
|
||||
@ -447,7 +447,7 @@ pub(super) fn borrowed_content_source(
|
||||
|
||||
// If we didn't find an overloaded deref or index, then assume it's a
|
||||
// built in deref and check the type of the base.
|
||||
let base_ty = Place::ty_from(&deref_base.local, deref_base.projection, *self.body, tcx).ty;
|
||||
let base_ty = Place::ty_from(deref_base.local, deref_base.projection, *self.body, tcx).ty;
|
||||
if base_ty.is_unsafe_ptr() {
|
||||
BorrowedContentSource::DerefRawPointer
|
||||
} else if base_ty.is_mutable_ptr() {
|
||||
|
@ -57,7 +57,7 @@ pub(crate) fn report_mutability_error(
|
||||
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
|
||||
} => {
|
||||
debug_assert!(is_closure_or_generator(
|
||||
Place::ty_from(&local, proj_base, *self.body, self.infcx.tcx).ty
|
||||
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
|
||||
));
|
||||
|
||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
||||
@ -101,7 +101,7 @@ pub(crate) fn report_mutability_error(
|
||||
debug_assert!(self.body.local_decls[Local::new(1)].ty.is_region_ptr());
|
||||
debug_assert!(is_closure_or_generator(
|
||||
Place::ty_from(
|
||||
&the_place_err.local,
|
||||
the_place_err.local,
|
||||
the_place_err.projection,
|
||||
*self.body,
|
||||
self.infcx.tcx
|
||||
@ -195,7 +195,7 @@ pub(crate) fn report_mutability_error(
|
||||
|
||||
if let Some((span, message)) = annotate_struct_field(
|
||||
self.infcx.tcx,
|
||||
Place::ty_from(&local, proj_base, *self.body, self.infcx.tcx).ty,
|
||||
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty,
|
||||
field,
|
||||
) {
|
||||
err.span_suggestion(
|
||||
@ -271,7 +271,7 @@ pub(crate) fn report_mutability_error(
|
||||
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
|
||||
} => {
|
||||
debug_assert!(is_closure_or_generator(
|
||||
Place::ty_from(&local, proj_base, *self.body, self.infcx.tcx).ty
|
||||
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
|
||||
));
|
||||
|
||||
err.span_label(span, format!("cannot {ACT}", ACT = act));
|
||||
|
@ -1623,7 +1623,7 @@ fn check_if_path_or_subpath_is_moved(
|
||||
place_span.0.projection
|
||||
{
|
||||
let place_ty =
|
||||
Place::ty_from(&place_span.0.local, base_proj, self.body(), self.infcx.tcx);
|
||||
Place::ty_from(place_span.0.local, base_proj, self.body(), self.infcx.tcx);
|
||||
if let ty::Array(..) = place_ty.ty.kind {
|
||||
let array_place = PlaceRef { local: place_span.0.local, projection: base_proj };
|
||||
self.check_if_subslice_element_is_moved(
|
||||
@ -1740,7 +1740,7 @@ fn check_if_assigned_path_is_moved(
|
||||
// assigning to `P.f` requires `P` itself
|
||||
// be already initialized
|
||||
let tcx = self.infcx.tcx;
|
||||
let base_ty = Place::ty_from(&place.local, proj_base, self.body(), tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, proj_base, self.body(), tcx).ty;
|
||||
match base_ty.kind {
|
||||
ty::Adt(def, _) if def.has_dtor(tcx) => {
|
||||
self.check_if_path_or_subpath_is_moved(
|
||||
@ -1844,7 +1844,7 @@ fn check_parent_of_field<'cx, 'tcx>(
|
||||
// of the union - we should error in that case.
|
||||
let tcx = this.infcx.tcx;
|
||||
if let ty::Adt(def, _) =
|
||||
Place::ty_from(&base.local, base.projection, this.body(), tcx).ty.kind
|
||||
Place::ty_from(base.local, base.projection, this.body(), tcx).ty.kind
|
||||
{
|
||||
if def.is_union() {
|
||||
if this.move_data.path_map[mpi].iter().any(|moi| {
|
||||
@ -2058,7 +2058,7 @@ fn is_mutable<'d>(
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
let base_ty =
|
||||
Place::ty_from(&place.local, proj_base, self.body(), self.infcx.tcx).ty;
|
||||
Place::ty_from(place.local, proj_base, self.body(), self.infcx.tcx).ty;
|
||||
|
||||
// Check the kind of deref to decide
|
||||
match base_ty.kind {
|
||||
@ -2192,7 +2192,7 @@ pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'cx, 'tcx>) -> Optio
|
||||
match place_projection {
|
||||
[base @ .., ProjectionElem::Field(field, _ty)] => {
|
||||
let tcx = self.infcx.tcx;
|
||||
let base_ty = Place::ty_from(&place_ref.local, base, self.body(), tcx).ty;
|
||||
let base_ty = Place::ty_from(place_ref.local, base, self.body(), tcx).ty;
|
||||
|
||||
if (base_ty.is_closure() || base_ty.is_generator())
|
||||
&& (!by_ref || self.upvars[field.index()].by_ref)
|
||||
|
@ -48,7 +48,7 @@ fn ignore_borrow(
|
||||
let proj_base = &self.projection[..i];
|
||||
|
||||
if *elem == ProjectionElem::Deref {
|
||||
let ty = Place::ty_from(&self.local, proj_base, body, tcx).ty;
|
||||
let ty = Place::ty_from(self.local, proj_base, body, tcx).ty;
|
||||
match ty.kind {
|
||||
ty::Ref(_, _, hir::Mutability::Not) if i == 0 => {
|
||||
// For references to thread-local statics, we do need
|
||||
|
@ -208,7 +208,7 @@ fn place_components_conflict<'tcx>(
|
||||
// access cares about.
|
||||
|
||||
let proj_base = &borrow_place.projection[..access_place.projection.len() + i];
|
||||
let base_ty = Place::ty_from(&borrow_local, proj_base, body, tcx).ty;
|
||||
let base_ty = Place::ty_from(borrow_local, proj_base, body, tcx).ty;
|
||||
|
||||
match (elem, &base_ty.kind, access) {
|
||||
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
|
||||
@ -329,7 +329,7 @@ fn place_projection_conflict<'tcx>(
|
||||
debug!("place_element_conflict: DISJOINT-OR-EQ-FIELD");
|
||||
Overlap::EqualOrDisjoint
|
||||
} else {
|
||||
let ty = Place::ty_from(&pi1_local, pi1_proj_base, body, tcx).ty;
|
||||
let ty = Place::ty_from(pi1_local, pi1_proj_base, body, tcx).ty;
|
||||
match ty.kind {
|
||||
ty::Adt(def, _) if def.is_union() => {
|
||||
// Different fields of a union, we are basically stuck.
|
||||
|
@ -120,7 +120,7 @@ fn next(&mut self) -> Option<Self::Item> {
|
||||
// derefs, except we stop at the deref of a shared
|
||||
// reference.
|
||||
|
||||
let ty = Place::ty_from(&cursor.local, proj_base, *self.body, self.tcx).ty;
|
||||
let ty = Place::ty_from(cursor.local, proj_base, *self.body, self.tcx).ty;
|
||||
match ty.kind {
|
||||
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
|
||||
// don't continue traversing over derefs of raw pointers or shared
|
||||
|
@ -2390,7 +2390,7 @@ fn add_reborrow_constraint(
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
let tcx = self.infcx.tcx;
|
||||
let base_ty = Place::ty_from(&borrowed_place.local, proj_base, body, tcx).ty;
|
||||
let base_ty = Place::ty_from(borrowed_place.local, proj_base, body, tcx).ty;
|
||||
|
||||
debug!("add_reborrow_constraint - base_ty = {:?}", base_ty);
|
||||
match base_ty.kind {
|
||||
|
@ -109,7 +109,7 @@ fn move_path_for(&mut self, place: &Place<'tcx>) -> Result<MovePathIndex, MoveEr
|
||||
let proj_base = &place.projection[..i];
|
||||
let body = self.builder.body;
|
||||
let tcx = self.builder.tcx;
|
||||
let place_ty = Place::ty_from(&place.local, proj_base, body, tcx).ty;
|
||||
let place_ty = Place::ty_from(place.local, proj_base, body, tcx).ty;
|
||||
match place_ty.kind {
|
||||
ty::Ref(..) | ty::RawPtr(..) => {
|
||||
let proj = &place.projection[..i + 1];
|
||||
@ -490,7 +490,7 @@ fn gather_init(&mut self, place: PlaceRef<'cx, 'tcx>, kind: InitKind) {
|
||||
// of the union so it is marked as initialized again.
|
||||
if let [proj_base @ .., ProjectionElem::Field(_, _)] = place.projection {
|
||||
if let ty::Adt(def, _) =
|
||||
Place::ty_from(&place.local, proj_base, self.builder.body, self.builder.tcx).ty.kind
|
||||
Place::ty_from(place.local, proj_base, self.builder.body, self.builder.tcx).ty.kind
|
||||
{
|
||||
if def.is_union() {
|
||||
place = PlaceRef { local: place.local, projection: proj_base }
|
||||
|
@ -46,7 +46,7 @@ fn in_projection_structurally(
|
||||
let qualif = base_qualif
|
||||
&& Self::in_any_value_of_ty(
|
||||
cx,
|
||||
Place::ty_from(&place.local, proj_base, *cx.body, cx.tcx)
|
||||
Place::ty_from(place.local, proj_base, *cx.body, cx.tcx)
|
||||
.projection_ty(cx.tcx, elem)
|
||||
.ty,
|
||||
);
|
||||
@ -149,7 +149,7 @@ fn in_rvalue_structurally(
|
||||
Rvalue::Ref(_, _, ref place) | Rvalue::AddressOf(_, ref place) => {
|
||||
// Special-case reborrows to be more like a copy of the reference.
|
||||
if let [proj_base @ .., ProjectionElem::Deref] = place.projection.as_ref() {
|
||||
let base_ty = Place::ty_from(&place.local, proj_base, *cx.body, cx.tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, proj_base, *cx.body, cx.tcx).ty;
|
||||
if let ty::Ref(..) = base_ty.kind {
|
||||
return Self::in_place(
|
||||
cx,
|
||||
|
@ -448,7 +448,7 @@ fn visit_projection_elem(
|
||||
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
let base_ty = Place::ty_from(place_local, proj_base, *self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(*place_local, proj_base, *self.body, self.tcx).ty;
|
||||
if let ty::RawPtr(_) = base_ty.kind {
|
||||
if proj_base.is_empty() {
|
||||
if let (local, []) = (place_local, proj_base) {
|
||||
@ -472,7 +472,7 @@ fn visit_projection_elem(
|
||||
| ProjectionElem::Subslice { .. }
|
||||
| ProjectionElem::Field(..)
|
||||
| ProjectionElem::Index(_) => {
|
||||
let base_ty = Place::ty_from(place_local, proj_base, *self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(*place_local, proj_base, *self.body, self.tcx).ty;
|
||||
match base_ty.ty_adt_def() {
|
||||
Some(def) if def.is_union() => {
|
||||
self.check_op(ops::UnionAccess);
|
||||
@ -664,7 +664,7 @@ fn place_as_reborrow(
|
||||
//
|
||||
// This is sufficient to prevent an access to a `static mut` from being marked as a
|
||||
// reborrow, even if the check above were to disappear.
|
||||
let inner_ty = Place::ty_from(&place.local, inner, body, tcx).ty;
|
||||
let inner_ty = Place::ty_from(place.local, inner, body, tcx).ty;
|
||||
match inner_ty.kind {
|
||||
ty::Ref(..) => Some(inner),
|
||||
_ => None,
|
||||
|
@ -215,7 +215,7 @@ fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location:
|
||||
}
|
||||
}
|
||||
let is_borrow_of_interior_mut = context.is_borrow()
|
||||
&& !Place::ty_from(&place.local, proj_base, self.body, self.tcx).ty.is_freeze(
|
||||
&& !Place::ty_from(place.local, proj_base, self.body, self.tcx).ty.is_freeze(
|
||||
self.tcx,
|
||||
self.param_env,
|
||||
self.source_info.span,
|
||||
@ -260,7 +260,7 @@ fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location:
|
||||
}
|
||||
}
|
||||
}
|
||||
let base_ty = Place::ty_from(&place.local, proj_base, self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, proj_base, self.body, self.tcx).ty;
|
||||
match base_ty.kind {
|
||||
ty::RawPtr(..) => self.require_unsafe(
|
||||
"dereference of raw pointer",
|
||||
@ -414,7 +414,7 @@ fn check_mut_borrowing_layout_constrained_field(
|
||||
match elem {
|
||||
ProjectionElem::Field(..) => {
|
||||
let ty =
|
||||
Place::ty_from(&place.local, proj_base, &self.body.local_decls, self.tcx)
|
||||
Place::ty_from(place.local, proj_base, &self.body.local_decls, self.tcx)
|
||||
.ty;
|
||||
match ty.kind {
|
||||
ty::Adt(def, _) => match self.tcx.layout_scalar_valid_range(def.did) {
|
||||
|
@ -95,7 +95,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
|
||||
if let PlaceRef { local, projection: &[ref proj_base @ .., ProjectionElem::Deref] } =
|
||||
place.as_ref()
|
||||
{
|
||||
if Place::ty_from(&local, proj_base, self.body, self.tcx).ty.is_region_ptr() {
|
||||
if Place::ty_from(local, proj_base, self.body, self.tcx).ty.is_region_ptr() {
|
||||
self.optimizations.and_stars.insert(location);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
|
||||
// FIXME(eddyb) this is probably excessive, with
|
||||
// the exception of `union` member accesses.
|
||||
let ty =
|
||||
Place::ty_from(&place.local, proj_base, *self.body, self.tcx)
|
||||
Place::ty_from(place.local, proj_base, *self.body, self.tcx)
|
||||
.projection_ty(self.tcx, elem)
|
||||
.ty;
|
||||
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
|
||||
@ -491,7 +491,7 @@ fn validate_place(&self, place: PlaceRef<'_, 'tcx>) -> Result<(), Unpromotable>
|
||||
ProjectionElem::Field(..) => {
|
||||
if self.const_kind.is_none() {
|
||||
let base_ty =
|
||||
Place::ty_from(&place.local, proj_base, *self.body, self.tcx).ty;
|
||||
Place::ty_from(place.local, proj_base, *self.body, self.tcx).ty;
|
||||
if let Some(def) = base_ty.ty_adt_def() {
|
||||
// No promotion of union field accesses.
|
||||
if def.is_union() {
|
||||
@ -589,7 +589,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
|
||||
// Raw reborrows can come from reference to pointer coercions,
|
||||
// so are allowed.
|
||||
if let [proj_base @ .., ProjectionElem::Deref] = place.projection.as_ref() {
|
||||
let base_ty = Place::ty_from(&place.local, proj_base, *self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, proj_base, *self.body, self.tcx).ty;
|
||||
if let ty::Ref(..) = base_ty.kind {
|
||||
return self.validate_place(PlaceRef {
|
||||
local: place.local,
|
||||
@ -628,7 +628,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
|
||||
// Special-case reborrows to be more like a copy of the reference.
|
||||
let mut place = place.as_ref();
|
||||
if let [proj_base @ .., ProjectionElem::Deref] = &place.projection {
|
||||
let base_ty = Place::ty_from(&place.local, proj_base, *self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, proj_base, *self.body, self.tcx).ty;
|
||||
if let ty::Ref(..) = base_ty.kind {
|
||||
place = PlaceRef { local: place.local, projection: proj_base };
|
||||
}
|
||||
@ -647,7 +647,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
|
||||
while let [proj_base @ .., elem] = place_projection {
|
||||
// FIXME(eddyb) this is probably excessive, with
|
||||
// the exception of `union` member accesses.
|
||||
let ty = Place::ty_from(&place.local, proj_base, *self.body, self.tcx)
|
||||
let ty = Place::ty_from(place.local, proj_base, *self.body, self.tcx)
|
||||
.projection_ty(self.tcx, elem)
|
||||
.ty;
|
||||
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
|
||||
|
@ -268,7 +268,7 @@ fn check_place(
|
||||
ProjectionElem::Downcast(_symbol, _variant_index) => {}
|
||||
|
||||
ProjectionElem::Field(..) => {
|
||||
let base_ty = Place::ty_from(&place.local, &proj_base, body, tcx).ty;
|
||||
let base_ty = Place::ty_from(place.local, &proj_base, body, tcx).ty;
|
||||
if let Some(def) = base_ty.ty_adt_def() {
|
||||
// No union field accesses in `const fn`
|
||||
if def.is_union() {
|
||||
|
@ -46,7 +46,7 @@ fn is_within_packed<'tcx, L>(tcx: TyCtxt<'tcx>, local_decls: &L, place: &Place<'
|
||||
// encountered a Deref, which is ABI-aligned
|
||||
ProjectionElem::Deref => break,
|
||||
ProjectionElem::Field(..) => {
|
||||
let ty = Place::ty_from(&place.local, proj_base, local_decls, tcx).ty;
|
||||
let ty = Place::ty_from(place.local, proj_base, local_decls, tcx).ty;
|
||||
match ty.kind {
|
||||
ty::Adt(def, _) if def.repr.packed() => return true,
|
||||
_ => {}
|
||||
|
@ -364,7 +364,7 @@ fn add_fake_borrows_of_base(
|
||||
) {
|
||||
let tcx = self.hir.tcx();
|
||||
let place_ty =
|
||||
Place::ty_from(&base_place.local, &base_place.projection, &self.local_decls, tcx);
|
||||
Place::ty_from(base_place.local, &base_place.projection, &self.local_decls, tcx);
|
||||
if let ty::Slice(_) = place_ty.ty.kind {
|
||||
// We need to create fake borrows to ensure that the bounds
|
||||
// check that we just did stays valid. Since we can't assign to
|
||||
@ -374,7 +374,7 @@ fn add_fake_borrows_of_base(
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
let fake_borrow_deref_ty = Place::ty_from(
|
||||
&base_place.local,
|
||||
base_place.local,
|
||||
&base_place.projection[..idx],
|
||||
&self.local_decls,
|
||||
tcx,
|
||||
@ -399,7 +399,7 @@ fn add_fake_borrows_of_base(
|
||||
}
|
||||
ProjectionElem::Index(_) => {
|
||||
let index_ty = Place::ty_from(
|
||||
&base_place.local,
|
||||
base_place.local,
|
||||
&base_place.projection[..idx],
|
||||
&self.local_decls,
|
||||
tcx,
|
||||
|
Loading…
Reference in New Issue
Block a user