2020-09-24 07:49:22 -05:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![warn(clippy::all)]
|
|
|
|
#![warn(clippy::redundant_pattern_matching)]
|
2021-04-22 04:31:13 -05:00
|
|
|
#![allow(
|
|
|
|
unused_must_use,
|
|
|
|
clippy::needless_bool,
|
|
|
|
clippy::match_like_matches_macro,
|
2021-10-07 04:21:30 -05:00
|
|
|
clippy::equatable_if_let,
|
2021-04-22 04:31:13 -05:00
|
|
|
clippy::if_same_then_else
|
|
|
|
)]
|
2020-09-24 07:49:22 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if None::<()>.is_none() {}
|
|
|
|
|
|
|
|
if Some(42).is_some() {}
|
|
|
|
|
|
|
|
if Some(42).is_some() {
|
|
|
|
foo();
|
|
|
|
} else {
|
|
|
|
bar();
|
|
|
|
}
|
|
|
|
|
|
|
|
while Some(42).is_some() {}
|
|
|
|
|
|
|
|
while Some(42).is_none() {}
|
|
|
|
|
|
|
|
while None::<()>.is_none() {}
|
|
|
|
|
|
|
|
let mut v = vec![1, 2, 3];
|
|
|
|
while v.pop().is_some() {
|
|
|
|
foo();
|
|
|
|
}
|
|
|
|
|
|
|
|
if None::<i32>.is_none() {}
|
|
|
|
|
|
|
|
if Some(42).is_some() {}
|
|
|
|
|
|
|
|
Some(42).is_some();
|
|
|
|
|
|
|
|
None::<()>.is_none();
|
|
|
|
|
|
|
|
let _ = None::<()>.is_none();
|
|
|
|
|
|
|
|
let opt = Some(false);
|
2020-12-06 08:01:03 -06:00
|
|
|
let _ = if opt.is_some() { true } else { false };
|
2020-09-24 07:49:22 -05:00
|
|
|
|
|
|
|
issue6067();
|
|
|
|
|
|
|
|
let _ = if gen_opt().is_some() {
|
|
|
|
1
|
|
|
|
} else if gen_opt().is_none() {
|
|
|
|
2
|
|
|
|
} else {
|
|
|
|
3
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn gen_opt() -> Option<()> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo() {}
|
|
|
|
|
|
|
|
fn bar() {}
|
|
|
|
|
|
|
|
// Methods that are unstable const should not be suggested within a const context, see issue #5697.
|
|
|
|
// However, in Rust 1.48.0 the methods `is_some` and `is_none` of `Option` were stabilized as const,
|
|
|
|
// so the following should be linted.
|
|
|
|
const fn issue6067() {
|
|
|
|
if Some(42).is_some() {}
|
|
|
|
|
|
|
|
if None::<()>.is_none() {}
|
|
|
|
|
|
|
|
while Some(42).is_some() {}
|
|
|
|
|
|
|
|
while None::<()>.is_none() {}
|
|
|
|
|
|
|
|
Some(42).is_some();
|
|
|
|
|
|
|
|
None::<()>.is_none();
|
|
|
|
}
|
2021-12-06 05:33:31 -06:00
|
|
|
|
2022-01-27 08:12:45 -06:00
|
|
|
#[allow(clippy::deref_addrof, dead_code, clippy::needless_borrow)]
|
2021-12-06 05:33:31 -06:00
|
|
|
fn issue7921() {
|
|
|
|
if (&None::<()>).is_none() {}
|
|
|
|
if (&None::<()>).is_none() {}
|
|
|
|
}
|