提交 09d073a4 编写于 作者: R Ryan Leckey

stabilize extern_crate_self

上级 aea9f0aa
......@@ -30,7 +30,7 @@
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 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_scope: ParentScop
.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 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
// 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 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
(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
......
extern crate self as foo; //~ ERROR `extern crate self` is unstable
fn main() {}
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`.
#![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`
......
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`
| ^^^^^^^^^^^^
......
// 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);
}
// 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() {}
// 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);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册