Made requested changes

This commit is contained in:
Michael Wright 2018-01-17 07:24:33 +02:00
parent 21fde9a9d1
commit e7567f2eac
2 changed files with 10 additions and 23 deletions

View file

@ -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<T>` instead of `Option<Option<T>>`",
"`Option<_>` is easier to use than `Option<Option<_>`",
"consider using `Option<T>` instead of `Option<Option<T>>` or a custom \
enum if you need to distinguish all 3 cases",
);
return; // don't recurse into the type
}

View file

@ -1,57 +1,44 @@
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:1:13
|
1 | fn input(_: Option<Option<u8>>) {
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D option-option` implied by `-D warnings`
= help: `Option<_>` is easier to use than `Option<Option<_>`
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:4:16
|
4 | fn output() -> Option<Option<u8>> {
| ^^^^^^^^^^^^^^^^^^
|
= help: `Option<_>` is easier to use than `Option<Option<_>`
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:8:27
|
8 | fn output_nested() -> Vec<Option<Option<u8>>> {
| ^^^^^^^^^^^^^^^^^^
|
= help: `Option<_>` is easier to use than `Option<Option<_>`
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:13:30
|
13 | fn output_nested_nested() -> Option<Option<Option<u8>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: `Option<_>` is easier to use than `Option<Option<_>`
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:18:8
|
18 | x: Option<Option<u8>>,
| ^^^^^^^^^^^^^^^^^^
|
= help: `Option<_>` is easier to use than `Option<Option<_>`
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:22:11
|
22 | Tuple(Option<Option<u8>>),
| ^^^^^^^^^^^^^^^^^^
|
= help: `Option<_>` is easier to use than `Option<Option<_>`
error: consider using `Option<T>` instead of `Option<Option<T>>`
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
--> $DIR/option_option.rs:23:15
|
23 | Struct{x: Option<Option<u8>>},
| ^^^^^^^^^^^^^^^^^^
|
= help: `Option<_>` is easier to use than `Option<Option<_>`