clean-up tests

This commit is contained in:
Ada Alakbarova 2025-10-12 13:52:54 +02:00
parent 35f8bffb91
commit 3e1f8623f7
No known key found for this signature in database
2 changed files with 16 additions and 19 deletions

View file

@ -1,52 +1,52 @@
#![deny(clippy::option_option)]
#![allow(clippy::unnecessary_wraps, clippy::manual_unwrap_or_default)]
#![warn(clippy::option_option)]
#![expect(clippy::unnecessary_wraps)]
const C: Option<Option<i32>> = None;
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
//~^ option_option
static S: Option<Option<i32>> = None;
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
//~^ option_option
fn input(_: Option<Option<u8>>) {}
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
//~^ option_option
fn output() -> Option<Option<u8>> {
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
//~^ option_option
None
}
fn output_nested() -> Vec<Option<Option<u8>>> {
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
//~^ option_option
vec![None]
}
// The lint only generates one warning for this
fn output_nested_nested() -> Option<Option<Option<u8>>> {
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if
//~^ option_option
None
}
struct Struct {
x: Option<Option<u8>>,
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum
//~^ option_option
}
impl Struct {
fn struct_fn() -> Option<Option<u8>> {
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum
//~^ option_option
None
}
}
trait Trait {
fn trait_fn() -> Option<Option<u8>>;
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum
//~^ option_option
}
enum Enum {
Tuple(Option<Option<u8>>),
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum
//~^ option_option
Struct { x: Option<Option<u8>> },
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum
//~^ option_option
}
// The lint allows this
@ -88,7 +88,7 @@ mod issue_4298 {
#[serde(default)]
#[serde(borrow)]
foo: Option<Option<Cow<'a, str>>>,
//~^ ERROR: consider using `Option<T>` instead of `Option<Option<T>>` or a custom
//~^ option_option
}
#[allow(clippy::option_option)]

View file

@ -4,11 +4,8 @@ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enu
LL | const C: Option<Option<i32>> = None;
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> tests/ui/option_option.rs:1:9
|
LL | #![deny(clippy::option_option)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: `-D clippy::option-option` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::option_option)]`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> tests/ui/option_option.rs:6:11