Skip to content

Commit a27ea1d

Browse files
committed
cleanup
1 parent 4bd1a8c commit a27ea1d

File tree

2 files changed

+13
-47
lines changed

2 files changed

+13
-47
lines changed

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 11 additions & 38 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(
@@ -44,37 +40,14 @@ pub fn inject(
4440
let cx = ExtCtxt::new(sess, ecfg, resolver, None);
4541

4642
// .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-
//
57-
// See also `is_private_dep` within `rustc_metadata`.
58-
cx.item(
59-
span,
60-
Ident::new(kw::Underscore, ident_span),
61-
thin_vec![],
62-
ast::ItemKind::ExternCrate(Some(name)),
63-
)
64-
} else */{
65-
cx.item(
66-
span,
67-
Ident::new(name, ident_span),
68-
thin_vec![cx.attr_word(sym::macro_use, span)],
69-
ast::ItemKind::ExternCrate(None),
70-
)
71-
};
72-
krate.items.insert(0, item);
73-
}
74-
75-
// The crates have been injected, the assumption is that the first one is
76-
// the one with the prelude.
77-
let name = names[0];
43+
let ident_span = if edition >= Edition2018 { span } else { call_site };
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+
krate.items.insert(0, item);
7851

7952
let root = (edition == Edition2015).then_some(kw::PathRoot);
8053

compiler/rustc_metadata/src/creader.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ use rustc_index::IndexVec;
2424
use rustc_middle::bug;
2525
use rustc_middle::ty::{TyCtxt, TyCtxtFeed};
2626
use rustc_session::config::{self, CrateType, ExternLocation};
27-
use rustc_session::cstore::{
28-
CrateDepKind, CrateSource, CrateStore, ExternCrate, ExternCrateSource,
29-
};
27+
use rustc_session::cstore::{CrateDepKind, CrateSource, ExternCrate, ExternCrateSource};
3028
use rustc_session::lint::{self, BuiltinLintDiag};
3129
use rustc_session::output::validate_crate_name;
3230
use rustc_session::search_paths::PathKind;
@@ -1042,7 +1040,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
10421040
return;
10431041
}
10441042

1045-
10461043
let res = self.maybe_resolve_crate(
10471044
sym::compiler_builtins,
10481045
CrateDepKind::Implicit,
@@ -1203,11 +1200,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
12031200
CrateDepKind::Explicit
12041201
};
12051202

1206-
let cnum =
1207-
self.resolve_crate(name, item.span, dep_kind, CrateOrigin::AstExtern {
1208-
name,
1209-
orig_name,
1210-
})?;
1203+
let cnum = self.resolve_crate(name, item.span, dep_kind, CrateOrigin::AstExtern)?;
12111204

12121205
let path_len = definitions.def_path(def_id).data.len();
12131206
self.cstore.update_extern_crate(cnum, ExternCrate {

0 commit comments

Comments
 (0)