File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 1- use clippy_utils:: diagnostics:: span_lint_and_help ;
1+ use clippy_utils:: diagnostics:: span_lint_and_sugg ;
22use clippy_utils:: ty:: is_type_diagnostic_item;
33use if_chain:: if_chain;
4+ use rustc_errors:: Applicability ;
45use rustc_hir:: { Expr , ExprKind , QPath } ;
56use rustc_lint:: LateContext ;
67use rustc_span:: { sym, Span } ;
@@ -40,13 +41,14 @@ pub(super) fn check<'tcx>(
4041 unwrap_expr. span
4142 } ;
4243
43- span_lint_and_help (
44+ span_lint_and_sugg (
4445 cx,
4546 OR_THEN_UNWRAP ,
4647 or_span. to ( unwrap_span) ,
4748 title,
48- None ,
49- "use `unwrap_or()` instead" ,
49+ "try this" ,
50+ "unwrap_or(...)" . into ( ) ,
51+ Applicability :: HasPlaceholders ,
5052 ) ;
5153}
5254
Original file line number Diff line number Diff line change @@ -2,18 +2,15 @@ error: .or(Some(…)).unwrap() found
22 --> $DIR/or_then_unwrap.rs:22:20
33 |
44LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint
5- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or(...)`
66 |
77 = note: `-D clippy::or-then-unwrap` implied by `-D warnings`
8- = help: use `unwrap_or()` instead
98
109error: .or(Ok(…)).unwrap() found
1110 --> $DIR/or_then_unwrap.rs:25:20
1211 |
1312LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint
14- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15- |
16- = help: use `unwrap_or()` instead
13+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or(...)`
1714
1815error: aborting due to 2 previous errors
1916
You can’t perform that action at this time.
0 commit comments