diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-05-12 20:13:54 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-05-12 20:16:11 +0200 |
| commit | ecbda428ec4e0d2744e26268129f0ded42cbc865 (patch) | |
| tree | acaf1be9f4f63a0b9d5cbc3fdc1dde50b661a9cc | |
| parent | dde7bff5740134c98edfa38090dab1e7cbdc29a6 (diff) | |
| download | rust-ecbda428ec4e0d2744e26268129f0ded42cbc865.tar.gz rust-ecbda428ec4e0d2744e26268129f0ded42cbc865.zip | |
Correct comment.
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index d847068b5bf..f4318044c00 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1996,6 +1996,7 @@ impl<'tcx> TyCtxt<'tcx> { .filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value()) } + /// Look up the name of a definition across crates. This does not look at HIR. fn opt_item_name(self, def_id: DefId) -> Option<Symbol> { if let Some(cnum) = def_id.as_crate_root() { Some(self.crate_name(cnum)) @@ -2016,16 +2017,11 @@ impl<'tcx> TyCtxt<'tcx> { /// Look up the name of a definition across crates. This does not look at HIR. /// - /// When possible, this function should be used for cross-crate lookups over - /// [`opt_item_name`] to avoid invalidating the incremental cache. If you - /// need to handle items without a name, or HIR items that will not be - /// serialized cross-crate, or if you need the span of the item, use + /// This method will ICE if the corresponding item does not have a name. In these cases, use /// [`opt_item_name`] instead. /// /// [`opt_item_name`]: Self::opt_item_name pub fn item_name(self, id: DefId) -> Symbol { - // Look at cross-crate items first to avoid invalidating the incremental cache - // unless we have to. self.opt_item_name(id).unwrap_or_else(|| { bug!("item_name: no name for {:?}", self.def_path(id)); }) |
