From d376012a43f91f6dfdd761d786c016f7c343f950 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 15 Sep 2022 13:43:44 +0000 Subject: [PATCH] Derive TypeFoldable and TypeVisitable for mir::PlaceElement --- compiler/rustc_middle/src/mir/mod.rs | 2 -- compiler/rustc_middle/src/mir/syntax.rs | 2 +- compiler/rustc_middle/src/mir/type_foldable.rs | 17 ----------------- compiler/rustc_middle/src/mir/type_visitable.rs | 12 ------------ 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 526bb5d7285..685f11db4e0 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2551,8 +2551,6 @@ pub(crate) fn variant( } } -TrivialTypeTraversalAndLiftImpls! { ProjectionKind, } - impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection { fn try_fold_with>(self, folder: &mut F) -> Result { Ok(UserTypeProjection { diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index d2bb897b5b6..89b999b55b9 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -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 { Deref, Field(Field, T), diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index dc72d409473..64dac2e3834 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -175,23 +175,6 @@ fn try_fold_with>(self, folder: &mut F) -> Result TypeFoldable<'tcx> for PlaceElem<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { - 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>(self, _: &mut F) -> Result { Ok(self) diff --git a/compiler/rustc_middle/src/mir/type_visitable.rs b/compiler/rustc_middle/src/mir/type_visitable.rs index 2963c3273ab..7875b2bb8cf 100644 --- a/compiler/rustc_middle/src/mir/type_visitable.rs +++ b/compiler/rustc_middle/src/mir/type_visitable.rs @@ -137,18 +137,6 @@ fn visit_with>(&self, visitor: &mut V) -> ControlFlow TypeVisitable<'tcx> for PlaceElem<'tcx> { - fn visit_with>(&self, visitor: &mut Vs) -> ControlFlow { - 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>(&self, _: &mut V) -> ControlFlow { ControlFlow::CONTINUE