Skip to content

Commit e1d1487

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 099b3d8 commit e1d1487

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
@@ -828,7 +828,7 @@ impl<'a> Resolver<'a> {
828828
// but its `Def` should coincide with a crate passed with `--extern`
829829
// (otherwise there would be ambiguity) and we can skip feature error in this case.
830830
'ok: {
831-
if !is_import || self.session.features_untracked().uniform_paths {
831+
if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) {
832832
break 'ok;
833833
}
834834
if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() {
@@ -844,10 +844,15 @@ impl<'a> Resolver<'a> {
844844
}
845845
}
846846

847-
let msg = "imports can only refer to extern crate names \
848-
passed with `--extern` on stable channel";
847+
let reason = if rust_2015 {
848+
"in macros originating from 2015 edition"
849+
} else {
850+
"on stable channel"
851+
};
852+
let msg = format!("imports can only refer to extern crate names \
853+
passed with `--extern` {}", reason);
849854
let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
850-
ident.span, GateIssue::Language, msg);
855+
ident.span, GateIssue::Language, &msg);
851856

852857
let what = self.binding_description(binding, ident,
853858
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)