]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/redundant_closure_call_late.rs
Add 'src/tools/rust-analyzer/' from commit '977e12a0bdc3e329af179ef3a9d466af9eb613bb'
[rust.git] / src / tools / clippy / tests / ui / redundant_closure_call_late.rs
1 // non rustfixable, see redundant_closure_call_fixable.rs
2
3 #![warn(clippy::redundant_closure_call)]
4 #![allow(clippy::needless_late_init)]
5
6 fn main() {
7     let mut i = 1;
8
9     // don't lint here, the closure is used more than once
10     let closure = |i| i + 1;
11     i = closure(3);
12     i = closure(4);
13
14     // lint here
15     let redun_closure = || 1;
16     i = redun_closure();
17
18     // shadowed closures are supported, lint here
19     let shadowed_closure = || 1;
20     i = shadowed_closure();
21     let shadowed_closure = || 2;
22     i = shadowed_closure();
23
24     // don't lint here
25     let shadowed_closure = || 2;
26     i = shadowed_closure();
27     i = shadowed_closure();
28
29     // Fix FP in #5916
30     let mut x;
31     let create = || 2 * 2;
32     x = create();
33     fun(move || {
34         x = create();
35     })
36 }
37
38 fn fun<T: 'static + FnMut()>(mut f: T) {
39     f();
40 }