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
This commit is contained in:
Vadim Petrochenkov 2018-12-09 22:58:51 +03:00
parent 099b3d86f9
commit e1d1487fc4
2 changed files with 10 additions and 5 deletions

View File

@ -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));

View File

@ -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 :: * ; } }