Skip to content

Commit

Permalink
tests: use alloc instead of libc in unnecessary-extern-crate, to make…
Browse files Browse the repository at this point in the history
… it work on wasm.
  • Loading branch information
eddyb committed Nov 30, 2018
1 parent f385589 commit dcf736d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
38 changes: 17 additions & 21 deletions src/test/ui/unnecessary-extern-crate.rs
Expand Up @@ -13,10 +13,10 @@
#![deny(unused_extern_crates)]
#![feature(alloc, test, libc, crate_visibility_modifier)]

extern crate alloc;
extern crate libc;
//~^ ERROR unused extern crate
//~| HELP remove
extern crate alloc as x;
extern crate libc as x;
//~^ ERROR unused extern crate
//~| HELP remove

Expand All @@ -27,22 +27,22 @@ extern crate test;

pub extern crate test as y;

pub extern crate libc;
pub extern crate alloc;

pub(crate) extern crate libc as a;
pub(crate) extern crate alloc as a;

crate extern crate libc as b;
crate extern crate alloc as b;

mod foo {
pub(in crate::foo) extern crate libc as c;
pub(in crate::foo) extern crate alloc as c;

pub(super) extern crate libc as d;
pub(super) extern crate alloc as d;

extern crate alloc;
extern crate libc;
//~^ ERROR unused extern crate
//~| HELP remove

extern crate alloc as x;
extern crate libc as x;
//~^ ERROR unused extern crate
//~| HELP remove

Expand All @@ -51,35 +51,31 @@ mod foo {
pub extern crate test as y;

mod bar {
extern crate alloc;
extern crate libc;
//~^ ERROR unused extern crate
//~| HELP remove

extern crate alloc as x;
extern crate libc as x;
//~^ ERROR unused extern crate
//~| HELP remove

pub(in crate::foo::bar) extern crate libc as e;
pub(in crate::foo::bar) extern crate alloc as e;

fn dummy() {
unsafe {
e::getpid();
}
e::string::String::new();
}
}

fn dummy() {
unsafe {
c::getpid();
d::getpid();
}
c::string::String::new();
d::string::String::new();
}
}


fn main() {
unsafe { a::getpid(); }
unsafe { b::getpid(); }
a::string::String::new();
b::string::String::new();

proc_macro::TokenStream::new();
}
24 changes: 12 additions & 12 deletions src/test/ui/unnecessary-extern-crate.stderr
@@ -1,8 +1,8 @@
error: unused extern crate
--> $DIR/unnecessary-extern-crate.rs:16:1
|
LL | extern crate alloc;
| ^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate libc;
| ^^^^^^^^^^^^^^^^^^ help: remove it
|
note: lint level defined here
--> $DIR/unnecessary-extern-crate.rs:13:9
Expand All @@ -13,32 +13,32 @@ LL | #![deny(unused_extern_crates)]
error: unused extern crate
--> $DIR/unnecessary-extern-crate.rs:19:1
|
LL | extern crate alloc as x;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate libc as x;
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

error: unused extern crate
--> $DIR/unnecessary-extern-crate.rs:41:5
|
LL | extern crate alloc;
| ^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate libc;
| ^^^^^^^^^^^^^^^^^^ help: remove it

error: unused extern crate
--> $DIR/unnecessary-extern-crate.rs:45:5
|
LL | extern crate alloc as x;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate libc as x;
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

error: unused extern crate
--> $DIR/unnecessary-extern-crate.rs:54:9
|
LL | extern crate alloc;
| ^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate libc;
| ^^^^^^^^^^^^^^^^^^ help: remove it

error: unused extern crate
--> $DIR/unnecessary-extern-crate.rs:58:9
|
LL | extern crate alloc as x;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate libc as x;
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

error: aborting due to 6 previous errors

0 comments on commit dcf736d

Please sign in to comment.