Skip to content

Commit

Permalink
Stabilize uniform_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jan 12, 2019
1 parent 2f3db49 commit 79134c0
Show file tree
Hide file tree
Showing 32 changed files with 60 additions and 213 deletions.
29 changes: 10 additions & 19 deletions src/librustc_resolve/macros.rs
Expand Up @@ -831,32 +831,23 @@ 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 || (!rust_2015 && self.session.features_untracked().uniform_paths) {
if !is_import || !rust_2015 {
break 'ok;
}
if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() {
break 'ok;
}
if rust_2015 {
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
let root_module = self.resolve_crate_root(root_ident);
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
orig_ident, ns, None, false, path_span)
.is_ok() {
break 'ok;
}
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
let root_module = self.resolve_crate_root(root_ident);
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
orig_ident, ns, None, false, path_span)
.is_ok() {
break 'ok;
}

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

let msg = "imports can only refer to extern crate names passed with \
`--extern` in macros originating from 2015 edition";
let mut err = self.session.struct_span_err(ident.span, msg);
let what = self.binding_description(binding, ident,
flags.contains(Flags::MISC_FROM_PRELUDE));
let note_msg = format!("this import refers to {what}", what = what);
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -440,9 +440,6 @@ declare_features! (
// support for arbitrary delimited token streams in non-macro attributes
(active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None),

// Allows `use x::y;` to resolve through `self::x`, not just `::x`.
(active, uniform_paths, "1.30.0", Some(53130), None),

// Allows unsized rvalues at arguments and parameters.
(active, unsized_locals, "1.30.0", Some(48055), None),

Expand Down Expand Up @@ -687,6 +684,8 @@ declare_features! (
(accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
// Top level or-patterns (`p | q`) in `if let` and `while let`.
(accepted, if_while_or_patterns, "1.33.0", Some(48215), None),
// Allows `use x::y;` to search `x` in the current scope.
(accepted, uniform_paths, "1.32.0", Some(53130), None),
);

// If you change this, please modify `src/doc/unstable-book` as well. You must
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/uniform-paths/auxiliary/issue-53691.rs
@@ -1,7 +1,5 @@
// edition:2018

#![feature(uniform_paths)]

mod m { pub fn f() {} }
mod n { pub fn g() {} }

Expand Down
10 changes: 5 additions & 5 deletions src/test/run-pass/uniform-paths/basic-nested.rs
@@ -1,12 +1,12 @@
// run-pass
#![allow(unused_imports)]
#![allow(non_camel_case_types)]
// This test is similar to `basic.rs`, but nested in modules.

// run-pass
// edition:2018

#![feature(decl_macro, uniform_paths)]
#![feature(decl_macro)]

// This test is similar to `basic.rs`, but nested in modules.
#![allow(unused_imports)]
#![allow(non_camel_case_types)]

mod foo {
// Test that ambiguity errors are not emitted between `self::test` and
Expand Down
6 changes: 2 additions & 4 deletions src/test/run-pass/uniform-paths/basic.rs
@@ -1,10 +1,8 @@
// run-pass
#![allow(unused_imports)]
#![allow(non_camel_case_types)]

// edition:2018

#![feature(uniform_paths)]
#![allow(unused_imports)]
#![allow(non_camel_case_types)]

// Test that ambiguity errors are not emitted between `self::test` and
// `::test`, assuming the latter (crate) is not in `extern_prelude`.
Expand Down
8 changes: 3 additions & 5 deletions src/test/run-pass/uniform-paths/macros-nested.rs
@@ -1,11 +1,9 @@
// run-pass
#![allow(non_camel_case_types)]
// This test is similar to `macros.rs`, but nested in modules.

// run-pass
// edition:2018

#![feature(uniform_paths)]

// This test is similar to `macros.rs`, but nested in modules.
#![allow(non_camel_case_types)]

mod foo {
// Test that ambiguity errors are not emitted between `self::test` and
Expand Down
8 changes: 3 additions & 5 deletions src/test/run-pass/uniform-paths/macros.rs
@@ -1,11 +1,9 @@
// run-pass
#![allow(non_camel_case_types)]
// This test is similar to `basic.rs`, but with macros defining local items.

// run-pass
// edition:2018

#![feature(uniform_paths)]

// This test is similar to `basic.rs`, but with macros defining local items.
#![allow(non_camel_case_types)]

// Test that ambiguity errors are not emitted between `self::test` and
// `::test`, assuming the latter (crate) is not in `extern_prelude`.
Expand Down
3 changes: 0 additions & 3 deletions src/test/run-pass/uniform-paths/same-crate.rs
@@ -1,9 +1,6 @@
// run-pass

// edition:2018

#![feature(uniform_paths)]

pub const A: usize = 0;

pub mod foo {
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/editions/edition-imports-2015.rs
Expand Up @@ -3,8 +3,6 @@
// aux-build:edition-imports-2018.rs
// aux-build:absolute.rs

#![feature(uniform_paths)]

#[macro_use]
extern crate edition_imports_2018;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/editions/edition-imports-2015.stderr
@@ -1,5 +1,5 @@
error: cannot glob-import all possible crates
--> $DIR/edition-imports-2015.rs:25:5
--> $DIR/edition-imports-2015.rs:23:5
|
LL | gen_glob!(); //~ ERROR cannot glob-import all possible crates
| ^^^^^^^^^^^^
Expand Down
@@ -1,4 +1,4 @@
error[E0658]: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition (see issue #53130)
error: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition
--> <::edition_imports_2015::gen_gated macros>:1:50
|
LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } }
Expand All @@ -9,7 +9,6 @@ LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } }
LL | gen_gated!();
| ------------- not an extern crate passed with `--extern`
|
= help: add #![feature(uniform_paths)] to the crate attributes to enable
note: this import refers to the enum defined here
--> $DIR/edition-imports-virtual-2015-gated.rs:9:5
|
Expand All @@ -19,4 +18,3 @@ LL | gen_gated!();

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
19 changes: 0 additions & 19 deletions src/test/ui/feature-gates/feature-gate-uniform-paths.rs

This file was deleted.

50 changes: 0 additions & 50 deletions src/test/ui/feature-gates/feature-gate-uniform-paths.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/ui/imports/issue-56125.rs
Expand Up @@ -2,8 +2,6 @@
// compile-flags:--extern issue_56125
// aux-build:issue-56125.rs

#![feature(uniform_paths)]

mod m1 {
use issue_56125::last_segment::*;
//~^ ERROR `issue_56125` is ambiguous
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/imports/issue-56125.stderr
@@ -1,49 +1,49 @@
error[E0432]: unresolved import `empty::issue_56125`
--> $DIR/issue-56125.rs:19:9
--> $DIR/issue-56125.rs:17:9
|
LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125`
| ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty`

error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
--> $DIR/issue-56125.rs:8:9
--> $DIR/issue-56125.rs:6:9
|
LL | use issue_56125::last_segment::*;
| ^^^^^^^^^^^ ambiguous name
|
= note: `issue_56125` could refer to an extern crate passed with `--extern`
= help: use `::issue_56125` to refer to this extern crate unambiguously
note: `issue_56125` could also refer to the module imported here
--> $DIR/issue-56125.rs:8:9
--> $DIR/issue-56125.rs:6:9
|
LL | use issue_56125::last_segment::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use `self::issue_56125` to refer to this module unambiguously

error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
--> $DIR/issue-56125.rs:13:9
--> $DIR/issue-56125.rs:11:9
|
LL | use issue_56125::non_last_segment::non_last_segment::*;
| ^^^^^^^^^^^ ambiguous name
|
= note: `issue_56125` could refer to an extern crate passed with `--extern`
= help: use `::issue_56125` to refer to this extern crate unambiguously
note: `issue_56125` could also refer to the module imported here
--> $DIR/issue-56125.rs:13:9
--> $DIR/issue-56125.rs:11:9
|
LL | use issue_56125::non_last_segment::non_last_segment::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use `self::issue_56125` to refer to this module unambiguously

error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
--> $DIR/issue-56125.rs:20:9
--> $DIR/issue-56125.rs:18:9
|
LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
| ^^^^^^^^^^^ ambiguous name
|
= note: `issue_56125` could refer to an extern crate passed with `--extern`
= help: use `::issue_56125` to refer to this extern crate unambiguously
note: `issue_56125` could also refer to the module imported here
--> $DIR/issue-56125.rs:20:9
--> $DIR/issue-56125.rs:17:9
|
LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
| ^^^^^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs
@@ -1,7 +1,5 @@
// edition:2018

#![feature(uniform_paths)]

// Tests that arbitrary crates (other than `core`, `std` and `meta`)
// aren't allowed without `--extern`, even if they're in the sysroot.
use alloc; //~ ERROR unresolved import `alloc`
Expand Down
@@ -1,11 +1,11 @@
error: cannot import a built-in macro
--> $DIR/not-whitelisted.rs:8:5
--> $DIR/not-whitelisted.rs:6:5
|
LL | use test; //~ ERROR cannot import a built-in macro
| ^^^^

error[E0432]: unresolved import `alloc`
--> $DIR/not-whitelisted.rs:7:5
--> $DIR/not-whitelisted.rs:5:5
|
LL | use alloc; //~ ERROR unresolved import `alloc`
| ^^^^^ no `alloc` external crate
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rust-2018/future-proofing-locals.rs
@@ -1,6 +1,5 @@
// edition:2018

#![feature(uniform_paths)]
#![allow(non_camel_case_types)]

mod T {
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/rust-2018/future-proofing-locals.stderr
@@ -1,47 +1,47 @@
error: imports cannot refer to type parameters
--> $DIR/future-proofing-locals.rs:14:9
--> $DIR/future-proofing-locals.rs:13:9
|
LL | use T as _; //~ ERROR imports cannot refer to type parameters
| ^

error: imports cannot refer to type parameters
--> $DIR/future-proofing-locals.rs:15:9
--> $DIR/future-proofing-locals.rs:14:9
|
LL | use T::U; //~ ERROR imports cannot refer to type parameters
| ^

error: imports cannot refer to type parameters
--> $DIR/future-proofing-locals.rs:16:9
--> $DIR/future-proofing-locals.rs:15:9
|
LL | use T::*; //~ ERROR imports cannot refer to type parameters
| ^

error: imports cannot refer to local variables
--> $DIR/future-proofing-locals.rs:26:9
--> $DIR/future-proofing-locals.rs:25:9
|
LL | use x as _; //~ ERROR imports cannot refer to local variables
| ^

error: imports cannot refer to local variables
--> $DIR/future-proofing-locals.rs:32:9
--> $DIR/future-proofing-locals.rs:31:9
|
LL | use x; //~ ERROR imports cannot refer to local variables
| ^

error: imports cannot refer to local variables
--> $DIR/future-proofing-locals.rs:38:17
--> $DIR/future-proofing-locals.rs:37:17
|
LL | use x; //~ ERROR imports cannot refer to local variables
| ^

error: imports cannot refer to type parameters
--> $DIR/future-proofing-locals.rs:46:10
--> $DIR/future-proofing-locals.rs:45:10
|
LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters
| ^

error: imports cannot refer to local variables
--> $DIR/future-proofing-locals.rs:46:18
--> $DIR/future-proofing-locals.rs:45:18
|
LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters
| ^
Expand Down

0 comments on commit 79134c0

Please sign in to comment.