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