1
Fork 0

Remove AdtFlags::IS_ANONYMOUS and Copy/Clone condition for anonymous ADT

This commit is contained in:
Michael Goulet 2025-03-10 02:31:16 +00:00
parent 385970f0c1
commit f525b173ed
3 changed files with 1 additions and 18 deletions

View file

@ -53,8 +53,6 @@ bitflags::bitflags! {
const IS_VARIANT_LIST_NON_EXHAUSTIVE = 1 << 8; const IS_VARIANT_LIST_NON_EXHAUSTIVE = 1 << 8;
/// Indicates whether the type is `UnsafeCell`. /// Indicates whether the type is `UnsafeCell`.
const IS_UNSAFE_CELL = 1 << 9; const IS_UNSAFE_CELL = 1 << 9;
/// Indicates whether the type is anonymous.
const IS_ANONYMOUS = 1 << 10;
} }
} }
rustc_data_structures::external_bitflags_debug! { AdtFlags } rustc_data_structures::external_bitflags_debug! { AdtFlags }
@ -402,12 +400,6 @@ impl<'tcx> AdtDef<'tcx> {
self.flags().contains(AdtFlags::IS_MANUALLY_DROP) self.flags().contains(AdtFlags::IS_MANUALLY_DROP)
} }
/// Returns `true` if this is an anonymous adt
#[inline]
pub fn is_anonymous(self) -> bool {
self.flags().contains(AdtFlags::IS_ANONYMOUS)
}
/// Returns `true` if this type has a destructor. /// Returns `true` if this type has a destructor.
pub fn has_dtor(self, tcx: TyCtxt<'tcx>) -> bool { pub fn has_dtor(self, tcx: TyCtxt<'tcx>) -> bool {
self.destructor(tcx).is_some() self.destructor(tcx).is_some()

View file

@ -1151,7 +1151,7 @@ pub struct VariantDef {
/// `DefId` that identifies the variant's constructor. /// `DefId` that identifies the variant's constructor.
/// If this variant is a struct variant, then this is `None`. /// If this variant is a struct variant, then this is `None`.
pub ctor: Option<(CtorKind, DefId)>, pub ctor: Option<(CtorKind, DefId)>,
/// Variant or struct name, maybe empty for anonymous adt (struct or union). /// Variant or struct name.
pub name: Symbol, pub name: Symbol,
/// Discriminant of this variant. /// Discriminant of this variant.
pub discr: VariantDiscr, pub discr: VariantDiscr,

View file

@ -2231,15 +2231,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
} }
} }
// `Copy` and `Clone` are automatically implemented for an anonymous adt
// if all of its fields are `Copy` and `Clone`
ty::Adt(adt, args) if adt.is_anonymous() => {
// (*) binder moved here
Where(obligation.predicate.rebind(
adt.non_enum_variant().fields.iter().map(|f| f.ty(self.tcx(), args)).collect(),
))
}
ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => { ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {
// Fallback to whatever user-defined impls exist in this case. // Fallback to whatever user-defined impls exist in this case.
None None