From 86b0dd419752788c8e63313c9c3ae19d27b3e8e4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 1 Apr 2020 12:00:49 -0700 Subject: [PATCH 1/2] Downgrade option_option to pedantic --- clippy_lints/src/lib.rs | 3 +-- clippy_lints/src/types.rs | 2 +- src/lintlist/mod.rs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 5d5b5d9a6da5c..4235cd40a22eb 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1125,6 +1125,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&types::CAST_SIGN_LOSS), LintId::of(&types::INVALID_UPCAST_COMPARISONS), LintId::of(&types::LINKEDLIST), + LintId::of(&types::OPTION_OPTION), LintId::of(&unicode::NON_ASCII_LITERAL), LintId::of(&unicode::UNICODE_NOT_NFC), LintId::of(&unused_self::UNUSED_SELF), @@ -1375,7 +1376,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION), LintId::of(&types::IMPLICIT_HASHER), LintId::of(&types::LET_UNIT_VALUE), - LintId::of(&types::OPTION_OPTION), LintId::of(&types::TYPE_COMPLEXITY), LintId::of(&types::UNIT_ARG), LintId::of(&types::UNIT_CMP), @@ -1565,7 +1565,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&transmute::TRANSMUTE_PTR_TO_REF), LintId::of(&types::BORROWED_BOX), LintId::of(&types::CHAR_LIT_AS_U8), - LintId::of(&types::OPTION_OPTION), LintId::of(&types::TYPE_COMPLEXITY), LintId::of(&types::UNIT_ARG), LintId::of(&types::UNNECESSARY_CAST), diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 4ff2947378f88..7fae477b83274 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -108,7 +108,7 @@ declare_clippy_lint! { /// } /// ``` pub OPTION_OPTION, - complexity, + pedantic, "usage of `Option>`" } diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs index 3b89f5d194777..9d135beae4f32 100644 --- a/src/lintlist/mod.rs +++ b/src/lintlist/mod.rs @@ -1566,7 +1566,7 @@ pub static ref ALL_LINTS: Vec = vec![ }, Lint { name: "option_option", - group: "complexity", + group: "pedantic", desc: "usage of `Option>`", deprecation: None, module: "types", From f6e8da81f184efb4036db16940ef3bfc84a29984 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 1 Apr 2020 12:15:21 -0700 Subject: [PATCH 2/2] Update option_option ui test --- tests/ui/option_option.rs | 2 ++ tests/ui/option_option.stderr | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/ui/option_option.rs b/tests/ui/option_option.rs index e2e649a810876..904c50e14039a 100644 --- a/tests/ui/option_option.rs +++ b/tests/ui/option_option.rs @@ -1,3 +1,5 @@ +#![deny(clippy::option_option)] + fn input(_: Option>) {} fn output() -> Option> { diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 9e9425cf9540b..79db186d7ea77 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,55 +1,59 @@ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:1:13 + --> $DIR/option_option.rs:3:13 | LL | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::option-option` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/option_option.rs:1:9 + | +LL | #![deny(clippy::option_option)] + | ^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:3:16 + --> $DIR/option_option.rs:5:16 | LL | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:7:27 + --> $DIR/option_option.rs:9:27 | LL | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:12:30 + --> $DIR/option_option.rs:14:30 | LL | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:17:8 + --> $DIR/option_option.rs:19:8 | LL | x: Option>, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:21:23 + --> $DIR/option_option.rs:23:23 | LL | fn struct_fn() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:27:22 + --> $DIR/option_option.rs:29:22 | LL | fn trait_fn() -> Option>; | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:31:11 + --> $DIR/option_option.rs:33:11 | LL | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:32:17 + --> $DIR/option_option.rs:34:17 | LL | Struct { x: Option> }, | ^^^^^^^^^^^^^^^^^^