Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize extern_crate_self #57407

Merged
merged 1 commit into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/test/ui/feature-gates/feature-gate-extern_crate_self.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -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`
| ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// compile-pass

#![feature(extern_crate_self)]

extern crate self as foo;

struct S;
Expand Down