Skip to content

Commit 85f512b

Browse files
committed
Add impl for separate_provide_extern
1 parent fce5588 commit 85f512b

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ provide! { tcx, def_id, other, cdata,
402402
tcx.arena.alloc_from_iter(cdata.get_doc_link_traits_in_scope(def_id.index))
403403
}
404404
anon_const_kind => { table }
405+
const_of_item => { table }
405406
}
406407

407408
pub(in crate::rmeta) fn provide(providers: &mut Providers) {

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,19 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16021602
if let DefKind::AnonConst = def_kind {
16031603
record!(self.tables.anon_const_kind[def_id] <- self.tcx.anon_const_kind(def_id));
16041604
}
1605+
if let DefKind::Const = def_kind {
1606+
record!(self.tables.const_of_item[def_id] <- self.tcx.const_of_item(def_id));
1607+
}
1608+
if let DefKind::AssocConst = def_kind {
1609+
let assoc_item = tcx.associated_item(def_id);
1610+
let should_encode = match assoc_item.container {
1611+
ty::AssocContainer::InherentImpl | ty::AssocContainer::TraitImpl(_) => true,
1612+
ty::AssocContainer::Trait => assoc_item.defaultness(tcx).has_value(),
1613+
};
1614+
if should_encode {
1615+
record!(self.tables.const_of_item[def_id] <- self.tcx.const_of_item(def_id));
1616+
}
1617+
}
16051618
if tcx.impl_method_has_trait_impl_trait_tys(def_id)
16061619
&& let Ok(table) = self.tcx.collect_return_position_impl_trait_in_trait_tys(def_id)
16071620
{

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ define_tables! {
468468
assumed_wf_types_for_rpitit: Table<DefIndex, LazyArray<(Ty<'static>, Span)>>,
469469
opaque_ty_origin: Table<DefIndex, LazyValue<hir::OpaqueTyOrigin<DefId>>>,
470470
anon_const_kind: Table<DefIndex, LazyValue<ty::AnonConstKind>>,
471+
const_of_item: Table<DefIndex, LazyValue<ty::EarlyBinder<'static, ty::Const<'static>>>>,
471472
associated_types_for_impl_traits_in_trait_or_impl: Table<DefIndex, LazyValue<DefIdMap<Vec<DefId>>>>,
472473
}
473474

compiler/rustc_parse/src/parser/item.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,8 @@ impl<'a> Parser<'a> {
10131013
define_opaque,
10141014
}) => {
10151015
self.dcx().emit_err(errors::AssociatedStaticItemNotAllowed { span });
1016-
let body = expr.map(|e| Box::new(AnonConst { id: DUMMY_NODE_ID, value: e }));
1016+
let body =
1017+
expr.map(|e| Box::new(AnonConst { id: DUMMY_NODE_ID, value: e }));
10171018
AssocItemKind::Const(Box::new(ConstItem {
10181019
defaultness: Defaultness::Final,
10191020
ident,
@@ -1483,7 +1484,8 @@ impl<'a> Parser<'a> {
14831484
let before_where_clause =
14841485
if self.may_recover() { self.parse_where_clause()? } else { WhereClause::default() };
14851486

1486-
let body = if self.eat(exp!(Eq)) { Some(Box::new(self.parse_expr_anon_const()?)) } else { None };
1487+
let body =
1488+
if self.eat(exp!(Eq)) { Some(Box::new(self.parse_expr_anon_const()?)) } else { None };
14871489

14881490
let after_where_clause = self.parse_where_clause()?;
14891491

0 commit comments

Comments
 (0)