diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index d4b212a15d82f..0f931d4374e59 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3277,9 +3277,8 @@ impl<'a> Resolver<'a> { let prev_name = path[0].name; if prev_name == keywords::Extern.name() || prev_name == keywords::CrateRoot.name() && - // Note: When this feature stabilizes, this should - // be gated on sess.rust_2018() - self.session.features_untracked().extern_absolute_paths { + self.session.features_untracked().extern_absolute_paths && + self.session.rust_2018() { // `::extern_crate::a::b` let crate_id = self.crate_loader.process_path_extern(name, ident.span); let crate_root = diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 17aa510b565e9..6a5a31a885fb9 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -646,7 +646,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { if module_path.len() == 1 && (module_path[0].name == keywords::CrateRoot.name() || module_path[0].name == keywords::Extern.name()) { let is_extern = module_path[0].name == keywords::Extern.name() || - self.session.features_untracked().extern_absolute_paths; + (self.session.features_untracked().extern_absolute_paths && + self.session.rust_2018()); match directive.subclass { GlobImport { .. } if is_extern => { return Some((directive.span, diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4c6d0282c2a14..5155408ba63f3 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1849,8 +1849,10 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], let mut feature_checker = FeatureChecker::default(); for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { - if f_edition <= crate_edition { - set(&mut features, DUMMY_SP); + if let Some(f_edition) = f_edition { + if f_edition <= crate_edition { + set(&mut features, DUMMY_SP); + } } } diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs index 14d5d9caa317f..fcf4714ba9695 100644 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs +++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: --edition=2018 -Zunstable-options + #![feature(extern_absolute_paths)] use xcrate::S; //~ ERROR can't find crate for `xcrate` diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs index defd103f9e457..c256c5592c269 100644 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs +++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: --edition=2018 -Zunstable-options + #![feature(extern_absolute_paths)] fn main() { diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs index be1708e2b5748..837dc617b3ad0 100644 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs +++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: --edition=2018 -Zunstable-options + #![feature(extern_absolute_paths)] use ycrate; //~ ERROR can't find crate for `ycrate` diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs index e44465750d1dd..9b7baa0016344 100644 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs +++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:xcrate.rs +// compile-flags: --edition=2018 -Zunstable-options #![feature(crate_in_paths)] #![feature(extern_absolute_paths)] diff --git a/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile b/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile index a132668ec7c8a..6a67b5862a815 100644 --- a/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile +++ b/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile @@ -1,9 +1,9 @@ -include ../tools.mk all: extern_absolute_paths.rs extern_in_paths.rs krate2 - $(RUSTC) extern_absolute_paths.rs -Zsave-analysis + $(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018 cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py - $(RUSTC) extern_in_paths.rs -Zsave-analysis + $(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018 cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py krate2: krate2.rs diff --git a/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs b/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs index 0fa125a3e503e..bbe066481a8b1 100644 --- a/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs +++ b/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:xcrate.rs +// compile-flags: --edition=2018 -Zunstable-options #![feature(extern_absolute_paths)] diff --git a/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs b/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs index 796f652d6b57b..ead462cf0d2ca 100644 --- a/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs +++ b/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs @@ -12,7 +12,7 @@ // // Regression test for #47075. -// compile-flags: --test +// compile-flags: --test --edition=2018 -Zunstable-options #![feature(extern_absolute_paths)]