Skip to content

Commit 98567b5

Browse files
committed
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
1 parent 62956b5 commit 98567b5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/librustc_resolve/macros.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
953953
// but its `Def` should coincide with a crate passed with `--extern`
954954
// (otherwise there would be ambiguity) and we can skip feature error in this case.
955955
'ok: {
956-
if !is_import || self.session.features_untracked().uniform_paths {
956+
if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) {
957957
break 'ok;
958958
}
959959
if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() {
@@ -969,10 +969,15 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
969969
}
970970
}
971971

972-
let msg = "imports can only refer to extern crate names \
973-
passed with `--extern` on stable channel";
972+
let reason = if rust_2015 {
973+
"in macros originating from 2015 edition"
974+
} else {
975+
"on stable channel"
976+
};
977+
let msg = format!("imports can only refer to extern crate names \
978+
passed with `--extern` {}", reason);
974979
let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
975-
ident.span, GateIssue::Language, msg);
980+
ident.span, GateIssue::Language, &msg);
976981

977982
let what = self.binding_description(binding, ident,
978983
flags.contains(Flags::MISC_FROM_PRELUDE));

src/test/ui/editions/edition-imports-virtual-2015-gated.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)
1+
error[E0658]: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition (see issue #53130)
22
--> <::edition_imports_2015::gen_gated macros>:1:50
33
|
44
LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } }

0 commit comments

Comments
 (0)