Skip to content

Commit

Permalink
Suppress let_and_return if let has attributes
Browse files Browse the repository at this point in the history
Fixes #3882.
  • Loading branch information
kraai committed Apr 24, 2019
1 parent 9897442 commit c047940
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/let_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit c047940

Please sign in to comment.