-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10023 - Jarcho:issue_10017, r=xFrednet
Fix `zero_ptr` suggestion for `no_std` crates fixes #10017 --- changelog: [`zero_ptr`]: Now suggests `core::` paths for `no_std` crates [#10023](#10023)
- Loading branch information
Showing
5 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
|
||
#![feature(lang_items, start, libc)] | ||
#![no_std] | ||
#![deny(clippy::zero_ptr)] | ||
|
||
#[start] | ||
fn main(_argc: isize, _argv: *const *const u8) -> isize { | ||
let _ = core::ptr::null::<usize>(); | ||
let _ = core::ptr::null_mut::<f64>(); | ||
let _: *const u8 = core::ptr::null(); | ||
0 | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} | ||
|
||
#[lang = "eh_personality"] | ||
extern "C" fn eh_personality() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
|
||
#![feature(lang_items, start, libc)] | ||
#![no_std] | ||
#![deny(clippy::zero_ptr)] | ||
|
||
#[start] | ||
fn main(_argc: isize, _argv: *const *const u8) -> isize { | ||
let _ = 0 as *const usize; | ||
let _ = 0 as *mut f64; | ||
let _: *const u8 = 0 as *const _; | ||
0 | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} | ||
|
||
#[lang = "eh_personality"] | ||
extern "C" fn eh_personality() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: `0 as *const _` detected | ||
--> $DIR/zero_ptr_no_std.rs:9:13 | ||
| | ||
LL | let _ = 0 as *const usize; | ||
| ^^^^^^^^^^^^^^^^^ help: try: `core::ptr::null::<usize>()` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/zero_ptr_no_std.rs:5:9 | ||
| | ||
LL | #![deny(clippy::zero_ptr)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `0 as *mut _` detected | ||
--> $DIR/zero_ptr_no_std.rs:10:13 | ||
| | ||
LL | let _ = 0 as *mut f64; | ||
| ^^^^^^^^^^^^^ help: try: `core::ptr::null_mut::<f64>()` | ||
|
||
error: `0 as *const _` detected | ||
--> $DIR/zero_ptr_no_std.rs:11:24 | ||
| | ||
LL | let _: *const u8 = 0 as *const _; | ||
| ^^^^^^^^^^^^^ help: try: `core::ptr::null()` | ||
|
||
error: aborting due to 3 previous errors | ||
|