Skip to content

Commit dcf736d

Browse files
committed
tests: use alloc instead of libc in unnecessary-extern-crate, to make it work on wasm.
1 parent f385589 commit dcf736d

File tree

2 files changed

+29
-33
lines changed

2 files changed

+29
-33
lines changed

src/test/ui/unnecessary-extern-crate.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#![deny(unused_extern_crates)]
1414
#![feature(alloc, test, libc, crate_visibility_modifier)]
1515

16-
extern crate alloc;
16+
extern crate libc;
1717
//~^ ERROR unused extern crate
1818
//~| HELP remove
19-
extern crate alloc as x;
19+
extern crate libc as x;
2020
//~^ ERROR unused extern crate
2121
//~| HELP remove
2222

@@ -27,22 +27,22 @@ extern crate test;
2727

2828
pub extern crate test as y;
2929

30-
pub extern crate libc;
30+
pub extern crate alloc;
3131

32-
pub(crate) extern crate libc as a;
32+
pub(crate) extern crate alloc as a;
3333

34-
crate extern crate libc as b;
34+
crate extern crate alloc as b;
3535

3636
mod foo {
37-
pub(in crate::foo) extern crate libc as c;
37+
pub(in crate::foo) extern crate alloc as c;
3838

39-
pub(super) extern crate libc as d;
39+
pub(super) extern crate alloc as d;
4040

41-
extern crate alloc;
41+
extern crate libc;
4242
//~^ ERROR unused extern crate
4343
//~| HELP remove
4444

45-
extern crate alloc as x;
45+
extern crate libc as x;
4646
//~^ ERROR unused extern crate
4747
//~| HELP remove
4848

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

5353
mod bar {
54-
extern crate alloc;
54+
extern crate libc;
5555
//~^ ERROR unused extern crate
5656
//~| HELP remove
5757

58-
extern crate alloc as x;
58+
extern crate libc as x;
5959
//~^ ERROR unused extern crate
6060
//~| HELP remove
6161

62-
pub(in crate::foo::bar) extern crate libc as e;
62+
pub(in crate::foo::bar) extern crate alloc as e;
6363

6464
fn dummy() {
65-
unsafe {
66-
e::getpid();
67-
}
65+
e::string::String::new();
6866
}
6967
}
7068

7169
fn dummy() {
72-
unsafe {
73-
c::getpid();
74-
d::getpid();
75-
}
70+
c::string::String::new();
71+
d::string::String::new();
7672
}
7773
}
7874

7975

8076
fn main() {
81-
unsafe { a::getpid(); }
82-
unsafe { b::getpid(); }
77+
a::string::String::new();
78+
b::string::String::new();
8379

8480
proc_macro::TokenStream::new();
8581
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: unused extern crate
22
--> $DIR/unnecessary-extern-crate.rs:16:1
33
|
4-
LL | extern crate alloc;
5-
| ^^^^^^^^^^^^^^^^^^^ help: remove it
4+
LL | extern crate libc;
5+
| ^^^^^^^^^^^^^^^^^^ help: remove it
66
|
77
note: lint level defined here
88
--> $DIR/unnecessary-extern-crate.rs:13:9
@@ -13,32 +13,32 @@ LL | #![deny(unused_extern_crates)]
1313
error: unused extern crate
1414
--> $DIR/unnecessary-extern-crate.rs:19:1
1515
|
16-
LL | extern crate alloc as x;
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
16+
LL | extern crate libc as x;
17+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
1818

1919
error: unused extern crate
2020
--> $DIR/unnecessary-extern-crate.rs:41:5
2121
|
22-
LL | extern crate alloc;
23-
| ^^^^^^^^^^^^^^^^^^^ help: remove it
22+
LL | extern crate libc;
23+
| ^^^^^^^^^^^^^^^^^^ help: remove it
2424

2525
error: unused extern crate
2626
--> $DIR/unnecessary-extern-crate.rs:45:5
2727
|
28-
LL | extern crate alloc as x;
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
28+
LL | extern crate libc as x;
29+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
3030

3131
error: unused extern crate
3232
--> $DIR/unnecessary-extern-crate.rs:54:9
3333
|
34-
LL | extern crate alloc;
35-
| ^^^^^^^^^^^^^^^^^^^ help: remove it
34+
LL | extern crate libc;
35+
| ^^^^^^^^^^^^^^^^^^ help: remove it
3636

3737
error: unused extern crate
3838
--> $DIR/unnecessary-extern-crate.rs:58:9
3939
|
40-
LL | extern crate alloc as x;
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
40+
LL | extern crate libc as x;
41+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
4242

4343
error: aborting due to 6 previous errors
4444

0 commit comments

Comments
 (0)