From c0479402e4db4d1d83dbfa7ef1af552d9fea023e Mon Sep 17 00:00:00 2001 From: Matthew Kraai Date: Tue, 23 Apr 2019 23:32:16 -0700 Subject: [PATCH] Suppress let_and_return if let has attributes Fixes #3882. --- clippy_lints/src/returns.rs | 2 +- tests/ui/let_return.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index ba871c464ead..7f298faddbd2 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -157,7 +157,7 @@ impl Return { if let ast::StmtKind::Local(ref local) = stmt.node; // don't lint in the presence of type inference if local.ty.is_none(); - if !local.attrs.iter().any(attr_is_cfg); + if local.attrs.is_empty(); if let Some(ref initexpr) = local.init; if let ast::PatKind::Ident(_, ident, _) = local.pat.node; if let ast::ExprKind::Path(_, ref path) = retexpr.node; diff --git a/tests/ui/let_return.rs b/tests/ui/let_return.rs index d2e46621f9f8..40052f86dd53 100644 --- a/tests/ui/let_return.rs +++ b/tests/ui/let_return.rs @@ -39,4 +39,10 @@ fn test_nowarn_4() -> i32 { x } +fn test_nowarn_5(x: i16) -> u16 { + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] + let x = x as u16; + x +} + fn main() {}