about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-12-09 22:58:51 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-01-12 16:17:26 +0300
commite1d1487fc44104d59f3faa550b91d5e248d2bce1 (patch)
treee146e8708a43641ec75f0e1cddb3602bcc141dd6 /src
parent099b3d86f92166ca5974a103e6998fdbaf6a9872 (diff)
downloadrust-e1d1487fc44104d59f3faa550b91d5e248d2bce1.tar.gz
rust-e1d1487fc44104d59f3faa550b91d5e248d2bce1.zip
resolve: Prohibit use of uniform paths in macros originating from 2015 edition
...while still keeping ambiguity errors future-proofing for uniform paths.
This corner case is not going to be stabilized for 1.32 and needs some more general experiments about retrofitting 2018 import rules to 2015 edition
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/macros.rs13
-rw-r--r--src/test/ui/editions/edition-imports-virtual-2015-gated.stderr2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index 7856661741d..b2b794c6925 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -828,7 +828,7 @@ impl<'a> Resolver<'a> {
             // but its `Def` should coincide with a crate passed with `--extern`
             // (otherwise there would be ambiguity) and we can skip feature error in this case.
             'ok: {
-                if !is_import || self.session.features_untracked().uniform_paths {
+                if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) {
                     break 'ok;
                 }
                 if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() {
@@ -844,10 +844,15 @@ impl<'a> Resolver<'a> {
                     }
                 }
 
-                let msg = "imports can only refer to extern crate names \
-                           passed with `--extern` on stable channel";
+                let reason = if rust_2015 {
+                    "in macros originating from 2015 edition"
+                } else {
+                    "on stable channel"
+                };
+                let msg = format!("imports can only refer to extern crate names \
+                                   passed with `--extern` {}", reason);
                 let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
-                                          ident.span, GateIssue::Language, msg);
+                                          ident.span, GateIssue::Language, &msg);
 
                 let what = self.binding_description(binding, ident,
                                                     flags.contains(Flags::MISC_FROM_PRELUDE));
diff --git a/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr b/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr
index 7c1837e3f56..3cf967dbf70 100644
--- a/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr
+++ b/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr
@@ -1,4 +1,4 @@
-error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)
+error[E0658]: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition (see issue #53130)
   --> <::edition_imports_2015::gen_gated macros>:1:50
    |
 LL | (  ) => { fn check_gated (  ) { enum E { A } use E :: * ; } }