Skip to content

Commit

Permalink
Fixes #1735
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 11, 2017
1 parent fb68958 commit 81b35d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clippy_lints/src/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ impl ReturnPass {
let ast::StmtKind::Expr(ref retexpr) = retexpr.node,
let Some(stmt) = it.next_back(),
let ast::StmtKind::Local(ref local) = stmt.node,
// don't lint in the presence of type inference
local.ty.is_none(),
!local.attrs.iter().any(attr_is_cfg),
let Some(ref initexpr) = local.init,
let ast::PatKind::Ident(_, Spanned { node: id, .. }, _) = local.pat.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 @@ -36,5 +36,11 @@ fn test_nowarn_3() -> (i32, i32) {
(x, y)
}

fn test_nowarn_4() -> i32 {
// this should technically warn, but not b/c of let_and_return, but b/c of useless type
let x: i32 = 5;
x
}

fn main() {
}

0 comments on commit 81b35d1

Please sign in to comment.