@@ -54,21 +54,6 @@ impl LateLintPass<'_> for ManualUnwrapOr {
54
54
}
55
55
}
56
56
57
- #[ derive( Copy , Clone ) ]
58
- enum Case {
59
- Option ,
60
- Result ,
61
- }
62
-
63
- impl Case {
64
- fn unwrap_fn_path ( & self ) -> & str {
65
- match self {
66
- Case :: Option => "Option::unwrap_or" ,
67
- Case :: Result => "Result::unwrap_or" ,
68
- }
69
- }
70
- }
71
-
72
57
fn lint_manual_unwrap_or < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
73
58
fn applicable_or_arm < ' a > ( cx : & LateContext < ' _ > , arms : & ' a [ Arm < ' a > ] ) -> Option < & ' a Arm < ' a > > {
74
59
if_chain ! {
@@ -101,10 +86,10 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
101
86
if_chain ! {
102
87
if let ExprKind :: Match ( scrutinee, match_arms, _) = expr. kind;
103
88
let ty = cx. typeck_results( ) . expr_ty( scrutinee) ;
104
- if let Some ( case ) = if is_type_diagnostic_item( cx, ty, sym:: option_type) {
105
- Some ( Case :: Option )
89
+ if let Some ( ty_name ) = if is_type_diagnostic_item( cx, ty, sym:: option_type) {
90
+ Some ( " Option" )
106
91
} else if is_type_diagnostic_item( cx, ty, sym:: result_type) {
107
- Some ( Case :: Result )
92
+ Some ( " Result" )
108
93
} else {
109
94
None
110
95
} ;
@@ -127,7 +112,7 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
127
112
span_lint_and_sugg(
128
113
cx,
129
114
MANUAL_UNWRAP_OR , expr. span,
130
- & format!( "this pattern reimplements `{}`" , case . unwrap_fn_path ( ) ) ,
115
+ & format!( "this pattern reimplements `{}::unwrap_or `" , ty_name ) ,
131
116
"replace with" ,
132
117
format!(
133
118
"{}.unwrap_or({})" ,
0 commit comments