Skip to content

Commit 99e070f

Browse files
committed
Derive traversable impls for UserTypeProjection
UserTypeProjection had explicit traversable implementations, but which were in effect no-ops. There is no good reason for these impls not be derived instead.
1 parent d2ec961 commit 99e070f

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

+3-24
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::*;
@@ -2709,6 +2709,7 @@ impl<'tcx> UserTypeProjections {
27092709
/// `field[0]` (aka `.0`), indicating that the type of `s` is
27102710
/// determined by finding the type of the `.0` field from `T`.
27112711
#[derive(Clone, Debug, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
2712+
#[derive(TypeFoldable, TypeVisitable)]
27122713
pub struct UserTypeProjection {
27132714
pub base: UserTypeAnnotationIndex,
27142715
pub projs: Vec<ProjectionKind>,
@@ -2752,28 +2753,6 @@ impl UserTypeProjection {
27522753
}
27532754
}
27542755

2755-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for UserTypeProjection {
2756-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
2757-
self,
2758-
folder: &mut F,
2759-
) -> Result<Self, F::Error> {
2760-
Ok(UserTypeProjection {
2761-
base: self.base.try_fold_with(folder)?,
2762-
projs: self.projs.try_fold_with(folder)?,
2763-
})
2764-
}
2765-
}
2766-
2767-
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for UserTypeProjection {
2768-
fn visit_with<Vs: TypeVisitor<TyCtxt<'tcx>>>(
2769-
&self,
2770-
visitor: &mut Vs,
2771-
) -> ControlFlow<Vs::BreakTy> {
2772-
self.base.visit_with(visitor)
2773-
// Note: there's nothing in `self.proj` to visit.
2774-
}
2775-
}
2776-
27772756
rustc_index::newtype_index! {
27782757
#[derive(HashStable)]
27792758
#[debug_format = "promoted[{}]"]

0 commit comments

Comments
 (0)