Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/mir.rs')
-rw-r--r--crates/hir-ty/src/mir.rs269
1 files changed, 131 insertions, 138 deletions
diff --git a/crates/hir-ty/src/mir.rs b/crates/hir-ty/src/mir.rs
index 7aebe17e5b..6642386011 100644
--- a/crates/hir-ty/src/mir.rs
+++ b/crates/hir-ty/src/mir.rs
@@ -12,7 +12,7 @@ use hir_def::{
use la_arena::{Arena, ArenaMap, Idx, RawIdx};
use rustc_ast_ir::Mutability;
use rustc_hash::FxHashMap;
-use rustc_type_ir::inherent::{AdtDef, GenericArgs as _, IntoKind, SliceLike, Ty as _};
+use rustc_type_ir::inherent::{GenericArgs as _, IntoKind, Ty as _};
use smallvec::{SmallVec, smallvec};
use stdx::{impl_from, never};
@@ -22,9 +22,9 @@ use crate::{
db::{HirDatabase, InternedClosureId},
display::{DisplayTarget, HirDisplay},
infer::PointerCast,
- lang_items::is_box,
next_solver::{
- Const, DbInterner, ErrorGuaranteed, GenericArgs, ParamEnv, Ty, TyKind,
+ Const, DbInterner, ErrorGuaranteed, GenericArgs, ParamEnv, StoredConst, StoredGenericArgs,
+ StoredTy, Ty, TyKind,
infer::{InferCtxt, traits::ObligationCause},
obligation_ctxt::ObligationCtxt,
},
@@ -50,16 +50,16 @@ pub(crate) use monomorphization::monomorphized_mir_body_cycle_result;
use super::consteval::try_const_usize;
-pub type BasicBlockId<'db> = Idx<BasicBlock<'db>>;
-pub type LocalId<'db> = Idx<Local<'db>>;
+pub type BasicBlockId = Idx<BasicBlock>;
+pub type LocalId = Idx<Local>;
-fn return_slot<'db>() -> LocalId<'db> {
+fn return_slot() -> LocalId {
LocalId::from_raw(RawIdx::from(0))
}
#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct Local<'db> {
- pub ty: Ty<'db>,
+pub struct Local {
+ pub ty: StoredTy,
}
/// An operand in MIR represents a "value" in Rust, the definition of which is undecided and part of
@@ -81,19 +81,19 @@ pub struct Local<'db> {
/// currently implements it, but it seems like this may be something to check against in the
/// validator.
#[derive(Debug, PartialEq, Eq, Clone)]
-pub struct Operand<'db> {
- kind: OperandKind<'db>,
+pub struct Operand {
+ kind: OperandKind,
// FIXME : This should actually just be of type `MirSpan`.
span: Option<MirSpan>,
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum OperandKind<'db> {
+pub enum OperandKind {
/// Creates a value by loading the given place.
///
/// Before drop elaboration, the type of the place must be `Copy`. After drop elaboration there
/// is no such requirement.
- Copy(Place<'db>),
+ Copy(Place),
/// Creates a value by performing loading the place, just like the `Copy` operand.
///
@@ -102,21 +102,21 @@ pub enum OperandKind<'db> {
/// place without first re-initializing it.
///
/// [UCG#188]: https://github.com/rust-lang/unsafe-code-guidelines/issues/188
- Move(Place<'db>),
+ Move(Place),
/// Constants are already semantically values, and remain unchanged.
- Constant { konst: Const<'db>, ty: Ty<'db> },
+ Constant { konst: StoredConst, ty: StoredTy },
/// NON STANDARD: This kind of operand returns an immutable reference to that static memory. Rustc
/// handles it with the `Constant` variant somehow.
Static(StaticId),
}
-impl<'db> Operand<'db> {
+impl<'db> Operand {
fn from_concrete_const(data: Box<[u8]>, memory_map: MemoryMap<'db>, ty: Ty<'db>) -> Self {
let interner = DbInterner::conjure();
Operand {
kind: OperandKind::Constant {
- konst: Const::new_valtree(interner, ty, data, memory_map),
- ty,
+ konst: Const::new_valtree(interner, ty, data, memory_map).store(),
+ ty: ty.store(),
},
span: None,
}
@@ -126,7 +126,7 @@ impl<'db> Operand<'db> {
Operand::from_concrete_const(data, MemoryMap::default(), ty)
}
- fn const_zst(ty: Ty<'db>) -> Operand<'db> {
+ fn const_zst(ty: Ty<'db>) -> Operand {
Self::from_bytes(Box::default(), ty)
}
@@ -134,15 +134,15 @@ impl<'db> Operand<'db> {
db: &'db dyn HirDatabase,
func_id: hir_def::FunctionId,
generic_args: GenericArgs<'db>,
- ) -> Operand<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ ) -> Operand {
+ let interner = DbInterner::new_no_crate(db);
let ty = Ty::new_fn_def(interner, CallableDefId::FunctionId(func_id).into(), generic_args);
Operand::from_bytes(Box::default(), ty)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub enum ProjectionElem<V, T> {
+pub enum ProjectionElem<V: PartialEq> {
Deref,
Field(Either<FieldId, TupleFieldId>),
// FIXME: get rid of this, and use FieldId for tuples and closures
@@ -151,13 +151,14 @@ pub enum ProjectionElem<V, T> {
ConstantIndex { offset: u64, from_end: bool },
Subslice { from: u64, to: u64 },
//Downcast(Option<Symbol>, VariantIdx),
- OpaqueCast(T),
+ OpaqueCast(StoredTy),
}
-impl<V, T> ProjectionElem<V, T> {
+impl<V: PartialEq> ProjectionElem<V> {
pub fn projected_ty<'db>(
&self,
infcx: &InferCtxt<'db>,
+ env: ParamEnv<'db>,
mut base: Ty<'db>,
closure_field: impl FnOnce(InternedClosureId, GenericArgs<'db>, usize) -> Ty<'db>,
krate: Crate,
@@ -174,8 +175,6 @@ impl<V, T> ProjectionElem<V, T> {
if matches!(base.kind(), TyKind::Alias(..)) {
let mut ocx = ObligationCtxt::new(infcx);
- // FIXME: we should get this from caller
- let env = ParamEnv::empty();
match ocx.structurally_normalize_ty(&ObligationCause::dummy(), env, base) {
Ok(it) => base = it,
Err(_) => return Ty::new_error(interner, ErrorGuaranteed),
@@ -185,7 +184,7 @@ impl<V, T> ProjectionElem<V, T> {
match self {
ProjectionElem::Deref => match base.kind() {
TyKind::RawPtr(inner, _) | TyKind::Ref(_, inner, _) => inner,
- TyKind::Adt(adt_def, subst) if is_box(db, adt_def.def_id().0) => subst.type_at(0),
+ TyKind::Adt(adt_def, subst) if adt_def.is_box() => subst.type_at(0),
_ => {
never!(
"Overloaded deref on type {} is not a projection",
@@ -196,7 +195,7 @@ impl<V, T> ProjectionElem<V, T> {
},
ProjectionElem::Field(Either::Left(f)) => match base.kind() {
TyKind::Adt(_, subst) => {
- db.field_types(f.parent)[f.local_id].instantiate(interner, subst)
+ db.field_types(f.parent)[f.local_id].get().instantiate(interner, subst)
}
ty => {
never!("Only adt has field, found {:?}", ty);
@@ -255,18 +254,18 @@ impl<V, T> ProjectionElem<V, T> {
}
}
-type PlaceElem<'db> = ProjectionElem<LocalId<'db>, Ty<'db>>;
+type PlaceElem = ProjectionElem<LocalId>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ProjectionId(u32);
#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct ProjectionStore<'db> {
- id_to_proj: FxHashMap<ProjectionId, Box<[PlaceElem<'db>]>>,
- proj_to_id: FxHashMap<Box<[PlaceElem<'db>]>, ProjectionId>,
+pub struct ProjectionStore {
+ id_to_proj: FxHashMap<ProjectionId, Box<[PlaceElem]>>,
+ proj_to_id: FxHashMap<Box<[PlaceElem]>, ProjectionId>,
}
-impl Default for ProjectionStore<'_> {
+impl Default for ProjectionStore {
fn default() -> Self {
let mut this = Self { id_to_proj: Default::default(), proj_to_id: Default::default() };
// Ensure that [] will get the id 0 which is used in `ProjectionId::Empty`
@@ -275,17 +274,17 @@ impl Default for ProjectionStore<'_> {
}
}
-impl<'db> ProjectionStore<'db> {
+impl ProjectionStore {
pub fn shrink_to_fit(&mut self) {
self.id_to_proj.shrink_to_fit();
self.proj_to_id.shrink_to_fit();
}
- pub fn intern_if_exist(&self, projection: &[PlaceElem<'db>]) -> Option<ProjectionId> {
+ pub fn intern_if_exist(&self, projection: &[PlaceElem]) -> Option<ProjectionId> {
self.proj_to_id.get(projection).copied()
}
- pub fn intern(&mut self, projection: Box<[PlaceElem<'db>]>) -> ProjectionId {
+ pub fn intern(&mut self, projection: Box<[PlaceElem]>) -> ProjectionId {
let new_id = ProjectionId(self.proj_to_id.len() as u32);
match self.proj_to_id.entry(projection) {
Entry::Occupied(id) => *id.get(),
@@ -306,15 +305,11 @@ impl ProjectionId {
self == ProjectionId::EMPTY
}
- pub fn lookup<'a, 'db>(self, store: &'a ProjectionStore<'db>) -> &'a [PlaceElem<'db>] {
+ pub fn lookup(self, store: &ProjectionStore) -> &[PlaceElem] {
store.id_to_proj.get(&self).unwrap()
}
- pub fn project<'db>(
- self,
- projection: PlaceElem<'db>,
- store: &mut ProjectionStore<'db>,
- ) -> ProjectionId {
+ pub fn project(self, projection: PlaceElem, store: &mut ProjectionStore) -> ProjectionId {
let mut current = self.lookup(store).to_vec();
current.push(projection);
store.intern(current.into())
@@ -322,13 +317,13 @@ impl ProjectionId {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
-pub struct Place<'db> {
- pub local: LocalId<'db>,
+pub struct Place {
+ pub local: LocalId,
pub projection: ProjectionId,
}
-impl<'db> Place<'db> {
- fn is_parent(&self, child: &Place<'db>, store: &ProjectionStore<'db>) -> bool {
+impl Place {
+ fn is_parent(&self, child: &Place, store: &ProjectionStore) -> bool {
self.local == child.local
&& child.projection.lookup(store).starts_with(self.projection.lookup(store))
}
@@ -336,39 +331,39 @@ impl<'db> Place<'db> {
/// The place itself is not included
fn iterate_over_parents<'a>(
&'a self,
- store: &'a ProjectionStore<'db>,
- ) -> impl Iterator<Item = Place<'db>> + 'a {
+ store: &'a ProjectionStore,
+ ) -> impl Iterator<Item = Place> + 'a {
let projection = self.projection.lookup(store);
(0..projection.len()).map(|x| &projection[0..x]).filter_map(move |x| {
Some(Place { local: self.local, projection: store.intern_if_exist(x)? })
})
}
- fn project(&self, projection: PlaceElem<'db>, store: &mut ProjectionStore<'db>) -> Place<'db> {
+ fn project(&self, projection: PlaceElem, store: &mut ProjectionStore) -> Place {
Place { local: self.local, projection: self.projection.project(projection, store) }
}
}
-impl<'db> From<LocalId<'db>> for Place<'db> {
- fn from(local: LocalId<'db>) -> Self {
+impl From<LocalId> for Place {
+ fn from(local: LocalId) -> Self {
Self { local, projection: ProjectionId::EMPTY }
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum AggregateKind<'db> {
+pub enum AggregateKind {
/// The type is of the element
- Array(Ty<'db>),
+ Array(StoredTy),
/// The type is of the tuple
- Tuple(Ty<'db>),
- Adt(VariantId, GenericArgs<'db>),
+ Tuple(StoredTy),
+ Adt(VariantId, StoredGenericArgs),
Union(UnionId, FieldId),
- Closure(Ty<'db>),
+ Closure(StoredTy),
//Coroutine(LocalDefId, SubstsRef, Movability),
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
-pub struct SwitchTargets<'db> {
+pub struct SwitchTargets {
/// Possible values. The locations to branch to in each case
/// are found in the corresponding indices from the `targets` vector.
values: SmallVec<[u128; 1]>,
@@ -385,17 +380,17 @@ pub struct SwitchTargets<'db> {
//
// However we’ve decided to keep this as-is until we figure a case
// where some other approach seems to be strictly better than other.
- targets: SmallVec<[BasicBlockId<'db>; 2]>,
+ targets: SmallVec<[BasicBlockId; 2]>,
}
-impl<'db> SwitchTargets<'db> {
+impl SwitchTargets {
/// Creates switch targets from an iterator of values and target blocks.
///
/// The iterator may be empty, in which case the `SwitchInt` instruction is equivalent to
/// `goto otherwise;`.
pub fn new(
- targets: impl Iterator<Item = (u128, BasicBlockId<'db>)>,
- otherwise: BasicBlockId<'db>,
+ targets: impl Iterator<Item = (u128, BasicBlockId)>,
+ otherwise: BasicBlockId,
) -> Self {
let (values, mut targets): (SmallVec<_>, SmallVec<_>) = targets.unzip();
targets.push(otherwise);
@@ -404,12 +399,12 @@ impl<'db> SwitchTargets<'db> {
/// Builds a switch targets definition that jumps to `then` if the tested value equals `value`,
/// and to `else_` if not.
- pub fn static_if(value: u128, then: BasicBlockId<'db>, else_: BasicBlockId<'db>) -> Self {
+ pub fn static_if(value: u128, then: BasicBlockId, else_: BasicBlockId) -> Self {
Self { values: smallvec![value], targets: smallvec![then, else_] }
}
/// Returns the fallback target that is jumped to when none of the values match the operand.
- pub fn otherwise(&self) -> BasicBlockId<'db> {
+ pub fn otherwise(&self) -> BasicBlockId {
*self.targets.last().unwrap()
}
@@ -419,33 +414,33 @@ impl<'db> SwitchTargets<'db> {
/// including the `otherwise` fallback target.
///
/// Note that this may yield 0 elements. Only the `otherwise` branch is mandatory.
- pub fn iter(&self) -> impl Iterator<Item = (u128, BasicBlockId<'db>)> + '_ {
+ pub fn iter(&self) -> impl Iterator<Item = (u128, BasicBlockId)> + '_ {
iter::zip(&self.values, &self.targets).map(|(x, y)| (*x, *y))
}
/// Returns a slice with all possible jump targets (including the fallback target).
- pub fn all_targets(&self) -> &[BasicBlockId<'db>] {
+ pub fn all_targets(&self) -> &[BasicBlockId] {
&self.targets
}
/// Finds the `BasicBlock` to which this `SwitchInt` will branch given the
/// specific value. This cannot fail, as it'll return the `otherwise`
/// branch if there's not a specific match for the value.
- pub fn target_for_value(&self, value: u128) -> BasicBlockId<'db> {
+ pub fn target_for_value(&self, value: u128) -> BasicBlockId {
self.iter().find_map(|(v, t)| (v == value).then_some(t)).unwrap_or_else(|| self.otherwise())
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub struct Terminator<'db> {
+pub struct Terminator {
pub span: MirSpan,
- pub kind: TerminatorKind<'db>,
+ pub kind: TerminatorKind,
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum TerminatorKind<'db> {
+pub enum TerminatorKind {
/// Block has one successor; we continue execution there.
- Goto { target: BasicBlockId<'db> },
+ Goto { target: BasicBlockId },
/// Switches based on the computed value.
///
@@ -457,9 +452,9 @@ pub enum TerminatorKind<'db> {
/// Target values may not appear more than once.
SwitchInt {
/// The discriminant value being tested.
- discr: Operand<'db>,
+ discr: Operand,
- targets: SwitchTargets<'db>,
+ targets: SwitchTargets,
},
/// Indicates that the landing pad is finished and that the process should continue unwinding.
@@ -510,7 +505,7 @@ pub enum TerminatorKind<'db> {
/// > The drop glue is executed if, among all statements executed within this `Body`, an assignment to
/// > the place or one of its "parents" occurred more recently than a move out of it. This does not
/// > consider indirect assignments.
- Drop { place: Place<'db>, target: BasicBlockId<'db>, unwind: Option<BasicBlockId<'db>> },
+ Drop { place: Place, target: BasicBlockId, unwind: Option<BasicBlockId> },
/// Drops the place and assigns a new value to it.
///
@@ -543,10 +538,10 @@ pub enum TerminatorKind<'db> {
///
/// Disallowed after drop elaboration.
DropAndReplace {
- place: Place<'db>,
- value: Operand<'db>,
- target: BasicBlockId<'db>,
- unwind: Option<BasicBlockId<'db>>,
+ place: Place,
+ value: Operand,
+ target: BasicBlockId,
+ unwind: Option<BasicBlockId>,
},
/// Roughly speaking, evaluates the `func` operand and the arguments, and starts execution of
@@ -561,18 +556,18 @@ pub enum TerminatorKind<'db> {
/// [#71117]: https://github.com/rust-lang/rust/issues/71117
Call {
/// The function that’s being called.
- func: Operand<'db>,
+ func: Operand,
/// Arguments the function is called with.
/// These are owned by the callee, which is free to modify them.
/// This allows the memory occupied by "by-value" arguments to be
/// reused across function calls without duplicating the contents.
- args: Box<[Operand<'db>]>,
+ args: Box<[Operand]>,
/// Where the returned value will be written
- destination: Place<'db>,
+ destination: Place,
/// Where to go after this call returns. If none, the call necessarily diverges.
- target: Option<BasicBlockId<'db>>,
+ target: Option<BasicBlockId>,
/// Cleanups to be done if the call unwinds.
- cleanup: Option<BasicBlockId<'db>>,
+ cleanup: Option<BasicBlockId>,
/// `true` if this is from a call in HIR rather than from an overloaded
/// operator. True for overloaded function call.
from_hir_call: bool,
@@ -588,11 +583,11 @@ pub enum TerminatorKind<'db> {
/// necessarily executed even in the case of a panic, for example in `-C panic=abort`. If the
/// assertion does not fail, execution continues at the specified basic block.
Assert {
- cond: Operand<'db>,
+ cond: Operand,
expected: bool,
//msg: AssertMessage,
- target: BasicBlockId<'db>,
- cleanup: Option<BasicBlockId<'db>>,
+ target: BasicBlockId,
+ cleanup: Option<BasicBlockId>,
},
/// Marks a suspend point.
@@ -609,13 +604,13 @@ pub enum TerminatorKind<'db> {
/// **Needs clarification**: What about the evaluation order of the `resume_arg` and `value`?
Yield {
/// The value to return.
- value: Operand<'db>,
+ value: Operand,
/// Where to resume to.
- resume: BasicBlockId<'db>,
+ resume: BasicBlockId,
/// The place to store the resume argument in.
- resume_arg: Place<'db>,
+ resume_arg: Place,
/// Cleanup to be done if the coroutine is dropped at this suspend point.
- drop: Option<BasicBlockId<'db>>,
+ drop: Option<BasicBlockId>,
},
/// Indicates the end of dropping a coroutine.
@@ -638,10 +633,10 @@ pub enum TerminatorKind<'db> {
/// Disallowed after drop elaboration.
FalseEdge {
/// The target normal control flow will take.
- real_target: BasicBlockId<'db>,
+ real_target: BasicBlockId,
/// A block control flow could conceptually jump to, but won't in
/// practice.
- imaginary_target: BasicBlockId<'db>,
+ imaginary_target: BasicBlockId,
},
/// A terminator for blocks that only take one path in reality, but where we reserve the right
@@ -653,14 +648,14 @@ pub enum TerminatorKind<'db> {
/// Disallowed after drop elaboration.
FalseUnwind {
/// The target normal control flow will take.
- real_target: BasicBlockId<'db>,
+ real_target: BasicBlockId,
/// The imaginary cleanup block link. This particular path will never be taken
/// in practice, but in order to avoid fragility we want to always
/// consider it in borrowck. We don't want to accept programs which
/// pass borrowck only when `panic=abort` or some assertions are disabled
/// due to release vs. debug mode builds. This needs to be an `Option` because
/// of the `remove_noop_landing_pads` and `abort_unwinding_calls` passes.
- unwind: Option<BasicBlockId<'db>>,
+ unwind: Option<BasicBlockId>,
},
}
@@ -847,8 +842,8 @@ impl From<hir_def::hir::CmpOp> for BinOp {
}
}
-impl<'db> From<Operand<'db>> for Rvalue<'db> {
- fn from(x: Operand<'db>) -> Self {
+impl From<Operand> for Rvalue {
+ fn from(x: Operand) -> Self {
Self::Use(x)
}
}
@@ -877,14 +872,14 @@ pub enum CastKind {
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum Rvalue<'db> {
+pub enum Rvalue {
/// Yields the operand unchanged
- Use(Operand<'db>),
+ Use(Operand),
/// Creates an array where each element is the value of the operand.
///
/// Corresponds to source code like `[x; 32]`.
- Repeat(Operand<'db>, Const<'db>),
+ Repeat(Operand, StoredConst),
/// Creates a reference of the indicated kind to the place.
///
@@ -893,7 +888,7 @@ pub enum Rvalue<'db> {
/// exactly what the behavior of this operation should be.
///
/// `Shallow` borrows are disallowed after drop lowering.
- Ref(BorrowKind, Place<'db>),
+ Ref(BorrowKind, Place),
/// Creates a pointer/reference to the given thread local.
///
@@ -924,7 +919,7 @@ pub enum Rvalue<'db> {
/// If the type of the place is an array, this is the array length. For slices (`[T]`, not
/// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is
/// ill-formed for places of other types.
- Len(Place<'db>),
+ Len(Place),
/// Performs essentially all of the casts that can be performed via `as`.
///
@@ -932,7 +927,7 @@ pub enum Rvalue<'db> {
///
/// **FIXME**: Document exactly which `CastKind`s allow which types of casts. Figure out why
/// `ArrayToPointer` and `MutToConstPointer` are special.
- Cast(CastKind, Operand<'db>, Ty<'db>),
+ Cast(CastKind, Operand, StoredTy),
// FIXME link to `pointer::offset` when it hits stable.
/// * `Offset` has the same semantics as `pointer::offset`, except that the second
@@ -964,7 +959,7 @@ pub enum Rvalue<'db> {
/// when the value of right-hand side is negative.
///
/// Other combinations of types and operators are unsupported.
- CheckedBinaryOp(BinOp, Operand<'db>, Operand<'db>),
+ CheckedBinaryOp(BinOp, Operand, Operand),
/// Computes a value as described by the operation.
//NullaryOp(NullOp, Ty),
@@ -975,19 +970,17 @@ pub enum Rvalue<'db> {
/// Also does two's-complement arithmetic. Negation requires a signed integer or a float;
/// bitwise not requires a signed integer, unsigned integer, or bool. Both operation kinds
/// return a value with the same type as their operand.
- UnaryOp(UnOp, Operand<'db>),
+ UnaryOp(UnOp, Operand),
/// Computes the discriminant of the place, returning it as an integer of type
- /// [`discriminant_ty`]. Returns zero for types without discriminant.
+ /// `discriminant_ty`. Returns zero for types without discriminant.
///
/// The validity requirements for the underlying value are undecided for this rvalue, see
/// [#91095]. Note too that the value of the discriminant is not the same thing as the
- /// variant index; use [`discriminant_for_variant`] to convert.
+ /// variant index; use `discriminant_for_variant` to convert.
///
- /// [`discriminant_ty`]: crate::ty::Ty::discriminant_ty
/// [#91095]: https://github.com/rust-lang/rust/issues/91095
- /// [`discriminant_for_variant`]: crate::ty::Ty::discriminant_for_variant
- Discriminant(Place<'db>),
+ Discriminant(Place),
/// Creates an aggregate value, like a tuple or struct.
///
@@ -997,17 +990,17 @@ pub enum Rvalue<'db> {
///
/// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After
/// coroutine lowering, `Coroutine` aggregate kinds are disallowed too.
- Aggregate(AggregateKind<'db>, Box<[Operand<'db>]>),
+ Aggregate(AggregateKind, Box<[Operand]>),
/// Transmutes a `*mut u8` into shallow-initialized `Box<T>`.
///
/// This is different from a normal transmute because dataflow analysis will treat the box as
/// initialized but its content as uninitialized. Like other pointer casts, this in general
/// affects alias analysis.
- ShallowInitBox(Operand<'db>, Ty<'db>),
+ ShallowInitBox(Operand, StoredTy),
/// NON STANDARD: allocates memory with the type's layout, and shallow init the box with the resulting pointer.
- ShallowInitBoxWithAlloc(Ty<'db>),
+ ShallowInitBoxWithAlloc(StoredTy),
/// A CopyForDeref is equivalent to a read from a place at the
/// codegen level, but is treated specially by drop elaboration. When such a read happens, it
@@ -1017,41 +1010,41 @@ pub enum Rvalue<'db> {
/// read never happened and just projects further. This allows simplifying various MIR
/// optimizations and codegen backends that previously had to handle deref operations anywhere
/// in a place.
- CopyForDeref(Place<'db>),
+ CopyForDeref(Place),
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum StatementKind<'db> {
- Assign(Place<'db>, Rvalue<'db>),
- FakeRead(Place<'db>),
+pub enum StatementKind {
+ Assign(Place, Rvalue),
+ FakeRead(Place),
//SetDiscriminant {
// place: Box<Place>,
// variant_index: VariantIdx,
//},
- Deinit(Place<'db>),
- StorageLive(LocalId<'db>),
- StorageDead(LocalId<'db>),
+ Deinit(Place),
+ StorageLive(LocalId),
+ StorageDead(LocalId),
//Retag(RetagKind, Box<Place>),
//AscribeUserType(Place, UserTypeProjection, Variance),
//Intrinsic(Box<NonDivergingIntrinsic>),
Nop,
}
-impl<'db> StatementKind<'db> {
- fn with_span(self, span: MirSpan) -> Statement<'db> {
+impl StatementKind {
+ fn with_span(self, span: MirSpan) -> Statement {
Statement { kind: self, span }
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
-pub struct Statement<'db> {
- pub kind: StatementKind<'db>,
+pub struct Statement {
+ pub kind: StatementKind,
pub span: MirSpan,
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
-pub struct BasicBlock<'db> {
+pub struct BasicBlock {
/// List of statements in this block.
- pub statements: Vec<Statement<'db>>,
+ pub statements: Vec<Statement>,
/// Terminator for this block.
///
@@ -1061,7 +1054,7 @@ pub struct BasicBlock<'db> {
/// exception is that certain passes, such as `simplify_cfg`, swap
/// out the terminator temporarily with `None` while they continue
/// to recurse over the set of basic blocks.
- pub terminator: Option<Terminator<'db>>,
+ pub terminator: Option<Terminator>,
/// If true, this block lies on an unwind path. This is used
/// during codegen where distinct kinds of basic blocks may be
@@ -1071,29 +1064,29 @@ pub struct BasicBlock<'db> {
}
#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct MirBody<'db> {
- pub projection_store: ProjectionStore<'db>,
- pub basic_blocks: Arena<BasicBlock<'db>>,
- pub locals: Arena<Local<'db>>,
- pub start_block: BasicBlockId<'db>,
+pub struct MirBody {
+ pub projection_store: ProjectionStore,
+ pub basic_blocks: Arena<BasicBlock>,
+ pub locals: Arena<Local>,
+ pub start_block: BasicBlockId,
pub owner: DefWithBodyId,
- pub binding_locals: ArenaMap<BindingId, LocalId<'db>>,
- pub param_locals: Vec<LocalId<'db>>,
+ pub binding_locals: ArenaMap<BindingId, LocalId>,
+ pub param_locals: Vec<LocalId>,
/// This field stores the closures directly owned by this body. It is used
/// in traversing every mir body.
pub closures: Vec<InternedClosureId>,
}
-impl<'db> MirBody<'db> {
- pub fn local_to_binding_map(&self) -> ArenaMap<LocalId<'db>, BindingId> {
+impl MirBody {
+ pub fn local_to_binding_map(&self) -> ArenaMap<LocalId, BindingId> {
self.binding_locals.iter().map(|(it, y)| (*y, it)).collect()
}
- fn walk_places(&mut self, mut f: impl FnMut(&mut Place<'db>, &mut ProjectionStore<'db>)) {
- fn for_operand<'db>(
- op: &mut Operand<'db>,
- f: &mut impl FnMut(&mut Place<'db>, &mut ProjectionStore<'db>),
- store: &mut ProjectionStore<'db>,
+ fn walk_places(&mut self, mut f: impl FnMut(&mut Place, &mut ProjectionStore)) {
+ fn for_operand(
+ op: &mut Operand,
+ f: &mut impl FnMut(&mut Place, &mut ProjectionStore),
+ store: &mut ProjectionStore,
) {
match &mut op.kind {
OperandKind::Copy(p) | OperandKind::Move(p) => {