11warning: function pointers are not nullable, so checking them for null will always return false
2- --> $DIR/fn_null_check.rs:6 :8
2+ --> $DIR/fn_null_check.rs:7 :8
33 |
44LL | if (fn_ptr as *mut ()).is_null() {}
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,60 +8,124 @@ LL | if (fn_ptr as *mut ()).is_null() {}
88 = note: `#[warn(incorrect_fn_null_checks)]` on by default
99
1010warning: function pointers are not nullable, so checking them for null will always return false
11- --> $DIR/fn_null_check.rs:8 :8
11+ --> $DIR/fn_null_check.rs:9 :8
1212 |
1313LL | if (fn_ptr as *const u8).is_null() {}
1414 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515 |
1616 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
1717
1818warning: function pointers are not nullable, so checking them for null will always return false
19- --> $DIR/fn_null_check.rs:10 :8
19+ --> $DIR/fn_null_check.rs:11 :8
2020 |
2121LL | if (fn_ptr as *const ()) == std::ptr::null() {}
2222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323 |
2424 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
2525
2626warning: function pointers are not nullable, so checking them for null will always return false
27- --> $DIR/fn_null_check.rs:12 :8
27+ --> $DIR/fn_null_check.rs:13 :8
2828 |
2929LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
3030 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3131 |
3232 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
3333
3434warning: function pointers are not nullable, so checking them for null will always return false
35- --> $DIR/fn_null_check.rs:14 :8
35+ --> $DIR/fn_null_check.rs:15 :8
3636 |
3737LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
3838 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939 |
4040 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
4141
4242warning: function pointers are not nullable, so checking them for null will always return false
43- --> $DIR/fn_null_check.rs:16 :8
43+ --> $DIR/fn_null_check.rs:17 :8
4444 |
4545LL | if <*const _>::is_null(fn_ptr as *const ()) {}
4646 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747 |
4848 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
4949
5050warning: function pointers are not nullable, so checking them for null will always return false
51- --> $DIR/fn_null_check.rs:18 :8
51+ --> $DIR/fn_null_check.rs:19 :8
5252 |
5353LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
5454 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5555 |
5656 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
5757
5858warning: function pointers are not nullable, so checking them for null will always return false
59- --> $DIR/fn_null_check.rs:20 :8
59+ --> $DIR/fn_null_check.rs:21 :8
6060 |
6161LL | if (fn_ptr as fn() as *const ()).is_null() {}
6262 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6363 |
6464 = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
6565
66- warning: 8 warnings emitted
66+ warning: references are not nullable, so checking them for null will always return false
67+ --> $DIR/fn_null_check.rs:25:8
68+ |
69+ LL | if (&mut 8 as *mut i32).is_null() {}
70+ | ^------^^^^^^^^^^^^^^^^^^^^^^^
71+ | |
72+ | expression has type `&mut i32`
73+
74+ warning: references are not nullable, so checking them for null will always return false
75+ --> $DIR/fn_null_check.rs:27:8
76+ |
77+ LL | if (&8 as *const i32).is_null() {}
78+ | ^--^^^^^^^^^^^^^^^^^^^^^^^^^
79+ | |
80+ | expression has type `&i32`
81+
82+ warning: references are not nullable, so checking them for null will always return false
83+ --> $DIR/fn_null_check.rs:29:8
84+ |
85+ LL | if (&8 as *const i32) == std::ptr::null() {}
86+ | ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87+ | |
88+ | expression has type `&i32`
89+
90+ warning: references are not nullable, so checking them for null will always return false
91+ --> $DIR/fn_null_check.rs:32:8
92+ |
93+ LL | if (ref_num as *const i32) == std::ptr::null() {}
94+ | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95+ | |
96+ | expression has type `&i32`
97+
98+ warning: references are not nullable, so checking them for null will always return false
99+ --> $DIR/fn_null_check.rs:34:8
100+ |
101+ LL | if (b"\0" as *const u8).is_null() {}
102+ | ^-----^^^^^^^^^^^^^^^^^^^^^^^^
103+ | |
104+ | expression has type `&[u8; 1]`
105+
106+ warning: references are not nullable, so checking them for null will always return false
107+ --> $DIR/fn_null_check.rs:36:8
108+ |
109+ LL | if ("aa" as *const str).is_null() {}
110+ | ^----^^^^^^^^^^^^^^^^^^^^^^^^^
111+ | |
112+ | expression has type `&str`
113+
114+ warning: references are not nullable, so checking them for null will always return false
115+ --> $DIR/fn_null_check.rs:38:8
116+ |
117+ LL | if (&[1, 2] as *const i32).is_null() {}
118+ | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
119+ | |
120+ | expression has type `&[i32; 2]`
121+
122+ warning: references are not nullable, so checking them for null will always return false
123+ --> $DIR/fn_null_check.rs:40:8
124+ |
125+ LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
126+ | ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127+ | |
128+ | expression has type `&mut [i32; 2]`
129+
130+ warning: 16 warnings emitted
67131
0 commit comments