Rollup merge of #145145 - fee1-dead-contrib:push-qnmpmtmtpkkr, r=jieyouxu
some `derive_more` refactors some clauses can be merged together without requiring an attribute for each trait derived. also manually impl `Eq` because the `derive_where` generated code is too much for my comfort (cc https://github.com/ModProg/derive-where/pull/128)
This commit is contained in:
commit
b81be36719
17 changed files with 180 additions and 100 deletions
|
|
@ -68,7 +68,7 @@ impl<I: Interner> From<WipCanonicalGoalEvaluationStep<I>> for DebugSolver<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(PartialEq, Debug; I: Interner)]
|
||||
struct WipGoalEvaluation<I: Interner> {
|
||||
pub uncanonicalized_goal: Goal<I, I::Predicate>,
|
||||
pub orig_values: Vec<I::GenericArg>,
|
||||
|
|
@ -78,6 +78,8 @@ struct WipGoalEvaluation<I: Interner> {
|
|||
pub result: Option<QueryResult<I>>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for WipGoalEvaluation<I> {}
|
||||
|
||||
impl<I: Interner> WipGoalEvaluation<I> {
|
||||
fn finalize(self) -> inspect::GoalEvaluation<I> {
|
||||
inspect::GoalEvaluation {
|
||||
|
|
@ -98,7 +100,7 @@ impl<I: Interner> WipGoalEvaluation<I> {
|
|||
/// This only exists during proof tree building and does not have
|
||||
/// a corresponding struct in `inspect`. We need this to track a
|
||||
/// bunch of metadata about the current evaluation.
|
||||
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(PartialEq, Debug; I: Interner)]
|
||||
struct WipCanonicalGoalEvaluationStep<I: Interner> {
|
||||
/// Unlike `EvalCtxt::var_values`, we append a new
|
||||
/// generic arg here whenever we create a new inference
|
||||
|
|
@ -111,6 +113,8 @@ struct WipCanonicalGoalEvaluationStep<I: Interner> {
|
|||
evaluation: WipProbe<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for WipCanonicalGoalEvaluationStep<I> {}
|
||||
|
||||
impl<I: Interner> WipCanonicalGoalEvaluationStep<I> {
|
||||
fn current_evaluation_scope(&mut self) -> &mut WipProbe<I> {
|
||||
let mut current = &mut self.evaluation;
|
||||
|
|
@ -132,7 +136,7 @@ impl<I: Interner> WipCanonicalGoalEvaluationStep<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(PartialEq, Debug; I: Interner)]
|
||||
struct WipProbe<I: Interner> {
|
||||
initial_num_var_values: usize,
|
||||
steps: Vec<WipProbeStep<I>>,
|
||||
|
|
@ -140,6 +144,8 @@ struct WipProbe<I: Interner> {
|
|||
final_state: Option<inspect::CanonicalState<I, ()>>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for WipProbe<I> {}
|
||||
|
||||
impl<I: Interner> WipProbe<I> {
|
||||
fn finalize(self) -> inspect::Probe<I> {
|
||||
inspect::Probe {
|
||||
|
|
@ -150,7 +156,7 @@ impl<I: Interner> WipProbe<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(PartialEq, Debug; I: Interner)]
|
||||
enum WipProbeStep<I: Interner> {
|
||||
AddGoal(GoalSource, inspect::CanonicalState<I, Goal<I, I::Predicate>>),
|
||||
NestedProbe(WipProbe<I>),
|
||||
|
|
@ -158,6 +164,8 @@ enum WipProbeStep<I: Interner> {
|
|||
RecordImplArgs { impl_args: inspect::CanonicalState<I, I::GenericArgs> },
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for WipProbeStep<I> {}
|
||||
|
||||
impl<I: Interner> WipProbeStep<I> {
|
||||
fn finalize(self) -> inspect::ProbeStep<I> {
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{ControlFlow, Deref};
|
||||
|
||||
|
|
@ -23,18 +21,16 @@ use crate::{self as ty, Interner};
|
|||
/// for more details.
|
||||
///
|
||||
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
|
||||
#[derive_where(Clone; I: Interner, T: Clone)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, T)]
|
||||
#[derive_where(Copy; I: Interner, T: Copy)]
|
||||
#[derive_where(Hash; I: Interner, T: Hash)]
|
||||
#[derive_where(PartialEq; I: Interner, T: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, T: Eq)]
|
||||
#[derive_where(Debug; I: Interner, T: Debug)]
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
pub struct Binder<I: Interner, T> {
|
||||
value: T,
|
||||
bound_vars: I::BoundVarKinds,
|
||||
}
|
||||
|
||||
impl<I: Interner, T: Eq> Eq for Binder<I, T> {}
|
||||
|
||||
// FIXME: We manually derive `Lift` because the `derive(Lift_Generic)` doesn't
|
||||
// understand how to turn `T` to `T::Lifted` in the output `type Lifted`.
|
||||
impl<I: Interner, U: Interner, T> Lift<U> for Binder<I, T>
|
||||
|
|
@ -356,14 +352,9 @@ impl<I: Interner> TypeVisitor<I> for ValidateBoundVars<I> {
|
|||
/// `instantiate`.
|
||||
///
|
||||
/// See <https://rustc-dev-guide.rust-lang.org/ty_module/early_binder.html> for more details.
|
||||
#[derive_where(Clone; I: Interner, T: Clone)]
|
||||
#[derive_where(Copy; I: Interner, T: Copy)]
|
||||
#[derive_where(PartialEq; I: Interner, T: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, T: Eq)]
|
||||
#[derive_where(Ord; I: Interner, T: Ord)]
|
||||
#[derive_where(Clone, PartialEq, Ord, Hash, Debug; I: Interner, T)]
|
||||
#[derive_where(PartialOrd; I: Interner, T: Ord)]
|
||||
#[derive_where(Hash; I: Interner, T: Hash)]
|
||||
#[derive_where(Debug; I: Interner, T: Debug)]
|
||||
#[derive_where(Copy; I: Interner, T: Copy)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -374,6 +365,8 @@ pub struct EarlyBinder<I: Interner, T> {
|
|||
_tcx: PhantomData<fn() -> I>,
|
||||
}
|
||||
|
||||
impl<I: Interner, T: Eq> Eq for EarlyBinder<I, T> {}
|
||||
|
||||
/// For early binders, you should first call `instantiate` before using any visitors.
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<I: Interner, T> !TypeFoldable<I> for ty::EarlyBinder<I, T> {}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ use crate::data_structures::HashMap;
|
|||
use crate::inherent::*;
|
||||
use crate::{self as ty, Interner, TypingMode, UniverseIndex};
|
||||
|
||||
#[derive_where(Clone; I: Interner, V: Clone)]
|
||||
#[derive_where(Hash; I: Interner, V: Hash)]
|
||||
#[derive_where(PartialEq; I: Interner, V: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, V: Eq)]
|
||||
#[derive_where(Debug; I: Interner, V: fmt::Debug)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, V)]
|
||||
#[derive_where(Copy; I: Interner, V: Copy)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -26,14 +22,12 @@ pub struct CanonicalQueryInput<I: Interner, V> {
|
|||
pub typing_mode: TypingMode<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner, V: Eq> Eq for CanonicalQueryInput<I, V> {}
|
||||
|
||||
/// A "canonicalized" type `V` is one where all free inference
|
||||
/// variables have been rewritten to "canonical vars". These are
|
||||
/// numbered starting from 0 in order of first appearance.
|
||||
#[derive_where(Clone; I: Interner, V: Clone)]
|
||||
#[derive_where(Hash; I: Interner, V: Hash)]
|
||||
#[derive_where(PartialEq; I: Interner, V: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, V: Eq)]
|
||||
#[derive_where(Debug; I: Interner, V: fmt::Debug)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, V)]
|
||||
#[derive_where(Copy; I: Interner, V: Copy)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -45,6 +39,8 @@ pub struct Canonical<I: Interner, V> {
|
|||
pub variables: I::CanonicalVarKinds,
|
||||
}
|
||||
|
||||
impl<I: Interner, V: Eq> Eq for Canonical<I, V> {}
|
||||
|
||||
impl<I: Interner, V> Canonical<I, V> {
|
||||
/// Allows you to map the `value` of a canonical while keeping the
|
||||
/// same set of bound variables.
|
||||
|
|
@ -89,7 +85,7 @@ impl<I: Interner, V: fmt::Display> fmt::Display for Canonical<I, V> {
|
|||
/// canonical value. This is sufficient information for code to create
|
||||
/// a copy of the canonical value in some other inference context,
|
||||
/// with fresh inference variables replacing the canonical values.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -116,6 +112,8 @@ pub enum CanonicalVarKind<I: Interner> {
|
|||
PlaceholderConst(I::PlaceholderConst),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CanonicalVarKind<I> {}
|
||||
|
||||
impl<I: Interner> CanonicalVarKind<I> {
|
||||
pub fn universe(self) -> UniverseIndex {
|
||||
match self {
|
||||
|
|
@ -223,7 +221,7 @@ pub enum CanonicalTyVarKind {
|
|||
/// vectors with the original values that were replaced by canonical
|
||||
/// variables. You will need to supply it later to instantiate the
|
||||
/// canonicalized query response.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -233,6 +231,8 @@ pub struct CanonicalVarValues<I: Interner> {
|
|||
pub var_values: I::GenericArgs,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CanonicalVarValues<I> {}
|
||||
|
||||
impl<I: Interner> CanonicalVarValues<I> {
|
||||
pub fn is_identity(&self) -> bool {
|
||||
self.var_values.iter().enumerate().all(|(bv, arg)| match arg.kind() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Gen
|
|||
use crate::{self as ty, DebruijnIndex, Interner};
|
||||
|
||||
/// Represents a constant in Rust.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -45,6 +45,8 @@ pub enum ConstKind<I: Interner> {
|
|||
Expr(I::ExprConst),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ConstKind<I> {}
|
||||
|
||||
impl<I: Interner> fmt::Debug for ConstKind<I> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use ConstKind::*;
|
||||
|
|
@ -63,7 +65,7 @@ impl<I: Interner> fmt::Debug for ConstKind<I> {
|
|||
}
|
||||
|
||||
/// An unevaluated (potentially generic) constant used in the type-system.
|
||||
#[derive_where(Clone, Copy, Debug, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Debug, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -74,6 +76,8 @@ pub struct UnevaluatedConst<I: Interner> {
|
|||
pub args: I::GenericArgs,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for UnevaluatedConst<I> {}
|
||||
|
||||
impl<I: Interner> UnevaluatedConst<I> {
|
||||
#[inline]
|
||||
pub fn new(def: I::DefId, args: I::GenericArgs) -> UnevaluatedConst<I> {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ impl<T> ExpectedFound<T> {
|
|||
}
|
||||
|
||||
// Data structures used in type unification
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic)]
|
||||
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
|
||||
pub enum TypeError<I: Interner> {
|
||||
|
|
@ -58,6 +58,8 @@ pub enum TypeError<I: Interner> {
|
|||
TargetFeatureCast(I::DefId),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for TypeError<I> {}
|
||||
|
||||
impl<I: Interner> TypeError<I> {
|
||||
pub fn involves_regions(self) -> bool {
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContex
|
|||
|
||||
use crate::Interner;
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -15,7 +15,9 @@ pub enum GenericArgKind<I: Interner> {
|
|||
Const(I::Const),
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Debug; I: Interner)]
|
||||
impl<I: Interner> Eq for GenericArgKind<I> {}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -24,3 +26,5 @@ pub enum TermKind<I: Interner> {
|
|||
Ty(I::Ty),
|
||||
Const(I::Const),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for TermKind<I> {}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use crate::{self as ty, Interner};
|
|||
///
|
||||
/// If neither of these functions are available, feel free to reach out to
|
||||
/// t-types for help.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -90,6 +90,8 @@ pub enum TypingMode<I: Interner> {
|
|||
PostAnalysis,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for TypingMode<I> {}
|
||||
|
||||
impl<I: Interner> TypingMode<I> {
|
||||
/// Analysis outside of a body does not define any opaque types.
|
||||
pub fn non_body_analysis() -> TypingMode<I> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};
|
|||
use crate::inherent::*;
|
||||
use crate::{self as ty, Interner};
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -17,6 +17,8 @@ pub struct OpaqueTypeKey<I: Interner> {
|
|||
pub args: I::GenericArgs,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for OpaqueTypeKey<I> {}
|
||||
|
||||
impl<I: Interner> OpaqueTypeKey<I> {
|
||||
pub fn iter_captured_args(self, cx: I) -> impl Iterator<Item = (usize, I::GenericArg)> {
|
||||
let variances = cx.variances_of(self.def_id.into());
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Gen
|
|||
|
||||
use crate::Interner;
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -15,3 +15,5 @@ pub enum PatternKind<I: Interner> {
|
|||
Range { start: I::Const, end: I::Const },
|
||||
Or(I::PatList),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for PatternKind<I> {}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,8 @@ use crate::visit::TypeVisitableExt as _;
|
|||
use crate::{self as ty, Interner};
|
||||
|
||||
/// `A: 'region`
|
||||
#[derive_where(Clone; I: Interner, A: Clone)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, A)]
|
||||
#[derive_where(Copy; I: Interner, A: Copy)]
|
||||
#[derive_where(Hash; I: Interner, A: Hash)]
|
||||
#[derive_where(PartialEq; I: Interner, A: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, A: Eq)]
|
||||
#[derive_where(Debug; I: Interner, A: fmt::Debug)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -28,6 +24,8 @@ use crate::{self as ty, Interner};
|
|||
)]
|
||||
pub struct OutlivesPredicate<I: Interner, A>(pub A, pub I::Region);
|
||||
|
||||
impl<I: Interner, A: Eq> Eq for OutlivesPredicate<I, A> {}
|
||||
|
||||
// FIXME: We manually derive `Lift` because the `derive(Lift_Generic)` doesn't
|
||||
// understand how to turn `A` to `A::Lifted` in the output `type Lifted`.
|
||||
impl<I: Interner, U: Interner, A> Lift<U> for OutlivesPredicate<I, A>
|
||||
|
|
@ -53,7 +51,7 @@ where
|
|||
///
|
||||
/// Trait references also appear in object types like `Foo<U>`, but in
|
||||
/// that case the `Self` parameter is absent from the generic parameters.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -67,6 +65,8 @@ pub struct TraitRef<I: Interner> {
|
|||
_use_trait_ref_new_instead: (),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for TraitRef<I> {}
|
||||
|
||||
impl<I: Interner> TraitRef<I> {
|
||||
pub fn new_from_args(interner: I, trait_def_id: I::DefId, args: I::GenericArgs) -> Self {
|
||||
interner.debug_assert_args_compatible(trait_def_id, args);
|
||||
|
|
@ -128,7 +128,7 @@ impl<I: Interner> ty::Binder<I, TraitRef<I>> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -145,6 +145,8 @@ pub struct TraitPredicate<I: Interner> {
|
|||
pub polarity: PredicatePolarity,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for TraitPredicate<I> {}
|
||||
|
||||
impl<I: Interner> TraitPredicate<I> {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
Self {
|
||||
|
|
@ -271,7 +273,7 @@ impl fmt::Display for PredicatePolarity {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -286,6 +288,8 @@ pub enum ExistentialPredicate<I: Interner> {
|
|||
AutoTrait(I::DefId),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ExistentialPredicate<I> {}
|
||||
|
||||
impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
|
||||
/// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`),
|
||||
/// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self`
|
||||
|
|
@ -319,7 +323,7 @@ impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
|
|||
/// ```
|
||||
/// The generic parameters don't include the erased `Self`, only trait
|
||||
/// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above).
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -333,6 +337,8 @@ pub struct ExistentialTraitRef<I: Interner> {
|
|||
_use_existential_trait_ref_new_instead: (),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ExistentialTraitRef<I> {}
|
||||
|
||||
impl<I: Interner> ExistentialTraitRef<I> {
|
||||
pub fn new_from_args(interner: I, trait_def_id: I::DefId, args: I::GenericArgs) -> Self {
|
||||
interner.debug_assert_existential_args_compatible(trait_def_id, args);
|
||||
|
|
@ -386,7 +392,7 @@ impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> {
|
|||
}
|
||||
|
||||
/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -402,6 +408,8 @@ pub struct ExistentialProjection<I: Interner> {
|
|||
use_existential_projection_new_instead: (),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ExistentialProjection<I> {}
|
||||
|
||||
impl<I: Interner> ExistentialProjection<I> {
|
||||
pub fn new_from_args(
|
||||
interner: I,
|
||||
|
|
@ -542,7 +550,7 @@ impl From<ty::AliasTyKind> for AliasTermKind {
|
|||
/// * For a projection, this would be `<Ty as Trait<...>>::N<...>`.
|
||||
/// * For an inherent projection, this would be `Ty::N<...>`.
|
||||
/// * For an opaque type, there is no explicit syntax.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -578,6 +586,8 @@ pub struct AliasTerm<I: Interner> {
|
|||
_use_alias_term_new_instead: (),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for AliasTerm<I> {}
|
||||
|
||||
impl<I: Interner> AliasTerm<I> {
|
||||
pub fn new_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTerm<I> {
|
||||
interner.debug_assert_args_compatible(def_id, args);
|
||||
|
|
@ -752,7 +762,7 @@ impl<I: Interner> From<ty::UnevaluatedConst<I>> for AliasTerm<I> {
|
|||
/// equality between arbitrary types. Processing an instance of
|
||||
/// Form #2 eventually yields one of these `ProjectionPredicate`
|
||||
/// instances to normalize the LHS.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -763,6 +773,8 @@ pub struct ProjectionPredicate<I: Interner> {
|
|||
pub term: I::Term,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ProjectionPredicate<I> {}
|
||||
|
||||
impl<I: Interner> ProjectionPredicate<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
self.projection_term.self_ty()
|
||||
|
|
@ -813,7 +825,7 @@ impl<I: Interner> fmt::Debug for ProjectionPredicate<I> {
|
|||
|
||||
/// Used by the new solver to normalize an alias. This always expects the `term` to
|
||||
/// be an unconstrained inference variable which is used as the output.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -824,6 +836,8 @@ pub struct NormalizesTo<I: Interner> {
|
|||
pub term: I::Term,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for NormalizesTo<I> {}
|
||||
|
||||
impl<I: Interner> NormalizesTo<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
self.alias.self_ty()
|
||||
|
|
@ -848,7 +862,7 @@ impl<I: Interner> fmt::Debug for NormalizesTo<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -859,6 +873,8 @@ pub struct HostEffectPredicate<I: Interner> {
|
|||
pub constness: BoundConstness,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for HostEffectPredicate<I> {}
|
||||
|
||||
impl<I: Interner> HostEffectPredicate<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
self.trait_ref.self_ty()
|
||||
|
|
@ -892,7 +908,7 @@ impl<I: Interner> ty::Binder<I, HostEffectPredicate<I>> {
|
|||
/// Encodes that `a` must be a subtype of `b`. The `a_is_expected` flag indicates
|
||||
/// whether the `a` type is the type that we should label as "expected" when
|
||||
/// presenting user diagnostics.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -904,8 +920,10 @@ pub struct SubtypePredicate<I: Interner> {
|
|||
pub b: I::Ty,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for SubtypePredicate<I> {}
|
||||
|
||||
/// Encodes that we have to coerce *from* the `a` type to the `b` type.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -916,6 +934,8 @@ pub struct CoercePredicate<I: Interner> {
|
|||
pub b: I::Ty,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CoercePredicate<I> {}
|
||||
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{self as ty, Interner};
|
|||
|
||||
/// A clause is something that can appear in where bounds or be inferred
|
||||
/// by implied bounds.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -55,7 +55,9 @@ pub enum ClauseKind<I: Interner> {
|
|||
),
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
impl<I: Interner> Eq for ClauseKind<I> {}
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -109,6 +111,8 @@ pub enum PredicateKind<I: Interner> {
|
|||
AliasRelate(I::Term, I::Term, AliasRelationDirection),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for PredicateKind<I> {}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ rustc_index::newtype_index! {
|
|||
/// [1]: https://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/
|
||||
/// [2]: https://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/
|
||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext))]
|
||||
pub enum RegionKind<I: Interner> {
|
||||
/// A region parameter; for example `'a` in `impl<'a> Trait for &'a ()`.
|
||||
|
|
@ -177,6 +177,8 @@ pub enum RegionKind<I: Interner> {
|
|||
ReError(I::ErrorGuaranteed),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for RegionKind<I> {}
|
||||
|
||||
impl<I: Interner> fmt::Debug for RegionKind<I> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub enum StructurallyRelateAliases {
|
|||
/// a miscompilation or unsoundness.
|
||||
///
|
||||
/// When in doubt, use `VarianceDiagInfo::default()`
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Debug, Default; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Debug, Default; I: Interner)]
|
||||
pub enum VarianceDiagInfo<I: Interner> {
|
||||
/// No additional information - this is the default.
|
||||
/// We will not add any additional information to error messages.
|
||||
|
|
@ -51,6 +51,8 @@ pub enum VarianceDiagInfo<I: Interner> {
|
|||
},
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for VarianceDiagInfo<I> {}
|
||||
|
||||
impl<I: Interner> VarianceDiagInfo<I> {
|
||||
/// Mirrors `Variance::xform` - used to 'combine' the existing
|
||||
/// and new `VarianceDiagInfo`s when our variance changes.
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@
|
|||
//!
|
||||
//! [canonicalized]: https://rustc-dev-guide.rust-lang.org/solve/canonicalization.html
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
|
||||
use derive_where::derive_where;
|
||||
use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};
|
||||
|
||||
|
|
@ -32,25 +29,23 @@ use crate::{Canonical, CanonicalVarValues, Interner};
|
|||
/// This is only ever used as [CanonicalState]. Any type information in proof
|
||||
/// trees used mechanically has to be canonicalized as we otherwise leak
|
||||
/// inference variables from a nested `InferCtxt`.
|
||||
#[derive_where(Clone; I: Interner, T: Clone)]
|
||||
#[derive_where(Clone, PartialEq, Hash, Debug; I: Interner, T)]
|
||||
#[derive_where(Copy; I: Interner, T: Copy)]
|
||||
#[derive_where(PartialEq; I: Interner, T: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, T: Eq)]
|
||||
#[derive_where(Hash; I: Interner, T: Hash)]
|
||||
#[derive_where(Debug; I: Interner, T: Debug)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
pub struct State<I: Interner, T> {
|
||||
pub var_values: CanonicalVarValues<I>,
|
||||
pub data: T,
|
||||
}
|
||||
|
||||
impl<I: Interner, T: Eq> Eq for State<I, T> {}
|
||||
|
||||
pub type CanonicalState<I, T> = Canonical<I, State<I, T>>;
|
||||
|
||||
/// When evaluating a goal we also store the original values
|
||||
/// for the `CanonicalVarValues` of the canonicalized goal.
|
||||
/// We use this to map any [CanonicalState] from the local `InferCtxt`
|
||||
/// of the solver query to the `InferCtxt` of the caller.
|
||||
#[derive_where(PartialEq, Eq, Hash; I: Interner)]
|
||||
#[derive_where(PartialEq, Hash; I: Interner)]
|
||||
pub struct GoalEvaluation<I: Interner> {
|
||||
pub uncanonicalized_goal: Goal<I, I::Predicate>,
|
||||
pub orig_values: Vec<I::GenericArg>,
|
||||
|
|
@ -58,7 +53,9 @@ pub struct GoalEvaluation<I: Interner> {
|
|||
pub result: QueryResult<I>,
|
||||
}
|
||||
|
||||
#[derive_where(PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
impl<I: Interner> Eq for GoalEvaluation<I> {}
|
||||
|
||||
#[derive_where(PartialEq, Hash, Debug; I: Interner)]
|
||||
pub enum GoalEvaluationKind<I: Interner> {
|
||||
Overflow,
|
||||
Evaluation {
|
||||
|
|
@ -67,10 +64,12 @@ pub enum GoalEvaluationKind<I: Interner> {
|
|||
},
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for GoalEvaluationKind<I> {}
|
||||
|
||||
/// A self-contained computation during trait solving. This either
|
||||
/// corresponds to a `EvalCtxt::probe(_X)` call or the root evaluation
|
||||
/// of a goal.
|
||||
#[derive_where(PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(PartialEq, Hash, Debug; I: Interner)]
|
||||
pub struct Probe<I: Interner> {
|
||||
/// What happened inside of this probe in chronological order.
|
||||
pub steps: Vec<ProbeStep<I>>,
|
||||
|
|
@ -78,7 +77,9 @@ pub struct Probe<I: Interner> {
|
|||
pub final_state: CanonicalState<I, ()>,
|
||||
}
|
||||
|
||||
#[derive_where(PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
impl<I: Interner> Eq for Probe<I> {}
|
||||
|
||||
#[derive_where(PartialEq, Hash, Debug; I: Interner)]
|
||||
pub enum ProbeStep<I: Interner> {
|
||||
/// We added a goal to the `EvalCtxt` which will get proven
|
||||
/// the next time `EvalCtxt::try_evaluate_added_goals` is called.
|
||||
|
|
@ -97,10 +98,12 @@ pub enum ProbeStep<I: Interner> {
|
|||
MakeCanonicalResponse { shallow_certainty: Certainty },
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ProbeStep<I> {}
|
||||
|
||||
/// What kind of probe we're in. In case the probe represents a candidate, or
|
||||
/// the final result of the current goal - via [ProbeKind::Root] - we also
|
||||
/// store the [QueryResult].
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
pub enum ProbeKind<I: Interner> {
|
||||
/// The root inference context while proving a goal.
|
||||
|
|
@ -125,3 +128,5 @@ pub enum ProbeKind<I: Interner> {
|
|||
/// Checking that a rigid alias is well-formed.
|
||||
RigidAlias { result: QueryResult<I> },
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ProbeKind<I> {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
pub mod inspect;
|
||||
|
||||
use std::fmt;
|
||||
use std::hash::Hash;
|
||||
|
||||
use derive_where::derive_where;
|
||||
|
|
@ -32,12 +31,8 @@ pub struct NoSolution;
|
|||
///
|
||||
/// Most of the time the `param_env` contains the `where`-bounds of the function
|
||||
/// we're currently typechecking while the `predicate` is some trait bound.
|
||||
#[derive_where(Clone; I: Interner, P: Clone)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, P)]
|
||||
#[derive_where(Copy; I: Interner, P: Copy)]
|
||||
#[derive_where(Hash; I: Interner, P: Hash)]
|
||||
#[derive_where(PartialEq; I: Interner, P: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, P: Eq)]
|
||||
#[derive_where(Debug; I: Interner, P: fmt::Debug)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -48,6 +43,8 @@ pub struct Goal<I: Interner, P> {
|
|||
pub predicate: P,
|
||||
}
|
||||
|
||||
impl<I: Interner, P: Eq> Eq for Goal<I, P> {}
|
||||
|
||||
impl<I: Interner, P> Goal<I, P> {
|
||||
pub fn new(cx: I, param_env: I::ParamEnv, predicate: impl Upcast<I, P>) -> Goal<I, P> {
|
||||
Goal { param_env, predicate: predicate.upcast(cx) }
|
||||
|
|
@ -98,12 +95,8 @@ pub enum GoalSource {
|
|||
NormalizeGoal(PathKind),
|
||||
}
|
||||
|
||||
#[derive_where(Clone; I: Interner, Goal<I, P>: Clone)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, Goal<I, P>)]
|
||||
#[derive_where(Copy; I: Interner, Goal<I, P>: Copy)]
|
||||
#[derive_where(Hash; I: Interner, Goal<I, P>: Hash)]
|
||||
#[derive_where(PartialEq; I: Interner, Goal<I, P>: PartialEq)]
|
||||
#[derive_where(Eq; I: Interner, Goal<I, P>: Eq)]
|
||||
#[derive_where(Debug; I: Interner, Goal<I, P>: fmt::Debug)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -114,8 +107,10 @@ pub struct QueryInput<I: Interner, P> {
|
|||
pub predefined_opaques_in_body: I::PredefinedOpaques,
|
||||
}
|
||||
|
||||
impl<I: Interner, P: Eq> Eq for QueryInput<I, P> {}
|
||||
|
||||
/// Opaques that are defined in the inference context before a query is called.
|
||||
#[derive_where(Clone, Hash, PartialEq, Eq, Debug, Default; I: Interner)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug, Default; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -125,8 +120,10 @@ pub struct PredefinedOpaquesData<I: Interner> {
|
|||
pub opaque_types: Vec<(ty::OpaqueTypeKey<I>, I::Ty)>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for PredefinedOpaquesData<I> {}
|
||||
|
||||
/// Possible ways the given goal can be proven.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
pub enum CandidateSource<I: Interner> {
|
||||
/// A user written impl.
|
||||
///
|
||||
|
|
@ -189,6 +186,8 @@ pub enum CandidateSource<I: Interner> {
|
|||
CoherenceUnknowable,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CandidateSource<I> {}
|
||||
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
|
||||
pub enum ParamEnvSource {
|
||||
/// Preferred eagerly.
|
||||
|
|
@ -217,7 +216,7 @@ pub enum BuiltinImplSource {
|
|||
TraitUpcasting(usize),
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
pub struct Response<I: Interner> {
|
||||
|
|
@ -227,8 +226,10 @@ pub struct Response<I: Interner> {
|
|||
pub external_constraints: I::ExternalConstraints,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for Response<I> {}
|
||||
|
||||
/// Additional constraints returned on success.
|
||||
#[derive_where(Clone, Hash, PartialEq, Eq, Debug, Default; I: Interner)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug, Default; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
pub struct ExternalConstraintsData<I: Interner> {
|
||||
|
|
@ -237,6 +238,8 @@ pub struct ExternalConstraintsData<I: Interner> {
|
|||
pub normalization_nested_goals: NestedNormalizationGoals<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ExternalConstraintsData<I> {}
|
||||
|
||||
impl<I: Interner> ExternalConstraintsData<I> {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.region_constraints.is_empty()
|
||||
|
|
@ -245,11 +248,13 @@ impl<I: Interner> ExternalConstraintsData<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Hash, PartialEq, Eq, Debug, Default; I: Interner)]
|
||||
#[derive_where(Clone, Hash, PartialEq, Debug, Default; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
pub struct NestedNormalizationGoals<I: Interner>(pub Vec<(GoalSource, Goal<I, I::Predicate>)>);
|
||||
|
||||
impl<I: Interner> Eq for NestedNormalizationGoals<I> {}
|
||||
|
||||
impl<I: Interner> NestedNormalizationGoals<I> {
|
||||
pub fn empty() -> Self {
|
||||
NestedNormalizationGoals(vec![])
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ impl AliasTyKind {
|
|||
/// Types written by the user start out as `hir::TyKind` and get
|
||||
/// converted to this representation using `<dyn HirTyLowerer>::lower_ty`.
|
||||
#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "IrTyKind")]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -268,6 +268,8 @@ pub enum TyKind<I: Interner> {
|
|||
Error(I::ErrorGuaranteed),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for TyKind<I> {}
|
||||
|
||||
impl<I: Interner> TyKind<I> {
|
||||
pub fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
|
||||
match self {
|
||||
|
|
@ -404,7 +406,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
|
|||
/// * For a projection, this would be `<Ty as Trait<...>>::N<...>`.
|
||||
/// * For an inherent projection, this would be `Ty::N<...>`.
|
||||
/// * For an opaque type, there is no explicit syntax.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
|
|
@ -440,6 +442,8 @@ pub struct AliasTy<I: Interner> {
|
|||
pub(crate) _use_alias_ty_new_instead: (),
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for AliasTy<I> {}
|
||||
|
||||
impl<I: Interner> AliasTy<I> {
|
||||
pub fn new_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTy<I> {
|
||||
interner.debug_assert_args_compatible(def_id, args);
|
||||
|
|
@ -720,7 +724,7 @@ impl fmt::Debug for InferTy {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -731,7 +735,9 @@ pub struct TypeAndMut<I: Interner> {
|
|||
pub mutbl: Mutability,
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash; I: Interner)]
|
||||
impl<I: Interner> Eq for TypeAndMut<I> {}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -748,6 +754,8 @@ pub struct FnSig<I: Interner> {
|
|||
pub abi: I::Abi,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for FnSig<I> {}
|
||||
|
||||
impl<I: Interner> FnSig<I> {
|
||||
pub fn inputs(self) -> I::FnInputTys {
|
||||
self.inputs_and_output.inputs()
|
||||
|
|
@ -845,11 +853,13 @@ impl<I: Interner> fmt::Debug for FnSig<I> {
|
|||
|
||||
// FIXME: this is a distinct type because we need to define `Encode`/`Decode`
|
||||
// impls in this crate for `Binder<I, I::Ty>`.
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, I::Ty>);
|
||||
|
||||
impl<I: Interner> Eq for UnsafeBinderInner<I> {}
|
||||
|
||||
impl<I: Interner> From<ty::Binder<I, I::Ty>> for UnsafeBinderInner<I> {
|
||||
fn from(value: ty::Binder<I, I::Ty>) -> Self {
|
||||
UnsafeBinderInner(value)
|
||||
|
|
@ -906,7 +916,7 @@ where
|
|||
}
|
||||
|
||||
// This is just a `FnSig` without the `FnHeader` fields.
|
||||
#[derive_where(Clone, Copy, Debug, PartialEq, Eq, Hash; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -916,6 +926,8 @@ pub struct FnSigTys<I: Interner> {
|
|||
pub inputs_and_output: I::Tys,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for FnSigTys<I> {}
|
||||
|
||||
impl<I: Interner> FnSigTys<I> {
|
||||
pub fn inputs(self) -> I::FnInputTys {
|
||||
self.inputs_and_output.inputs()
|
||||
|
|
@ -958,7 +970,7 @@ impl<I: Interner> ty::Binder<I, FnSigTys<I>> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Debug, PartialEq, Eq, Hash; I: Interner)]
|
||||
#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -970,7 +982,9 @@ pub struct FnHeader<I: Interner> {
|
|||
pub abi: I::Abi,
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, Debug, PartialEq, Eq, Hash; I: Interner)]
|
||||
impl<I: Interner> Eq for FnHeader<I> {}
|
||||
|
||||
#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
|
|
@ -980,3 +994,5 @@ pub struct CoroutineWitnessTypes<I: Interner> {
|
|||
pub types: I::Tys,
|
||||
pub assumptions: I::RegionAssumptions,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CoroutineWitnessTypes<I> {}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ use crate::{self as ty, Interner};
|
|||
/// `yield` inside the coroutine.
|
||||
/// * `GR`: The "return type", which is the type of value returned upon
|
||||
/// completion of the coroutine.
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
pub struct ClosureArgs<I: Interner> {
|
||||
/// Lifetime and type parameters from the enclosing function,
|
||||
|
|
@ -112,6 +112,8 @@ pub struct ClosureArgs<I: Interner> {
|
|||
pub args: I::GenericArgs,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for ClosureArgs<I> {}
|
||||
|
||||
/// Struct returned by `split()`.
|
||||
pub struct ClosureArgsParts<I: Interner> {
|
||||
/// This is the args of the typeck root.
|
||||
|
|
@ -203,12 +205,14 @@ impl<I: Interner> ClosureArgs<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
pub struct CoroutineClosureArgs<I: Interner> {
|
||||
pub args: I::GenericArgs,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CoroutineClosureArgs<I> {}
|
||||
|
||||
/// See docs for explanation of how each argument is used.
|
||||
///
|
||||
/// See [`CoroutineClosureSignature`] for how these arguments are put together
|
||||
|
|
@ -348,7 +352,7 @@ impl<I: Interner> TypeVisitor<I> for HasRegionsBoundAt {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
pub struct CoroutineClosureSignature<I: Interner> {
|
||||
pub tupled_inputs_ty: I::Ty,
|
||||
|
|
@ -371,6 +375,8 @@ pub struct CoroutineClosureSignature<I: Interner> {
|
|||
pub abi: I::Abi,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CoroutineClosureSignature<I> {}
|
||||
|
||||
impl<I: Interner> CoroutineClosureSignature<I> {
|
||||
/// Construct a coroutine from the closure signature. Since a coroutine signature
|
||||
/// is agnostic to the type of generator that is returned (by-ref/by-move),
|
||||
|
|
@ -541,7 +547,7 @@ impl<I: Interner> TypeFolder<I> for FoldEscapingRegions<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
pub struct GenSig<I: Interner> {
|
||||
pub resume_ty: I::Ty,
|
||||
|
|
@ -549,13 +555,16 @@ pub struct GenSig<I: Interner> {
|
|||
pub return_ty: I::Ty,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for GenSig<I> {}
|
||||
/// Similar to `ClosureArgs`; see the above documentation for more.
|
||||
#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
pub struct CoroutineArgs<I: Interner> {
|
||||
pub args: I::GenericArgs,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CoroutineArgs<I> {}
|
||||
|
||||
pub struct CoroutineArgsParts<I: Interner> {
|
||||
/// This is the args of the typeck root.
|
||||
pub parent_args: I::GenericArgsSlice,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue