File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 1+ // run-rustfix
2+
3+ #![feature(lang_items, start, libc)]
4+ #![no_std]
5+ #![deny(clippy::zero_ptr)]
6+
7+ #[start]
8+ fn main(_argc: isize, _argv: *const *const u8) -> isize {
9+ let _ = core::ptr::null::<usize>();
10+ let _ = core::ptr::null_mut::<f64>();
11+ let _: *const u8 = core::ptr::null();
12+ 0
13+ }
14+
15+ #[panic_handler]
16+ fn panic(_info: &core::panic::PanicInfo) -> ! {
17+ loop {}
18+ }
19+
20+ #[lang = "eh_personality"]
21+ extern "C" fn eh_personality() {}
Original file line number Diff line number Diff line change 1+ // run-rustfix
2+
3+ #![ feature( lang_items, start, libc) ]
4+ #![ no_std]
5+ #![ deny( clippy:: zero_ptr) ]
6+
7+ #[ start]
8+ fn main ( _argc : isize , _argv : * const * const u8 ) -> isize {
9+ let _ = 0 as * const usize ;
10+ let _ = 0 as * mut f64 ;
11+ let _: * const u8 = 0 as * const _ ;
12+ 0
13+ }
14+
15+ #[ panic_handler]
16+ fn panic ( _info : & core:: panic:: PanicInfo ) -> ! {
17+ loop { }
18+ }
19+
20+ #[ lang = "eh_personality" ]
21+ extern "C" fn eh_personality ( ) { }
Original file line number Diff line number Diff line change 1+ error: `0 as *const _` detected
2+ --> $DIR/zero_ptr_no_std.rs:9:13
3+ |
4+ LL | let _ = 0 as *const usize;
5+ | ^^^^^^^^^^^^^^^^^ help: try: `core::ptr::null::<usize>()`
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/zero_ptr_no_std.rs:5:9
9+ |
10+ LL | #![deny(clippy::zero_ptr)]
11+ | ^^^^^^^^^^^^^^^^
12+
13+ error: `0 as *mut _` detected
14+ --> $DIR/zero_ptr_no_std.rs:10:13
15+ |
16+ LL | let _ = 0 as *mut f64;
17+ | ^^^^^^^^^^^^^ help: try: `core::ptr::null_mut::<f64>()`
18+
19+ error: `0 as *const _` detected
20+ --> $DIR/zero_ptr_no_std.rs:11:24
21+ |
22+ LL | let _: *const u8 = 0 as *const _;
23+ | ^^^^^^^^^^^^^ help: try: `core::ptr::null()`
24+
25+ error: aborting due to 3 previous errors
26+
You can’t perform that action at this time.
0 commit comments