From 8c5e617c9a22de40cbde76e8aa2d0fd49d0303f5 Mon Sep 17 00:00:00 2001 From: Oliver 'ker' Schneider Date: Sat, 25 Jun 2016 18:59:37 +0200 Subject: [PATCH] don't lint on comparing `*const f32`s --- clippy_lints/src/utils/mod.rs | 6 ++---- tests/compile-fail/float_cmp.rs | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index a2b2ecfbcc0..e35b1bbac6b 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -523,8 +523,7 @@ pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, /// Return the base type for references and raw pointers. pub fn walk_ptrs_ty(ty: ty::Ty) -> ty::Ty { match ty.sty { - ty::TyRef(_, ref tm) | - ty::TyRawPtr(ref tm) => walk_ptrs_ty(tm.ty), + ty::TyRef(_, ref tm) => walk_ptrs_ty(tm.ty), _ => ty, } } @@ -533,8 +532,7 @@ pub fn walk_ptrs_ty(ty: ty::Ty) -> ty::Ty { pub fn walk_ptrs_ty_depth(ty: ty::Ty) -> (ty::Ty, usize) { fn inner(ty: ty::Ty, depth: usize) -> (ty::Ty, usize) { match ty.sty { - ty::TyRef(_, ref tm) | - ty::TyRawPtr(ref tm) => inner(tm.ty, depth + 1), + ty::TyRef(_, ref tm) => inner(tm.ty, depth + 1), _ => (ty, depth), } } diff --git a/tests/compile-fail/float_cmp.rs b/tests/compile-fail/float_cmp.rs index 85df1ded5ac..9f611dd3fd9 100644 --- a/tests/compile-fail/float_cmp.rs +++ b/tests/compile-fail/float_cmp.rs @@ -63,4 +63,10 @@ fn main() { x > 0.0; x <= 0.0; x >= 0.0; + + let xs : [f32; 1] = [0.0]; + let a: *const f32 = xs.as_ptr(); + let b: *const f32 = xs.as_ptr(); + + assert!(a == b); // no errors } -- 2.44.0