diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2023-05-03 16:42:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-03 16:42:51 -0700 |
| commit | 48c78248a35385f474b7b27a1da3da1d146b04dc (patch) | |
| tree | c16021555bb5e1a977bbe8d8955b0aaa9d942540 /compiler/rustc_middle/src/ty | |
| parent | 54cf5618899e90293783e0300d5080790956782b (diff) | |
| parent | 6f6c379ee065d65fb8121db46bf5b0fbcdcb905c (diff) | |
| download | rust-48c78248a35385f474b7b27a1da3da1d146b04dc.tar.gz rust-48c78248a35385f474b7b27a1da3da1d146b04dc.zip | |
Rollup merge of #111146 - petrochenkov:decident, r=compiler-errors
rustc_middle: Fix `opt_item_ident` for non-local def ids Noticed while working on https://github.com/rust-lang/rust/pull/110855.
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 7 |
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 8986defacc7..58e5c84fc81 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2108,10 +2108,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)) } |
