Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2697,7 +2697,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,no_run
/// ```rust,compile_fail
/// # #![allow(unused)]
/// use std::ptr;
/// unsafe {
Expand All @@ -2716,7 +2716,7 @@ declare_lint! {
///
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
pub DEREF_NULLPTR,
Warn,
Deny,
"detects when an null pointer is dereferenced"
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/lint-forbid-internal-unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ macro_rules! evil {

fn main() {
println!("{}", evil!(*(0 as *const u8)));
//~^ WARNING dereferencing a null pointer
//~^ ERROR dereferencing a null pointer
}
6 changes: 3 additions & 3 deletions tests/ui/lint/lint-forbid-internal-unsafe.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ note: the lint level is defined here
LL | #![forbid(unsafe_code)]
| ^^^^^^^^^^^

warning: dereferencing a null pointer
error: dereferencing a null pointer
--> $DIR/lint-forbid-internal-unsafe.rs:15:26
|
LL | println!("{}", evil!(*(0 as *const u8)));
| ^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed
|
= note: `#[warn(deref_nullptr)]` on by default
= note: `#[deny(deref_nullptr)]` on by default

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion tests/ui/unreachable-code/unreachable-bool-read-7246.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::ptr;
pub unsafe fn g() {
return;
if *ptr::null() {}; //~ ERROR unreachable
//~| WARNING dereferencing a null pointer
//~| ERROR dereferencing a null pointer
}

pub fn main() {}
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/unreachable-code/unreachable-bool-read-7246.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ note: the lint level is defined here
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^

warning: dereferencing a null pointer
error: dereferencing a null pointer
--> $DIR/unreachable-bool-read-7246.rs:7:8
|
LL | if *ptr::null() {};
| ^^^^^^^^^^^^ this code causes undefined behavior when executed
|
= note: `#[warn(deref_nullptr)]` on by default
= note: `#[deny(deref_nullptr)]` on by default

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors

Loading