Skip to content

Commit c009797

Browse files
committed
Make deref_nullptr deny by default instead of warn
1 parent c871d09 commit c009797

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,7 @@ declare_lint! {
26972697
///
26982698
/// ### Example
26992699
///
2700-
/// ```rust,no_run
2700+
/// ```rust,compile_fail
27012701
/// # #![allow(unused)]
27022702
/// use std::ptr;
27032703
/// unsafe {
@@ -2716,7 +2716,7 @@ declare_lint! {
27162716
///
27172717
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
27182718
pub DEREF_NULLPTR,
2719-
Warn,
2719+
Deny,
27202720
"detects when an null pointer is dereferenced"
27212721
}
27222722

tests/ui/lint/lint-forbid-internal-unsafe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ macro_rules! evil {
1313

1414
fn main() {
1515
println!("{}", evil!(*(0 as *const u8)));
16-
//~^ WARNING dereferencing a null pointer
16+
//~^ ERROR dereferencing a null pointer
1717
}

tests/ui/lint/lint-forbid-internal-unsafe.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ note: the lint level is defined here
1010
LL | #![forbid(unsafe_code)]
1111
| ^^^^^^^^^^^
1212

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

21-
error: aborting due to 1 previous error; 1 warning emitted
21+
error: aborting due to 2 previous errors
2222

tests/ui/unreachable-code/unreachable-bool-read-7246.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ptr;
55
pub unsafe fn g() {
66
return;
77
if *ptr::null() {}; //~ ERROR unreachable
8-
//~| WARNING dereferencing a null pointer
8+
//~| ERROR dereferencing a null pointer
99
}
1010

1111
pub fn main() {}

tests/ui/unreachable-code/unreachable-bool-read-7246.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ note: the lint level is defined here
1212
LL | #![deny(unreachable_code)]
1313
| ^^^^^^^^^^^^^^^^
1414

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

23-
error: aborting due to 1 previous error; 1 warning emitted
23+
error: aborting due to 2 previous errors
2424

0 commit comments

Comments
 (0)