1
Fork 0

Rollup merge of #136114 - compiler-errors:more-idents, r=jieyouxu

Use identifiers more in diagnostics code

This should make the diagnostics code slightly more correct when rendering idents in mixed crate edition situations. Kinda a no-op, but a cleanup regardless.

r? oli-obk or reassign
This commit is contained in:
Guillaume Gomez 2025-01-27 15:38:30 +01:00 committed by GitHub
commit 03fdcffa1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 97 additions and 90 deletions

View file

@ -1596,6 +1596,15 @@ impl<'tcx> TyCtxt<'tcx> {
Some(Ident::new(def, span))
}
/// Look up the name and span of a definition.
///
/// See [`item_name`][Self::item_name] for more information.
pub fn item_ident(self, def_id: DefId) -> Ident {
self.opt_item_ident(def_id).unwrap_or_else(|| {
bug!("item_ident: no name for {:?}", self.def_path(def_id));
})
}
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
Some(self.associated_item(def_id))