diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index a452bbf0c9d54..75bfdcc2f448a 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -30,7 +30,7 @@ use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::base::Determinacy::Undetermined; use syntax::ext::hygiene::Mark; use syntax::ext::tt::macro_rules; -use syntax::feature_gate::{is_builtin_attr, emit_feature_err, GateIssue}; +use syntax::feature_gate::is_builtin_attr; use syntax::parse::token::{self, Token}; use syntax::std_inject::injected_crate_name; use syntax::symbol::keywords; @@ -349,10 +349,6 @@ impl<'a> Resolver<'a> { .emit(); return; } else if orig_name == Some(keywords::SelfLower.name()) { - if !self.session.features_untracked().extern_crate_self { - emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span, - GateIssue::Language, "`extern crate self` is unstable"); - } self.graph_root } else { let crate_id = self.crate_loader.process_extern_crate(item, &self.definitions); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ed278e834cbc7..afbc010626276 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -453,9 +453,6 @@ declare_features! ( // Adds `reason` and `expect` lint attributes. (active, lint_reasons, "1.31.0", Some(54503), None), - // `extern crate self as foo;` puts local crate root into extern prelude under name `foo`. - (active, extern_crate_self, "1.31.0", Some(56409), None), - // Allows paths to enum variants on type aliases. (active, type_alias_enum_variants, "1.31.0", Some(49683), None), @@ -685,6 +682,8 @@ declare_features! ( (accepted, uniform_paths, "1.32.0", Some(53130), None), // Allows `cfg(target_vendor = "...")`. (accepted, cfg_target_vendor, "1.33.0", Some(29718), None), + // `extern crate self as foo;` puts local crate root into extern prelude under name `foo`. + (accepted, extern_crate_self, "1.34.0", Some(56409), None), ); // If you change this, please modify `src/doc/unstable-book` as well. You must diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_self.rs b/src/test/ui/feature-gates/feature-gate-extern_crate_self.rs deleted file mode 100644 index 2161932c2f6aa..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-extern_crate_self.rs +++ /dev/null @@ -1,3 +0,0 @@ -extern crate self as foo; //~ ERROR `extern crate self` is unstable - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr b/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr deleted file mode 100644 index 530015b2cb712..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: `extern crate self` is unstable (see issue #56409) - --> $DIR/feature-gate-extern_crate_self.rs:1:1 - | -LL | extern crate self as foo; //~ ERROR `extern crate self` is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(extern_crate_self)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/imports/extern-crate-self-fail.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs similarity index 85% rename from src/test/ui/imports/extern-crate-self-fail.rs rename to src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs index eab7b7032aa07..defa0e294bd74 100644 --- a/src/test/ui/imports/extern-crate-self-fail.rs +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs @@ -1,5 +1,3 @@ -#![feature(extern_crate_self)] - extern crate self; //~ ERROR `extern crate self;` requires renaming #[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self` diff --git a/src/test/ui/imports/extern-crate-self-fail.stderr b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr similarity index 91% rename from src/test/ui/imports/extern-crate-self-fail.stderr rename to src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr index 0ca0d89eaf08e..b47d10343f689 100644 --- a/src/test/ui/imports/extern-crate-self-fail.stderr +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr @@ -1,11 +1,11 @@ error: `extern crate self;` requires renaming - --> $DIR/extern-crate-self-fail.rs:3:1 + --> $DIR/extern-crate-self-fail.rs:1:1 | LL | extern crate self; //~ ERROR `extern crate self;` requires renaming | ^^^^^^^^^^^^^^^^^^ help: try: `extern crate self as name;` error: `macro_use` is not supported on `extern crate self` - --> $DIR/extern-crate-self-fail.rs:5:1 + --> $DIR/extern-crate-self-fail.rs:3:1 | LL | #[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self` | ^^^^^^^^^^^^ diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs new file mode 100644 index 0000000000000..79683522888cb --- /dev/null +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs @@ -0,0 +1,16 @@ +// run-pass + +// Test that a macro can correctly expand the alias +// in an `extern crate self as ALIAS` item. + +fn the_answer() -> usize { 42 } + +macro_rules! alias_self { + ($alias:ident) => { extern crate self as $alias; } +} + +alias_self!(the_alias); + +fn main() { + assert_eq!(the_alias::the_answer(), 42); +} diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs new file mode 100644 index 0000000000000..9c9397999ff67 --- /dev/null +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs @@ -0,0 +1,12 @@ +// compile-pass + +// Test that `extern crate self;` is accepted +// syntactically as an item for use in a macro. + +macro_rules! accept_item { ($x:item) => {} } + +accept_item! { + extern crate self; +} + +fn main() {} diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs new file mode 100644 index 0000000000000..009a92e877645 --- /dev/null +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs @@ -0,0 +1,16 @@ +// run-pass + +// Test that a macro can correctly expand `self` in +// an `extern crate self as ALIAS` item. + +fn the_answer() -> usize { 42 } + +macro_rules! extern_something { + ($alias:ident) => { extern crate $alias as the_alias; } +} + +extern_something!(self); + +fn main() { + assert_eq!(the_alias::the_answer(), 42); +} diff --git a/src/test/ui/imports/extern-crate-self-pass.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs similarity index 79% rename from src/test/ui/imports/extern-crate-self-pass.rs rename to src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs index bf255bb6b8194..6f6343a614886 100644 --- a/src/test/ui/imports/extern-crate-self-pass.rs +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs @@ -1,7 +1,5 @@ // compile-pass -#![feature(extern_crate_self)] - extern crate self as foo; struct S;