]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/transmute_undefined_repr.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / transmute_undefined_repr.txt
1 ### What it does
2 Checks for transmutes between types which do not have a representation defined relative to
3 each other.
4
5 ### Why is this bad?
6 The results of such a transmute are not defined.
7
8 ### Known problems
9 This lint has had multiple problems in the past and was moved to `nursery`. See issue
10 [#8496](https://github.com/rust-lang/rust-clippy/issues/8496) for more details.
11
12 ### Example
13 ```
14 struct Foo<T>(u32, T);
15 let _ = unsafe { core::mem::transmute::<Foo<u32>, Foo<i32>>(Foo(0u32, 0u32)) };
16 ```
17 Use instead:
18 ```
19 #[repr(C)]
20 struct Foo<T>(u32, T);
21 let _ = unsafe { core::mem::transmute::<Foo<u32>, Foo<i32>>(Foo(0u32, 0u32)) };
22 ```