Skip to content

Commit d376012

Browse files
committed
Derive TypeFoldable and TypeVisitable for mir::PlaceElement
1 parent 10c0560 commit d376012

File tree

4 files changed

+1
-32
lines changed

4 files changed

+1
-32
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,6 @@ impl UserTypeProjection {
25512551
}
25522552
}
25532553

2554-
TrivialTypeTraversalAndLiftImpls! { ProjectionKind, }
2555-
25562554
impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
25572555
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
25582556
Ok(UserTypeProjection {

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ pub struct Place<'tcx> {
872872
}
873873

874874
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
875-
#[derive(TyEncodable, TyDecodable, HashStable)]
875+
#[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
876876
pub enum ProjectionElem<V, T> {
877877
Deref,
878878
Field(Field, T),

compiler/rustc_middle/src/mir/type_foldable.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,23 +175,6 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
175175
}
176176
}
177177

178-
impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
179-
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
180-
use crate::mir::ProjectionElem::*;
181-
182-
Ok(match self {
183-
Deref => Deref,
184-
Field(f, ty) => Field(f, ty.try_fold_with(folder)?),
185-
Index(v) => Index(v.try_fold_with(folder)?),
186-
Downcast(symbol, variantidx) => Downcast(symbol, variantidx),
187-
ConstantIndex { offset, min_length, from_end } => {
188-
ConstantIndex { offset, min_length, from_end }
189-
}
190-
Subslice { from, to, from_end } => Subslice { from, to, from_end },
191-
})
192-
}
193-
}
194-
195178
impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
196179
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
197180
Ok(self)

compiler/rustc_middle/src/mir/type_visitable.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,6 @@ impl<'tcx> TypeVisitable<'tcx> for Operand<'tcx> {
137137
}
138138
}
139139

140-
impl<'tcx> TypeVisitable<'tcx> for PlaceElem<'tcx> {
141-
fn visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<Vs::BreakTy> {
142-
use crate::mir::ProjectionElem::*;
143-
144-
match self {
145-
Field(_, ty) => ty.visit_with(visitor),
146-
Index(v) => v.visit_with(visitor),
147-
_ => ControlFlow::CONTINUE,
148-
}
149-
}
150-
}
151-
152140
impl<'tcx> TypeVisitable<'tcx> for GeneratorSavedLocal {
153141
fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
154142
ControlFlow::CONTINUE

0 commit comments

Comments
 (0)