Skip to content

Commit 9d34e8d

Browse files
committed
Make extern_absolute_paths only work on the new edition
1 parent b1951f4 commit 9d34e8d

File tree

10 files changed

+19
-9
lines changed

10 files changed

+19
-9
lines changed

src/librustc_resolve/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,9 +3277,8 @@ impl<'a> Resolver<'a> {
32773277
let prev_name = path[0].name;
32783278
if prev_name == keywords::Extern.name() ||
32793279
prev_name == keywords::CrateRoot.name() &&
3280-
// Note: When this feature stabilizes, this should
3281-
// be gated on sess.rust_2018()
3282-
self.session.features_untracked().extern_absolute_paths {
3280+
self.session.features_untracked().extern_absolute_paths &&
3281+
self.session.rust_2018() {
32833282
// `::extern_crate::a::b`
32843283
let crate_id = self.crate_loader.process_path_extern(name, ident.span);
32853284
let crate_root =

src/librustc_resolve/resolve_imports.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
646646
if module_path.len() == 1 && (module_path[0].name == keywords::CrateRoot.name() ||
647647
module_path[0].name == keywords::Extern.name()) {
648648
let is_extern = module_path[0].name == keywords::Extern.name() ||
649-
self.session.features_untracked().extern_absolute_paths;
649+
(self.session.features_untracked().extern_absolute_paths &&
650+
self.session.rust_2018());
650651
match directive.subclass {
651652
GlobImport { .. } if is_extern => {
652653
return Some((directive.span,

src/libsyntax/feature_gate.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,8 +1849,10 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
18491849
let mut feature_checker = FeatureChecker::default();
18501850

18511851
for &(.., f_edition, set) in ACTIVE_FEATURES.iter() {
1852-
if f_edition <= crate_edition {
1853-
set(&mut features, DUMMY_SP);
1852+
if let Some(f_edition) = f_edition {
1853+
if f_edition <= crate_edition {
1854+
set(&mut features, DUMMY_SP);
1855+
}
18541856
}
18551857
}
18561858

src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// compile-flags: --edition=2018 -Zunstable-options
12+
1113
#![feature(extern_absolute_paths)]
1214

1315
use xcrate::S; //~ ERROR can't find crate for `xcrate`

src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// compile-flags: --edition=2018 -Zunstable-options
12+
1113
#![feature(extern_absolute_paths)]
1214

1315
fn main() {

src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// compile-flags: --edition=2018 -Zunstable-options
12+
1113
#![feature(extern_absolute_paths)]
1214

1315
use ycrate; //~ ERROR can't find crate for `ycrate`

src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// aux-build:xcrate.rs
12+
// compile-flags: --edition=2018 -Zunstable-options
1213

1314
#![feature(crate_in_paths)]
1415
#![feature(extern_absolute_paths)]

src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-include ../tools.mk
22

33
all: extern_absolute_paths.rs extern_in_paths.rs krate2
4-
$(RUSTC) extern_absolute_paths.rs -Zsave-analysis
4+
$(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018
55
cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
6-
$(RUSTC) extern_in_paths.rs -Zsave-analysis
6+
$(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018
77
cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py
88

99
krate2: krate2.rs

src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// aux-build:xcrate.rs
12+
// compile-flags: --edition=2018 -Zunstable-options
1213

1314
#![feature(extern_absolute_paths)]
1415

src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
// Regression test for #47075.
1414

15-
// compile-flags: --test
15+
// compile-flags: --test --edition=2018 -Zunstable-options
1616

1717
#![feature(extern_absolute_paths)]
1818

0 commit comments

Comments
 (0)