Skip to content

Commit 79134c0

Browse files
committed
Stabilize uniform_paths
1 parent 2f3db49 commit 79134c0

32 files changed

+60
-213
lines changed

src/librustc_resolve/macros.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -831,32 +831,23 @@ impl<'a> Resolver<'a> {
831831
// but its `Def` should coincide with a crate passed with `--extern`
832832
// (otherwise there would be ambiguity) and we can skip feature error in this case.
833833
'ok: {
834-
if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) {
834+
if !is_import || !rust_2015 {
835835
break 'ok;
836836
}
837837
if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() {
838838
break 'ok;
839839
}
840-
if rust_2015 {
841-
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
842-
let root_module = self.resolve_crate_root(root_ident);
843-
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
844-
orig_ident, ns, None, false, path_span)
845-
.is_ok() {
846-
break 'ok;
847-
}
840+
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
841+
let root_module = self.resolve_crate_root(root_ident);
842+
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
843+
orig_ident, ns, None, false, path_span)
844+
.is_ok() {
845+
break 'ok;
848846
}
849847

850-
let reason = if rust_2015 {
851-
"in macros originating from 2015 edition"
852-
} else {
853-
"on stable channel"
854-
};
855-
let msg = format!("imports can only refer to extern crate names \
856-
passed with `--extern` {}", reason);
857-
let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
858-
ident.span, GateIssue::Language, &msg);
859-
848+
let msg = "imports can only refer to extern crate names passed with \
849+
`--extern` in macros originating from 2015 edition";
850+
let mut err = self.session.struct_span_err(ident.span, msg);
860851
let what = self.binding_description(binding, ident,
861852
flags.contains(Flags::MISC_FROM_PRELUDE));
862853
let note_msg = format!("this import refers to {what}", what = what);

src/libsyntax/feature_gate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,6 @@ declare_features! (
440440
// support for arbitrary delimited token streams in non-macro attributes
441441
(active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None),
442442

443-
// Allows `use x::y;` to resolve through `self::x`, not just `::x`.
444-
(active, uniform_paths, "1.30.0", Some(53130), None),
445-
446443
// Allows unsized rvalues at arguments and parameters.
447444
(active, unsized_locals, "1.30.0", Some(48055), None),
448445

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

692691
// If you change this, please modify `src/doc/unstable-book` as well. You must

src/test/run-pass/uniform-paths/auxiliary/issue-53691.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// edition:2018
22

3-
#![feature(uniform_paths)]
4-
53
mod m { pub fn f() {} }
64
mod n { pub fn g() {} }
75

src/test/run-pass/uniform-paths/basic-nested.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// run-pass
2-
#![allow(unused_imports)]
3-
#![allow(non_camel_case_types)]
1+
// This test is similar to `basic.rs`, but nested in modules.
42

3+
// run-pass
54
// edition:2018
65

7-
#![feature(decl_macro, uniform_paths)]
6+
#![feature(decl_macro)]
87

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

1111
mod foo {
1212
// Test that ambiguity errors are not emitted between `self::test` and

src/test/run-pass/uniform-paths/basic.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// run-pass
2-
#![allow(unused_imports)]
3-
#![allow(non_camel_case_types)]
4-
52
// edition:2018
63

7-
#![feature(uniform_paths)]
4+
#![allow(unused_imports)]
5+
#![allow(non_camel_case_types)]
86

97
// Test that ambiguity errors are not emitted between `self::test` and
108
// `::test`, assuming the latter (crate) is not in `extern_prelude`.

src/test/run-pass/uniform-paths/macros-nested.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
// run-pass
2-
#![allow(non_camel_case_types)]
1+
// This test is similar to `macros.rs`, but nested in modules.
32

3+
// run-pass
44
// edition:2018
55

6-
#![feature(uniform_paths)]
7-
8-
// This test is similar to `macros.rs`, but nested in modules.
6+
#![allow(non_camel_case_types)]
97

108
mod foo {
119
// Test that ambiguity errors are not emitted between `self::test` and

src/test/run-pass/uniform-paths/macros.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
// run-pass
2-
#![allow(non_camel_case_types)]
1+
// This test is similar to `basic.rs`, but with macros defining local items.
32

3+
// run-pass
44
// edition:2018
55

6-
#![feature(uniform_paths)]
7-
8-
// This test is similar to `basic.rs`, but with macros defining local items.
6+
#![allow(non_camel_case_types)]
97

108
// Test that ambiguity errors are not emitted between `self::test` and
119
// `::test`, assuming the latter (crate) is not in `extern_prelude`.

src/test/run-pass/uniform-paths/same-crate.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// run-pass
2-
32
// edition:2018
43

5-
#![feature(uniform_paths)]
6-
74
pub const A: usize = 0;
85

96
pub mod foo {

src/test/ui/editions/edition-imports-2015.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// aux-build:edition-imports-2018.rs
44
// aux-build:absolute.rs
55

6-
#![feature(uniform_paths)]
7-
86
#[macro_use]
97
extern crate edition_imports_2018;
108

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: cannot glob-import all possible crates
2-
--> $DIR/edition-imports-2015.rs:25:5
2+
--> $DIR/edition-imports-2015.rs:23:5
33
|
44
LL | gen_glob!(); //~ ERROR cannot glob-import all possible crates
55
| ^^^^^^^^^^^^

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

+1-3
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` in macros originating from 2015 edition (see issue #53130)
1+
error: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition
22
--> <::edition_imports_2015::gen_gated macros>:1:50
33
|
44
LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } }
@@ -9,7 +9,6 @@ LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } }
99
LL | gen_gated!();
1010
| ------------- not an extern crate passed with `--extern`
1111
|
12-
= help: add #![feature(uniform_paths)] to the crate attributes to enable
1312
note: this import refers to the enum defined here
1413
--> $DIR/edition-imports-virtual-2015-gated.rs:9:5
1514
|
@@ -19,4 +18,3 @@ LL | gen_gated!();
1918

2019
error: aborting due to previous error
2120

22-
For more information about this error, try `rustc --explain E0658`.

src/test/ui/feature-gates/feature-gate-uniform-paths.rs

-19
This file was deleted.

src/test/ui/feature-gates/feature-gate-uniform-paths.stderr

-50
This file was deleted.

src/test/ui/imports/issue-56125.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// compile-flags:--extern issue_56125
33
// aux-build:issue-56125.rs
44

5-
#![feature(uniform_paths)]
6-
75
mod m1 {
86
use issue_56125::last_segment::*;
97
//~^ ERROR `issue_56125` is ambiguous

src/test/ui/imports/issue-56125.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
error[E0432]: unresolved import `empty::issue_56125`
2-
--> $DIR/issue-56125.rs:19:9
2+
--> $DIR/issue-56125.rs:17:9
33
|
44
LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125`
55
| ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty`
66

77
error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
8-
--> $DIR/issue-56125.rs:8:9
8+
--> $DIR/issue-56125.rs:6:9
99
|
1010
LL | use issue_56125::last_segment::*;
1111
| ^^^^^^^^^^^ ambiguous name
1212
|
1313
= note: `issue_56125` could refer to an extern crate passed with `--extern`
1414
= help: use `::issue_56125` to refer to this extern crate unambiguously
1515
note: `issue_56125` could also refer to the module imported here
16-
--> $DIR/issue-56125.rs:8:9
16+
--> $DIR/issue-56125.rs:6:9
1717
|
1818
LL | use issue_56125::last_segment::*;
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020
= help: use `self::issue_56125` to refer to this module unambiguously
2121

2222
error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
23-
--> $DIR/issue-56125.rs:13:9
23+
--> $DIR/issue-56125.rs:11:9
2424
|
2525
LL | use issue_56125::non_last_segment::non_last_segment::*;
2626
| ^^^^^^^^^^^ ambiguous name
2727
|
2828
= note: `issue_56125` could refer to an extern crate passed with `--extern`
2929
= help: use `::issue_56125` to refer to this extern crate unambiguously
3030
note: `issue_56125` could also refer to the module imported here
31-
--> $DIR/issue-56125.rs:13:9
31+
--> $DIR/issue-56125.rs:11:9
3232
|
3333
LL | use issue_56125::non_last_segment::non_last_segment::*;
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3535
= help: use `self::issue_56125` to refer to this module unambiguously
3636

3737
error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
38-
--> $DIR/issue-56125.rs:20:9
38+
--> $DIR/issue-56125.rs:18:9
3939
|
4040
LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
4141
| ^^^^^^^^^^^ ambiguous name
4242
|
4343
= note: `issue_56125` could refer to an extern crate passed with `--extern`
4444
= help: use `::issue_56125` to refer to this extern crate unambiguously
4545
note: `issue_56125` could also refer to the module imported here
46-
--> $DIR/issue-56125.rs:20:9
46+
--> $DIR/issue-56125.rs:17:9
4747
|
4848
LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
4949
| ^^^^^^^^^^^^^^

src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// edition:2018
22

3-
#![feature(uniform_paths)]
4-
53
// Tests that arbitrary crates (other than `core`, `std` and `meta`)
64
// aren't allowed without `--extern`, even if they're in the sysroot.
75
use alloc; //~ ERROR unresolved import `alloc`

src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: cannot import a built-in macro
2-
--> $DIR/not-whitelisted.rs:8:5
2+
--> $DIR/not-whitelisted.rs:6:5
33
|
44
LL | use test; //~ ERROR cannot import a built-in macro
55
| ^^^^
66

77
error[E0432]: unresolved import `alloc`
8-
--> $DIR/not-whitelisted.rs:7:5
8+
--> $DIR/not-whitelisted.rs:5:5
99
|
1010
LL | use alloc; //~ ERROR unresolved import `alloc`
1111
| ^^^^^ no `alloc` external crate

src/test/ui/rust-2018/future-proofing-locals.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// edition:2018
22

3-
#![feature(uniform_paths)]
43
#![allow(non_camel_case_types)]
54

65
mod T {

src/test/ui/rust-2018/future-proofing-locals.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
error: imports cannot refer to type parameters
2-
--> $DIR/future-proofing-locals.rs:14:9
2+
--> $DIR/future-proofing-locals.rs:13:9
33
|
44
LL | use T as _; //~ ERROR imports cannot refer to type parameters
55
| ^
66

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)