Skip to content

Commit 35c135e

Browse files
committed
Don't inject compiler_builtins in the AST
1 parent c51af58 commit 35c135e

File tree

3 files changed

+14
-41
lines changed

3 files changed

+14
-41
lines changed

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ pub fn inject(
1919
let edition = sess.psess.edition;
2020

2121
// the first name in this list is the crate name of the crate with the prelude
22-
let names: &[Symbol] = if attr::contains_name(pre_configured_attrs, sym::no_core) {
22+
let name: Symbol = if attr::contains_name(pre_configured_attrs, sym::no_core) {
2323
return 0;
2424
} else if attr::contains_name(pre_configured_attrs, sym::no_std) {
25-
if attr::contains_name(pre_configured_attrs, sym::compiler_builtins) {
26-
&[sym::core]
27-
} else {
28-
&[sym::core, sym::compiler_builtins]
29-
}
25+
sym::core
3026
} else {
31-
&[sym::std]
27+
sym::std
3228
};
3329

3430
let expn_id = resolver.expansion_for_ast_pass(
@@ -43,37 +39,18 @@ pub fn inject(
4339
let ecfg = ExpansionConfig::default("std_lib_injection".to_string(), features);
4440
let cx = ExtCtxt::new(sess, ecfg, resolver, None);
4541

46-
// .rev() to preserve ordering above in combination with insert(0, ...)
47-
for &name in names.iter().rev() {
48-
let ident_span = if edition >= Edition2018 { span } else { call_site };
49-
let item = if name == sym::compiler_builtins {
50-
// compiler_builtins is a private implementation detail. We only
51-
// need to insert it into the crate graph for linking and should not
52-
// expose any of its public API.
53-
//
54-
// FIXME(#113634) We should inject this during post-processing like
55-
// we do for the panic runtime, profiler runtime, etc.
56-
cx.item(
57-
span,
58-
Ident::new(kw::Underscore, ident_span),
59-
thin_vec![],
60-
ast::ItemKind::ExternCrate(Some(name)),
61-
)
62-
} else {
63-
cx.item(
64-
span,
65-
Ident::new(name, ident_span),
66-
thin_vec![cx.attr_word(sym::macro_use, span)],
67-
ast::ItemKind::ExternCrate(None),
68-
)
69-
};
70-
krate.items.insert(0, item);
71-
}
42+
let ident_span = if edition >= Edition2018 { span } else { call_site };
7243

73-
// The crates have been injected, the assumption is that the first one is
74-
// the one with the prelude.
75-
let name = names[0];
44+
let item = cx.item(
45+
span,
46+
Ident::new(name, ident_span),
47+
thin_vec![cx.attr_word(sym::macro_use, span)],
48+
ast::ItemKind::ExternCrate(None),
49+
);
50+
51+
krate.items.insert(0, item);
7652

53+
// Inject the relevant crate's prelude.
7754
let root = (edition == Edition2015).then_some(kw::PathRoot);
7855

7956
let import_path = root

compiler/rustc_metadata/src/creader.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
12131213
CrateDepKind::Explicit
12141214
};
12151215

1216-
if name == sym::compiler_builtins {
1217-
info!("BUILTINS DETECTED dep_kind {dep_kind:?}");
1218-
return None;
1219-
}
1220-
12211216
let cnum = self.resolve_crate(name, item.span, dep_kind, CrateOrigin::AstExtern)?;
12221217

12231218
let path_len = definitions.def_path(def_id).data.len();

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ impl<'tcx> TyCtxt<'tcx> {
408408
inspecting def_id={:?} span={:?} of stability={:?}",
409409
def_id, span, stability
410410
);
411+
tracing::info!("stability table: {:#?}", self.stability());
411412

412413
match stability {
413414
Some(Stability {

0 commit comments

Comments
 (0)