Simplify some Copy impls in rustc_type_ir

This commit is contained in:
Michael Goulet 2023-12-11 21:06:26 +00:00
parent e2a3c9b3f0
commit e947234520
3 changed files with 11 additions and 55 deletions

View File

@ -119,12 +119,7 @@ fn visit_with<F: TypeVisitor<I>>(&self, folder: &mut F) -> ControlFlow<F::BreakT
/// a copy of the canonical value in some other inference context,
/// with fresh inference variables replacing the canonical values.
#[derive(derivative::Derivative)]
#[derivative(
Clone(bound = ""),
Hash(bound = ""),
Copy(bound = "CanonicalVarKind<I>: Copy"),
Debug(bound = "")
)]
#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""), Debug(bound = ""))]
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
pub struct CanonicalVarInfo<I: Interner> {
pub kind: CanonicalVarKind<I>,
@ -207,7 +202,7 @@ pub fn expect_placeholder_index(self) -> usize {
/// in the type-theory sense of the term -- i.e., a "meta" type system
/// that analyzes type-like values.
#[derive(derivative::Derivative)]
#[derivative(Clone(bound = ""), Hash(bound = ""), Debug(bound = ""))]
#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""), Debug(bound = ""))]
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
pub enum CanonicalVarKind<I: Interner> {
/// Some kind of type inference variable.
@ -234,15 +229,6 @@ pub enum CanonicalVarKind<I: Interner> {
PlaceholderConst(I::PlaceholderConst, I::Ty),
}
impl<I: Interner> Copy for CanonicalVarKind<I>
where
I::PlaceholderTy: Copy,
I::PlaceholderRegion: Copy,
I::PlaceholderConst: Copy,
I::Ty: Copy,
{
}
impl<I: Interner> PartialEq for CanonicalVarKind<I> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {

View File

@ -8,7 +8,7 @@
/// A clause is something that can appear in where bounds or be inferred
/// by implied bounds.
#[derive(derivative::Derivative)]
#[derivative(Clone(bound = ""), Hash(bound = ""))]
#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""))]
#[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))]
pub enum ClauseKind<I: Interner> {
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
@ -37,18 +37,6 @@ pub enum ClauseKind<I: Interner> {
ConstEvaluatable(I::Const),
}
impl<I: Interner> Copy for ClauseKind<I>
where
I::Ty: Copy,
I::Const: Copy,
I::GenericArg: Copy,
I::TraitPredicate: Copy,
I::ProjectionPredicate: Copy,
I::TypeOutlivesPredicate: Copy,
I::RegionOutlivesPredicate: Copy,
{
}
impl<I: Interner> PartialEq for ClauseKind<I> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
@ -120,7 +108,13 @@ fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::Break
}
#[derive(derivative::Derivative)]
#[derivative(Clone(bound = ""), Hash(bound = ""), PartialEq(bound = ""), Eq(bound = ""))]
#[derivative(
Clone(bound = ""),
Copy(bound = ""),
Hash(bound = ""),
PartialEq(bound = ""),
Eq(bound = "")
)]
#[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))]
pub enum PredicateKind<I: Interner> {
/// Prove a clause
@ -169,19 +163,6 @@ pub enum PredicateKind<I: Interner> {
AliasRelate(I::Term, I::Term, AliasRelationDirection),
}
impl<I: Interner> Copy for PredicateKind<I>
where
I::DefId: Copy,
I::Const: Copy,
I::GenericArgs: Copy,
I::Term: Copy,
I::CoercePredicate: Copy,
I::SubtypePredicate: Copy,
I::NormalizesTo: Copy,
ClauseKind<I>: Copy,
{
}
impl<I: Interner> TypeFoldable<I> for PredicateKind<I>
where
I::DefId: TypeFoldable<I>,

View File

@ -115,6 +115,7 @@
#[derive(derivative::Derivative)]
#[derivative(
Clone(bound = ""),
Copy(bound = ""),
PartialOrd(bound = ""),
PartialOrd = "feature_allow_slow_enum",
Ord(bound = ""),
@ -189,18 +190,6 @@ const fn regionkind_discriminant<I: Interner>(value: &RegionKind<I>) -> usize {
}
}
// This is manually implemented because a derive would require `I: Copy`
impl<I: Interner> Copy for RegionKind<I>
where
I::EarlyParamRegion: Copy,
I::BoundRegion: Copy,
I::LateParamRegion: Copy,
I::InferRegion: Copy,
I::PlaceholderRegion: Copy,
I::ErrorGuaranteed: Copy,
{
}
// This is manually implemented because a derive would require `I: PartialEq`
impl<I: Interner> PartialEq for RegionKind<I> {
#[inline]