File tree Expand file tree Collapse file tree 4 files changed +8
-6
lines changed Expand file tree Collapse file tree 4 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
#![ allow( dead_code) ]
2
2
#![ warn( clippy:: transmute_null_to_fn) ]
3
3
#![ allow( clippy:: zero_ptr, clippy:: missing_transmute_annotations) ]
4
+ #![ allow( clippy:: manual_dangling_ptr) ]
4
5
5
6
// Easy to lint because these only span one line.
6
7
fn one_liners ( ) {
@@ -14,7 +15,7 @@ fn one_liners() {
14
15
}
15
16
16
17
pub const ZPTR : * const usize = 0 as * const _ ;
17
- pub const NOT_ZPTR : * const usize = std :: ptr :: dangling ( ) ;
18
+ pub const NOT_ZPTR : * const usize = 1 as * const _ ;
18
19
19
20
fn transmute_const ( ) {
20
21
unsafe {
Original file line number Diff line number Diff line change 1
1
error: transmuting a known null pointer into a function pointer
2
- --> tests/ui/transmute_null_to_fn.rs:8 :23
2
+ --> tests/ui/transmute_null_to_fn.rs:9 :23
3
3
|
4
4
LL | let _: fn() = std::mem::transmute(0 as *const ());
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior
Original file line number Diff line number Diff line change 3
3
#![ allow( clippy:: zero_ptr) ]
4
4
#![ allow( clippy:: transmute_ptr_to_ref) ]
5
5
#![ allow( clippy:: eq_op, clippy:: missing_transmute_annotations) ]
6
+ #![ allow( clippy:: manual_dangling_ptr) ]
6
7
7
8
// Easy to lint because these only span one line.
8
9
fn one_liners ( ) {
@@ -16,7 +17,7 @@ fn one_liners() {
16
17
}
17
18
18
19
pub const ZPTR : * const usize = 0 as * const _ ;
19
- pub const NOT_ZPTR : * const usize = std :: ptr :: dangling ( ) ;
20
+ pub const NOT_ZPTR : * const usize = 1 as * const _ ;
20
21
21
22
fn transmute_const ( ) {
22
23
unsafe {
Original file line number Diff line number Diff line change 1
1
error: transmuting a known null pointer into a reference
2
- --> tests/ui/transmuting_null.rs:10 :23
2
+ --> tests/ui/transmuting_null.rs:11 :23
3
3
|
4
4
LL | let _: &u64 = std::mem::transmute(0 as *const u64);
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,13 +8,13 @@ LL | let _: &u64 = std::mem::transmute(0 as *const u64);
8
8
= help: to override `-D warnings` add `#[allow(clippy::transmuting_null)]`
9
9
10
10
error: transmuting a known null pointer into a reference
11
- --> tests/ui/transmuting_null.rs:13 :23
11
+ --> tests/ui/transmuting_null.rs:14 :23
12
12
|
13
13
LL | let _: &u64 = std::mem::transmute(std::ptr::null::<u64>());
14
14
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15
15
16
16
error: transmuting a known null pointer into a reference
17
- --> tests/ui/transmuting_null.rs:24 :23
17
+ --> tests/ui/transmuting_null.rs:25 :23
18
18
|
19
19
LL | let _: &u64 = std::mem::transmute(ZPTR);
20
20
| ^^^^^^^^^^^^^^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments