clean-up
This commit is contained in:
parent
e6298692a5
commit
e7b4ae869e
4 changed files with 10 additions and 15 deletions
|
|
@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
|||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
|
||||
if let TraitItemKind::Fn(sig, trait_method) = &item.kind {
|
||||
if matches!(trait_method, TraitFn::Provided(_)) {
|
||||
// Handled by check body.
|
||||
// Handled by `check_body`.
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -393,10 +393,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
|
|||
hir_tys: &'tcx [hir::Ty<'tcx>],
|
||||
params: &'tcx [Param<'tcx>],
|
||||
) -> impl Iterator<Item = PtrArg<'tcx>> + 'cx {
|
||||
fn_sig
|
||||
.inputs()
|
||||
.iter()
|
||||
.zip(hir_tys.iter())
|
||||
iter::zip(fn_sig.inputs(), hir_tys)
|
||||
.enumerate()
|
||||
.filter_map(move |(i, (ty, hir_ty))| {
|
||||
if let ty::Ref(_, ty, mutability) = *ty.kind()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![warn(clippy::cmp_null)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
use std::ptr;
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ fn main() {
|
|||
}
|
||||
|
||||
let mut y = 0;
|
||||
let mut m: *mut usize = &mut y;
|
||||
let m: *mut usize = &mut y;
|
||||
if m.is_null() {
|
||||
//~^ cmp_null
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![warn(clippy::cmp_null)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
use std::ptr;
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ fn main() {
|
|||
}
|
||||
|
||||
let mut y = 0;
|
||||
let mut m: *mut usize = &mut y;
|
||||
let m: *mut usize = &mut y;
|
||||
if m == ptr::null_mut() {
|
||||
//~^ cmp_null
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: comparing with null is better expressed by the `.is_null()` method
|
||||
--> tests/ui/cmp_null.rs:9:8
|
||||
--> tests/ui/cmp_null.rs:8:8
|
||||
|
|
||||
LL | if p == ptr::null() {
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `p.is_null()`
|
||||
|
|
@ -8,31 +8,31 @@ LL | if p == ptr::null() {
|
|||
= help: to override `-D warnings` add `#[allow(clippy::cmp_null)]`
|
||||
|
||||
error: comparing with null is better expressed by the `.is_null()` method
|
||||
--> tests/ui/cmp_null.rs:14:8
|
||||
--> tests/ui/cmp_null.rs:13:8
|
||||
|
|
||||
LL | if ptr::null() == p {
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `p.is_null()`
|
||||
|
||||
error: comparing with null is better expressed by the `.is_null()` method
|
||||
--> tests/ui/cmp_null.rs:22:8
|
||||
--> tests/ui/cmp_null.rs:21:8
|
||||
|
|
||||
LL | if m == ptr::null_mut() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `m.is_null()`
|
||||
|
||||
error: comparing with null is better expressed by the `.is_null()` method
|
||||
--> tests/ui/cmp_null.rs:27:8
|
||||
--> tests/ui/cmp_null.rs:26:8
|
||||
|
|
||||
LL | if ptr::null_mut() == m {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `m.is_null()`
|
||||
|
||||
error: comparing with null is better expressed by the `.is_null()` method
|
||||
--> tests/ui/cmp_null.rs:33:13
|
||||
--> tests/ui/cmp_null.rs:32:13
|
||||
|
|
||||
LL | let _ = x as *const () == ptr::null();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(x as *const ()).is_null()`
|
||||
|
||||
error: comparing with null is better expressed by the `.is_null()` method
|
||||
--> tests/ui/cmp_null.rs:39:19
|
||||
--> tests/ui/cmp_null.rs:38:19
|
||||
|
|
||||
LL | debug_assert!(f != std::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!f.is_null()`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue