-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add std/core to prelude if extern_prelude enabled #51181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_resolve/lib.rs
Outdated
let mut extern_prelude: FxHashSet<Name> = | ||
session.opts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect(); | ||
if !attr::contains_name(&krate.attrs, "no_std") { | ||
extern_prelude.insert(Symbol::intern("std")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds std
to the prelude for no_core
crates.
(The logic should mirror fn maybe_inject_crates_ref
in libsyntax/std_inject.rs
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, should core
be available in extern prelude by default (for not no_std
/no_core
crates)?
Also, should other stable crates from the standard distribution like proc_macro
be available?
I'd say no for a start, they can always be added later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this to share the same logic as maybe_inject_crates_ref
.
src/librustc_resolve/lib.rs
Outdated
@@ -1610,6 +1611,12 @@ impl<'a> Resolver<'a> { | |||
DefCollector::new(&mut definitions, Mark::root()) | |||
.collect_root(crate_name, session.local_crate_disambiguator()); | |||
|
|||
let mut extern_prelude: FxHashSet<Name> = | |||
session.opts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect(); | |||
for name in crates_to_inject(&krate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to add compiler_builtins
to the prelude though, like crates_to_inject
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@bors r+ |
📌 Commit c91beee has been approved by |
🔒 Merge conflict |
Rebased. |
@bors r=petrochenkov |
📌 Commit 72ab4b4 has been approved by |
⌛ Testing commit 72ab4b4 with merge 885eb94fa78b7b7ff38b64f05fff93a6681f67e5... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
1 similar comment
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry |
Add std/core to prelude if extern_prelude enabled Fixes #50605
☀️ Test successful - status-appveyor, status-travis |
Fixes #50605