fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
932 B31 linesraw
1// run-rustfix
2
3// Suggest providing a std::ptr::null{,_mut}() to a function that takes in a raw
4// pointer if a literal 0 was provided by the user.
5
6extern "C" {
7    fn foo(ptr: *const u8);
8
9    fn foo_mut(ptr: *mut u8);
10
11    fn usize(ptr: *const usize);
12
13    fn usize_mut(ptr: *mut usize);
14}
15
16fn main() {
17    unsafe {
18        foo(std::ptr::null());
19        //~^ mismatched types [E0308]
20        //~| if you meant to create a null pointer, use `std::ptr::null()`
21        foo_mut(std::ptr::null_mut());
22        //~^ mismatched types [E0308]
23        //~| if you meant to create a null pointer, use `std::ptr::null_mut()`
24        usize(std::ptr::null());
25        //~^ mismatched types [E0308]
26        //~| if you meant to create a null pointer, use `std::ptr::null()`
27        usize_mut(std::ptr::null_mut());
28        //~^ mismatched types [E0308]
29        //~| if you meant to create a null pointer, use `std::ptr::null_mut()`
30    }
31}