Add #[derive(TypeVisitable)]

This commit is contained in:
Alan Egerton 2022-06-17 10:53:29 +01:00
parent bca894909c
commit e4b9625b87
No known key found for this signature in database
GPG key ID: 07CAC3CCA7E0643F
31 changed files with 183 additions and 221 deletions

View file

@ -318,7 +318,7 @@ pub struct InferCtxt<'a, 'tcx> {
} }
/// See the `error_reporting` module for more details. /// See the `error_reporting` module for more details.
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable)] #[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable)]
pub enum ValuePairs<'tcx> { pub enum ValuePairs<'tcx> {
Regions(ExpectedFound<ty::Region<'tcx>>), Regions(ExpectedFound<ty::Region<'tcx>>),
Terms(ExpectedFound<ty::Term<'tcx>>), Terms(ExpectedFound<ty::Term<'tcx>>),

View file

@ -165,7 +165,7 @@ pub struct Verify<'tcx> {
pub bound: VerifyBound<'tcx>, pub bound: VerifyBound<'tcx>,
} }
#[derive(Copy, Clone, PartialEq, Eq, Hash, TypeFoldable)] #[derive(Copy, Clone, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
pub enum GenericKind<'tcx> { pub enum GenericKind<'tcx> {
Param(ty::ParamTy), Param(ty::ParamTy),
Projection(ty::ProjectionTy<'tcx>), Projection(ty::ProjectionTy<'tcx>),
@ -272,7 +272,7 @@ pub enum VerifyBound<'tcx> {
/// } /// }
/// } /// }
/// ``` /// ```
#[derive(Debug, Copy, Clone, TypeFoldable)] #[derive(Debug, Copy, Clone, TypeFoldable, TypeVisitable)]
pub struct VerifyIfEq<'tcx> { pub struct VerifyIfEq<'tcx> {
/// Type which must match the generic `G` /// Type which must match the generic `G`
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,

View file

@ -20,7 +20,7 @@ pub struct MismatchedProjectionTypes<'tcx> {
pub err: ty::error::TypeError<'tcx>, pub err: ty::error::TypeError<'tcx>,
} }
#[derive(Clone, TypeFoldable)] #[derive(Clone, TypeFoldable, TypeVisitable)]
pub struct Normalized<'tcx, T> { pub struct Normalized<'tcx, T> {
pub value: T, pub value: T,
pub obligations: Vec<PredicateObligation<'tcx>>, pub obligations: Vec<PredicateObligation<'tcx>>,

View file

@ -18,6 +18,7 @@ mod query;
mod serialize; mod serialize;
mod symbols; mod symbols;
mod type_foldable; mod type_foldable;
mod type_visitable;
#[proc_macro] #[proc_macro]
pub fn rustc_queries(input: TokenStream) -> TokenStream { pub fn rustc_queries(input: TokenStream) -> TokenStream {
@ -121,6 +122,7 @@ decl_derive!([TyEncodable] => serialize::type_encodable_derive);
decl_derive!([MetadataDecodable] => serialize::meta_decodable_derive); decl_derive!([MetadataDecodable] => serialize::meta_decodable_derive);
decl_derive!([MetadataEncodable] => serialize::meta_encodable_derive); decl_derive!([MetadataEncodable] => serialize::meta_encodable_derive);
decl_derive!([TypeFoldable, attributes(type_foldable)] => type_foldable::type_foldable_derive); decl_derive!([TypeFoldable, attributes(type_foldable)] => type_foldable::type_foldable_derive);
decl_derive!([TypeVisitable, attributes(type_visitable)] => type_visitable::type_visitable_derive);
decl_derive!([Lift, attributes(lift)] => lift::lift_derive); decl_derive!([Lift, attributes(lift)] => lift::lift_derive);
decl_derive!( decl_derive!(
[SessionDiagnostic, attributes( [SessionDiagnostic, attributes(

View file

@ -11,11 +11,6 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
} }
s.add_bounds(synstructure::AddBounds::Generics); s.add_bounds(synstructure::AddBounds::Generics);
let body_visit = s.each(|bind| {
quote! {
::rustc_middle::ty::fold::TypeFoldable::visit_with(#bind, __folder)?;
}
});
s.bind_with(|_| synstructure::BindStyle::Move); s.bind_with(|_| synstructure::BindStyle::Move);
let body_fold = s.each_variant(|vi| { let body_fold = s.each_variant(|vi| {
let bindings = vi.bindings(); let bindings = vi.bindings();
@ -36,14 +31,6 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
) -> Result<Self, __F::Error> { ) -> Result<Self, __F::Error> {
Ok(match self { #body_fold }) Ok(match self { #body_fold })
} }
fn visit_with<__F: ::rustc_middle::ty::fold::TypeVisitor<'tcx>>(
&self,
__folder: &mut __F
) -> ::std::ops::ControlFlow<__F::BreakTy> {
match *self { #body_visit }
::std::ops::ControlFlow::CONTINUE
}
}, },
) )
} }

View file

@ -0,0 +1,33 @@
use quote::quote;
use syn::parse_quote;
pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
if let syn::Data::Union(_) = s.ast().data {
panic!("cannot derive on union")
}
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
s.add_impl_generic(parse_quote! { 'tcx });
}
s.add_bounds(synstructure::AddBounds::Generics);
let body_visit = s.each(|bind| {
quote! {
::rustc_middle::ty::visit::TypeVisitable::visit_with(#bind, __visitor)?;
}
});
s.bind_with(|_| synstructure::BindStyle::Move);
s.bound_impl(
quote!(::rustc_middle::ty::visit::TypeVisitable<'tcx>),
quote! {
fn visit_with<__V: ::rustc_middle::ty::visit::TypeVisitor<'tcx>>(
&self,
__visitor: &mut __V
) -> ::std::ops::ControlFlow<__V::BreakTy> {
match *self { #body_visit }
::std::ops::ControlFlow::CONTINUE
}
},
)
}

View file

@ -4,18 +4,8 @@ use crate::ty::Ty;
use rustc_hir::HirId; use rustc_hir::HirId;
use rustc_target::abi::VariantIdx; use rustc_target::abi::VariantIdx;
#[derive( #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
Copy,
Debug,
PartialEq,
Eq,
Hash,
TyEncodable,
TyDecodable,
TypeFoldable,
HashStable
)]
pub enum PlaceBase { pub enum PlaceBase {
/// A temporary variable. /// A temporary variable.
Rvalue, Rvalue,
@ -27,18 +17,8 @@ pub enum PlaceBase {
Upvar(ty::UpvarId), Upvar(ty::UpvarId),
} }
#[derive( #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
Copy,
Debug,
PartialEq,
Eq,
Hash,
TyEncodable,
TyDecodable,
TypeFoldable,
HashStable
)]
pub enum ProjectionKind { pub enum ProjectionKind {
/// A dereference of a pointer, reference or `Box<T>` of the given type. /// A dereference of a pointer, reference or `Box<T>` of the given type.
Deref, Deref,
@ -58,18 +38,8 @@ pub enum ProjectionKind {
Subslice, Subslice,
} }
#[derive( #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
Copy,
Debug,
PartialEq,
Eq,
Hash,
TyEncodable,
TyDecodable,
TypeFoldable,
HashStable
)]
pub struct Projection<'tcx> { pub struct Projection<'tcx> {
/// Type after the projection is applied. /// Type after the projection is applied.
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,
@ -81,7 +51,8 @@ pub struct Projection<'tcx> {
/// A `Place` represents how a value is located in memory. /// A `Place` represents how a value is located in memory.
/// ///
/// This is an HIR version of [`rustc_middle::mir::Place`]. /// This is an HIR version of [`rustc_middle::mir::Place`].
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, TypeFoldable, HashStable)] #[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct Place<'tcx> { pub struct Place<'tcx> {
/// The type of the `PlaceBase` /// The type of the `PlaceBase`
pub base_ty: Ty<'tcx>, pub base_ty: Ty<'tcx>,
@ -94,7 +65,8 @@ pub struct Place<'tcx> {
/// A `PlaceWithHirId` represents how a value is located in memory. /// A `PlaceWithHirId` represents how a value is located in memory.
/// ///
/// This is an HIR version of [`rustc_middle::mir::Place`]. /// This is an HIR version of [`rustc_middle::mir::Place`].
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, TypeFoldable, HashStable)] #[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct PlaceWithHirId<'tcx> { pub struct PlaceWithHirId<'tcx> {
/// `HirId` of the expression or pattern producing this value. /// `HirId` of the expression or pattern producing this value.
pub hir_id: HirId, pub hir_id: HirId,

View file

@ -34,7 +34,7 @@ use std::ops::Index;
/// variables have been rewritten to "canonical vars". These are /// variables have been rewritten to "canonical vars". These are
/// numbered starting from 0 in order of first appearance. /// numbered starting from 0 in order of first appearance.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct Canonical<'tcx, V> { pub struct Canonical<'tcx, V> {
pub max_universe: ty::UniverseIndex, pub max_universe: ty::UniverseIndex,
pub variables: CanonicalVarInfos<'tcx>, pub variables: CanonicalVarInfos<'tcx>,
@ -53,7 +53,7 @@ pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;
/// variables. You will need to supply it later to instantiate the /// variables. You will need to supply it later to instantiate the
/// canonicalized query response. /// canonicalized query response.
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)] #[derive(Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct CanonicalVarValues<'tcx> { pub struct CanonicalVarValues<'tcx> {
pub var_values: IndexVec<BoundVar, GenericArg<'tcx>>, pub var_values: IndexVec<BoundVar, GenericArg<'tcx>>,
} }
@ -173,7 +173,7 @@ pub enum CanonicalTyVarKind {
/// After we execute a query with a canonicalized key, we get back a /// After we execute a query with a canonicalized key, we get back a
/// `Canonical<QueryResponse<..>>`. You can use /// `Canonical<QueryResponse<..>>`. You can use
/// `instantiate_query_result` to access the data in this result. /// `instantiate_query_result` to access the data in this result.
#[derive(Clone, Debug, HashStable, TypeFoldable, Lift)] #[derive(Clone, Debug, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct QueryResponse<'tcx, R> { pub struct QueryResponse<'tcx, R> {
pub var_values: CanonicalVarValues<'tcx>, pub var_values: CanonicalVarValues<'tcx>,
pub region_constraints: QueryRegionConstraints<'tcx>, pub region_constraints: QueryRegionConstraints<'tcx>,
@ -187,7 +187,7 @@ pub struct QueryResponse<'tcx, R> {
pub value: R, pub value: R,
} }
#[derive(Clone, Debug, Default, HashStable, TypeFoldable, Lift)] #[derive(Clone, Debug, Default, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct QueryRegionConstraints<'tcx> { pub struct QueryRegionConstraints<'tcx> {
pub outlives: Vec<QueryOutlivesConstraint<'tcx>>, pub outlives: Vec<QueryOutlivesConstraint<'tcx>>,
pub member_constraints: Vec<MemberConstraint<'tcx>>, pub member_constraints: Vec<MemberConstraint<'tcx>>,

View file

@ -13,7 +13,7 @@ use rustc_span::Span;
/// ```text /// ```text
/// R0 member of [O1..On] /// R0 member of [O1..On]
/// ``` /// ```
#[derive(Debug, Clone, HashStable, TypeFoldable, Lift)] #[derive(Debug, Clone, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct MemberConstraint<'tcx> { pub struct MemberConstraint<'tcx> {
/// The `DefId` of the opaque type causing this constraint: used for error reporting. /// The `DefId` of the opaque type causing this constraint: used for error reporting.
pub opaque_type_def_id: DefId, pub opaque_type_def_id: DefId,

View file

@ -100,7 +100,7 @@ impl From<InjectedExpressionId> for ExpressionOperandId {
} }
} }
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)] #[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
pub enum CoverageKind { pub enum CoverageKind {
Counter { Counter {
function_source_hash: u64, function_source_hash: u64,
@ -148,18 +148,8 @@ impl Debug for CoverageKind {
} }
} }
#[derive( #[derive(Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq, Eq, PartialOrd, Ord)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
TyEncodable,
TyDecodable,
Hash,
HashStable,
TypeFoldable,
PartialEq,
Eq,
PartialOrd,
Ord
)]
pub struct CodeRegion { pub struct CodeRegion {
pub file_name: Symbol, pub file_name: Symbol,
pub start_line: u32, pub start_line: u32,
@ -178,7 +168,8 @@ impl Debug for CodeRegion {
} }
} }
#[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)] #[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum Op { pub enum Op {
Subtract, Subtract,
Add, Add,

View file

@ -136,7 +136,7 @@ impl MirPhase {
/// Where a specific `mir::Body` comes from. /// Where a specific `mir::Body` comes from.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable)] #[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)]
pub struct MirSource<'tcx> { pub struct MirSource<'tcx> {
pub instance: InstanceDef<'tcx>, pub instance: InstanceDef<'tcx>,
@ -166,7 +166,7 @@ impl<'tcx> MirSource<'tcx> {
} }
} }
#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable)] #[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorInfo<'tcx> { pub struct GeneratorInfo<'tcx> {
/// The yield type of the function, if it is a generator. /// The yield type of the function, if it is a generator.
pub yield_ty: Option<Ty<'tcx>>, pub yield_ty: Option<Ty<'tcx>>,
@ -183,7 +183,7 @@ pub struct GeneratorInfo<'tcx> {
} }
/// The lowered representation of a single function. /// The lowered representation of a single function.
#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable)] #[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct Body<'tcx> { pub struct Body<'tcx> {
/// A list of basic blocks. References to basic block use a newtyped index type [`BasicBlock`] /// A list of basic blocks. References to basic block use a newtyped index type [`BasicBlock`]
/// that indexes into this vector. /// that indexes into this vector.
@ -601,7 +601,7 @@ impl<'tcx> IndexMut<BasicBlock> for Body<'tcx> {
} }
} }
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable)] #[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub enum ClearCrossCrate<T> { pub enum ClearCrossCrate<T> {
Clear, Clear,
Set(T), Set(T),
@ -807,7 +807,7 @@ pub struct BlockTailInfo {
/// ///
/// This can be a binding declared by the user, a temporary inserted by the compiler, a function /// This can be a binding declared by the user, a temporary inserted by the compiler, a function
/// argument, or the return place. /// argument, or the return place.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct LocalDecl<'tcx> { pub struct LocalDecl<'tcx> {
/// Whether this is a mutable binding (i.e., `let x` or `let mut x`). /// Whether this is a mutable binding (i.e., `let x` or `let mut x`).
/// ///
@ -942,7 +942,7 @@ static_assert_size!(LocalDecl<'_>, 56);
/// ///
/// Not used for non-StaticRef temporaries, the return place, or anonymous /// Not used for non-StaticRef temporaries, the return place, or anonymous
/// function parameters. /// function parameters.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub enum LocalInfo<'tcx> { pub enum LocalInfo<'tcx> {
/// A user-defined local variable or function parameter /// A user-defined local variable or function parameter
/// ///
@ -1081,7 +1081,7 @@ impl<'tcx> LocalDecl<'tcx> {
} }
} }
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub enum VarDebugInfoContents<'tcx> { pub enum VarDebugInfoContents<'tcx> {
/// NOTE(eddyb) There's an unenforced invariant that this `Place` is /// NOTE(eddyb) There's an unenforced invariant that this `Place` is
/// based on a `Local`, not a `Static`, and contains no indexing. /// based on a `Local`, not a `Static`, and contains no indexing.
@ -1099,7 +1099,7 @@ impl<'tcx> Debug for VarDebugInfoContents<'tcx> {
} }
/// Debug information pertaining to a user variable. /// Debug information pertaining to a user variable.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct VarDebugInfo<'tcx> { pub struct VarDebugInfo<'tcx> {
pub name: Symbol, pub name: Symbol,
@ -1155,7 +1155,7 @@ impl BasicBlock {
// BasicBlockData // BasicBlockData
/// See [`BasicBlock`] for documentation on what basic blocks are at a high level. /// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct BasicBlockData<'tcx> { pub struct BasicBlockData<'tcx> {
/// List of statements in this block. /// List of statements in this block.
pub statements: Vec<Statement<'tcx>>, pub statements: Vec<Statement<'tcx>>,
@ -1392,7 +1392,7 @@ impl<O: fmt::Debug> fmt::Debug for AssertKind<O> {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Statements // Statements
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct Statement<'tcx> { pub struct Statement<'tcx> {
pub source_info: SourceInfo, pub source_info: SourceInfo,
pub kind: StatementKind<'tcx>, pub kind: StatementKind<'tcx>,
@ -1758,7 +1758,7 @@ impl SourceScope {
} }
} }
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct SourceScopeData<'tcx> { pub struct SourceScopeData<'tcx> {
pub span: Span, pub span: Span,
pub parent_scope: Option<SourceScope>, pub parent_scope: Option<SourceScope>,
@ -2524,7 +2524,7 @@ impl<'tcx> ConstantKind<'tcx> {
/// The first will lead to the constraint `w: &'1 str` (for some /// The first will lead to the constraint `w: &'1 str` (for some
/// inferred region `'1`). The second will lead to the constraint `w: /// inferred region `'1`). The second will lead to the constraint `w:
/// &'static str`. /// &'static str`.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct UserTypeProjections { pub struct UserTypeProjections {
pub contents: Vec<(UserTypeProjection, Span)>, pub contents: Vec<(UserTypeProjection, Span)>,
} }

View file

@ -161,7 +161,7 @@ rustc_index::newtype_index! {
} }
/// The layout of generator state. /// The layout of generator state.
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorLayout<'tcx> { pub struct GeneratorLayout<'tcx> {
/// The type of every local stored inside the generator. /// The type of every local stored inside the generator.
pub field_tys: IndexVec<GeneratorSavedLocal, Ty<'tcx>>, pub field_tys: IndexVec<GeneratorSavedLocal, Ty<'tcx>>,

View file

@ -179,7 +179,8 @@ pub enum BorrowKind {
/// Not all of these are allowed at every [`MirPhase`]. Check the documentation there to see which /// Not all of these are allowed at every [`MirPhase`]. Check the documentation there to see which
/// ones you do not have to worry about. The MIR validator will generally enforce such restrictions, /// ones you do not have to worry about. The MIR validator will generally enforce such restrictions,
/// causing an ICE if they are violated. /// causing an ICE if they are violated.
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)] #[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum StatementKind<'tcx> { pub enum StatementKind<'tcx> {
/// Assign statements roughly correspond to an assignment in Rust proper (`x = ...`) except /// Assign statements roughly correspond to an assignment in Rust proper (`x = ...`) except
/// without the possibility of dropping the previous value (that must be done separately, if at /// without the possibility of dropping the previous value (that must be done separately, if at
@ -376,13 +377,15 @@ pub enum FakeReadCause {
ForIndex, ForIndex,
} }
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)] #[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct Coverage { pub struct Coverage {
pub kind: CoverageKind, pub kind: CoverageKind,
pub code_region: Option<CodeRegion>, pub code_region: Option<CodeRegion>,
} }
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)] #[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct CopyNonOverlapping<'tcx> { pub struct CopyNonOverlapping<'tcx> {
pub src: Operand<'tcx>, pub src: Operand<'tcx>,
pub dst: Operand<'tcx>, pub dst: Operand<'tcx>,
@ -672,7 +675,8 @@ pub enum AssertKind<O> {
ResumedAfterPanic(GeneratorKind), ResumedAfterPanic(GeneratorKind),
} }
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)] #[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum InlineAsmOperand<'tcx> { pub enum InlineAsmOperand<'tcx> {
In { In {
reg: InlineAsmRegOrRegClass, reg: InlineAsmRegOrRegClass,

View file

@ -9,7 +9,7 @@ use crate::ty::{self, Ty, TyCtxt};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_target::abi::VariantIdx; use rustc_target::abi::VariantIdx;
#[derive(Copy, Clone, Debug, TypeFoldable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct PlaceTy<'tcx> { pub struct PlaceTy<'tcx> {
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,
/// Downcast to a particular variant of an enum or a generator, if included. /// Downcast to a particular variant of an enum or a generator, if included.

View file

@ -191,18 +191,8 @@ pub enum StmtKind<'tcx> {
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Expr<'_>, 104); rustc_data_structures::static_assert_size!(Expr<'_>, 104);
#[derive( #[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
Debug,
Copy,
PartialEq,
Eq,
Hash,
HashStable,
TyEncodable,
TyDecodable,
TypeFoldable
)]
pub struct LocalVarId(pub hir::HirId); pub struct LocalVarId(pub hir::HirId);
/// A THIR expression. /// A THIR expression.

View file

@ -390,7 +390,7 @@ impl<'tcx> chalk_ir::interner::HasInterner for RustInterner<'tcx> {
} }
/// A chalk environment and goal. /// A chalk environment and goal.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct ChalkEnvironmentAndGoal<'tcx> { pub struct ChalkEnvironmentAndGoal<'tcx> {
pub environment: &'tcx ty::List<ty::Predicate<'tcx>>, pub environment: &'tcx ty::List<ty::Predicate<'tcx>>,
pub goal: ty::Predicate<'tcx>, pub goal: ty::Predicate<'tcx>,

View file

@ -523,7 +523,7 @@ pub struct DerivedObligationCause<'tcx> {
pub parent_code: InternedObligationCauseCode<'tcx>, pub parent_code: InternedObligationCauseCode<'tcx>,
} }
#[derive(Clone, Debug, TypeFoldable, Lift)] #[derive(Clone, Debug, TypeFoldable, TypeVisitable, Lift)]
pub enum SelectionError<'tcx> { pub enum SelectionError<'tcx> {
/// The trait is not implemented. /// The trait is not implemented.
Unimplemented, Unimplemented,
@ -592,7 +592,8 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
/// ### The type parameter `N` /// ### The type parameter `N`
/// ///
/// See explanation on `ImplSourceUserDefinedData`. /// See explanation on `ImplSourceUserDefinedData`.
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum ImplSource<'tcx, N> { pub enum ImplSource<'tcx, N> {
/// ImplSource identifying a particular impl. /// ImplSource identifying a particular impl.
UserDefined(ImplSourceUserDefinedData<'tcx, N>), UserDefined(ImplSourceUserDefinedData<'tcx, N>),
@ -753,14 +754,16 @@ impl<'tcx, N> ImplSource<'tcx, N> {
/// is `Obligation`, as one might expect. During codegen, however, this /// is `Obligation`, as one might expect. During codegen, however, this
/// is `()`, because codegen only requires a shallow resolution of an /// is `()`, because codegen only requires a shallow resolution of an
/// impl, and nested obligations are satisfied later. /// impl, and nested obligations are satisfied later.
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceUserDefinedData<'tcx, N> { pub struct ImplSourceUserDefinedData<'tcx, N> {
pub impl_def_id: DefId, pub impl_def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceGeneratorData<'tcx, N> { pub struct ImplSourceGeneratorData<'tcx, N> {
pub generator_def_id: DefId, pub generator_def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
@ -769,7 +772,8 @@ pub struct ImplSourceGeneratorData<'tcx, N> {
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceClosureData<'tcx, N> { pub struct ImplSourceClosureData<'tcx, N> {
pub closure_def_id: DefId, pub closure_def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
@ -778,13 +782,15 @@ pub struct ImplSourceClosureData<'tcx, N> {
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceAutoImplData<N> { pub struct ImplSourceAutoImplData<N> {
pub trait_def_id: DefId, pub trait_def_id: DefId,
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceTraitUpcastingData<'tcx, N> { pub struct ImplSourceTraitUpcastingData<'tcx, N> {
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`. /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
pub upcast_trait_ref: ty::PolyTraitRef<'tcx>, pub upcast_trait_ref: ty::PolyTraitRef<'tcx>,
@ -798,12 +804,14 @@ pub struct ImplSourceTraitUpcastingData<'tcx, N> {
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceBuiltinData<N> { pub struct ImplSourceBuiltinData<N> {
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(PartialEq, Eq, Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(PartialEq, Eq, Clone, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceObjectData<'tcx, N> { pub struct ImplSourceObjectData<'tcx, N> {
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`. /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
pub upcast_trait_ref: ty::PolyTraitRef<'tcx>, pub upcast_trait_ref: ty::PolyTraitRef<'tcx>,
@ -817,7 +825,8 @@ pub struct ImplSourceObjectData<'tcx, N> {
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceFnPointerData<'tcx, N> { pub struct ImplSourceFnPointerData<'tcx, N> {
pub fn_ty: Ty<'tcx>, pub fn_ty: Ty<'tcx>,
pub nested: Vec<N>, pub nested: Vec<N>,
@ -830,12 +839,14 @@ pub struct ImplSourceDiscriminantKindData;
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)] #[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
pub struct ImplSourcePointeeData; pub struct ImplSourcePointeeData;
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceConstDestructData<N> { pub struct ImplSourceConstDestructData<N> {
pub nested: Vec<N>, pub nested: Vec<N>,
} }
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceTraitAliasData<'tcx, N> { pub struct ImplSourceTraitAliasData<'tcx, N> {
pub alias_def_id: DefId, pub alias_def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,

View file

@ -24,7 +24,8 @@ pub mod type_op {
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use std::fmt; use std::fmt;
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct AscribeUserType<'tcx> { pub struct AscribeUserType<'tcx> {
pub mir_ty: Ty<'tcx>, pub mir_ty: Ty<'tcx>,
pub def_id: DefId, pub def_id: DefId,
@ -37,19 +38,22 @@ pub mod type_op {
} }
} }
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct Eq<'tcx> { pub struct Eq<'tcx> {
pub a: Ty<'tcx>, pub a: Ty<'tcx>,
pub b: Ty<'tcx>, pub b: Ty<'tcx>,
} }
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct Subtype<'tcx> { pub struct Subtype<'tcx> {
pub sub: Ty<'tcx>, pub sub: Ty<'tcx>,
pub sup: Ty<'tcx>, pub sup: Ty<'tcx>,
} }
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ProvePredicate<'tcx> { pub struct ProvePredicate<'tcx> {
pub predicate: Predicate<'tcx>, pub predicate: Predicate<'tcx>,
} }
@ -60,7 +64,8 @@ pub mod type_op {
} }
} }
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct Normalize<T> { pub struct Normalize<T> {
pub value: T, pub value: T,
} }
@ -107,7 +112,7 @@ impl<'tcx> From<TypeError<'tcx>> for NoSolution {
} }
} }
#[derive(Clone, Debug, Default, HashStable, TypeFoldable, Lift)] #[derive(Clone, Debug, Default, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct DropckOutlivesResult<'tcx> { pub struct DropckOutlivesResult<'tcx> {
pub kinds: Vec<GenericArg<'tcx>>, pub kinds: Vec<GenericArg<'tcx>>,
pub overflows: Vec<Ty<'tcx>>, pub overflows: Vec<Ty<'tcx>>,
@ -208,7 +213,7 @@ pub struct MethodAutoderefBadTy<'tcx> {
} }
/// Result from the `normalize_projection_ty` query. /// Result from the `normalize_projection_ty` query.
#[derive(Clone, Debug, HashStable, TypeFoldable, Lift)] #[derive(Clone, Debug, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct NormalizationResult<'tcx> { pub struct NormalizationResult<'tcx> {
/// Result of normalization. /// Result of normalization.
pub normalized_ty: Ty<'tcx>, pub normalized_ty: Ty<'tcx>,
@ -221,7 +226,7 @@ pub struct NormalizationResult<'tcx> {
/// case they are called implied bounds). They are fed to the /// case they are called implied bounds). They are fed to the
/// `OutlivesEnv` which in turn is supplied to the region checker and /// `OutlivesEnv` which in turn is supplied to the region checker and
/// other parts of the inference system. /// other parts of the inference system.
#[derive(Clone, Debug, TypeFoldable, Lift)] #[derive(Clone, Debug, TypeFoldable, TypeVisitable, Lift)]
pub enum OutlivesBound<'tcx> { pub enum OutlivesBound<'tcx> {
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>), RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
RegionSubParam(ty::Region<'tcx>, ty::ParamTy), RegionSubParam(ty::Region<'tcx>, ty::ParamTy),

View file

@ -103,7 +103,7 @@ pub type EvaluationCache<'tcx> = Cache<
/// required for associated types to work in default impls, as the bounds /// required for associated types to work in default impls, as the bounds
/// are visible both as projection bounds and as where-clauses from the /// are visible both as projection bounds and as where-clauses from the
/// parameter environment. /// parameter environment.
#[derive(PartialEq, Eq, Debug, Clone, TypeFoldable)] #[derive(PartialEq, Eq, Debug, Clone, TypeFoldable, TypeVisitable)]
pub enum SelectionCandidate<'tcx> { pub enum SelectionCandidate<'tcx> {
BuiltinCandidate { BuiltinCandidate {
/// `false` if there are no *further* obligations. /// `false` if there are no *further* obligations.

View file

@ -77,7 +77,7 @@ pub enum PointerCast {
/// At some point, of course, `Box` should move out of the compiler, in which /// At some point, of course, `Box` should move out of the compiler, in which
/// case this is analogous to transforming a struct. E.g., `Box<[i32; 4]>` -> /// case this is analogous to transforming a struct. E.g., `Box<[i32; 4]>` ->
/// `Box<[i32]>` is an `Adjust::Unsize` with the target `Box<[i32]>`. /// `Box<[i32]>` is an `Adjust::Unsize` with the target `Box<[i32]>`.
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct Adjustment<'tcx> { pub struct Adjustment<'tcx> {
pub kind: Adjust<'tcx>, pub kind: Adjust<'tcx>,
pub target: Ty<'tcx>, pub target: Ty<'tcx>,
@ -89,7 +89,7 @@ impl<'tcx> Adjustment<'tcx> {
} }
} }
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub enum Adjust<'tcx> { pub enum Adjust<'tcx> {
/// Go from ! to any type. /// Go from ! to any type.
NeverToAny, NeverToAny,
@ -107,7 +107,8 @@ pub enum Adjust<'tcx> {
/// call, with the signature `&'a T -> &'a U` or `&'a mut T -> &'a mut U`. /// call, with the signature `&'a T -> &'a U` or `&'a mut T -> &'a mut U`.
/// The target type is `U` in both cases, with the region and mutability /// The target type is `U` in both cases, with the region and mutability
/// being those shared by both the receiver and the returned reference. /// being those shared by both the receiver and the returned reference.
#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct OverloadedDeref<'tcx> { pub struct OverloadedDeref<'tcx> {
pub region: ty::Region<'tcx>, pub region: ty::Region<'tcx>,
pub mutbl: hir::Mutability, pub mutbl: hir::Mutability,
@ -165,7 +166,8 @@ impl From<AutoBorrowMutability> for hir::Mutability {
} }
} }
#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum AutoBorrow<'tcx> { pub enum AutoBorrow<'tcx> {
/// Converts from T to &T. /// Converts from T to &T.
Ref(ty::Region<'tcx>, AutoBorrowMutability), Ref(ty::Region<'tcx>, AutoBorrowMutability),

View file

@ -18,18 +18,8 @@ use self::BorrowKind::*;
// This represents accessing self in the closure structure // This represents accessing self in the closure structure
pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::from_u32(1); pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::from_u32(1);
#[derive( #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
Copy,
Debug,
PartialEq,
Eq,
Hash,
TyEncodable,
TyDecodable,
TypeFoldable,
HashStable
)]
pub struct UpvarPath { pub struct UpvarPath {
pub hir_id: hir::HirId, pub hir_id: hir::HirId,
} }
@ -37,7 +27,8 @@ pub struct UpvarPath {
/// Upvars do not get their own `NodeId`. Instead, we use the pair of /// Upvars do not get their own `NodeId`. Instead, we use the pair of
/// the original var ID (that is, the root variable that is referenced /// the original var ID (that is, the root variable that is referenced
/// by the upvar) and the ID of the closure expression. /// by the upvar) and the ID of the closure expression.
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, TypeFoldable, HashStable)] #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct UpvarId { pub struct UpvarId {
pub var_path: UpvarPath, pub var_path: UpvarPath,
pub closure_expr_id: LocalDefId, pub closure_expr_id: LocalDefId,
@ -51,7 +42,8 @@ impl UpvarId {
/// Information describing the capture of an upvar. This is computed /// Information describing the capture of an upvar. This is computed
/// during `typeck`, specifically by `regionck`. /// during `typeck`, specifically by `regionck`.
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, TypeFoldable, HashStable)] #[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum UpvarCapture { pub enum UpvarCapture {
/// Upvar is captured by value. This is always true when the /// Upvar is captured by value. This is always true when the
/// closure is labeled `move`, but can also be true in other cases /// closure is labeled `move`, but can also be true in other cases
@ -139,7 +131,8 @@ impl<'tcx> ClosureKind {
} }
/// A composite describing a `Place` that is captured by a closure. /// A composite describing a `Place` that is captured by a closure.
#[derive(PartialEq, Clone, Debug, TyEncodable, TyDecodable, TypeFoldable, HashStable)] #[derive(PartialEq, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct CapturedPlace<'tcx> { pub struct CapturedPlace<'tcx> {
/// The `Place` that is captured. /// The `Place` that is captured.
pub place: HirPlace<'tcx>, pub place: HirPlace<'tcx>,
@ -284,7 +277,8 @@ pub fn is_ancestor_or_same_capture(
/// Part of `MinCaptureInformationMap`; describes the capture kind (&, &mut, move) /// Part of `MinCaptureInformationMap`; describes the capture kind (&, &mut, move)
/// for a particular capture as well as identifying the part of the source code /// for a particular capture as well as identifying the part of the source code
/// that triggered this capture to occur. /// that triggered this capture to occur.
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, TypeFoldable, HashStable)] #[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct CaptureInfo { pub struct CaptureInfo {
/// Expr Id pointing to use that resulted in selecting the current capture kind /// Expr Id pointing to use that resulted in selecting the current capture kind
/// ///
@ -362,7 +356,8 @@ pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tc
curr_string curr_string
} }
#[derive(Clone, PartialEq, Debug, TyEncodable, TyDecodable, TypeFoldable, Copy, HashStable)] #[derive(Clone, PartialEq, Debug, TyEncodable, TyDecodable, Copy, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum BorrowKind { pub enum BorrowKind {
/// Data must be immutable and is aliasable. /// Data must be immutable and is aliasable.
ImmBorrow, ImmBorrow,

View file

@ -390,7 +390,7 @@ impl<'a, V> LocalTableInContextMut<'a, V> {
/// Here, we would store the type `T`, the span of the value `x`, the "scope-span" for /// Here, we would store the type `T`, the span of the value `x`, the "scope-span" for
/// the scope that contains `x`, the expr `T` evaluated from, and the span of `foo.await`. /// the scope that contains `x`, the expr `T` evaluated from, and the span of `foo.await`.
#[derive(TyEncodable, TyDecodable, Clone, Debug, Eq, Hash, PartialEq, HashStable)] #[derive(TyEncodable, TyDecodable, Clone, Debug, Eq, Hash, PartialEq, HashStable)]
#[derive(TypeFoldable)] #[derive(TypeFoldable, TypeVisitable)]
pub struct GeneratorInteriorTypeCause<'tcx> { pub struct GeneratorInteriorTypeCause<'tcx> {
/// Type of the captured binding. /// Type of the captured binding.
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,
@ -871,7 +871,7 @@ rustc_index::newtype_index! {
pub type CanonicalUserTypeAnnotations<'tcx> = pub type CanonicalUserTypeAnnotations<'tcx> =
IndexVec<UserTypeAnnotationIndex, CanonicalUserTypeAnnotation<'tcx>>; IndexVec<UserTypeAnnotationIndex, CanonicalUserTypeAnnotation<'tcx>>;
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct CanonicalUserTypeAnnotation<'tcx> { pub struct CanonicalUserTypeAnnotation<'tcx> {
pub user_ty: CanonicalUserType<'tcx>, pub user_ty: CanonicalUserType<'tcx>,
pub span: Span, pub span: Span,
@ -931,7 +931,7 @@ impl<'tcx> CanonicalUserType<'tcx> {
/// from constants that are named via paths, like `Foo::<A>::new` and /// from constants that are named via paths, like `Foo::<A>::new` and
/// so forth. /// so forth.
#[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable)] #[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub enum UserType<'tcx> { pub enum UserType<'tcx> {
Ty(Ty<'tcx>), Ty(Ty<'tcx>),

View file

@ -13,7 +13,7 @@ use rustc_target::spec::abi;
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt; use std::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable)] #[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable)]
pub struct ExpectedFound<T> { pub struct ExpectedFound<T> {
pub expected: T, pub expected: T,
pub found: T, pub found: T,
@ -30,7 +30,7 @@ impl<T> ExpectedFound<T> {
} }
// Data structures used in type unification // Data structures used in type unification
#[derive(Clone, Debug, TypeFoldable)] #[derive(Clone, Debug, TypeFoldable, TypeVisitable)]
pub enum TypeError<'tcx> { pub enum TypeError<'tcx> {
Mismatch, Mismatch,
ConstnessMismatch(ExpectedFound<ty::BoundConstness>), ConstnessMismatch(ExpectedFound<ty::BoundConstness>),

View file

@ -25,7 +25,7 @@ pub struct Instance<'tcx> {
} }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable)] #[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub enum InstanceDef<'tcx> { pub enum InstanceDef<'tcx> {
/// A user-defined callable item. /// A user-defined callable item.
/// ///

View file

@ -206,7 +206,7 @@ impl MainDefinition {
/// The "header" of an impl is everything outside the body: a Self type, a trait /// The "header" of an impl is everything outside the body: a Self type, a trait
/// ref (in the case of a trait impl), and a set of predicates (from the /// ref (in the case of a trait impl), and a set of predicates (from the
/// bounds / where-clauses). /// bounds / where-clauses).
#[derive(Clone, Debug, TypeFoldable)] #[derive(Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct ImplHeader<'tcx> { pub struct ImplHeader<'tcx> {
pub impl_def_id: DefId, pub impl_def_id: DefId,
pub self_ty: Ty<'tcx>, pub self_ty: Ty<'tcx>,
@ -214,24 +214,14 @@ pub struct ImplHeader<'tcx> {
pub predicates: Vec<Predicate<'tcx>>, pub predicates: Vec<Predicate<'tcx>>,
} }
#[derive(Copy, Clone, Debug, TypeFoldable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
pub enum ImplSubject<'tcx> { pub enum ImplSubject<'tcx> {
Trait(TraitRef<'tcx>), Trait(TraitRef<'tcx>),
Inherent(Ty<'tcx>), Inherent(Ty<'tcx>),
} }
#[derive( #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable, Debug)]
Copy, #[derive(TypeFoldable, TypeVisitable)]
Clone,
PartialEq,
Eq,
Hash,
TyEncodable,
TyDecodable,
HashStable,
Debug,
TypeFoldable
)]
pub enum ImplPolarity { pub enum ImplPolarity {
/// `impl Trait for Type` /// `impl Trait for Type`
Positive, Positive,
@ -307,18 +297,8 @@ impl fmt::Display for BoundConstness {
} }
} }
#[derive( #[derive(Clone, Debug, PartialEq, Eq, Copy, Hash, TyEncodable, TyDecodable, HashStable)]
Clone, #[derive(TypeFoldable, TypeVisitable)]
Debug,
PartialEq,
Eq,
Copy,
Hash,
TyEncodable,
TyDecodable,
HashStable,
TypeFoldable
)]
pub struct ClosureSizeProfileData<'tcx> { pub struct ClosureSizeProfileData<'tcx> {
/// Tuple containing the types of closure captures before the feature `capture_disjoint_fields` /// Tuple containing the types of closure captures before the feature `capture_disjoint_fields`
pub before_feature_tys: Ty<'tcx>, pub before_feature_tys: Ty<'tcx>,
@ -618,7 +598,7 @@ impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
} }
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub enum PredicateKind<'tcx> { pub enum PredicateKind<'tcx> {
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
/// the `Self` type of the trait reference and `A`, `B`, and `C` /// the `Self` type of the trait reference and `A`, `B`, and `C`
@ -790,7 +770,7 @@ impl<'tcx> Predicate<'tcx> {
} }
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct TraitPredicate<'tcx> { pub struct TraitPredicate<'tcx> {
pub trait_ref: TraitRef<'tcx>, pub trait_ref: TraitRef<'tcx>,
@ -869,7 +849,7 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
} }
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct OutlivesPredicate<A, B>(pub A, pub B); // `A: B` pub struct OutlivesPredicate<A, B>(pub A, pub B); // `A: B`
pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>; pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>;
pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>; pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>;
@ -880,7 +860,7 @@ pub type PolyTypeOutlivesPredicate<'tcx> = ty::Binder<'tcx, TypeOutlivesPredicat
/// whether the `a` type is the type that we should label as "expected" when /// whether the `a` type is the type that we should label as "expected" when
/// presenting user diagnostics. /// presenting user diagnostics.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct SubtypePredicate<'tcx> { pub struct SubtypePredicate<'tcx> {
pub a_is_expected: bool, pub a_is_expected: bool,
pub a: Ty<'tcx>, pub a: Ty<'tcx>,
@ -890,7 +870,7 @@ pub type PolySubtypePredicate<'tcx> = ty::Binder<'tcx, SubtypePredicate<'tcx>>;
/// Encodes that we have to coerce *from* the `a` type to the `b` type. /// Encodes that we have to coerce *from* the `a` type to the `b` type.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct CoercePredicate<'tcx> { pub struct CoercePredicate<'tcx> {
pub a: Ty<'tcx>, pub a: Ty<'tcx>,
pub b: Ty<'tcx>, pub b: Ty<'tcx>,
@ -898,7 +878,7 @@ pub struct CoercePredicate<'tcx> {
pub type PolyCoercePredicate<'tcx> = ty::Binder<'tcx, CoercePredicate<'tcx>>; pub type PolyCoercePredicate<'tcx> = ty::Binder<'tcx, CoercePredicate<'tcx>>;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, TyEncodable, TyDecodable)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub enum Term<'tcx> { pub enum Term<'tcx> {
Ty(Ty<'tcx>), Ty(Ty<'tcx>),
Const(Const<'tcx>), Const(Const<'tcx>),
@ -946,7 +926,7 @@ impl<'tcx> Term<'tcx> {
/// Form #2 eventually yields one of these `ProjectionPredicate` /// Form #2 eventually yields one of these `ProjectionPredicate`
/// instances to normalize the LHS. /// instances to normalize the LHS.
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct ProjectionPredicate<'tcx> { pub struct ProjectionPredicate<'tcx> {
pub projection_ty: ProjectionTy<'tcx>, pub projection_ty: ProjectionTy<'tcx>,
pub term: Term<'tcx>, pub term: Term<'tcx>,
@ -1090,7 +1070,7 @@ impl<'tcx> Predicate<'tcx> {
/// `[[], [U:Bar<T>]]`. Now if there were some particular reference /// `[[], [U:Bar<T>]]`. Now if there were some particular reference
/// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[], /// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[],
/// [usize:Bar<isize>]]`. /// [usize:Bar<isize>]]`.
#[derive(Clone, Debug, TypeFoldable)] #[derive(Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct InstantiatedPredicates<'tcx> { pub struct InstantiatedPredicates<'tcx> {
pub predicates: Vec<Predicate<'tcx>>, pub predicates: Vec<Predicate<'tcx>>,
pub spans: Vec<Span>, pub spans: Vec<Span>,
@ -1106,24 +1086,14 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
} }
} }
#[derive( #[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable, Lift)]
Copy, #[derive(TypeFoldable, TypeVisitable)]
Clone,
Debug,
PartialEq,
Eq,
HashStable,
TyEncodable,
TyDecodable,
TypeFoldable,
Lift
)]
pub struct OpaqueTypeKey<'tcx> { pub struct OpaqueTypeKey<'tcx> {
pub def_id: DefId, pub def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
} }
#[derive(Copy, Clone, Debug, TypeFoldable, HashStable, TyEncodable, TyDecodable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, HashStable, TyEncodable, TyDecodable)]
pub struct OpaqueHiddenType<'tcx> { pub struct OpaqueHiddenType<'tcx> {
/// The span of this particular definition of the opaque type. So /// The span of this particular definition of the opaque type. So
/// for example: /// for example:
@ -1259,7 +1229,7 @@ pub type PlaceholderConst<'tcx> = Placeholder<BoundConst<'tcx>>;
/// except that instead of a `Ty` we bundle the `DefId` of the const parameter. /// except that instead of a `Ty` we bundle the `DefId` of the const parameter.
/// Meaning that we need to use `type_of(const_param_did)` if `const_param_did` is `Some` /// Meaning that we need to use `type_of(const_param_did)` if `const_param_did` is `Some`
/// to get the type of `did`. /// to get the type of `did`.
#[derive(Copy, Clone, Debug, TypeFoldable, Lift, TyEncodable, TyDecodable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift, TyEncodable, TyDecodable)]
#[derive(PartialEq, Eq, PartialOrd, Ord)] #[derive(PartialEq, Eq, PartialOrd, Ord)]
#[derive(Hash, HashStable)] #[derive(Hash, HashStable)]
pub struct WithOptConstParam<T> { pub struct WithOptConstParam<T> {
@ -1575,7 +1545,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
} }
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
pub struct ParamEnvAnd<'tcx, T> { pub struct ParamEnvAnd<'tcx, T> {
pub param_env: ParamEnv<'tcx>, pub param_env: ParamEnv<'tcx>,
pub value: T, pub value: T,

View file

@ -2388,7 +2388,7 @@ macro_rules! define_print_and_forward_display {
/// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only /// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only
/// the trait path. That is, it will print `Trait<U>` instead of /// the trait path. That is, it will print `Trait<U>` instead of
/// `<T as Trait<U>>`. /// `<T as Trait<U>>`.
#[derive(Copy, Clone, TypeFoldable, Lift)] #[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>); pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> { impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
@ -2400,7 +2400,7 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
/// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only /// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only
/// the trait name. That is, it will print `Trait` instead of /// the trait name. That is, it will print `Trait` instead of
/// `<T as Trait<U>>`. /// `<T as Trait<U>>`.
#[derive(Copy, Clone, TypeFoldable, Lift)] #[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
pub struct TraitRefPrintOnlyTraitName<'tcx>(ty::TraitRef<'tcx>); pub struct TraitRefPrintOnlyTraitName<'tcx>(ty::TraitRef<'tcx>);
impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitName<'tcx> { impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitName<'tcx> {
@ -2425,7 +2425,7 @@ impl<'tcx> ty::Binder<'tcx, ty::TraitRef<'tcx>> {
} }
} }
#[derive(Copy, Clone, TypeFoldable, Lift)] #[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
pub struct TraitPredPrintModifiersAndPath<'tcx>(ty::TraitPredicate<'tcx>); pub struct TraitPredPrintModifiersAndPath<'tcx>(ty::TraitPredicate<'tcx>);
impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> { impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> {

View file

@ -345,7 +345,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
} }
} }
#[derive(Copy, Debug, Clone, TypeFoldable)] #[derive(Copy, Debug, Clone, TypeFoldable, TypeVisitable)]
struct GeneratorWitness<'tcx>(&'tcx ty::List<Ty<'tcx>>); struct GeneratorWitness<'tcx>(&'tcx ty::List<Ty<'tcx>>);
impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> { impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {

View file

@ -38,7 +38,7 @@ pub type TyKind<'tcx> = IrTyKind<TyCtxt<'tcx>>;
pub type RegionKind<'tcx> = IrRegionKind<TyCtxt<'tcx>>; pub type RegionKind<'tcx> = IrRegionKind<TyCtxt<'tcx>>;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct TypeAndMut<'tcx> { pub struct TypeAndMut<'tcx> {
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,
pub mutbl: hir::Mutability, pub mutbl: hir::Mutability,
@ -201,7 +201,7 @@ static_assert_size!(TyKind<'_>, 32);
/// * `GR`: The "return type", which is the type of value returned upon /// * `GR`: The "return type", which is the type of value returned upon
/// completion of the generator. /// completion of the generator.
/// * `GW`: The "generator witness". /// * `GW`: The "generator witness".
#[derive(Copy, Clone, Debug, TypeFoldable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct ClosureSubsts<'tcx> { pub struct ClosureSubsts<'tcx> {
/// Lifetime and type parameters from the enclosing function, /// Lifetime and type parameters from the enclosing function,
/// concatenated with a tuple containing the types of the upvars. /// concatenated with a tuple containing the types of the upvars.
@ -328,7 +328,7 @@ impl<'tcx> ClosureSubsts<'tcx> {
} }
/// Similar to `ClosureSubsts`; see the above documentation for more. /// Similar to `ClosureSubsts`; see the above documentation for more.
#[derive(Copy, Clone, Debug, TypeFoldable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct GeneratorSubsts<'tcx> { pub struct GeneratorSubsts<'tcx> {
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
} }
@ -608,7 +608,7 @@ impl<'tcx> UpvarSubsts<'tcx> {
/// type of the constant. The reason that `R` is represented as an extra type parameter /// type of the constant. The reason that `R` is represented as an extra type parameter
/// is the same reason that [`ClosureSubsts`] have `CS` and `U` as type parameters: /// is the same reason that [`ClosureSubsts`] have `CS` and `U` as type parameters:
/// inline const can reference lifetimes that are internal to the creating function. /// inline const can reference lifetimes that are internal to the creating function.
#[derive(Copy, Clone, Debug, TypeFoldable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct InlineConstSubsts<'tcx> { pub struct InlineConstSubsts<'tcx> {
/// Generic parameters from the enclosing item, /// Generic parameters from the enclosing item,
/// concatenated with the inferred type of the constant. /// concatenated with the inferred type of the constant.
@ -655,7 +655,7 @@ impl<'tcx> InlineConstSubsts<'tcx> {
} }
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub enum ExistentialPredicate<'tcx> { pub enum ExistentialPredicate<'tcx> {
/// E.g., `Iterator`. /// E.g., `Iterator`.
Trait(ExistentialTraitRef<'tcx>), Trait(ExistentialTraitRef<'tcx>),
@ -781,7 +781,7 @@ impl<'tcx> List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
/// Trait references also appear in object types like `Foo<U>`, but in /// Trait references also appear in object types like `Foo<U>`, but in
/// that case the `Self` parameter is absent from the substitutions. /// that case the `Self` parameter is absent from the substitutions.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct TraitRef<'tcx> { pub struct TraitRef<'tcx> {
pub def_id: DefId, pub def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
@ -853,7 +853,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
/// The substitutions don't include the erased `Self`, only trait /// The substitutions don't include the erased `Self`, only trait
/// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above). /// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above).
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct ExistentialTraitRef<'tcx> { pub struct ExistentialTraitRef<'tcx> {
pub def_id: DefId, pub def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
@ -1143,7 +1143,7 @@ impl<'tcx, T> Binder<'tcx, Option<T>> {
/// Represents the projection of an associated type. In explicit UFCS /// Represents the projection of an associated type. In explicit UFCS
/// form this would be written `<T as Trait<..>>::N`. /// form this would be written `<T as Trait<..>>::N`.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct ProjectionTy<'tcx> { pub struct ProjectionTy<'tcx> {
/// The parameters of the associated item. /// The parameters of the associated item.
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
@ -1192,7 +1192,7 @@ impl<'tcx> ProjectionTy<'tcx> {
} }
} }
#[derive(Copy, Clone, Debug, TypeFoldable)] #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
pub struct GenSig<'tcx> { pub struct GenSig<'tcx> {
pub resume_ty: Ty<'tcx>, pub resume_ty: Ty<'tcx>,
pub yield_ty: Ty<'tcx>, pub yield_ty: Ty<'tcx>,
@ -1208,7 +1208,7 @@ pub type PolyGenSig<'tcx> = Binder<'tcx, GenSig<'tcx>>;
/// - `output`: is the return type. /// - `output`: is the return type.
/// - `c_variadic`: indicates whether this is a C-variadic function. /// - `c_variadic`: indicates whether this is a C-variadic function.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct FnSig<'tcx> { pub struct FnSig<'tcx> {
pub inputs_and_output: &'tcx List<Ty<'tcx>>, pub inputs_and_output: &'tcx List<Ty<'tcx>>,
pub c_variadic: bool, pub c_variadic: bool,
@ -1385,7 +1385,7 @@ impl From<BoundVar> for BoundTy {
/// A `ProjectionPredicate` for an `ExistentialTraitRef`. /// A `ProjectionPredicate` for an `ExistentialTraitRef`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable, TypeVisitable)]
pub struct ExistentialProjection<'tcx> { pub struct ExistentialProjection<'tcx> {
pub item_def_id: DefId, pub item_def_id: DefId,
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,

View file

@ -722,7 +722,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
/// Stores the user-given substs to reach some fully qualified path /// Stores the user-given substs to reach some fully qualified path
/// (e.g., `<T>::Item` or `<T as Trait>::Item`). /// (e.g., `<T>::Item` or `<T as Trait>::Item`).
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct UserSubsts<'tcx> { pub struct UserSubsts<'tcx> {
/// The substitutions for the item as given by the user. /// The substitutions for the item as given by the user.
pub substs: SubstsRef<'tcx>, pub substs: SubstsRef<'tcx>,
@ -749,7 +749,7 @@ pub struct UserSubsts<'tcx> {
/// the self type, giving `Foo<?A>`. Finally, we unify that with /// the self type, giving `Foo<?A>`. Finally, we unify that with
/// the self type here, which contains `?A` to be `&'static u32` /// the self type here, which contains `?A` to be `&'static u32`
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct UserSelfTy<'tcx> { pub struct UserSelfTy<'tcx> {
pub impl_def_id: DefId, pub impl_def_id: DefId,
pub self_ty: Ty<'tcx>, pub self_ty: Ty<'tcx>,

View file

@ -3,7 +3,7 @@ use crate::traits::query::Fallible;
use rustc_infer::traits::query::OutlivesBound; use rustc_infer::traits::query::OutlivesBound;
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt}; use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt};
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct ImpliedOutlivesBounds<'tcx> { pub struct ImpliedOutlivesBounds<'tcx> {
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,
} }

View file

@ -3,7 +3,7 @@ use crate::traits::query::dropck_outlives::{trivial_dropck_outlives, DropckOutli
use crate::traits::query::Fallible; use crate::traits::query::Fallible;
use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt}; use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, Lift)] #[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct DropckOutlives<'tcx> { pub struct DropckOutlives<'tcx> {
dropped_ty: Ty<'tcx>, dropped_ty: Ty<'tcx>,
} }