]> git.lizzy.rs Git - rust.git/commitdiff
resolve: Scale back hard-coded extern prelude additions
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 13 Oct 2018 18:24:50 +0000 (21:24 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 13 Oct 2018 18:35:19 +0000 (21:35 +0300)
src/librustc_resolve/lib.rs
src/test/ui/rust-2018/issue-54006.stderr

index 8cf3c0f8843a855787c116e60e986abfa7958b34..86fe584dc3a40fe937c4199474e1958402d8602c 100644 (file)
@@ -1680,13 +1680,15 @@ pub fn new(session: &'a Session,
         let mut extern_prelude: FxHashSet<Name> =
             session.opts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect();
 
-        // HACK(eddyb) this ignore the `no_{core,std}` attributes.
-        // FIXME(eddyb) warn (elsewhere) 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"));
+        if !attr::contains_name(&krate.attrs, "no_core") {
+            extern_prelude.insert(Symbol::intern("core"));
+            if !attr::contains_name(&krate.attrs, "no_std") {
+                extern_prelude.insert(Symbol::intern("std"));
+                if session.rust_2018() {
+                    extern_prelude.insert(Symbol::intern("meta"));
+                }
+            }
+        }
 
         let mut invocations = FxHashMap();
         invocations.insert(Mark::root(),
index 37bf19e61f8d84d765ee585df142245eb2e5dc8c..268a16e5d2a0f0163e01cf80efb8407443c0df21 100644 (file)
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `alloc`
   --> $DIR/issue-54006.rs:16:5
    |
 LL | use alloc::vec;
-   |     ^^^^^ Did you mean `std::alloc`?
+   |     ^^^^^ Did you mean `core::alloc`?
 
 error: cannot determine resolution for the macro `vec`
   --> $DIR/issue-54006.rs:20:18