diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-09 15:56:23 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-13 09:48:22 +0000 |
| commit | cb26b35b12d810d7a8215869d9e434c4b0c7f25c (patch) | |
| tree | aba9abf603b5700c176884740d05463a2a18c611 /compiler/rustc_privacy/src | |
| parent | 71ec1457ee9868a838e4521a3510cdd416c0c295 (diff) | |
| download | rust-cb26b35b12d810d7a8215869d9e434c4b0c7f25c.tar.gz rust-cb26b35b12d810d7a8215869d9e434c4b0c7f25c.zip | |
Make some diagnostics not depend on the source of what they reference being available
Diffstat (limited to 'compiler/rustc_privacy/src')
| -rw-r--r-- | compiler/rustc_privacy/src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index a254c892478..2c89f4add2e 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1308,15 +1308,15 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> { let is_local_static = if let DefKind::Static(_) = kind { def_id.is_local() } else { false }; if !self.item_is_accessible(def_id) && !is_local_static { - let sess = self.tcx.sess; - let sm = sess.source_map(); - let name = match qpath { - hir::QPath::Resolved(..) | hir::QPath::LangItem(..) => { - sm.span_to_snippet(qpath.span()).ok() + let name = match *qpath { + hir::QPath::LangItem(it, ..) => { + self.tcx.lang_items().get(it).map(|did| self.tcx.def_path_str(did)) } + hir::QPath::Resolved(_, path) => Some(self.tcx.def_path_str(path.res.def_id())), hir::QPath::TypeRelative(_, segment) => Some(segment.ident.to_string()), }; let kind = kind.descr(def_id); + let sess = self.tcx.sess; let _ = match name { Some(name) => { sess.emit_err(ItemIsPrivate { span, kind, descr: (&name).into() }) |
