Skip to content

Commit 8605824

Browse files
committed
Rename lint to invalid_null_ptr_usage.
1 parent 21425c3 commit 8605824

File tree

8 files changed

+18
-12
lines changed

8 files changed

+18
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ Released 2018-09-13
18721872
[`into_iter_on_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
18731873
[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
18741874
[`invalid_atomic_ordering`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering
1875-
[`invalid_null_usage`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_null_usage
1875+
[`invalid_null_ptr_usage`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_null_ptr_usage
18761876
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
18771877
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
18781878
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons

clippy_lints/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
804804
&pattern_type_mismatch::PATTERN_TYPE_MISMATCH,
805805
&precedence::PRECEDENCE,
806806
&ptr::CMP_NULL,
807-
&ptr::INVALID_NULL_USAGE,
807+
&ptr::INVALID_NULL_PTR_USAGE,
808808
&ptr::MUT_FROM_REF,
809809
&ptr::PTR_ARG,
810810
&ptr_eq::PTR_EQ,
@@ -1512,7 +1512,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15121512
LintId::of(&partialeq_ne_impl::PARTIALEQ_NE_IMPL),
15131513
LintId::of(&precedence::PRECEDENCE),
15141514
LintId::of(&ptr::CMP_NULL),
1515-
LintId::of(&ptr::INVALID_NULL_USAGE),
1515+
LintId::of(&ptr::INVALID_NULL_PTR_USAGE),
15161516
LintId::of(&ptr::MUT_FROM_REF),
15171517
LintId::of(&ptr::PTR_ARG),
15181518
LintId::of(&ptr_eq::PTR_EQ),
@@ -1836,7 +1836,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
18361836
LintId::of(&mut_key::MUTABLE_KEY_TYPE),
18371837
LintId::of(&open_options::NONSENSICAL_OPEN_OPTIONS),
18381838
LintId::of(&option_env_unwrap::OPTION_ENV_UNWRAP),
1839-
LintId::of(&ptr::INVALID_NULL_USAGE),
1839+
LintId::of(&ptr::INVALID_NULL_PTR_USAGE),
18401840
LintId::of(&ptr::MUT_FROM_REF),
18411841
LintId::of(&ranges::REVERSED_EMPTY_RANGES),
18421842
LintId::of(&regex::INVALID_REGEX),

clippy_lints/src/ptr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ declare_clippy_lint! {
135135
/// // Good
136136
/// unsafe { std::slice::from_raw_parts(NonNull::dangling().as_ptr(), 0); }
137137
/// ```
138-
pub INVALID_NULL_USAGE,
138+
pub INVALID_NULL_PTR_USAGE,
139139
correctness,
140140
"invalid usage of a null pointer, suggesting `NonNull::dangling()` instead."
141141
}
142142

143-
declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF, INVALID_NULL_USAGE]);
143+
declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF, INVALID_NULL_PTR_USAGE]);
144144

145145
impl<'tcx> LateLintPass<'tcx> for Ptr {
146146
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
@@ -187,7 +187,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
187187
if is_null_path(arg) {
188188
span_lint_and_sugg(
189189
cx,
190-
INVALID_NULL_USAGE,
190+
INVALID_NULL_PTR_USAGE,
191191
arg.span,
192192
"pointer must be non-null",
193193
"change this to",

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ vec![
978978
module: "atomic_ordering",
979979
},
980980
Lint {
981-
name: "invalid_null_usage",
981+
name: "invalid_null_ptr_usage",
982982
group: "correctness",
983983
desc: "invalid usage of a null pointer, suggesting `NonNull::dangling()` instead.",
984984
deprecation: None,

tests/ui/invalid_null_ptr_usage.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// run-rustfix
2+
3+
fn main() {
4+
let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
5+
let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
6+
}
File renamed without changes.

tests/ui/invalid_null_usage.stderr renamed to tests/ui/invalid_null_ptr_usage.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: pointer must be non-null
2-
--> $DIR/invalid_null_usage.rs:4:64
2+
--> $DIR/invalid_null_ptr_usage.rs:4:64
33
|
44
LL | let _slice: &[usize] = unsafe { std::slice::from_raw_parts(std::ptr::null(), 0) };
55
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
66
|
7-
= note: `#[deny(clippy::invalid_null_usage)]` on by default
7+
= note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default
88

99
error: pointer must be non-null
10-
--> $DIR/invalid_null_usage.rs:5:64
10+
--> $DIR/invalid_null_ptr_usage.rs:5:64
1111
|
1212
LL | let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::null(), 0) };
1313
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`

tests/ui/invalid_null_usage.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

33
fn main() {
4-
let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
4+
let _slice: &[usize] = unsafe { std::slice::from_raw_parts(std::ptr::null(), 0) };
55
let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
66
}

0 commit comments

Comments
 (0)