]> git.lizzy.rs Git - rust.git/commitdiff
Fixes #1735
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 11 May 2017 14:32:06 +0000 (16:32 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 11 May 2017 14:32:06 +0000 (16:32 +0200)
clippy_lints/src/returns.rs
tests/ui/let_return.rs

index 16f582c77c97fe7a880b546e327868513d067630..96b1e4e91857f9184bd13f75b5d955b35aa0657c 100644 (file)
@@ -111,6 +111,8 @@ fn check_let_return(&mut self, cx: &EarlyContext, block: &ast::Block) {
             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,
index de0bb9b3cc1c400b680ebeb482cabd8b2f3dabbf..71cdf88c8875bde2a9f5d1229c0d990c3da7315f 100644 (file)
@@ -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() {
 }