Derive TypeFoldable and TypeVisitable for mir::PlaceElement
This commit is contained in:
parent
10c0560cd2
commit
d376012a43
@ -2551,8 +2551,6 @@ pub(crate) fn variant(
|
||||
}
|
||||
}
|
||||
|
||||
TrivialTypeTraversalAndLiftImpls! { ProjectionKind, }
|
||||
|
||||
impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
|
||||
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
|
||||
Ok(UserTypeProjection {
|
||||
|
@ -872,7 +872,7 @@ pub struct Place<'tcx> {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
|
||||
pub enum ProjectionElem<V, T> {
|
||||
Deref,
|
||||
Field(Field, T),
|
||||
|
@ -175,23 +175,6 @@ fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Se
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
|
||||
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
|
||||
use crate::mir::ProjectionElem::*;
|
||||
|
||||
Ok(match self {
|
||||
Deref => Deref,
|
||||
Field(f, ty) => Field(f, ty.try_fold_with(folder)?),
|
||||
Index(v) => Index(v.try_fold_with(folder)?),
|
||||
Downcast(symbol, variantidx) => Downcast(symbol, variantidx),
|
||||
ConstantIndex { offset, min_length, from_end } => {
|
||||
ConstantIndex { offset, min_length, from_end }
|
||||
}
|
||||
Subslice { from, to, from_end } => Subslice { from, to, from_end },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
|
||||
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
|
||||
Ok(self)
|
||||
|
@ -137,18 +137,6 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::Br
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitable<'tcx> for PlaceElem<'tcx> {
|
||||
fn visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<Vs::BreakTy> {
|
||||
use crate::mir::ProjectionElem::*;
|
||||
|
||||
match self {
|
||||
Field(_, ty) => ty.visit_with(visitor),
|
||||
Index(v) => v.visit_with(visitor),
|
||||
_ => ControlFlow::CONTINUE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitable<'tcx> for GeneratorSavedLocal {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
ControlFlow::CONTINUE
|
||||
|
Loading…
Reference in New Issue
Block a user