]> git.lizzy.rs Git - rust.git/blob - tests/ui/redundant_closure_call.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / redundant_closure_call.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(redundant_closure_call)]
5
6 fn main() {
7         let a = (|| 42)();
8         //~^ ERROR Try not to call a closure in the expression where it is declared.
9         //~| HELP Try doing something like:
10         //~| SUGGESTION let a = 42;
11
12         let mut i = 1;
13         let k = (|m| m+1)(i); //~ERROR Try not to call a closure in the expression where it is declared.
14
15         k = (|a,b| a*b)(1,5); //~ERROR Try not to call a closure in the expression where it is declared.
16
17         let closure = || 32;
18         i = closure(); //~ERROR Closure called just once immediately after it was declared
19
20         let closure = |i| i+1;
21         i = closure(3); //~ERROR Closure called just once immediately after it was declared
22
23         i = closure(4);
24 }
25