Skip to content

Commit 46ab2b6

Browse files
committed
more tests for mutable_adt_argument_transmute
1 parent 4ba13c1 commit 46ab2b6

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

tests/ui/mutable_adt_argument_transmute.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,15 @@ fn main() {
44
unsafe {
55
let _: Option<&mut i32> = std::mem::transmute(Some(&5i32));
66
//~^ mutable_adt_argument_transmute
7+
let _: Result<&mut i32, ()> = std::mem::transmute(Result::<&i32, ()>::Ok(&5i32));
8+
//~^ mutable_adt_argument_transmute
9+
let _: Result<Option<&mut String>, ()> =
10+
std::mem::transmute(Result::<Option<&String>, ()>::Ok(Some(&"foo".to_string())));
11+
//~^ mutable_adt_argument_transmute
12+
let _: Result<&mut f32, &usize> = std::mem::transmute(Result::<&f32, &usize>::Ok(&2f32));
13+
//~^ mutable_adt_argument_transmute
14+
let _: Result<(), &mut usize> = std::mem::transmute(Result::<(), &usize>::Ok(()));
15+
//~^ mutable_adt_argument_transmute
16+
let _: Option<&i32> = std::mem::transmute(Some(&5i32));
717
}
818
}

tests/ui/mutable_adt_argument_transmute.stderr

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,29 @@ LL | let _: Option<&mut i32> = std::mem::transmute(Some(&5i32));
77
= note: `-D clippy::mutable-adt-argument-transmute` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::mutable_adt_argument_transmute)]`
99

10-
error: aborting due to 1 previous error
10+
error: transmute of type argument &i32 to &i32
11+
--> tests/ui/mutable_adt_argument_transmute.rs:7:39
12+
|
13+
LL | let _: Result<&mut i32, ()> = std::mem::transmute(Result::<&i32, ()>::Ok(&5i32));
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+
error: transmute of type argument &std::string::String to &std::string::String
17+
--> tests/ui/mutable_adt_argument_transmute.rs:10:13
18+
|
19+
LL | std::mem::transmute(Result::<Option<&String>, ()>::Ok(Some(&"foo".to_string())));
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
22+
error: transmute of type argument &f32 to &f32
23+
--> tests/ui/mutable_adt_argument_transmute.rs:12:43
24+
|
25+
LL | let _: Result<&mut f32, &usize> = std::mem::transmute(Result::<&f32, &usize>::Ok(&2f32));
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
28+
error: transmute of type argument &usize to &usize
29+
--> tests/ui/mutable_adt_argument_transmute.rs:14:41
30+
|
31+
LL | let _: Result<(), &mut usize> = std::mem::transmute(Result::<(), &usize>::Ok(()));
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
34+
error: aborting due to 5 previous errors
1135

0 commit comments

Comments
 (0)