Skip to content

Commit 556b7ba

Browse files
committed
Update existing test cases.
- Allow ClashingExternDecl for lint-dead-code-3 - Update test case for #5791 - Update test case for #1866 - Update extern-abi-from-macro test case
1 parent 8f07952 commit 556b7ba

8 files changed

+70
-24
lines changed

src/test/ui/issues/issue-1866.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// build-pass
22
#![allow(dead_code)]
33
#![allow(non_camel_case_types)]
4+
#![warn(clashing_extern_decl)]
45

56
// pretty-expanded FIXME #23616
67

@@ -20,6 +21,7 @@ mod b {
2021
use super::rust_task;
2122
extern {
2223
pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
24+
//~^ WARN `rust_task_is_unwinding` redeclared with a different signature
2325
}
2426
}
2527
}

src/test/ui/issues/issue-1866.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: `rust_task_is_unwinding` redeclared with a different signature
2+
--> $DIR/issue-1866.rs:23:13
3+
|
4+
LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
5+
| ------------------------------------------------------------ `rust_task_is_unwinding` previously declared here
6+
...
7+
LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
9+
|
10+
note: the lint level is defined here
11+
--> $DIR/issue-1866.rs:4:9
12+
|
13+
LL | #![warn(clashing_extern_decl)]
14+
| ^^^^^^^^^^^^^^^^^^^^
15+
= note: expected `unsafe extern "C" fn(*const usize) -> bool`
16+
found `unsafe extern "C" fn(*const bool) -> bool`
17+
18+
warning: 1 warning emitted
19+

src/test/ui/issues/issue-5791.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// run-pass
22
#![allow(dead_code)]
3+
#![warn(clashing_extern_decl)]
34
// pretty-expanded FIXME #23616
45

56
extern {
67
#[link_name = "malloc"]
78
fn malloc1(len: i32) -> *const u8;
89
#[link_name = "malloc"]
10+
//~^ WARN `malloc2` redeclares `malloc` with a different signature
911
fn malloc2(len: i32, foo: i32) -> *const u8;
1012
}
1113

src/test/ui/issues/issue-5791.stderr

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
warning: `malloc2` redeclares `malloc` with a different signature
2+
--> $DIR/issue-5791.rs:9:5
3+
|
4+
LL | / #[link_name = "malloc"]
5+
LL | | fn malloc1(len: i32) -> *const u8;
6+
| |______________________________________- `malloc` previously declared here
7+
LL | / #[link_name = "malloc"]
8+
LL | |
9+
LL | | fn malloc2(len: i32, foo: i32) -> *const u8;
10+
| |________________________________________________^ this signature doesn't match the previous declaration
11+
|
12+
note: the lint level is defined here
13+
--> $DIR/issue-5791.rs:3:9
14+
|
15+
LL | #![warn(clashing_extern_decl)]
16+
| ^^^^^^^^^^^^^^^^^^^^
17+
= note: expected `unsafe extern "C" fn(i32) -> *const u8`
18+
found `unsafe extern "C" fn(i32, i32) -> *const u8`
19+
20+
warning: 1 warning emitted
21+

src/test/ui/lint/clashing-extern-fn.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ note: the lint level is defined here
1212
|
1313
LL | #![warn(clashing_extern_decl)]
1414
| ^^^^^^^^^^^^^^^^^^^^
15-
= note: expected `unsafe extern "C" fn(u8)`
16-
found `unsafe extern "C" fn(u64)`
15+
= note: expected `unsafe extern "C" fn(u8)`
16+
found `unsafe extern "C" fn(u64)`
1717

1818
warning: `extern_fn` redeclared with a different signature
1919
--> $DIR/clashing-extern-fn.rs:39:9
@@ -24,8 +24,8 @@ LL | fn extern_fn(x: u64);
2424
LL | fn extern_fn(x: u32);
2525
| ^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
2626
|
27-
= note: expected `unsafe extern "C" fn(u64)`
28-
found `unsafe extern "C" fn(u32)`
27+
= note: expected `unsafe extern "C" fn(u64)`
28+
found `unsafe extern "C" fn(u32)`
2929

3030
warning: `extern_link_name` redeclared with a different signature
3131
--> $DIR/clashing-extern-fn.rs:64:9
@@ -37,8 +37,8 @@ LL | | fn some_new_name(x: i16);
3737
LL | fn extern_link_name(x: u32);
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
3939
|
40-
= note: expected `unsafe extern "C" fn(i16)`
41-
found `unsafe extern "C" fn(u32)`
40+
= note: expected `unsafe extern "C" fn(i16)`
41+
found `unsafe extern "C" fn(u32)`
4242

4343
warning: `some_other_extern_link_name` redeclares `some_other_new_name` with a different signature
4444
--> $DIR/clashing-extern-fn.rs:67:9
@@ -51,8 +51,8 @@ LL | |
5151
LL | | fn some_other_extern_link_name(x: u32);
5252
| |_______________________________________________^ this signature doesn't match the previous declaration
5353
|
54-
= note: expected `unsafe extern "C" fn(i16)`
55-
found `unsafe extern "C" fn(u32)`
54+
= note: expected `unsafe extern "C" fn(i16)`
55+
found `unsafe extern "C" fn(u32)`
5656

5757
warning: `other_both_names_different` redeclares `link_name_same` with a different signature
5858
--> $DIR/clashing-extern-fn.rs:71:9
@@ -66,8 +66,8 @@ LL | |
6666
LL | | fn other_both_names_different(x: u32);
6767
| |______________________________________________^ this signature doesn't match the previous declaration
6868
|
69-
= note: expected `unsafe extern "C" fn(i16)`
70-
found `unsafe extern "C" fn(u32)`
69+
= note: expected `unsafe extern "C" fn(i16)`
70+
found `unsafe extern "C" fn(u32)`
7171

7272
warning: `different_mod` redeclared with a different signature
7373
--> $DIR/clashing-extern-fn.rs:84:9
@@ -78,8 +78,8 @@ LL | fn different_mod(x: u8);
7878
LL | fn different_mod(x: u64);
7979
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
8080
|
81-
= note: expected `unsafe extern "C" fn(u8)`
82-
found `unsafe extern "C" fn(u64)`
81+
= note: expected `unsafe extern "C" fn(u8)`
82+
found `unsafe extern "C" fn(u64)`
8383

8484
warning: `variadic_decl` redeclared with a different signature
8585
--> $DIR/clashing-extern-fn.rs:94:9
@@ -90,8 +90,8 @@ LL | fn variadic_decl(x: u8, ...);
9090
LL | fn variadic_decl(x: u8);
9191
| ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
9292
|
93-
= note: expected `unsafe extern "C" fn(u8, ...)`
94-
found `unsafe extern "C" fn(u8)`
93+
= note: expected `unsafe extern "C" fn(u8, ...)`
94+
found `unsafe extern "C" fn(u8)`
9595

9696
warning: `weigh_banana` redeclared with a different signature
9797
--> $DIR/clashing-extern-fn.rs:137:22
@@ -102,8 +102,8 @@ LL | extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
102102
LL | extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
103103
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
104104
|
105-
= note: expected `unsafe extern "C" fn(*const banana::one::Banana) -> u64`
106-
found `unsafe extern "C" fn(*const banana::three::Banana) -> u64`
105+
= note: expected `unsafe extern "C" fn(*const banana::one::Banana) -> u64`
106+
found `unsafe extern "C" fn(*const banana::three::Banana) -> u64`
107107

108108
warning: `draw_point` redeclared with a different signature
109109
--> $DIR/clashing-extern-fn.rs:157:22
@@ -114,8 +114,8 @@ LL | extern "C" { fn draw_point(p: Point); }
114114
LL | extern "C" { fn draw_point(p: Point); }
115115
| ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
116116
|
117-
= note: expected `unsafe extern "C" fn(sameish_members::a::Point)`
118-
found `unsafe extern "C" fn(sameish_members::b::Point)`
117+
= note: expected `unsafe extern "C" fn(sameish_members::a::Point)`
118+
found `unsafe extern "C" fn(sameish_members::b::Point)`
119119

120120
warning: 9 warnings emitted
121121

src/test/ui/lint/dead-code/lint-dead-code-3.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![allow(unused_variables)]
22
#![allow(non_camel_case_types)]
3+
#![allow(clashing_extern_decl)]
34
#![deny(dead_code)]
45

56
#![crate_type="lib"]

src/test/ui/lint/dead-code/lint-dead-code-3.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
error: struct is never constructed: `Foo`
2-
--> $DIR/lint-dead-code-3.rs:13:8
2+
--> $DIR/lint-dead-code-3.rs:14:8
33
|
44
LL | struct Foo;
55
| ^^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/lint-dead-code-3.rs:3:9
8+
--> $DIR/lint-dead-code-3.rs:4:9
99
|
1010
LL | #![deny(dead_code)]
1111
| ^^^^^^^^^
1212

1313
error: associated function is never used: `foo`
14-
--> $DIR/lint-dead-code-3.rs:15:8
14+
--> $DIR/lint-dead-code-3.rs:16:8
1515
|
1616
LL | fn foo(&self) {
1717
| ^^^
1818

1919
error: function is never used: `bar`
20-
--> $DIR/lint-dead-code-3.rs:20:4
20+
--> $DIR/lint-dead-code-3.rs:21:4
2121
|
2222
LL | fn bar() {
2323
| ^^^
2424

2525
error: enum is never used: `c_void`
26-
--> $DIR/lint-dead-code-3.rs:59:6
26+
--> $DIR/lint-dead-code-3.rs:60:6
2727
|
2828
LL | enum c_void {}
2929
| ^^^^^^
3030

3131
error: function is never used: `free`
32-
--> $DIR/lint-dead-code-3.rs:61:5
32+
--> $DIR/lint-dead-code-3.rs:62:5
3333
|
3434
LL | fn free(p: *const c_void);
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/parser/extern-abi-from-mac-literal-frag.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clashing_extern_decl)]
12
// check-pass
23

34
// In this test we check that the parser accepts an ABI string when it

0 commit comments

Comments
 (0)