@@ -2,7 +2,9 @@ warning: function pointers are not nullable, so checking them for null will alwa
2
2
--> $DIR/ptr_null_checks.rs:14:8
3
3
|
4
4
LL | if (fn_ptr as *mut ()).is_null() {}
5
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5
+ | ^------^^^^^^^^^^^^^^^^^^^^^^
6
+ | |
7
+ | expression has type `fn() {main}`
6
8
|
7
9
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
8
10
= note: `#[warn(useless_ptr_null_checks)]` on by default
@@ -11,79 +13,99 @@ warning: function pointers are not nullable, so checking them for null will alwa
11
13
--> $DIR/ptr_null_checks.rs:16:8
12
14
|
13
15
LL | if (fn_ptr as *const u8).is_null() {}
14
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16
+ | ^------^^^^^^^^^^^^^^^^^^^^^^^^
17
+ | |
18
+ | expression has type `fn() {main}`
15
19
|
16
20
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
17
21
18
22
warning: function pointers are not nullable, so checking them for null will always return false
19
23
--> $DIR/ptr_null_checks.rs:18:8
20
24
|
21
25
LL | if (fn_ptr as *const ()) == std::ptr::null() {}
22
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
+ | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27
+ | |
28
+ | expression has type `fn() {main}`
23
29
|
24
30
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
25
31
26
32
warning: function pointers are not nullable, so checking them for null will always return false
27
33
--> $DIR/ptr_null_checks.rs:20:8
28
34
|
29
35
LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
30
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36
+ | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37
+ | |
38
+ | expression has type `fn() {main}`
31
39
|
32
40
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
33
41
34
42
warning: function pointers are not nullable, so checking them for null will always return false
35
43
--> $DIR/ptr_null_checks.rs:22:8
36
44
|
37
45
LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
38
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46
+ | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
+ | |
48
+ | expression has type `fn() {main}`
39
49
|
40
50
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
41
51
42
52
warning: function pointers are not nullable, so checking them for null will always return false
43
53
--> $DIR/ptr_null_checks.rs:24:8
44
54
|
45
55
LL | if <*const _>::is_null(fn_ptr as *const ()) {}
46
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56
+ | ^^^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^
57
+ | |
58
+ | expression has type `fn() {main}`
47
59
|
48
60
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
49
61
50
62
warning: function pointers are not nullable, so checking them for null will always return false
51
63
--> $DIR/ptr_null_checks.rs:26:8
52
64
|
53
65
LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
54
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
+ | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67
+ | |
68
+ | expression has type `fn() {main}`
55
69
|
56
70
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
57
71
58
72
warning: function pointers are not nullable, so checking them for null will always return false
59
73
--> $DIR/ptr_null_checks.rs:28:8
60
74
|
61
75
LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {}
62
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
+ | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77
+ | |
78
+ | expression has type `fn() {main}`
63
79
|
64
80
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
65
81
66
82
warning: function pointers are not nullable, so checking them for null will always return false
67
83
--> $DIR/ptr_null_checks.rs:30:8
68
84
|
69
85
LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {}
70
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
+ | ^^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
+ | |
88
+ | expression has type `fn() {main}`
71
89
|
72
90
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
73
91
74
92
warning: function pointers are not nullable, so checking them for null will always return false
75
93
--> $DIR/ptr_null_checks.rs:32:8
76
94
|
77
95
LL | if (fn_ptr as fn() as *const ()).is_null() {}
78
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96
+ | ^--------------^^^^^^^^^^^^^^^^^^^^^^^^
97
+ | |
98
+ | expression has type `fn()`
79
99
|
80
100
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
81
101
82
102
warning: function pointers are not nullable, so checking them for null will always return false
83
103
--> $DIR/ptr_null_checks.rs:34:8
84
104
|
85
105
LL | if (c_fn as *const fn()).is_null() {}
86
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
+ | ^----^^^^^^^^^^^^^^^^^^^^^^^^^^
107
+ | |
108
+ | expression has type `extern "C" fn() {c_fn}`
87
109
|
88
110
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
89
111
0 commit comments