2019-09-25 16:30:27 +00:00
|
|
|
// non rustfixable, see redundant_closure_call_fixable.rs
|
|
|
|
|
2018-07-28 15:34:52 +00:00
|
|
|
#![warn(clippy::redundant_closure_call)]
|
2016-03-03 19:14:49 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-12-09 22:26:16 +00:00
|
|
|
let mut i = 1;
|
2020-07-26 19:07:07 +00:00
|
|
|
|
|
|
|
// lint here
|
2018-12-09 22:26:16 +00:00
|
|
|
let mut k = (|m| m + 1)(i);
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: try not to call a closure in the expression where it is declared
|
|
|
|
//~| NOTE: `-D clippy::redundant-closure-call` implied by `-D warnings`
|
2016-03-03 19:14:49 +00:00
|
|
|
|
2020-07-26 19:07:07 +00:00
|
|
|
// lint here
|
2018-12-09 22:26:16 +00:00
|
|
|
k = (|a, b| a * b)(1, 5);
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: try not to call a closure in the expression where it is declared
|
2016-03-03 19:14:49 +00:00
|
|
|
|
2020-07-26 19:07:07 +00:00
|
|
|
// don't lint these
|
2018-11-14 06:01:39 +00:00
|
|
|
#[allow(clippy::needless_return)]
|
|
|
|
(|| return 2)();
|
|
|
|
(|| -> Option<i32> { None? })();
|
2021-07-21 03:23:22 +00:00
|
|
|
#[allow(clippy::try_err)]
|
2019-08-15 08:04:47 +00:00
|
|
|
(|| -> Result<i32, i32> { Err(2)? })();
|
2016-03-03 19:14:49 +00:00
|
|
|
}
|