stabilize extern_crate_self
This commit is contained in:
parent
aea9f0aa97
commit
09d073a4c5
@ -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);
|
||||
|
@ -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
|
||||
|
@ -1,3 +0,0 @@
|
||||
extern crate self as foo; //~ ERROR `extern crate self` is unstable
|
||||
|
||||
fn main() {}
|
@ -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`.
|
@ -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`
|
@ -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`
|
||||
| ^^^^^^^^^^^^
|
@ -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);
|
||||
}
|
@ -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() {}
|
@ -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);
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
// compile-pass
|
||||
|
||||
#![feature(extern_crate_self)]
|
||||
|
||||
extern crate self as foo;
|
||||
|
||||
struct S;
|
Loading…
x
Reference in New Issue
Block a user