Skip to content

Commit

Permalink
Update existing test cases.
Browse files Browse the repository at this point in the history
- Allow ClashingExternDecl for lint-dead-code-3
- Update test case for #5791
- Update test case for #1866
- Update extern-abi-from-macro test case
  • Loading branch information
jumbatm committed Jun 20, 2020
1 parent 8f07952 commit 556b7ba
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 24 deletions.
2 changes: 2 additions & 0 deletions src/test/ui/issues/issue-1866.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// build-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![warn(clashing_extern_decl)]

// pretty-expanded FIXME #23616

Expand All @@ -20,6 +21,7 @@ mod b {
use super::rust_task;
extern {
pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
//~^ WARN `rust_task_is_unwinding` redeclared with a different signature
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-1866.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
warning: `rust_task_is_unwinding` redeclared with a different signature
--> $DIR/issue-1866.rs:23:13
|
LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
| ------------------------------------------------------------ `rust_task_is_unwinding` previously declared here
...
LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
note: the lint level is defined here
--> $DIR/issue-1866.rs:4:9
|
LL | #![warn(clashing_extern_decl)]
| ^^^^^^^^^^^^^^^^^^^^
= note: expected `unsafe extern "C" fn(*const usize) -> bool`
found `unsafe extern "C" fn(*const bool) -> bool`

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/issues/issue-5791.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// run-pass
#![allow(dead_code)]
#![warn(clashing_extern_decl)]
// pretty-expanded FIXME #23616

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

Expand Down
21 changes: 21 additions & 0 deletions src/test/ui/issues/issue-5791.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
warning: `malloc2` redeclares `malloc` with a different signature
--> $DIR/issue-5791.rs:9:5
|
LL | / #[link_name = "malloc"]
LL | | fn malloc1(len: i32) -> *const u8;
| |______________________________________- `malloc` previously declared here
LL | / #[link_name = "malloc"]
LL | |
LL | | fn malloc2(len: i32, foo: i32) -> *const u8;
| |________________________________________________^ this signature doesn't match the previous declaration
|
note: the lint level is defined here
--> $DIR/issue-5791.rs:3:9
|
LL | #![warn(clashing_extern_decl)]
| ^^^^^^^^^^^^^^^^^^^^
= note: expected `unsafe extern "C" fn(i32) -> *const u8`
found `unsafe extern "C" fn(i32, i32) -> *const u8`

warning: 1 warning emitted

36 changes: 18 additions & 18 deletions src/test/ui/lint/clashing-extern-fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ note: the lint level is defined here
|
LL | #![warn(clashing_extern_decl)]
| ^^^^^^^^^^^^^^^^^^^^
= note: expected `unsafe extern "C" fn(u8)`
found `unsafe extern "C" fn(u64)`
= note: expected `unsafe extern "C" fn(u8)`
found `unsafe extern "C" fn(u64)`

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

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

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

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

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

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

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

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

warning: 9 warnings emitted

1 change: 1 addition & 0 deletions src/test/ui/lint/dead-code/lint-dead-code-3.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused_variables)]
#![allow(non_camel_case_types)]
#![allow(clashing_extern_decl)]
#![deny(dead_code)]

#![crate_type="lib"]
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/lint/dead-code/lint-dead-code-3.stderr
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
error: struct is never constructed: `Foo`
--> $DIR/lint-dead-code-3.rs:13:8
--> $DIR/lint-dead-code-3.rs:14:8
|
LL | struct Foo;
| ^^^
|
note: the lint level is defined here
--> $DIR/lint-dead-code-3.rs:3:9
--> $DIR/lint-dead-code-3.rs:4:9
|
LL | #![deny(dead_code)]
| ^^^^^^^^^

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

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

error: enum is never used: `c_void`
--> $DIR/lint-dead-code-3.rs:59:6
--> $DIR/lint-dead-code-3.rs:60:6
|
LL | enum c_void {}
| ^^^^^^

error: function is never used: `free`
--> $DIR/lint-dead-code-3.rs:61:5
--> $DIR/lint-dead-code-3.rs:62:5
|
LL | fn free(p: *const c_void);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/parser/extern-abi-from-mac-literal-frag.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clashing_extern_decl)]
// check-pass

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

0 comments on commit 556b7ba

Please sign in to comment.