rustc: expose the mir::Body reference lifetime from mir::ReadOnlyBodyCache (#64736 fallout).
This commit is contained in:
parent
4810cf1d1b
commit
a57aea88d4
16 changed files with 62 additions and 70 deletions
|
@ -279,18 +279,10 @@ impl<'a, 'b, 'tcx> graph::GraphSuccessors<'b> for ReadOnlyBodyCache<'a, 'tcx> {
|
|||
|
||||
|
||||
impl Deref for ReadOnlyBodyCache<'a, 'tcx> {
|
||||
type Target = Body<'tcx>;
|
||||
type Target = &'a Body<'tcx>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.body
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<BasicBlock> for ReadOnlyBodyCache<'a, 'tcx> {
|
||||
type Output = BasicBlockData<'tcx>;
|
||||
|
||||
fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx> {
|
||||
&self.body[index]
|
||||
&self.body
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
|||
};
|
||||
if is_consume {
|
||||
let base_ty =
|
||||
mir::Place::ty_from(place_ref.base, proj_base, &*self.fx.mir, cx.tcx());
|
||||
mir::Place::ty_from(place_ref.base, proj_base, *self.fx.mir, cx.tcx());
|
||||
let base_ty = self.fx.monomorphize(&base_ty);
|
||||
|
||||
// ZSTs don't require any actual memory access.
|
||||
|
|
|
@ -324,7 +324,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
target: mir::BasicBlock,
|
||||
unwind: Option<mir::BasicBlock>,
|
||||
) {
|
||||
let ty = location.ty(&*self.mir, bx.tcx()).ty;
|
||||
let ty = location.ty(*self.mir, bx.tcx()).ty;
|
||||
let ty = self.monomorphize(&ty);
|
||||
let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
|
||||
|
||||
|
@ -510,7 +510,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
|
||||
let extra_args = &args[sig.inputs().len()..];
|
||||
let extra_args = extra_args.iter().map(|op_arg| {
|
||||
let op_ty = op_arg.ty(&*self.mir, bx.tcx());
|
||||
let op_ty = op_arg.ty(*self.mir, bx.tcx());
|
||||
self.monomorphize(&op_ty)
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -594,7 +594,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
let place_ty = mir::Place::ty_from(
|
||||
place_ref.base,
|
||||
place_ref.projection,
|
||||
&*self.mir,
|
||||
*self.mir,
|
||||
tcx,
|
||||
);
|
||||
self.monomorphize(&place_ty.ty)
|
||||
|
|
|
@ -460,7 +460,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
|
||||
mir::Rvalue::Discriminant(ref place) => {
|
||||
let discr_ty = rvalue.ty(&*self.mir, bx.tcx());
|
||||
let discr_ty = rvalue.ty(*self.mir, bx.tcx());
|
||||
let discr = self.codegen_place(&mut bx, &place.as_ref())
|
||||
.codegen_get_discr(&mut bx, discr_ty);
|
||||
(bx, OperandRef {
|
||||
|
@ -513,7 +513,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
mir::Rvalue::Aggregate(..) => {
|
||||
// According to `rvalue_creates_operand`, only ZST
|
||||
// aggregate rvalues are allowed to be operands.
|
||||
let ty = rvalue.ty(&*self.mir, self.cx.tcx());
|
||||
let ty = rvalue.ty(*self.mir, self.cx.tcx());
|
||||
let operand = OperandRef::new_zst(
|
||||
&mut bx,
|
||||
self.cx.layout_of(self.monomorphize(&ty)),
|
||||
|
@ -710,7 +710,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
true,
|
||||
mir::Rvalue::Repeat(..) |
|
||||
mir::Rvalue::Aggregate(..) => {
|
||||
let ty = rvalue.ty(&*self.mir, self.cx.tcx());
|
||||
let ty = rvalue.ty(*self.mir, self.cx.tcx());
|
||||
let ty = self.monomorphize(&ty);
|
||||
self.cx.spanned_layout_of(ty, span).is_zst()
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let ty = Place::ty_from(
|
||||
used_place.base,
|
||||
used_place.projection,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
self.infcx.tcx
|
||||
).ty;
|
||||
let needs_note = match ty.kind {
|
||||
|
@ -225,7 +225,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let mpi = self.move_data.moves[move_out_indices[0]].path;
|
||||
let place = &self.move_data.move_paths[mpi].place;
|
||||
|
||||
let ty = place.ty(&*self.body, self.infcx.tcx).ty;
|
||||
let ty = place.ty(*self.body, self.infcx.tcx).ty;
|
||||
let opt_name =
|
||||
self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
|
||||
let note_msg = match opt_name {
|
||||
|
@ -625,7 +625,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let ty = Place::ty_from(
|
||||
place_base,
|
||||
place_projection,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
self.infcx.tcx
|
||||
).ty;
|
||||
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
|
||||
|
@ -1635,7 +1635,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
Place::ty_from(
|
||||
&place.base,
|
||||
proj_base,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
tcx
|
||||
).ty.is_box(),
|
||||
"Drop of value behind a reference or raw pointer"
|
||||
|
@ -1648,7 +1648,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let base_ty = Place::ty_from(
|
||||
&place.base,
|
||||
proj_base,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
tcx
|
||||
).ty;
|
||||
match base_ty.kind {
|
||||
|
|
|
@ -372,7 +372,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let base_ty = Place::ty_from(
|
||||
place.base,
|
||||
place.projection,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
self.infcx.tcx).ty;
|
||||
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
..
|
||||
}) = bbd.terminator {
|
||||
if let Some(source) = BorrowedContentSource::from_call(
|
||||
func.ty(&*self.body, tcx),
|
||||
func.ty(*self.body, tcx),
|
||||
tcx
|
||||
) {
|
||||
return source;
|
||||
|
@ -519,7 +519,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let base_ty = Place::ty_from(
|
||||
deref_base.base,
|
||||
deref_base.projection,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
tcx
|
||||
).ty;
|
||||
if base_ty.is_unsafe_ptr() {
|
||||
|
|
|
@ -646,7 +646,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
|
|||
let tcx = self.infcx.tcx;
|
||||
|
||||
// Compute the type with accurate region information.
|
||||
let drop_place_ty = drop_place.ty(&*self.body, self.infcx.tcx);
|
||||
let drop_place_ty = drop_place.ty(*self.body, self.infcx.tcx);
|
||||
|
||||
// Erase the regions.
|
||||
let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty).ty;
|
||||
|
|
|
@ -300,7 +300,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
// Inspect the type of the content behind the
|
||||
// borrow to provide feedback about why this
|
||||
// was a move rather than a copy.
|
||||
let ty = deref_target_place.ty(&*self.body, self.infcx.tcx).ty;
|
||||
let ty = deref_target_place.ty(*self.body, self.infcx.tcx).ty;
|
||||
let upvar_field = self.prefixes(move_place.as_ref(), PrefixSet::All)
|
||||
.find_map(|p| self.is_upvar_field_projection(p));
|
||||
|
||||
|
@ -411,7 +411,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
};
|
||||
let move_ty = format!(
|
||||
"{:?}",
|
||||
move_place.ty(&*self.body, self.infcx.tcx).ty,
|
||||
move_place.ty(*self.body, self.infcx.tcx).ty,
|
||||
);
|
||||
if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
|
||||
let is_option = move_ty.starts_with("std::option::Option");
|
||||
|
@ -454,7 +454,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
if binds_to.is_empty() {
|
||||
let place_ty = move_from.ty(&*self.body, self.infcx.tcx).ty;
|
||||
let place_ty = move_from.ty(*self.body, self.infcx.tcx).ty;
|
||||
let place_desc = match self.describe_place(move_from.as_ref()) {
|
||||
Some(desc) => format!("`{}`", desc),
|
||||
None => format!("value"),
|
||||
|
@ -482,7 +482,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
// No binding. Nothing to suggest.
|
||||
GroupedMoveError::OtherIllegalMove { ref original_path, use_spans, .. } => {
|
||||
let span = use_spans.var_or_use();
|
||||
let place_ty = original_path.ty(&*self.body, self.infcx.tcx).ty;
|
||||
let place_ty = original_path.ty(*self.body, self.infcx.tcx).ty;
|
||||
let place_desc = match self.describe_place(original_path.as_ref()) {
|
||||
Some(desc) => format!("`{}`", desc),
|
||||
None => format!("value"),
|
||||
|
|
|
@ -64,7 +64,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
Place::ty_from(
|
||||
&the_place_err.base,
|
||||
proj_base,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
self.infcx.tcx
|
||||
).ty));
|
||||
|
||||
|
@ -115,7 +115,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
Place::ty_from(
|
||||
the_place_err.base,
|
||||
the_place_err.projection,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
self.infcx.tcx
|
||||
)
|
||||
.ty
|
||||
|
@ -229,7 +229,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
|
||||
if let Some((span, message)) = annotate_struct_field(
|
||||
self.infcx.tcx,
|
||||
Place::ty_from(base, proj_base, &*self.body, self.infcx.tcx).ty,
|
||||
Place::ty_from(base, proj_base, *self.body, self.infcx.tcx).ty,
|
||||
field,
|
||||
) {
|
||||
err.span_suggestion(
|
||||
|
@ -304,7 +304,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
|
||||
} => {
|
||||
debug_assert!(is_closure_or_generator(
|
||||
Place::ty_from(base, proj_base, &*self.body, self.infcx.tcx).ty
|
||||
Place::ty_from(base, proj_base, *self.body, self.infcx.tcx).ty
|
||||
));
|
||||
|
||||
err.span_label(span, format!("cannot {ACT}", ACT = act));
|
||||
|
|
|
@ -1413,9 +1413,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
_ => ConstraintCategory::Assignment,
|
||||
};
|
||||
|
||||
let place_ty = place.ty(&*body, tcx).ty;
|
||||
let place_ty = place.ty(*body, tcx).ty;
|
||||
let place_ty = self.normalize(place_ty, location);
|
||||
let rv_ty = rv.ty(&*body, tcx);
|
||||
let rv_ty = rv.ty(*body, tcx);
|
||||
let rv_ty = self.normalize(rv_ty, location);
|
||||
if let Err(terr) =
|
||||
self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category)
|
||||
|
@ -1467,7 +1467,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
ref place,
|
||||
variant_index,
|
||||
} => {
|
||||
let place_type = place.ty(&*body, tcx).ty;
|
||||
let place_type = place.ty(*body, tcx).ty;
|
||||
let adt = match place_type.kind {
|
||||
ty::Adt(adt, _) if adt.is_enum() => adt,
|
||||
_ => {
|
||||
|
@ -1489,7 +1489,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
};
|
||||
}
|
||||
StatementKind::AscribeUserType(box(ref place, ref projection), variance) => {
|
||||
let place_ty = place.ty(&*body, tcx).ty;
|
||||
let place_ty = place.ty(*body, tcx).ty;
|
||||
if let Err(terr) = self.relate_type_and_user_type(
|
||||
place_ty,
|
||||
variance,
|
||||
|
@ -2010,7 +2010,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
// While this is located in `nll::typeck` this error is not an NLL error, it's
|
||||
// a required check to make sure that repeated elements implement `Copy`.
|
||||
let span = body.source_info(location).span;
|
||||
let ty = operand.ty(&*body, tcx);
|
||||
let ty = operand.ty(*body, tcx);
|
||||
if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty, span) {
|
||||
// To determine if `const_in_array_repeat_expressions` feature gate should
|
||||
// be mentioned, need to check if the rvalue is promotable.
|
||||
|
@ -2064,7 +2064,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
Rvalue::Cast(cast_kind, op, ty) => {
|
||||
match cast_kind {
|
||||
CastKind::Pointer(PointerCast::ReifyFnPointer) => {
|
||||
let fn_sig = op.ty(&*body, tcx).fn_sig(tcx);
|
||||
let fn_sig = op.ty(*body, tcx).fn_sig(tcx);
|
||||
|
||||
// The type that we see in the fcx is like
|
||||
// `foo::<'a, 'b>`, where `foo` is the path to a
|
||||
|
@ -2093,7 +2093,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
|
||||
CastKind::Pointer(PointerCast::ClosureFnPointer(unsafety)) => {
|
||||
let sig = match op.ty(&*body, tcx).kind {
|
||||
let sig = match op.ty(*body, tcx).kind {
|
||||
ty::Closure(def_id, substs) => {
|
||||
substs.as_closure().sig_ty(def_id, tcx).fn_sig(tcx)
|
||||
}
|
||||
|
@ -2119,7 +2119,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
|
||||
CastKind::Pointer(PointerCast::UnsafeFnPointer) => {
|
||||
let fn_sig = op.ty(&*body, tcx).fn_sig(tcx);
|
||||
let fn_sig = op.ty(*body, tcx).fn_sig(tcx);
|
||||
|
||||
// The type that we see in the fcx is like
|
||||
// `foo::<'a, 'b>`, where `foo` is the path to a
|
||||
|
@ -2151,7 +2151,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
let &ty = ty;
|
||||
let trait_ref = ty::TraitRef {
|
||||
def_id: tcx.lang_items().coerce_unsized_trait().unwrap(),
|
||||
substs: tcx.mk_substs_trait(op.ty(&*body, tcx), &[ty.into()]),
|
||||
substs: tcx.mk_substs_trait(op.ty(*body, tcx), &[ty.into()]),
|
||||
};
|
||||
|
||||
self.prove_trait_ref(
|
||||
|
@ -2162,7 +2162,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
|
||||
CastKind::Pointer(PointerCast::MutToConstPointer) => {
|
||||
let ty_from = match op.ty(&*body, tcx).kind {
|
||||
let ty_from = match op.ty(*body, tcx).kind {
|
||||
ty::RawPtr(ty::TypeAndMut {
|
||||
ty: ty_from,
|
||||
mutbl: hir::Mutability::Mutable,
|
||||
|
@ -2210,7 +2210,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
|
||||
CastKind::Pointer(PointerCast::ArrayToPointer) => {
|
||||
let ty_from = op.ty(&*body, tcx);
|
||||
let ty_from = op.ty(*body, tcx);
|
||||
|
||||
let opt_ty_elem = match ty_from.kind {
|
||||
ty::RawPtr(
|
||||
|
@ -2272,7 +2272,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
|
||||
CastKind::Misc => {
|
||||
let ty_from = op.ty(&*body, tcx);
|
||||
let ty_from = op.ty(*body, tcx);
|
||||
let cast_ty_from = CastTy::from_ty(ty_from);
|
||||
let cast_ty_to = CastTy::from_ty(ty);
|
||||
match (cast_ty_from, cast_ty_to) {
|
||||
|
@ -2339,9 +2339,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
| Rvalue::BinaryOp(BinOp::Le, left, right)
|
||||
| Rvalue::BinaryOp(BinOp::Gt, left, right)
|
||||
| Rvalue::BinaryOp(BinOp::Ge, left, right) => {
|
||||
let ty_left = left.ty(&*body, tcx);
|
||||
let ty_left = left.ty(*body, tcx);
|
||||
if let ty::RawPtr(_) | ty::FnPtr(_) = ty_left.kind {
|
||||
let ty_right = right.ty(&*body, tcx);
|
||||
let ty_right = right.ty(*body, tcx);
|
||||
let common_ty = self.infcx.next_ty_var(
|
||||
TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
|
|
|
@ -143,7 +143,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
|
|||
// derefs, except we stop at the deref of a shared
|
||||
// reference.
|
||||
|
||||
let ty = Place::ty_from(cursor.base, proj_base, &*self.body, self.tcx).ty;
|
||||
let ty = Place::ty_from(cursor.base, proj_base, *self.body, self.tcx).ty;
|
||||
match ty.kind {
|
||||
ty::RawPtr(_) |
|
||||
ty::Ref(
|
||||
|
|
|
@ -51,7 +51,7 @@ pub trait Qualif {
|
|||
});
|
||||
let qualif = base_qualif && Self::in_any_value_of_ty(
|
||||
cx,
|
||||
Place::ty_from(place.base, proj_base, &*cx.body, cx.tcx)
|
||||
Place::ty_from(place.base, proj_base, *cx.body, cx.tcx)
|
||||
.projection_ty(cx.tcx, elem)
|
||||
.ty,
|
||||
);
|
||||
|
@ -155,7 +155,7 @@ pub trait Qualif {
|
|||
// Special-case reborrows to be more like a copy of the reference.
|
||||
if let &[ref proj_base @ .., elem] = place.projection.as_ref() {
|
||||
if ProjectionElem::Deref == elem {
|
||||
let base_ty = Place::ty_from(&place.base, proj_base, &*cx.body, cx.tcx).ty;
|
||||
let base_ty = Place::ty_from(&place.base, proj_base, *cx.body, cx.tcx).ty;
|
||||
if let ty::Ref(..) = base_ty.kind {
|
||||
return Self::in_place(cx, per_local, PlaceRef {
|
||||
base: &place.base,
|
||||
|
@ -221,7 +221,7 @@ impl Qualif for HasMutInterior {
|
|||
Rvalue::Aggregate(ref kind, _) => {
|
||||
if let AggregateKind::Adt(def, ..) = **kind {
|
||||
if Some(def.did) == cx.tcx.lang_items().unsafe_cell_type() {
|
||||
let ty = rvalue.ty(&*cx.body, cx.tcx);
|
||||
let ty = rvalue.ty(*cx.body, cx.tcx);
|
||||
assert_eq!(Self::in_any_value_of_ty(cx, ty), true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ where
|
|||
args: &[mir::Operand<'tcx>],
|
||||
return_place: &mir::Place<'tcx>,
|
||||
) {
|
||||
let return_ty = return_place.ty(&*self.item.body, self.item.tcx).ty;
|
||||
let return_ty = return_place.ty(*self.item.body, self.item.tcx).ty;
|
||||
let qualif = Q::in_call(
|
||||
self.item,
|
||||
&|l| self.qualifs_per_local.contains(l),
|
||||
|
|
|
@ -304,7 +304,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
|
||||
// Special-case reborrows to be more like a copy of a reference.
|
||||
if let Rvalue::Ref(_, kind, ref place) = *rvalue {
|
||||
if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, &*self.body, place) {
|
||||
if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, *self.body, place) {
|
||||
let ctx = match kind {
|
||||
BorrowKind::Shared => PlaceContext::NonMutatingUse(
|
||||
NonMutatingUseContext::SharedBorrow,
|
||||
|
@ -342,7 +342,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
| Rvalue::Ref(_, kind @ BorrowKind::Mut { .. }, ref place)
|
||||
| Rvalue::Ref(_, kind @ BorrowKind::Unique, ref place)
|
||||
=> {
|
||||
let ty = place.ty(&*self.body, self.tcx).ty;
|
||||
let ty = place.ty(*self.body, self.tcx).ty;
|
||||
let is_allowed = match ty.kind {
|
||||
// Inside a `static mut`, `&mut [...]` is allowed.
|
||||
ty::Array(..) | ty::Slice(_) if self.const_kind() == ConstKind::StaticMut
|
||||
|
@ -390,7 +390,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
}
|
||||
|
||||
Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) => {
|
||||
let operand_ty = operand.ty(&*self.body, self.tcx);
|
||||
let operand_ty = operand.ty(*self.body, self.tcx);
|
||||
let cast_in = CastTy::from_ty(operand_ty).expect("bad input type for cast");
|
||||
let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast");
|
||||
|
||||
|
@ -401,7 +401,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
}
|
||||
|
||||
Rvalue::BinaryOp(op, ref lhs, _) => {
|
||||
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(&*self.body, self.tcx).kind {
|
||||
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(*self.body, self.tcx).kind {
|
||||
assert!(op == BinOp::Eq || op == BinOp::Ne ||
|
||||
op == BinOp::Le || op == BinOp::Lt ||
|
||||
op == BinOp::Ge || op == BinOp::Gt ||
|
||||
|
@ -475,7 +475,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
let base_ty = Place::ty_from(place_base, proj_base, &*self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(place_base, proj_base, *self.body, self.tcx).ty;
|
||||
if let ty::RawPtr(_) = base_ty.kind {
|
||||
if proj_base.is_empty() {
|
||||
if let (PlaceBase::Local(local), []) = (place_base, proj_base) {
|
||||
|
@ -499,7 +499,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
ProjectionElem::Subslice {..} |
|
||||
ProjectionElem::Field(..) |
|
||||
ProjectionElem::Index(_) => {
|
||||
let base_ty = Place::ty_from(place_base, proj_base, &*self.body, self.tcx).ty;
|
||||
let base_ty = Place::ty_from(place_base, proj_base, *self.body, self.tcx).ty;
|
||||
match base_ty.ty_adt_def() {
|
||||
Some(def) if def.is_union() => {
|
||||
self.check_op(ops::UnionAccess);
|
||||
|
@ -548,7 +548,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
|
||||
match kind {
|
||||
TerminatorKind::Call { func, .. } => {
|
||||
let fn_ty = func.ty(&*self.body, self.tcx);
|
||||
let fn_ty = func.ty(*self.body, self.tcx);
|
||||
|
||||
let def_id = match fn_ty.kind {
|
||||
ty::FnDef(def_id, _) => def_id,
|
||||
|
@ -609,7 +609,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
// Check to see if the type of this place can ever have a drop impl. If not, this
|
||||
// `Drop` terminator is frivolous.
|
||||
let ty_needs_drop = dropped_place
|
||||
.ty(&*self.body, self.tcx)
|
||||
.ty(*self.body, self.tcx)
|
||||
.ty
|
||||
.needs_drop(self.tcx, self.param_env);
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
let ty = Place::ty_from(
|
||||
&place.base,
|
||||
proj_base,
|
||||
&*self.body,
|
||||
*self.body,
|
||||
self.tcx
|
||||
)
|
||||
.projection_ty(self.tcx, elem)
|
||||
|
@ -373,7 +373,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
}
|
||||
|
||||
if let BorrowKind::Mut { .. } = kind {
|
||||
let ty = place.ty(&*self.body, self.tcx).ty;
|
||||
let ty = place.ty(*self.body, self.tcx).ty;
|
||||
|
||||
// In theory, any zero-sized value could be borrowed
|
||||
// mutably without consequences. However, only &mut []
|
||||
|
@ -522,7 +522,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
ProjectionElem::Field(..) => {
|
||||
if self.const_kind.is_none() {
|
||||
let base_ty =
|
||||
Place::ty_from(place.base, proj_base, &*self.body, self.tcx).ty;
|
||||
Place::ty_from(place.base, 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() {
|
||||
|
@ -571,7 +571,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
|
||||
match *rvalue {
|
||||
Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) if self.const_kind.is_none() => {
|
||||
let operand_ty = operand.ty(&*self.body, self.tcx);
|
||||
let operand_ty = operand.ty(*self.body, self.tcx);
|
||||
let cast_in = CastTy::from_ty(operand_ty).expect("bad input type for cast");
|
||||
let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast");
|
||||
match (cast_in, cast_out) {
|
||||
|
@ -585,7 +585,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
}
|
||||
|
||||
Rvalue::BinaryOp(op, ref lhs, _) if self.const_kind.is_none() => {
|
||||
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(&*self.body, self.tcx).kind {
|
||||
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(*self.body, self.tcx).kind {
|
||||
assert!(op == BinOp::Eq || op == BinOp::Ne ||
|
||||
op == BinOp::Le || op == BinOp::Lt ||
|
||||
op == BinOp::Ge || op == BinOp::Gt ||
|
||||
|
@ -620,7 +620,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
|
||||
Rvalue::Ref(_, kind, place) => {
|
||||
if let BorrowKind::Mut { .. } = kind {
|
||||
let ty = place.ty(&*self.body, self.tcx).ty;
|
||||
let ty = place.ty(*self.body, self.tcx).ty;
|
||||
|
||||
// In theory, any zero-sized value could be borrowed
|
||||
// mutably without consequences. However, only &mut []
|
||||
|
@ -647,7 +647,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
let mut place = place.as_ref();
|
||||
if let [proj_base @ .., ProjectionElem::Deref] = &place.projection {
|
||||
let base_ty =
|
||||
Place::ty_from(&place.base, proj_base, &*self.body, self.tcx).ty;
|
||||
Place::ty_from(&place.base, proj_base, *self.body, self.tcx).ty;
|
||||
if let ty::Ref(..) = base_ty.kind {
|
||||
place = PlaceRef {
|
||||
base: &place.base,
|
||||
|
@ -673,7 +673,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
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.base, proj_base, &*self.body, self.tcx)
|
||||
let ty = Place::ty_from(place.base, proj_base, *self.body, self.tcx)
|
||||
.projection_ty(self.tcx, elem)
|
||||
.ty;
|
||||
if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
|
||||
|
@ -706,7 +706,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
callee: &Operand<'tcx>,
|
||||
args: &[Operand<'tcx>],
|
||||
) -> Result<(), Unpromotable> {
|
||||
let fn_ty = callee.ty(&*self.body, self.tcx);
|
||||
let fn_ty = callee.ty(*self.body, self.tcx);
|
||||
|
||||
if !self.explicit && self.const_kind.is_none() {
|
||||
if let ty::FnDef(def_id, _) = fn_ty.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue