2020-10-30 16:06:27 -05:00
|
|
|
#![warn(clippy::unnecessary_lazy_evaluations)]
|
2023-05-31 12:47:10 -05:00
|
|
|
#![allow(clippy::unnecessary_literal_unwrap)]
|
2023-07-27 06:40:22 -05:00
|
|
|
//@no-rustfix
|
2020-10-30 16:06:27 -05:00
|
|
|
struct Deep(Option<usize>);
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
struct SomeStruct {
|
|
|
|
some_field: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// fix will break type inference
|
|
|
|
let _ = Ok(1).unwrap_or_else(|()| 2);
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: unnecessary closure used to substitute value for `Result::Err`
|
|
|
|
//~| NOTE: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings`
|
2020-10-30 16:06:27 -05:00
|
|
|
mod e {
|
|
|
|
pub struct E;
|
|
|
|
}
|
|
|
|
let _ = Ok(1).unwrap_or_else(|e::E| 2);
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: unnecessary closure used to substitute value for `Result::Err`
|
2020-10-30 16:06:27 -05:00
|
|
|
let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2);
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: unnecessary closure used to substitute value for `Result::Err`
|
2020-11-22 07:04:18 -06:00
|
|
|
|
|
|
|
// Fix #6343
|
|
|
|
let arr = [(Some(1),)];
|
|
|
|
Some(&0).and_then(|&i| arr[i].0);
|
2020-10-30 16:06:27 -05:00
|
|
|
}
|
2023-10-15 17:29:28 -05:00
|
|
|
|
|
|
|
fn issue11672() {
|
|
|
|
// Return type annotation helps type inference and removing it can break code
|
|
|
|
let _ = true.then(|| -> &[u8] { &[] });
|
|
|
|
}
|