diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-09-28 22:17:59 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-09-28 22:25:08 +0300 |
| commit | e90985acdec9928da9f6d157cfeb64f0ee98bffe (patch) | |
| tree | 69b30ecabe80dd8dd71e15bff84574fd91bbdacd /src/librustc/session | |
| parent | 80e6e3e582a9eb9115900d51ae6edecf46d81f6e (diff) | |
| download | rust-e90985acdec9928da9f6d157cfeb64f0ee98bffe.tar.gz rust-e90985acdec9928da9f6d157cfeb64f0ee98bffe.zip | |
rustc_resolve: move extern_prelude from Resolver to Session.
Diffstat (limited to 'src/librustc/session')
| -rw-r--r-- | src/librustc/session/mod.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index be347253e7f..20d4ba9c632 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -38,7 +38,7 @@ use syntax::parse; use syntax::parse::ParseSess; use syntax::{ast, source_map}; use syntax::feature_gate::AttributeType; -use syntax_pos::{MultiSpan, Span}; +use syntax_pos::{MultiSpan, Span, symbol::Symbol}; use util::profiling::SelfProfiler; use rustc_target::spec::PanicStrategy; @@ -168,6 +168,10 @@ pub struct Session { /// Cap lint level specified by a driver specifically. pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>, + + /// All the crate names specified with `--extern`, and the builtin ones. + /// Starting with the Rust 2018 edition, absolute paths resolve in this set. + pub extern_prelude: FxHashSet<Symbol>, } pub struct PerfStats { @@ -1126,6 +1130,18 @@ pub fn build_session_( CguReuseTracker::new_disabled() }; + + let mut extern_prelude: FxHashSet<Symbol> = + sopts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect(); + + // HACK(eddyb) this ignores the `no_{core,std}` attributes. + // FIXME(eddyb) warn (somewhere) if core/std is used with `no_{core,std}`. + // if !attr::contains_name(&krate.attrs, "no_core") { + // if !attr::contains_name(&krate.attrs, "no_std") { + extern_prelude.insert(Symbol::intern("core")); + extern_prelude.insert(Symbol::intern("std")); + extern_prelude.insert(Symbol::intern("meta")); + let sess = Session { target: target_cfg, host, @@ -1201,6 +1217,7 @@ pub fn build_session_( has_global_allocator: Once::new(), has_panic_handler: Once::new(), driver_lint_caps: FxHashMap(), + extern_prelude, }; validate_commandline_args_with_session_available(&sess); |
