Skip to content

Commit 19836b2

Browse files
committed
Stabilize uniform_paths
1 parent e412291 commit 19836b2

31 files changed

+52
-243
lines changed

src/librustc_resolve/macros.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -956,32 +956,23 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
956956
// but its `Def` should coincide with a crate passed with `--extern`
957957
// (otherwise there would be ambiguity) and we can skip feature error in this case.
958958
'ok: {
959-
if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) {
959+
if !is_import || !rust_2015 {
960960
break 'ok;
961961
}
962962
if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() {
963963
break 'ok;
964964
}
965-
if rust_2015 {
966-
let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span);
967-
let root_module = self.resolve_crate_root(root_ident);
968-
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
969-
orig_ident, ns, None, false, path_span)
970-
.is_ok() {
971-
break 'ok;
972-
}
965+
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
966+
let root_module = self.resolve_crate_root(root_ident);
967+
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
968+
orig_ident, ns, None, false, path_span)
969+
.is_ok() {
970+
break 'ok;
973971
}
974972

975-
let reason = if rust_2015 {
976-
"in macros originating from 2015 edition"
977-
} else {
978-
"on stable channel"
979-
};
980-
let msg = format!("imports can only refer to extern crate names \
981-
passed with `--extern` {}", reason);
982-
let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
983-
ident.span, GateIssue::Language, &msg);
984-
973+
let msg = "imports can only refer to extern crate names passed with \
974+
`--extern` in macros originating from 2015 edition";
975+
let mut err = self.session.struct_span_err(ident.span, msg);
985976
let what = self.binding_description(binding, ident,
986977
flags.contains(Flags::MISC_FROM_PRELUDE));
987978
let note_msg = format!("this import refers to {what}", what = what);

src/libsyntax/feature_gate.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,7 @@ declare_features! (
459459
// Support for arbitrary delimited token streams in non-macro attributes
460460
(active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None),
461461

462-
// Allows `use x::y;` to resolve through `self::x`, not just `::x`
463-
(active, uniform_paths, "1.30.0", Some(53130), None),
464-
465-
// Allows unsized rvalues at arguments and parameters
462+
// Allows unsized rvalues at arguments and parameters.
466463
(active, unsized_locals, "1.30.0", Some(48055), None),
467464

468465
// #![test_runner]
@@ -689,6 +686,8 @@ declare_features! (
689686
(accepted, self_struct_ctor, "1.32.0", Some(51994), None),
690687
// `Self` in type definitions (RFC 2300)
691688
(accepted, self_in_typedefs, "1.32.0", Some(49303), None),
689+
// Allows `use x::y;` to search `x` in the current scope.
690+
(accepted, uniform_paths, "1.32.0", Some(53130), None),
692691
);
693692

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

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// edition:2018
1212

13-
#![feature(uniform_paths)]
14-
1513
mod m { pub fn f() {} }
1614
mod n { pub fn g() {} }
1715

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// This test is similar to `basic.rs`, but nested in modules.
102

113
// run-pass
12-
#![allow(unused_imports)]
13-
#![allow(non_camel_case_types)]
14-
154
// edition:2018
165

17-
#![feature(decl_macro, uniform_paths)]
6+
#![feature(decl_macro)]
187

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

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

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
// except according to those terms.
1010

1111
// run-pass
12-
#![allow(unused_imports)]
13-
#![allow(non_camel_case_types)]
14-
1512
// edition:2018
1613

17-
#![feature(uniform_paths)]
14+
#![allow(unused_imports)]
15+
#![allow(non_camel_case_types)]
1816

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

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// This test is similar to `macros.rs`, but nested in modules.
102

113
// run-pass
12-
#![allow(non_camel_case_types)]
13-
144
// edition:2018
155

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

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

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// This test is similar to `basic.rs`, but with macros defining local items.
102

113
// run-pass
12-
#![allow(non_camel_case_types)]
13-
144
// edition:2018
155

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

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

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
// except according to those terms.
1010

1111
// run-pass
12-
1312
// edition:2018
1413

15-
#![feature(uniform_paths)]
16-
1714
pub const A: usize = 0;
1815

1916
pub mod foo {

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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,51 @@ LL | use issue_56125::last_segment::*;
1111
| ^^^^^^^^^^^^ could not find `last_segment` in `issue_56125`
1212

1313
error[E0432]: unresolved import `empty::issue_56125`
14-
--> $DIR/issue-56125.rs:21:9
14+
--> $DIR/issue-56125.rs:17:9
1515
|
1616
LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125`
1717
| ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty`
1818

1919
error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
20-
--> $DIR/issue-56125.rs:8:9
20+
--> $DIR/issue-56125.rs:6:9
2121
|
2222
LL | use issue_56125::last_segment::*;
2323
| ^^^^^^^^^^^ ambiguous name
2424
|
2525
= note: `issue_56125` could refer to an extern crate passed with `--extern`
2626
= help: use `::issue_56125` to refer to this extern crate unambiguously
2727
note: `issue_56125` could also refer to the module imported here
28-
--> $DIR/issue-56125.rs:8:9
28+
--> $DIR/issue-56125.rs:6:9
2929
|
3030
LL | use issue_56125::last_segment::*;
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232
= help: use `self::issue_56125` to refer to this module unambiguously
3333

3434
error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
35-
--> $DIR/issue-56125.rs:14:9
35+
--> $DIR/issue-56125.rs:11:9
3636
|
3737
LL | use issue_56125::non_last_segment::non_last_segment::*;
3838
| ^^^^^^^^^^^ ambiguous name
3939
|
4040
= note: `issue_56125` could refer to an extern crate passed with `--extern`
4141
= help: use `::issue_56125` to refer to this extern crate unambiguously
4242
note: `issue_56125` could also refer to the module imported here
43-
--> $DIR/issue-56125.rs:14:9
43+
--> $DIR/issue-56125.rs:11:9
4444
|
4545
LL | use issue_56125::non_last_segment::non_last_segment::*;
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747
= help: use `self::issue_56125` to refer to this module unambiguously
4848

4949
error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
50-
--> $DIR/issue-56125.rs:22:9
50+
--> $DIR/issue-56125.rs:18:9
5151
|
5252
LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
5353
| ^^^^^^^^^^^ ambiguous name
5454
|
5555
= note: `issue_56125` could refer to an extern crate passed with `--extern`
5656
= help: use `::issue_56125` to refer to this extern crate unambiguously
5757
note: `issue_56125` could also refer to the module imported here
58-
--> $DIR/issue-56125.rs:22:9
58+
--> $DIR/issue-56125.rs:17:9
5959
|
6060
LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
6161
| ^^^^^^^^^^^^^^

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// edition:2018
1212

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

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

Lines changed: 2 additions & 2 deletions
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:18: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:17: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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// edition:2018
22

3-
#![feature(uniform_paths, underscore_imports)]
3+
#![feature(underscore_imports)]
4+
#![allow(non_camel_case_types)]
45

56
mod T {
67
pub struct U;

src/test/ui/rust-2018/local-path-suggestions-2018.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// compile-flags:--extern baz
1313
// edition:2018
1414

15-
#![feature(uniform_paths)]
16-
1715
mod foo {
1816
pub type Bar = u32;
1917
}

0 commit comments

Comments
 (0)