Skip to content

Commit 6ed8cb6

Browse files
authored
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``
2 parents 4154e14 + 99d2290 commit 6ed8cb6

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,24 +1337,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13371337
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
13381338
let tcx = self.tcx;
13391339

1340-
let ast_item = tcx.hir().expect_trait_item(def_id.expect_local());
1341-
self.tables.impl_defaultness.set(def_id.index, ast_item.defaultness);
1340+
let impl_defaultness = tcx.impl_defaultness(def_id.expect_local());
1341+
self.tables.impl_defaultness.set(def_id.index, impl_defaultness);
13421342
let trait_item = tcx.associated_item(def_id);
13431343
self.tables.assoc_container.set(def_id.index, trait_item.container);
13441344

13451345
match trait_item.kind {
13461346
ty::AssocKind::Const => {}
13471347
ty::AssocKind::Fn => {
1348-
let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind else { bug!() };
1349-
match *m {
1350-
hir::TraitFn::Required(ref names) => {
1351-
record_array!(self.tables.fn_arg_names[def_id] <- *names)
1352-
}
1353-
hir::TraitFn::Provided(body) => {
1354-
record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body))
1355-
}
1356-
};
1357-
self.tables.asyncness.set(def_id.index, m_sig.header.asyncness);
1348+
record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id));
1349+
self.tables.asyncness.set(def_id.index, tcx.asyncness(def_id));
13581350
self.tables.constness.set(def_id.index, hir::Constness::NotConst);
13591351
}
13601352
ty::AssocKind::Type => {

0 commit comments

Comments
 (0)