Skip to content

Commit e7b4ae8

Browse files
committed
clean-up
1 parent e629869 commit e7b4ae8

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

clippy_lints/src/ptr.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
161161
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
162162
if let TraitItemKind::Fn(sig, trait_method) = &item.kind {
163163
if matches!(trait_method, TraitFn::Provided(_)) {
164-
// Handled by check body.
164+
// Handled by `check_body`.
165165
return;
166166
}
167167

@@ -393,10 +393,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
393393
hir_tys: &'tcx [hir::Ty<'tcx>],
394394
params: &'tcx [Param<'tcx>],
395395
) -> impl Iterator<Item = PtrArg<'tcx>> + 'cx {
396-
fn_sig
397-
.inputs()
398-
.iter()
399-
.zip(hir_tys.iter())
396+
iter::zip(fn_sig.inputs(), hir_tys)
400397
.enumerate()
401398
.filter_map(move |(i, (ty, hir_ty))| {
402399
if let ty::Ref(_, ty, mutability) = *ty.kind()

tests/ui/cmp_null.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::cmp_null)]
2-
#![allow(unused_mut)]
32

43
use std::ptr;
54

@@ -18,7 +17,7 @@ fn main() {
1817
}
1918

2019
let mut y = 0;
21-
let mut m: *mut usize = &mut y;
20+
let m: *mut usize = &mut y;
2221
if m.is_null() {
2322
//~^ cmp_null
2423

tests/ui/cmp_null.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::cmp_null)]
2-
#![allow(unused_mut)]
32

43
use std::ptr;
54

@@ -18,7 +17,7 @@ fn main() {
1817
}
1918

2019
let mut y = 0;
21-
let mut m: *mut usize = &mut y;
20+
let m: *mut usize = &mut y;
2221
if m == ptr::null_mut() {
2322
//~^ cmp_null
2423

tests/ui/cmp_null.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: comparing with null is better expressed by the `.is_null()` method
2-
--> tests/ui/cmp_null.rs:9:8
2+
--> tests/ui/cmp_null.rs:8:8
33
|
44
LL | if p == ptr::null() {
55
| ^^^^^^^^^^^^^^^^ help: try: `p.is_null()`
@@ -8,31 +8,31 @@ LL | if p == ptr::null() {
88
= help: to override `-D warnings` add `#[allow(clippy::cmp_null)]`
99

1010
error: comparing with null is better expressed by the `.is_null()` method
11-
--> tests/ui/cmp_null.rs:14:8
11+
--> tests/ui/cmp_null.rs:13:8
1212
|
1313
LL | if ptr::null() == p {
1414
| ^^^^^^^^^^^^^^^^ help: try: `p.is_null()`
1515

1616
error: comparing with null is better expressed by the `.is_null()` method
17-
--> tests/ui/cmp_null.rs:22:8
17+
--> tests/ui/cmp_null.rs:21:8
1818
|
1919
LL | if m == ptr::null_mut() {
2020
| ^^^^^^^^^^^^^^^^^^^^ help: try: `m.is_null()`
2121

2222
error: comparing with null is better expressed by the `.is_null()` method
23-
--> tests/ui/cmp_null.rs:27:8
23+
--> tests/ui/cmp_null.rs:26:8
2424
|
2525
LL | if ptr::null_mut() == m {
2626
| ^^^^^^^^^^^^^^^^^^^^ help: try: `m.is_null()`
2727

2828
error: comparing with null is better expressed by the `.is_null()` method
29-
--> tests/ui/cmp_null.rs:33:13
29+
--> tests/ui/cmp_null.rs:32:13
3030
|
3131
LL | let _ = x as *const () == ptr::null();
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(x as *const ()).is_null()`
3333

3434
error: comparing with null is better expressed by the `.is_null()` method
35-
--> tests/ui/cmp_null.rs:39:19
35+
--> tests/ui/cmp_null.rs:38:19
3636
|
3737
LL | debug_assert!(f != std::ptr::null_mut());
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!f.is_null()`

0 commit comments

Comments
 (0)