Skip to content

Commit

Permalink
Make extern_absolute_paths only work on the new edition
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed May 4, 2018
1 parent b1951f4 commit 9d34e8d
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// aux-build:xcrate.rs
// compile-flags: --edition=2018 -Zunstable-options

#![feature(extern_absolute_paths)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
// Regression test for #47075.

// compile-flags: --test
// compile-flags: --test --edition=2018 -Zunstable-options

#![feature(extern_absolute_paths)]

Expand Down

0 comments on commit 9d34e8d

Please sign in to comment.