about summary refs log tree commit diff
path: root/compiler/rustc_save_analysis
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2021-11-18 21:35:42 +0000
committerNoah Lev <camelidcamel@gmail.com>2022-01-07 12:28:12 -0800
commitd7595853a2ef0ff2884db8d627023687256c3845 (patch)
tree460f11bb7b22616fd8763be464df256fb6f44ae4 /compiler/rustc_save_analysis
parent0b1ab91d6604cf3277ef562eabd04f107015de58 (diff)
downloadrust-d7595853a2ef0ff2884db8d627023687256c3845.tar.gz
rust-d7595853a2ef0ff2884db8d627023687256c3845.zip
Add `trait_item_def_id` to `AssocItem`
This allows avoiding some lookups by name
Diffstat (limited to 'compiler/rustc_save_analysis')
-rw-r--r--compiler/rustc_save_analysis/src/lib.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs
index 7ec619e07ff..a83f0230814 100644
--- a/compiler/rustc_save_analysis/src/lib.rs
+++ b/compiler/rustc_save_analysis/src/lib.rs
@@ -710,13 +710,11 @@ impl<'tcx> SaveContext<'tcx> {
             }
             Res::Def(HirDefKind::AssocFn, decl_id) => {
                 let def_id = if decl_id.is_local() {
-                    let ti = self.tcx.associated_item(decl_id);
-
-                    self.tcx
-                        .associated_items(ti.container.id())
-                        .filter_by_name_unhygienic(ti.ident.name)
-                        .find(|item| item.defaultness.has_value())
-                        .map(|item| item.def_id)
+                    if self.tcx.associated_item(decl_id).defaultness.has_value() {
+                        Some(decl_id)
+                    } else {
+                        None
+                    }
                 } else {
                     None
                 };