diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-03 09:09:26 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-13 13:50:00 +0000 |
| commit | 36bc0948e0a67f5aeb2a1d997acf4cd94d948fa9 (patch) | |
| tree | 3b7603b8c6484721867b6d16392144c0d4941240 /compiler/rustc_middle/src/ty | |
| parent | 277b0ecf3493a89818a4008afbb36ae4e77c1024 (diff) | |
| download | rust-36bc0948e0a67f5aeb2a1d997acf4cd94d948fa9.tar.gz rust-36bc0948e0a67f5aeb2a1d997acf4cd94d948fa9.zip | |
Generalize TyCtxt::item_name.
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 0177a95498b..9df44bbc15e 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1590,7 +1590,8 @@ impl<'tcx> TyCtxt<'tcx> { } /// Look up the name of a definition across crates. This does not look at HIR. - pub fn opt_item_name(self, def_id: DefId) -> Option<Symbol> { + pub fn opt_item_name(self, def_id: impl IntoQueryParam<DefId>) -> Option<Symbol> { + let def_id = def_id.into_query_param(); if let Some(cnum) = def_id.as_crate_root() { Some(self.crate_name(cnum)) } else { @@ -1610,7 +1611,8 @@ impl<'tcx> TyCtxt<'tcx> { /// [`opt_item_name`] instead. /// /// [`opt_item_name`]: Self::opt_item_name - pub fn item_name(self, id: DefId) -> Symbol { + pub fn item_name(self, id: impl IntoQueryParam<DefId>) -> Symbol { + let id = id.into_query_param(); self.opt_item_name(id).unwrap_or_else(|| { bug!("item_name: no name for {:?}", self.def_path(id)); }) @@ -1619,7 +1621,8 @@ impl<'tcx> TyCtxt<'tcx> { /// Look up the name and span of a definition. /// /// See [`item_name`][Self::item_name] for more information. - pub fn opt_item_ident(self, def_id: DefId) -> Option<Ident> { + pub fn opt_item_ident(self, def_id: impl IntoQueryParam<DefId>) -> Option<Ident> { + let def_id = def_id.into_query_param(); let def = self.opt_item_name(def_id)?; let span = self .def_ident_span(def_id) @@ -1630,7 +1633,8 @@ impl<'tcx> TyCtxt<'tcx> { /// 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 { + pub fn item_ident(self, def_id: impl IntoQueryParam<DefId>) -> Ident { + let def_id = def_id.into_query_param(); self.opt_item_ident(def_id).unwrap_or_else(|| { bug!("item_ident: no name for {:?}", self.def_path(def_id)); }) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index fd80d85f198..174892c6f4d 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1683,7 +1683,7 @@ pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::Intrinsi _ => true, }; Some(ty::IntrinsicDef { - name: tcx.item_name(def_id.into()), + name: tcx.item_name(def_id), must_be_overridden, const_stable: tcx.has_attr(def_id, sym::rustc_intrinsic_const_stable_indirect), }) |
