Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn about calling a closure in the same expression where it's defined.
- Loading branch information
1 parent
bdda6a2
commit e421a0f
Showing
5 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![feature(plugin)] | ||
#![plugin(clippy)] | ||
|
||
#![deny(redundant_closure_call)] | ||
|
||
fn main() { | ||
let a = (|| 42)(); | ||
//~^ ERROR Try not to call a closure in the expression where it is declared. | ||
//~| HELP Try doing something like: | ||
//~| SUGGESTION let a = 42; | ||
|
||
let mut i = 1; | ||
let k = (|m| m+1)(i); //~ERROR Try not to call a closure in the expression where it is declared. | ||
|
||
k = (|a,b| a*b)(1,5); //~ERROR Try not to call a closure in the expression where it is declared. | ||
|
||
let closure = || 32; | ||
i = closure(); //~ERROR Closure called just once immediately after it was declared | ||
|
||
let closure = |i| i+1; | ||
i = closure(3); //~ERROR Closure called just once immediately after it was declared | ||
|
||
i = closure(4); | ||
} | ||
|