Skip to content

Commit fb142f2

Browse files
committed
adding test for mutable_adt_argument_transmute lint
1 parent 760f70e commit fb142f2

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

clippy_lints/src/transmute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ declare_clippy_lint! {
5353
///
5454
/// ```ignore
5555
/// unsafe {
56-
/// std::mem::transmute::<Option<&i32>, Option<&mut i32>>(&Some(5));
56+
/// std::mem::transmute::<Option<&i32>, Option<&mut i32>>(Some(&5));
5757
/// }
5858
/// ```
5959
#[clippy::version = "1.92.0"]
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#![warn(clippy::mutable_adt_argument_transmute)]
22

33
fn main() {
4-
// test code goes here
4+
unsafe {
5+
let _: Option<&mut i32> = std::mem::transmute(Some(&5i32));
6+
//~^ mutable_adt_argument_transmute
7+
}
58
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: transmute of type argument &i32 to &i32
2+
--> tests/ui/mutable_adt_argument_transmute.rs:5:35
3+
|
4+
LL | let _: Option<&mut i32> = std::mem::transmute(Some(&5i32));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::mutable-adt-argument-transmute` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::mutable_adt_argument_transmute)]`
9+
10+
error: aborting due to 1 previous error
11+

0 commit comments

Comments
 (0)