1
Fork 0

Move opt_rpitit_info field to hir::AssocKind::Type.

From `hir::AssocItem`.
This commit is contained in:
Nicholas Nethercote 2025-04-11 16:50:20 +10:00
parent ce2aa97cd6
commit b26f3d4347
28 changed files with 103 additions and 91 deletions

View file

@ -894,12 +894,14 @@ impl<'tcx> Stable<'tcx> for rustc_session::cstore::ForeignModule {
impl<'tcx> Stable<'tcx> for ty::AssocKind {
type T = stable_mir::ty::AssocKind;
fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
use stable_mir::ty::AssocKind;
match *self {
ty::AssocKind::Const => AssocKind::Const,
ty::AssocKind::Fn { has_self } => AssocKind::Fn { has_self },
ty::AssocKind::Type => AssocKind::Type,
ty::AssocKind::Type { opt_rpitit_info } => AssocKind::Type {
opt_rpitit_info: opt_rpitit_info.map(|rpitit| rpitit.stable(tables)),
},
}
}
}
@ -926,7 +928,6 @@ impl<'tcx> Stable<'tcx> for ty::AssocItem {
kind: self.kind.stable(tables),
container: self.container.stable(tables),
trait_item_def_id: self.trait_item_def_id.map(|did| tables.assoc_def(did)),
opt_rpitit_info: self.opt_rpitit_info.map(|rpitit| rpitit.stable(tables)),
}
}
}

View file

@ -25,7 +25,7 @@ impl Display for AssocKind {
AssocKind::Fn { has_self: true } => write!(f, "method"),
AssocKind::Fn { has_self: false } => write!(f, "associated function"),
AssocKind::Const => write!(f, "associated const"),
AssocKind::Type => write!(f, "associated type"),
AssocKind::Type { .. } => write!(f, "associated type"),
}
}
}

View file

@ -1585,18 +1585,20 @@ pub struct AssocItem {
/// 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>,
/// `Some` if the associated item (an associated type) comes from the
/// return-position `impl Trait` in trait desugaring. The `ImplTraitInTraitData`
/// provides additional information about its source.
pub opt_rpitit_info: Option<ImplTraitInTraitData>,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum AssocKind {
Const,
Fn { has_self: bool },
Type,
Fn {
has_self: bool,
},
Type {
/// `Some` if the associated type comes from an RPITIT. The
/// `ImplTraitInTraitData` provides additional information about its
/// source.
opt_rpitit_info: Option<ImplTraitInTraitData>,
},
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
@ -1613,6 +1615,6 @@ pub enum ImplTraitInTraitData {
impl AssocItem {
pub fn is_impl_trait_in_trait(&self) -> bool {
self.opt_rpitit_info.is_some()
matches!(self.kind, AssocKind::Type { opt_rpitit_info: Some(_) })
}
}