Split AssocContainer::{InherentImpl,TraitImpl}

This commit is contained in:
Cameron Steffen 2025-08-13 15:24:19 -05:00
parent 88a8bfcaf0
commit 9615ec7d10
33 changed files with 173 additions and 229 deletions

View file

@ -1613,10 +1613,6 @@ pub struct AssocItem {
pub def_id: AssocDef,
pub kind: AssocKind,
pub container: AssocContainer,
/// If this is an item in an impl of a trait then this is the `DefId` of
/// the associated item on the trait that this implements.
pub trait_item_def_id: Option<AssocDef>,
}
#[derive(Clone, PartialEq, Debug, Eq, Serialize)]
@ -1637,8 +1633,10 @@ pub enum AssocKind {
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum AssocContainer {
InherentImpl,
/// The `AssocDef` points to the trait item being implemented.
TraitImpl(AssocDef),
Trait,
Impl,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize)]

View file

@ -1079,11 +1079,18 @@ impl<'tcx> Stable<'tcx> for ty::AssocKind {
impl<'tcx> Stable<'tcx> for ty::AssocContainer {
type T = crate::ty::AssocContainer;
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
fn stable(
&self,
tables: &mut Tables<'_, BridgeTys>,
_: &CompilerCtxt<'_, BridgeTys>,
) -> Self::T {
use crate::ty::AssocContainer;
match self {
ty::AssocContainer::Trait => AssocContainer::Trait,
ty::AssocContainer::Impl => AssocContainer::Impl,
ty::AssocContainer::InherentImpl => AssocContainer::InherentImpl,
ty::AssocContainer::TraitImpl(trait_item_id) => {
AssocContainer::TraitImpl(tables.assoc_def(trait_item_id.unwrap()))
}
}
}
}
@ -1100,7 +1107,6 @@ impl<'tcx> Stable<'tcx> for ty::AssocItem {
def_id: tables.assoc_def(self.def_id),
kind: self.kind.stable(tables, cx),
container: self.container.stable(tables, cx),
trait_item_def_id: self.trait_item_def_id.map(|did| tables.assoc_def(did)),
}
}
}