Skip to content

Commit 253601a

Browse files
committed
Auto merge of #4024 - kraai:suppress-let_and_return-if-let-has-attributes, r=flip1995
Suppress let_and_return if let has attributes Fixes #3882. changelog: suppress `let_and_return` if `let` has attributes
2 parents 92d703f + c047940 commit 253601a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl Return {
157157
if let ast::StmtKind::Local(ref local) = stmt.node;
158158
// don't lint in the presence of type inference
159159
if local.ty.is_none();
160-
if !local.attrs.iter().any(attr_is_cfg);
160+
if local.attrs.is_empty();
161161
if let Some(ref initexpr) = local.init;
162162
if let ast::PatKind::Ident(_, ident, _) = local.pat.node;
163163
if let ast::ExprKind::Path(_, ref path) = retexpr.node;

tests/ui/let_return.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ fn test_nowarn_4() -> i32 {
3939
x
4040
}
4141

42+
fn test_nowarn_5(x: i16) -> u16 {
43+
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
44+
let x = x as u16;
45+
x
46+
}
47+
4248
fn main() {}

0 commit comments

Comments
 (0)