Skip to content

Commit a82ad2f

Browse files
committed
Derive Type{Foldable,Visitable} for UserTypeProjection.
Because the derived versions are good enough.
1 parent 671de6d commit a82ad2f

File tree

1 file changed

+3
-24
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+3
-24
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::mir::visit::MirVisitable;
99
use crate::ty::codec::{TyDecoder, TyEncoder};
1010
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
1111
use crate::ty::print::{FmtPrinter, Printer};
12-
use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
12+
use crate::ty::visit::TypeVisitableExt;
1313
use crate::ty::{self, List, Ty, TyCtxt};
1414
use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex};
1515
use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
@@ -36,7 +36,7 @@ use either::Either;
3636

3737
use std::borrow::Cow;
3838
use std::fmt::{self, Debug, Display, Formatter, Write};
39-
use std::ops::{ControlFlow, Index, IndexMut};
39+
use std::ops::{Index, IndexMut};
4040
use std::{iter, mem};
4141

4242
pub use self::query::*;
@@ -2722,6 +2722,7 @@ impl<'tcx> UserTypeProjections {
27222722
/// `field[0]` (aka `.0`), indicating that the type of `s` is
27232723
/// determined by finding the type of the `.0` field from `T`.
27242724
#[derive(Clone, Debug, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
2725+
#[derive(TypeFoldable, TypeVisitable)]
27252726
pub struct UserTypeProjection {
27262727
pub base: UserTypeAnnotationIndex,
27272728
pub projs: Vec<ProjectionKind>,
@@ -2765,28 +2766,6 @@ impl UserTypeProjection {
27652766
}
27662767
}
27672768

2768-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for UserTypeProjection {
2769-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
2770-
self,
2771-
folder: &mut F,
2772-
) -> Result<Self, F::Error> {
2773-
Ok(UserTypeProjection {
2774-
base: self.base.try_fold_with(folder)?,
2775-
projs: self.projs.try_fold_with(folder)?,
2776-
})
2777-
}
2778-
}
2779-
2780-
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for UserTypeProjection {
2781-
fn visit_with<Vs: TypeVisitor<TyCtxt<'tcx>>>(
2782-
&self,
2783-
visitor: &mut Vs,
2784-
) -> ControlFlow<Vs::BreakTy> {
2785-
self.base.visit_with(visitor)
2786-
// Note: there's nothing in `self.proj` to visit.
2787-
}
2788-
}
2789-
27902769
rustc_index::newtype_index! {
27912770
#[derive(HashStable)]
27922771
#[debug_format = "promoted[{}]"]

0 commit comments

Comments
 (0)