diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index c8b564e4228e..e5109cf3ebb3 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -220,12 +220,12 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) { } } else if match_def_path(cx.tcx, def_id, &paths::OPTION) { if match_type_parameter(cx, qpath, &paths::OPTION) { - span_help_and_lint( + span_lint( cx, OPTION_OPTION, ast_ty.span, - "consider using `Option` instead of `Option>`", - "`Option<_>` is easier to use than `Option`", + "consider using `Option` instead of `Option>` or a custom \ + enum if you need to distinguish all 3 cases", ); return; // don't recurse into the type } diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 514538be167e..91f686288dd5 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,57 +1,44 @@ -error: consider using `Option` instead of `Option>` +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 | 1 | fn input(_: Option>) { | ^^^^^^^^^^^^^^^^^^ | = note: `-D option-option` implied by `-D warnings` - = help: `Option<_>` is easier to use than `Option` -error: consider using `Option` instead of `Option>` +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:4:16 | 4 | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ - | - = help: `Option<_>` is easier to use than `Option` -error: consider using `Option` instead of `Option>` +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:8:27 | 8 | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ - | - = help: `Option<_>` is easier to use than `Option` -error: consider using `Option` instead of `Option>` +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:13:30 | 13 | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: `Option<_>` is easier to use than `Option` -error: consider using `Option` instead of `Option>` +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:18:8 | 18 | x: Option>, | ^^^^^^^^^^^^^^^^^^ - | - = help: `Option<_>` is easier to use than `Option` -error: consider using `Option` instead of `Option>` +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:22:11 | 22 | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ - | - = help: `Option<_>` is easier to use than `Option` -error: consider using `Option` instead of `Option>` +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:23:15 | 23 | Struct{x: Option>}, | ^^^^^^^^^^^^^^^^^^ - | - = help: `Option<_>` is easier to use than `Option`