Rollup merge of #57407 - mehcode:stabilize-extern-crate-self, r=Centril
Stabilize extern_crate_self Fixes #56409
This commit is contained in:
commit
5e6c2f40d0
10 changed files with 49 additions and 28 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue