1
1
warning: function pointers are not nullable, so checking them for null will always return false
2
- --> $DIR/ptr_null_checks.rs:7 :8
2
+ --> $DIR/ptr_null_checks.rs:10 :8
3
3
|
4
4
LL | if (fn_ptr as *mut ()).is_null() {}
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,124 +8,148 @@ LL | if (fn_ptr as *mut ()).is_null() {}
8
8
= note: `#[warn(useless_ptr_null_checks)]` on by default
9
9
10
10
warning: function pointers are not nullable, so checking them for null will always return false
11
- --> $DIR/ptr_null_checks.rs:9 :8
11
+ --> $DIR/ptr_null_checks.rs:12 :8
12
12
|
13
13
LL | if (fn_ptr as *const u8).is_null() {}
14
14
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15
15
|
16
16
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
17
17
18
18
warning: function pointers are not nullable, so checking them for null will always return false
19
- --> $DIR/ptr_null_checks.rs:11 :8
19
+ --> $DIR/ptr_null_checks.rs:14 :8
20
20
|
21
21
LL | if (fn_ptr as *const ()) == std::ptr::null() {}
22
22
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23
23
|
24
24
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
25
25
26
26
warning: function pointers are not nullable, so checking them for null will always return false
27
- --> $DIR/ptr_null_checks.rs:13 :8
27
+ --> $DIR/ptr_null_checks.rs:16 :8
28
28
|
29
29
LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
30
30
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31
31
|
32
32
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
33
33
34
34
warning: function pointers are not nullable, so checking them for null will always return false
35
- --> $DIR/ptr_null_checks.rs:15 :8
35
+ --> $DIR/ptr_null_checks.rs:18 :8
36
36
|
37
37
LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
38
38
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39
39
|
40
40
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
41
41
42
42
warning: function pointers are not nullable, so checking them for null will always return false
43
- --> $DIR/ptr_null_checks.rs:17 :8
43
+ --> $DIR/ptr_null_checks.rs:20 :8
44
44
|
45
45
LL | if <*const _>::is_null(fn_ptr as *const ()) {}
46
46
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
47
|
48
48
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
49
49
50
50
warning: function pointers are not nullable, so checking them for null will always return false
51
- --> $DIR/ptr_null_checks.rs:19 :8
51
+ --> $DIR/ptr_null_checks.rs:22 :8
52
52
|
53
53
LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
54
54
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55
55
|
56
56
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
57
57
58
58
warning: function pointers are not nullable, so checking them for null will always return false
59
- --> $DIR/ptr_null_checks.rs:21 :8
59
+ --> $DIR/ptr_null_checks.rs:24 :8
60
60
|
61
61
LL | if (fn_ptr as fn() as *const ()).is_null() {}
62
62
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
63
|
64
64
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
65
65
66
+ warning: function pointers are not nullable, so checking them for null will always return false
67
+ --> $DIR/ptr_null_checks.rs:26:8
68
+ |
69
+ LL | if (c_fn as *const fn()).is_null() {}
70
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71
+ |
72
+ = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
73
+
66
74
warning: references are not nullable, so checking them for null will always return false
67
- --> $DIR/ptr_null_checks.rs:25 :8
75
+ --> $DIR/ptr_null_checks.rs:30 :8
68
76
|
69
77
LL | if (&mut 8 as *mut i32).is_null() {}
70
78
| ^------^^^^^^^^^^^^^^^^^^^^^^^
71
79
| |
72
80
| expression has type `&mut i32`
73
81
74
82
warning: references are not nullable, so checking them for null will always return false
75
- --> $DIR/ptr_null_checks.rs:27 :8
83
+ --> $DIR/ptr_null_checks.rs:32 :8
76
84
|
77
85
LL | if (&8 as *const i32).is_null() {}
78
86
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^
79
87
| |
80
88
| expression has type `&i32`
81
89
82
90
warning: references are not nullable, so checking them for null will always return false
83
- --> $DIR/ptr_null_checks.rs:29 :8
91
+ --> $DIR/ptr_null_checks.rs:34 :8
84
92
|
85
93
LL | if (&8 as *const i32) == std::ptr::null() {}
86
94
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
95
| |
88
96
| expression has type `&i32`
89
97
90
98
warning: references are not nullable, so checking them for null will always return false
91
- --> $DIR/ptr_null_checks.rs:32 :8
99
+ --> $DIR/ptr_null_checks.rs:37 :8
92
100
|
93
101
LL | if (ref_num as *const i32) == std::ptr::null() {}
94
102
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95
103
| |
96
104
| expression has type `&i32`
97
105
98
106
warning: references are not nullable, so checking them for null will always return false
99
- --> $DIR/ptr_null_checks.rs:34 :8
107
+ --> $DIR/ptr_null_checks.rs:39 :8
100
108
|
101
109
LL | if (b"\0" as *const u8).is_null() {}
102
110
| ^-----^^^^^^^^^^^^^^^^^^^^^^^^
103
111
| |
104
112
| expression has type `&[u8; 1]`
105
113
106
114
warning: references are not nullable, so checking them for null will always return false
107
- --> $DIR/ptr_null_checks.rs:36 :8
115
+ --> $DIR/ptr_null_checks.rs:41 :8
108
116
|
109
117
LL | if ("aa" as *const str).is_null() {}
110
118
| ^----^^^^^^^^^^^^^^^^^^^^^^^^^
111
119
| |
112
120
| expression has type `&str`
113
121
114
122
warning: references are not nullable, so checking them for null will always return false
115
- --> $DIR/ptr_null_checks.rs:38 :8
123
+ --> $DIR/ptr_null_checks.rs:43 :8
116
124
|
117
125
LL | if (&[1, 2] as *const i32).is_null() {}
118
126
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
119
127
| |
120
128
| expression has type `&[i32; 2]`
121
129
122
130
warning: references are not nullable, so checking them for null will always return false
123
- --> $DIR/ptr_null_checks.rs:40 :8
131
+ --> $DIR/ptr_null_checks.rs:45 :8
124
132
|
125
133
LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
126
134
| ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
135
| |
128
136
| expression has type `&mut [i32; 2]`
129
137
130
- warning: 16 warnings emitted
138
+ warning: references are not nullable, so checking them for null will always return false
139
+ --> $DIR/ptr_null_checks.rs:47:8
140
+ |
141
+ LL | if (static_i32() as *const i32).is_null() {}
142
+ | ^------------^^^^^^^^^^^^^^^^^^^^^^^^^
143
+ | |
144
+ | expression has type `&i32`
145
+
146
+ warning: references are not nullable, so checking them for null will always return false
147
+ --> $DIR/ptr_null_checks.rs:49:8
148
+ |
149
+ LL | if (&*{ static_i32() } as *const i32).is_null() {}
150
+ | ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^
151
+ | |
152
+ | expression has type `&i32`
153
+
154
+ warning: 19 warnings emitted
131
155
0 commit comments