about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2022-07-14 15:09:30 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2022-08-23 00:08:42 +0200
commit613dc2204dc628e6804b9d2be8bdeb6f6f43611e (patch)
tree0f519991909524a2d658f38bb30cc104b51ba9cf /compiler/rustc_resolve/src/lib.rs
parentd7d701a9dc6c424e01d49d937925dc3bf7718138 (diff)
downloadrust-613dc2204dc628e6804b9d2be8bdeb6f6f43611e.tar.gz
rust-613dc2204dc628e6804b9d2be8bdeb6f6f43611e.zip
Improve local generic parameter suggestions.
Diffstat (limited to 'compiler/rustc_resolve/src/lib.rs')
-rw-r--r--compiler/rustc_resolve/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index 9c213da8c2a..eb727debc91 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -1945,6 +1945,16 @@ impl<'a> Resolver<'a> {
         def_id.as_local().map(|def_id| self.source_span[def_id])
     }
 
+    /// Retrieves the name of the given `DefId`.
+    #[inline]
+    pub fn opt_name(&self, def_id: DefId) -> Option<Symbol> {
+        let def_key = match def_id.as_local() {
+            Some(def_id) => self.definitions.def_key(def_id),
+            None => self.cstore().def_key(def_id),
+        };
+        def_key.get_opt_name()
+    }
+
     /// Checks if an expression refers to a function marked with
     /// `#[rustc_legacy_const_generics]` and returns the argument index list
     /// from the attribute.