Skip to content

Commit f40a339

Browse files
Update ui tests
1 parent 45971a5 commit f40a339

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+379
-232
lines changed

tests/ui/author/issue_3849.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(dead_code)]
22
#![allow(clippy::zero_ptr)]
33
#![allow(clippy::transmute_ptr_to_ref)]
4-
#![allow(clippy::transmuting_null)]
4+
#![allow(clippy::transmuting_null, clippy::missing_transmute_annotations)]
55

66
pub const ZPTR: *const usize = 0 as *const _;
77

tests/ui/auxiliary/macro_rules.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ macro_rules! macro_with_panic {
5050
panic!()
5151
};
5252
}
53+
54+
#[macro_export]
55+
macro_rules! bad_transmute {
56+
($e:expr) => {
57+
std::mem::transmute($e)
58+
};
59+
}

tests/ui/blocks_in_conditions.fixed

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
//@aux-build:proc_macro_attr.rs
22

33
#![warn(clippy::blocks_in_conditions)]
4-
#![allow(unused, clippy::let_and_return, clippy::needless_if)]
4+
#![allow(
5+
unused,
6+
clippy::let_and_return,
7+
clippy::needless_if,
8+
clippy::missing_transmute_annotations
9+
)]
510
#![warn(clippy::nonminimal_bool)]
611

712
macro_rules! blocky {

tests/ui/blocks_in_conditions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
//@aux-build:proc_macro_attr.rs
22

33
#![warn(clippy::blocks_in_conditions)]
4-
#![allow(unused, clippy::let_and_return, clippy::needless_if)]
4+
#![allow(
5+
unused,
6+
clippy::let_and_return,
7+
clippy::needless_if,
8+
clippy::missing_transmute_annotations
9+
)]
510
#![warn(clippy::nonminimal_bool)]
611

712
macro_rules! blocky {

tests/ui/blocks_in_conditions.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
2-
--> tests/ui/blocks_in_conditions.rs:25:5
2+
--> tests/ui/blocks_in_conditions.rs:30:5
33
|
44
LL | / if {
55
LL | |
@@ -20,13 +20,13 @@ LL ~ }; if res {
2020
|
2121

2222
error: omit braces around single expression condition
23-
--> tests/ui/blocks_in_conditions.rs:37:8
23+
--> tests/ui/blocks_in_conditions.rs:42:8
2424
|
2525
LL | if { true } { 6 } else { 10 }
2626
| ^^^^^^^^ help: try: `true`
2727

2828
error: this boolean expression can be simplified
29-
--> tests/ui/blocks_in_conditions.rs:43:8
29+
--> tests/ui/blocks_in_conditions.rs:48:8
3030
|
3131
LL | if true && x == 3 { 6 } else { 10 }
3232
| ^^^^^^^^^^^^^^ help: try: `x == 3`
@@ -35,7 +35,7 @@ LL | if true && x == 3 { 6 } else { 10 }
3535
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
3636

3737
error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
38-
--> tests/ui/blocks_in_conditions.rs:70:5
38+
--> tests/ui/blocks_in_conditions.rs:75:5
3939
|
4040
LL | / match {
4141
LL | |

tests/ui/crashes/ice-1782.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(dead_code, unused_variables)]
2-
#![allow(clippy::unnecessary_cast)]
2+
#![allow(clippy::unnecessary_cast, clippy::missing_transmute_annotations)]
33

44
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
55
///

tests/ui/crashes/ice-4968.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Test for https://github.com/rust-lang/rust-clippy/issues/4968
22

33
#![warn(clippy::unsound_collection_transmute)]
4-
#![allow(clippy::transmute_undefined_repr)]
4+
#![allow(clippy::transmute_undefined_repr, clippy::missing_transmute_annotations)]
55

66
trait Trait {
77
type Assoc;

tests/ui/eager_transmute.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(rustc_attrs)]
22
#![warn(clippy::eager_transmute)]
3-
#![allow(clippy::transmute_int_to_non_zero)]
3+
#![allow(clippy::transmute_int_to_non_zero, clippy::missing_transmute_annotations)]
44

55
use std::num::NonZeroU8;
66

tests/ui/eager_transmute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(rustc_attrs)]
22
#![warn(clippy::eager_transmute)]
3-
#![allow(clippy::transmute_int_to_non_zero)]
3+
#![allow(clippy::transmute_int_to_non_zero, clippy::missing_transmute_annotations)]
44

55
use std::num::NonZeroU8;
66

tests/ui/missing_const_for_fn/could_be_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::missing_const_for_fn)]
2-
#![allow(incomplete_features, clippy::let_and_return)]
2+
#![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)]
33
#![feature(const_mut_refs)]
44
#![feature(const_trait_impl)]
55

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,62 @@
1+
//@aux-build:macro_rules.rs
2+
13
#![warn(clippy::missing_transmute_annotations)]
24

3-
macro_rules! bad_transmute {
5+
#[macro_use]
6+
extern crate macro_rules;
7+
8+
macro_rules! local_bad_transmute {
49
($e:expr) => {
510
std::mem::transmute::<[u16; 2], i32>($e)
611
};
712
}
813

14+
fn bar(x: i32) -> i32 { x }
15+
16+
unsafe fn foo1() -> i32 {
17+
std::mem::transmute::<[u16; 2], i32>([1u16, 2u16])
18+
//~^ ERROR: transmute used without annotations
19+
}
20+
21+
unsafe fn foo2() -> i32 {
22+
std::mem::transmute::<[u16; 2], i32>([1u16, 2u16])
23+
//~^ ERROR: transmute used without annotations
24+
}
25+
26+
unsafe fn foo3() -> i32 {
27+
std::mem::transmute::<[u16; 2], i32>([1u16, 2u16])
28+
//~^ ERROR: transmute used without annotations
29+
}
30+
31+
unsafe fn foo4() -> i32 {
32+
std::mem::transmute::<[u16; 2], i32>([1u16, 2u16])
33+
//~^ ERROR: transmute used without annotations
34+
}
35+
36+
unsafe fn foo5() -> i32 {
37+
let x: i32 = bar(std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]));
38+
//~^ ERROR: transmute used without annotations
39+
bar(std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]))
40+
//~^ ERROR: transmute used without annotations
41+
}
42+
43+
unsafe fn foo6() -> i32 {
44+
local_bad_transmute!([1u16, 2u16])
45+
//~^ ERROR: transmute used without annotations
46+
}
47+
48+
unsafe fn foo7() -> i32 {
49+
// Should not warn.
50+
bad_transmute!([1u16, 2u16])
51+
}
52+
953
fn main() {
1054
unsafe {
11-
let x: i32 = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
12-
//~^ ERROR: transmute used without annotations
13-
let x: i32 = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
14-
//~^ ERROR: transmute used without annotations
15-
let x = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
16-
//~^ ERROR: transmute used without annotations
17-
let x: i32 = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
18-
//~^ ERROR: transmute used without annotations
19-
let x: i32 = bad_transmute!([1u16, 2u16]);
20-
//~^ ERROR: transmute used without annotations
21-
2255
// Should not warn.
56+
std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
2357
let x = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
58+
let x: i32 = std::mem::transmute::<[u16; 2], _>([1u16, 2u16]);
59+
let x: i32 = std::mem::transmute::<_, i32>([1u16, 2u16]);
60+
let x: i32 = std::mem::transmute([1u16, 2u16]);
2461
}
2562
}
Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,64 @@
1-
#![warn(clippy::missing_transmute_annotation)]
1+
//@aux-build:macro_rules.rs
22

3-
macro_rules! bad_transmute {
3+
#![warn(clippy::missing_transmute_annotations)]
4+
5+
#[macro_use]
6+
extern crate macro_rules;
7+
8+
macro_rules! local_bad_transmute {
49
($e:expr) => {
510
std::mem::transmute($e)
611
};
712
}
813

14+
fn bar(x: i32) -> i32 {
15+
x
16+
}
17+
18+
unsafe fn foo1() -> i32 {
19+
std::mem::transmute([1u16, 2u16])
20+
//~^ ERROR: transmute used without annotations
21+
}
22+
23+
unsafe fn foo2() -> i32 {
24+
std::mem::transmute::<_, _>([1u16, 2u16])
25+
//~^ ERROR: transmute used without annotations
26+
}
27+
28+
unsafe fn foo3() -> i32 {
29+
std::mem::transmute::<_, i32>([1u16, 2u16])
30+
//~^ ERROR: transmute used without annotations
31+
}
32+
33+
unsafe fn foo4() -> i32 {
34+
std::mem::transmute::<[u16; 2], _>([1u16, 2u16])
35+
//~^ ERROR: transmute used without annotations
36+
}
37+
38+
unsafe fn foo5() -> i32 {
39+
let x: i32 = bar(std::mem::transmute::<[u16; 2], _>([1u16, 2u16]));
40+
//~^ ERROR: transmute used without annotations
41+
bar(std::mem::transmute::<[u16; 2], _>([1u16, 2u16]))
42+
//~^ ERROR: transmute used without annotations
43+
}
44+
45+
unsafe fn foo6() -> i32 {
46+
local_bad_transmute!([1u16, 2u16])
47+
//~^ ERROR: transmute used without annotations
48+
}
49+
50+
unsafe fn foo7() -> i32 {
51+
// Should not warn.
52+
bad_transmute!([1u16, 2u16])
53+
}
54+
955
fn main() {
1056
unsafe {
11-
let x: i32 = std::mem::transmute([1u16, 2u16]);
12-
//~^ ERROR: transmute used without annotations
13-
let x: i32 = std::mem::transmute::<_, _>([1u16, 2u16]);
14-
//~^ ERROR: transmute used without annotations
15-
let x = std::mem::transmute::<_, i32>([1u16, 2u16]);
16-
//~^ ERROR: transmute used without annotations
17-
let x: i32 = std::mem::transmute::<[u16; 2], _>([1u16, 2u16]);
18-
//~^ ERROR: transmute used without annotations
19-
let x: i32 = bad_transmute!([1u16, 2u16]);
20-
//~^ ERROR: transmute used without annotations
21-
2257
// Should not warn.
58+
std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
2359
let x = std::mem::transmute::<[u16; 2], i32>([1u16, 2u16]);
60+
let x: i32 = std::mem::transmute::<[u16; 2], _>([1u16, 2u16]);
61+
let x: i32 = std::mem::transmute::<_, i32>([1u16, 2u16]);
62+
let x: i32 = std::mem::transmute([1u16, 2u16]);
2463
}
2564
}
Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
11
error: transmute used without annotations
2-
--> $DIR/missing_transmute_annotations.rs:11:32
2+
--> tests/ui/missing_transmute_annotations.rs:17:15
33
|
4-
LL | let x: i32 = std::mem::transmute([1u16, 2u16]);
5-
| ^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
4+
LL | std::mem::transmute([1u16, 2u16])
5+
| ^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
66
|
7-
= note: `-D clippy::missing-transmute-annotation` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::missing_transmute_annotation)]`
7+
= note: `-D clippy::missing-transmute-annotations` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::missing_transmute_annotations)]`
99

1010
error: transmute used without annotations
11-
--> $DIR/missing_transmute_annotations.rs:13:32
11+
--> tests/ui/missing_transmute_annotations.rs:22:15
1212
|
13-
LL | let x: i32 = std::mem::transmute::<_, _>([1u16, 2u16]);
14-
| ^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
13+
LL | std::mem::transmute::<_, _>([1u16, 2u16])
14+
| ^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
1515

1616
error: transmute used without annotations
17-
--> $DIR/missing_transmute_annotations.rs:15:27
17+
--> tests/ui/missing_transmute_annotations.rs:27:15
1818
|
19-
LL | let x = std::mem::transmute::<_, i32>([1u16, 2u16]);
20-
| ^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
19+
LL | std::mem::transmute::<_, i32>([1u16, 2u16])
20+
| ^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
2121

2222
error: transmute used without annotations
23-
--> $DIR/missing_transmute_annotations.rs:17:32
23+
--> tests/ui/missing_transmute_annotations.rs:32:15
2424
|
25-
LL | let x: i32 = std::mem::transmute::<[u16; 2], _>([1u16, 2u16]);
25+
LL | std::mem::transmute::<[u16; 2], _>([1u16, 2u16])
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
27+
28+
error: transmute used without annotations
29+
--> tests/ui/missing_transmute_annotations.rs:37:32
30+
|
31+
LL | let x: i32 = bar(std::mem::transmute::<[u16; 2], _>([1u16, 2u16]));
2632
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
2733

2834
error: transmute used without annotations
29-
--> $DIR/missing_transmute_annotations.rs:5:19
35+
--> tests/ui/missing_transmute_annotations.rs:39:19
36+
|
37+
LL | bar(std::mem::transmute::<[u16; 2], _>([1u16, 2u16]))
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
39+
40+
error: transmute used without annotations
41+
--> tests/ui/missing_transmute_annotations.rs:10:19
3042
|
3143
LL | std::mem::transmute($e)
3244
| ^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u16; 2], i32>`
3345
...
34-
LL | let x: i32 = bad_transmute!([1u16, 2u16]);
35-
| ---------------------------- in this macro invocation
46+
LL | local_bad_transmute!([1u16, 2u16])
47+
| ---------------------------------- in this macro invocation
3648
|
37-
= note: this error originates in the macro `bad_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
49+
= note: this error originates in the macro `local_bad_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
3850

39-
error: aborting due to 5 previous errors
51+
error: aborting due to 7 previous errors
4052

tests/ui/ptr_cast_constness.fixed

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
//@aux-build:proc_macros.rs
22

33
#![warn(clippy::ptr_cast_constness)]
4-
#![allow(clippy::transmute_ptr_to_ref, clippy::unnecessary_cast, unused)]
4+
#![allow(
5+
clippy::transmute_ptr_to_ref,
6+
clippy::unnecessary_cast,
7+
unused,
8+
clippy::missing_transmute_annotations
9+
)]
510

611
extern crate proc_macros;
712
use proc_macros::{external, inline_macros};

tests/ui/ptr_cast_constness.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
//@aux-build:proc_macros.rs
22

33
#![warn(clippy::ptr_cast_constness)]
4-
#![allow(clippy::transmute_ptr_to_ref, clippy::unnecessary_cast, unused)]
4+
#![allow(
5+
clippy::transmute_ptr_to_ref,
6+
clippy::unnecessary_cast,
7+
unused,
8+
clippy::missing_transmute_annotations
9+
)]
510

611
extern crate proc_macros;
712
use proc_macros::{external, inline_macros};

0 commit comments

Comments
 (0)