about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-11 23:36:46 +0100
committerGitHub <noreply@github.com>2022-12-11 23:36:46 +0100
commit6ed8cb6616694244efebd84f70c4e8b41eab6bbf (patch)
tree6e4276aacaa18843f5c7e7f0feb5d53770c85c59
parent4154e14f9ac586b4bb8c67db1d474b4d8c960e23 (diff)
parent99d229095e856c7f9a2ec3663e17f30967e4098e (diff)
downloadrust-6ed8cb6616694244efebd84f70c4e8b41eab6bbf.tar.gz
rust-6ed8cb6616694244efebd84f70c4e8b41eab6bbf.zip
Rollup merge of #105472 - spastorino:make-encoder-use-queries, r=oli-obk
Make encode_info_for_trait_item use queries instead of accessing the HIR

This change avoids accessing the HIR on `encode_info_for_trait_item` and uses queries. We will need to execute this function for elements that have no HIR and by using queries we will be able to feed for definitions that have no HIR.

r? ``@oli-obk``
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 8b4c4bb2675..29f9e82da75 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -1337,24 +1337,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
         debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
         let tcx = self.tcx;
 
-        let ast_item = tcx.hir().expect_trait_item(def_id.expect_local());
-        self.tables.impl_defaultness.set(def_id.index, ast_item.defaultness);
+        let impl_defaultness = tcx.impl_defaultness(def_id.expect_local());
+        self.tables.impl_defaultness.set(def_id.index, impl_defaultness);
         let trait_item = tcx.associated_item(def_id);
         self.tables.assoc_container.set(def_id.index, trait_item.container);
 
         match trait_item.kind {
             ty::AssocKind::Const => {}
             ty::AssocKind::Fn => {
-                let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind else { bug!() };
-                match *m {
-                    hir::TraitFn::Required(ref names) => {
-                        record_array!(self.tables.fn_arg_names[def_id] <- *names)
-                    }
-                    hir::TraitFn::Provided(body) => {
-                        record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body))
-                    }
-                };
-                self.tables.asyncness.set(def_id.index, m_sig.header.asyncness);
+                record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id));
+                self.tables.asyncness.set(def_id.index, tcx.asyncness(def_id));
                 self.tables.constness.set(def_id.index, hir::Constness::NotConst);
             }
             ty::AssocKind::Type => {