about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_resolve/macros.rs3
-rw-r--r--src/librustc_resolve/resolve_imports.rs2
-rw-r--r--src/test/ui/imports/glob-shadowing.rs44
-rw-r--r--src/test/ui/imports/glob-shadowing.stderr49
4 files changed, 95 insertions, 3 deletions
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index c85115c62f8..0ad652b4710 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -588,8 +588,7 @@ impl<'a> Resolver<'a> {
                             return potential_illegal_shadower;
                         }
                     }
-                    if binding.expansion != Mark::root() ||
-                       (binding.is_glob_import() && module.unwrap().def().is_some()) {
+                    if binding.is_glob_import() || binding.expansion != Mark::root() {
                         potential_illegal_shadower = result;
                     } else {
                         return result;
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index 97b9a385287..ba663052998 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -233,7 +233,7 @@ impl<'a> Resolver<'a> {
         // What on earth is this?
         // Apparently one more subtle interaction with `resolve_lexical_macro_path_segment`
         // that are going to be removed in the next commit.
-        if restricted_shadowing && module.def().is_some() {
+        if restricted_shadowing {
             return Err(Determined);
         }
 
diff --git a/src/test/ui/imports/glob-shadowing.rs b/src/test/ui/imports/glob-shadowing.rs
new file mode 100644
index 00000000000..e4f55137e66
--- /dev/null
+++ b/src/test/ui/imports/glob-shadowing.rs
@@ -0,0 +1,44 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(decl_macro)]
+
+mod m {
+    pub macro env($e: expr) { $e }
+    pub macro fenv() { 0 }
+}
+
+mod glob_in_normal_module {
+    use m::*;
+    fn check() {
+        let x = env!("PATH"); //~ ERROR `env` is ambiguous
+    }
+}
+
+mod glob_in_block_module {
+    fn block() {
+        use m::*;
+        fn check() {
+            let x = env!("PATH"); //~ ERROR `env` is ambiguous
+        }
+    }
+}
+
+mod glob_shadows_item {
+    pub macro fenv($e: expr) { $e }
+    fn block() {
+        use m::*;
+        fn check() {
+            let x = fenv!(); //~ ERROR `fenv` is ambiguous
+        }
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/glob-shadowing.stderr b/src/test/ui/imports/glob-shadowing.stderr
new file mode 100644
index 00000000000..7f61cd6c76d
--- /dev/null
+++ b/src/test/ui/imports/glob-shadowing.stderr
@@ -0,0 +1,49 @@
+error[E0659]: `env` is ambiguous
+  --> $DIR/glob-shadowing.rs:21:17
+   |
+LL |         let x = env!("PATH"); //~ ERROR `env` is ambiguous
+   |                 ^^^
+   |
+note: `env` could refer to the name imported here
+  --> $DIR/glob-shadowing.rs:19:9
+   |
+LL |     use m::*;
+   |         ^^^^
+   = note: `env` is also a builtin macro
+   = note: consider adding an explicit import of `env` to disambiguate
+
+error[E0659]: `env` is ambiguous
+  --> $DIR/glob-shadowing.rs:29:21
+   |
+LL |             let x = env!("PATH"); //~ ERROR `env` is ambiguous
+   |                     ^^^
+   |
+note: `env` could refer to the name imported here
+  --> $DIR/glob-shadowing.rs:27:13
+   |
+LL |         use m::*;
+   |             ^^^^
+   = note: `env` is also a builtin macro
+   = note: consider adding an explicit import of `env` to disambiguate
+
+error[E0659]: `fenv` is ambiguous
+  --> $DIR/glob-shadowing.rs:39:21
+   |
+LL |             let x = fenv!(); //~ ERROR `fenv` is ambiguous
+   |                     ^^^^
+   |
+note: `fenv` could refer to the name imported here
+  --> $DIR/glob-shadowing.rs:37:13
+   |
+LL |         use m::*;
+   |             ^^^^
+note: `fenv` could also refer to the name defined here
+  --> $DIR/glob-shadowing.rs:35:5
+   |
+LL |     pub macro fenv($e: expr) { $e }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: consider adding an explicit import of `fenv` to disambiguate
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0659`.