about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/mod.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2023-05-03 19:27:29 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2023-05-03 20:09:10 +0300
commit6f6c379ee065d65fb8121db46bf5b0fbcdcb905c (patch)
tree71b39efda51aed1c40f2776a0556b55ba03cc05e /compiler/rustc_middle/src/ty/mod.rs
parent82cd953c7c43e64dae6f705ce2f07b291f0e22e3 (diff)
downloadrust-6f6c379ee065d65fb8121db46bf5b0fbcdcb905c.tar.gz
rust-6f6c379ee065d65fb8121db46bf5b0fbcdcb905c.zip
rustc_middle: Fix `opt_item_ident` for non-local def ids
Diffstat (limited to 'compiler/rustc_middle/src/ty/mod.rs')
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index db6b35026a8..8d94aa9ecb8 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -2109,10 +2109,9 @@ impl<'tcx> TyCtxt<'tcx> {
     /// See [`item_name`][Self::item_name] for more information.
     pub fn opt_item_ident(self, def_id: DefId) -> Option<Ident> {
         let def = self.opt_item_name(def_id)?;
-        let span = def_id
-            .as_local()
-            .and_then(|id| self.def_ident_span(id))
-            .unwrap_or(rustc_span::DUMMY_SP);
+        let span = self
+            .def_ident_span(def_id)
+            .unwrap_or_else(|| bug!("missing ident span for {def_id:?}"));
         Some(Ident::new(def, span))
     }