Skip to content

Commit d2e7293

Browse files
committed
add allow unused_unsafe and allow dead_code
1 parent 58b8b11 commit d2e7293

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.fixed

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
// would otherwise be responsible for
55
#![warn(clippy::useless_transmute)]
66
#![warn(clippy::transmute_ptr_to_ptr)]
7+
#![allow(unused_unsafe)]
8+
#![allow(dead_code)]
79

810
use std::mem::{size_of, transmute};
911

1012
// rustc_typeck::check::cast contains documentation about when a cast `e as U` is
1113
// valid, which we quote from below.
12-
1314
fn main() {
1415
// We should see an error message for each transmute, and no error messages for
1516
// the casts, since the casts are the recommended fixes.

src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
// would otherwise be responsible for
55
#![warn(clippy::useless_transmute)]
66
#![warn(clippy::transmute_ptr_to_ptr)]
7+
#![allow(unused_unsafe)]
8+
#![allow(dead_code)]
79

810
use std::mem::{size_of, transmute};
911

1012
// rustc_typeck::check::cast contains documentation about when a cast `e as U` is
1113
// valid, which we quote from below.
12-
1314
fn main() {
1415
// We should see an error message for each transmute, and no error messages for
1516
// the casts, since the casts are the recommended fixes.

src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
error: transmute from an integer to a pointer
2-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:19:9
2+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:20:9
33
|
44
LL | transmute::<usize, *const i32>(usize::MAX)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32`
66
|
77
= note: `-D clippy::useless-transmute` implied by `-D warnings`
88

99
error: transmute from a pointer to a pointer
10-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:25:9
10+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:26:9
1111
|
1212
LL | transmute::<*const i32, *const i8>(ptr_i32)
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as *const i8`
1414
|
1515
= note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings`
1616

1717
error: transmute from a pointer to a pointer
18-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:33:9
18+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:34:9
1919
|
2020
LL | transmute::<*const [i32], *const [u16]>(slice_ptr)
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice_ptr as *const [u16]`
2222

2323
error: transmute from `*const i32` to `usize` which could be expressed as a pointer cast instead
24-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:41:9
24+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:42:9
2525
|
2626
LL | transmute::<*const i32, usize>(ptr_i32)
2727
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as usize`
2828
|
2929
= note: `-D clippy::transmutes-expressible-as-ptr-casts` implied by `-D warnings`
3030

3131
error: transmute from a reference to a pointer
32-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:49:9
32+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:50:9
3333
|
3434
LL | transmute::<&[i32; 4], *const [i32; 4]>(array_ref)
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array_ref as *const [i32; 4]`
3636

3737
error: transmute from `fn(usize) -> u8 {main::foo}` to `*const usize` which could be expressed as a pointer cast instead
38-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:57:9
38+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:58:9
3939
|
4040
LL | transmute::<fn(usize) -> u8, *const usize>(foo)
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as *const usize`
4242

4343
error: transmute from `fn(usize) -> u8 {main::foo}` to `usize` which could be expressed as a pointer cast instead
44-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:63:9
44+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:64:9
4545
|
4646
LL | transmute::<fn(usize) -> u8, usize>(foo)
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as usize`
4848

4949
error: transmute from a reference to a pointer
50-
--> $DIR/transmutes_expressible_as_ptr_casts.rs:76:14
50+
--> $DIR/transmutes_expressible_as_ptr_casts.rs:77:14
5151
|
5252
LL | unsafe { transmute::<&[i32; 1], *const u8>(in_param) }
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `in_param as *const [i32; 1] as *const u8`

0 commit comments

Comments
 (0)