mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Derive Type{Foldable,Visitable}
for UserTypeProjection
.
Because the derived versions are good enough.
This commit is contained in:
parent
671de6d62a
commit
a82ad2fed4
@ -9,7 +9,7 @@ use crate::mir::visit::MirVisitable;
|
||||
use crate::ty::codec::{TyDecoder, TyEncoder};
|
||||
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
|
||||
use crate::ty::visit::TypeVisitableExt;
|
||||
use crate::ty::{self, List, Ty, TyCtxt};
|
||||
use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex};
|
||||
use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
|
||||
@ -36,7 +36,7 @@ use either::Either;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::{self, Debug, Display, Formatter, Write};
|
||||
use std::ops::{ControlFlow, Index, IndexMut};
|
||||
use std::ops::{Index, IndexMut};
|
||||
use std::{iter, mem};
|
||||
|
||||
pub use self::query::*;
|
||||
@ -2722,6 +2722,7 @@ impl<'tcx> UserTypeProjections {
|
||||
/// `field[0]` (aka `.0`), indicating that the type of `s` is
|
||||
/// determined by finding the type of the `.0` field from `T`.
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
|
||||
#[derive(TypeFoldable, TypeVisitable)]
|
||||
pub struct UserTypeProjection {
|
||||
pub base: UserTypeAnnotationIndex,
|
||||
pub projs: Vec<ProjectionKind>,
|
||||
@ -2765,28 +2766,6 @@ impl UserTypeProjection {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for UserTypeProjection {
|
||||
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self, F::Error> {
|
||||
Ok(UserTypeProjection {
|
||||
base: self.base.try_fold_with(folder)?,
|
||||
projs: self.projs.try_fold_with(folder)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for UserTypeProjection {
|
||||
fn visit_with<Vs: TypeVisitor<TyCtxt<'tcx>>>(
|
||||
&self,
|
||||
visitor: &mut Vs,
|
||||
) -> ControlFlow<Vs::BreakTy> {
|
||||
self.base.visit_with(visitor)
|
||||
// Note: there's nothing in `self.proj` to visit.
|
||||
}
|
||||
}
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
#[derive(HashStable)]
|
||||
#[debug_format = "promoted[{}]"]
|
||||
|
Loading…
Reference in New Issue
Block a user