Skip to content

Commit 5872934

Browse files
viflip1995
authored andcommitted
Fill in Applicability from review comments by @flip1995
1 parent 3eccccb commit 5872934

29 files changed

+52
-48
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
9090
long
9191
),
9292
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
93-
Applicability::Unspecified,
93+
Applicability::MachineApplicable,
9494
);
9595
db.span_suggestion_with_applicability(
9696
expr.span,
9797
"or",
9898
long,
99-
Applicability::Unspecified,
99+
Applicability::MachineApplicable, // snippet
100100
);
101101
}
102102
},
@@ -183,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
183183
expr.span,
184184
"replace it with",
185185
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
186-
Applicability::Unspecified,
186+
Applicability::MachineApplicable,
187187
);
188188
}
189189
},

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
208208
line_span,
209209
"if you just forgot a `!`, use",
210210
sugg,
211-
Applicability::Unspecified,
211+
Applicability::MachineApplicable,
212212
);
213213
},
214214
);

clippy_lints/src/bit_mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
143143
e.span,
144144
"try",
145145
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),
146-
Applicability::Unspecified,
146+
Applicability::MaybeIncorrect,
147147
);
148148
});
149149
}

clippy_lints/src/booleans.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
395395
e.span,
396396
"it would look like the following",
397397
suggest(self.cx, suggestion, &h2q.terminals).0,
398+
// nonminimal_bool can produce minimal but
399+
// not human readable expressions (#3141)
398400
Applicability::Unspecified,
399401
);
400402
},
@@ -423,6 +425,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
423425
e.span,
424426
"try",
425427
suggestions,
428+
// nonminimal_bool can produce minimal but
429+
// not human readable expressions (#3141)
426430
Applicability::Unspecified,
427431
);
428432
},

clippy_lints/src/collapsible_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
142142
lhs.and(&rhs),
143143
snippet_block(cx, content.span, ".."),
144144
),
145-
Applicability::Unspecified,
145+
Applicability::MachineApplicable, // snippet
146146
);
147147
});
148148
}

clippy_lints/src/const_static_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl StaticConst {
6565
ty.span,
6666
"consider removing `'static`",
6767
sugg,
68-
Applicability::Unspecified,
68+
Applicability::MachineApplicable, //snippet
6969
);
7070
},
7171
);

clippy_lints/src/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
144144
self.span,
145145
"consider using",
146146
help,
147-
Applicability::Unspecified,
147+
Applicability::MachineApplicable, // snippet
148148
);
149149
}
150150
else {
@@ -156,7 +156,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
156156
self.span,
157157
"consider using",
158158
help,
159-
Applicability::Unspecified,
159+
Applicability::MachineApplicable, // snippet
160160
);
161161
}
162162
});

clippy_lints/src/eq_op.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
118118
left.span,
119119
"use the left value directly",
120120
lsnip,
121-
Applicability::Unspecified,
121+
Applicability::MachineApplicable, // snippet
122122
);
123123
})
124124
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()]) {
@@ -133,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
133133
right.span,
134134
"use the right value directly",
135135
rsnip,
136-
Applicability::Unspecified,
136+
Applicability::MachineApplicable, // snippet
137137
);
138138
},
139139
)
@@ -150,7 +150,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
150150
left.span,
151151
"use the left value directly",
152152
lsnip,
153-
Applicability::Unspecified,
153+
Applicability::MachineApplicable, // snippet
154154
);
155155
})
156156
}
@@ -166,7 +166,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
166166
right.span,
167167
"use the right value directly",
168168
rsnip,
169-
Applicability::Unspecified,
169+
Applicability::MachineApplicable, // snippet
170170
);
171171
})
172172
}

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
101101
expr.span,
102102
"remove closure as shown",
103103
snippet,
104-
Applicability::Unspecified,
104+
Applicability::MachineApplicable,
105105
);
106106
}
107107
});

clippy_lints/src/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
6565
expr.span,
6666
"consider using .to_string()",
6767
sugg,
68-
Applicability::Unspecified,
68+
Applicability::MachineApplicable,
6969
);
7070
});
7171
}
@@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
8080
span,
8181
"consider using .to_string()",
8282
sugg,
83-
Applicability::Unspecified,
83+
Applicability::MachineApplicable, // snippet
8484
);
8585
});
8686
}

clippy_lints/src/identity_conversion.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
6868
e.span,
6969
"consider removing `.into()`",
7070
sugg,
71-
Applicability::Unspecified,
71+
Applicability::MachineApplicable, // snippet
7272
);
7373
});
7474
}
@@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
8383
e.span,
8484
"consider removing `.into_iter()`",
8585
sugg,
86-
Applicability::Unspecified,
86+
Applicability::MachineApplicable, // snippet
8787
);
8888
});
8989
}
@@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
103103
e.span,
104104
&sugg_msg,
105105
sugg,
106-
Applicability::Unspecified,
106+
Applicability::MachineApplicable, // snippet
107107
);
108108
});
109109
}

clippy_lints/src/if_let_redundant_pattern_matching.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
8282
span,
8383
"try this",
8484
format!("if {}.{}", snippet(cx, op.span, "_"), good_method),
85-
Applicability::Unspecified,
85+
Applicability::MachineApplicable, // snippet
8686
);
8787
},
8888
);

clippy_lints/src/inline_fn_without_body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) {
5757
attr.span,
5858
&format!("use of `#[inline]` on trait method `{}` which has no body", name),
5959
|db| {
60-
db.suggest_remove_item(cx, attr.span, "remove", Applicability::Unspecified);
60+
db.suggest_remove_item(cx, attr.span, "remove", Applicability::MachineApplicable);
6161
},
6262
);
6363
}

clippy_lints/src/int_plus_one.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl IntPlusOne {
157157
block.span,
158158
"change `>= y + 1` to `> y` as shown",
159159
recommendation,
160-
Applicability::Unspecified,
160+
Applicability::MachineApplicable, // snippet
161161
);
162162
});
163163
}

clippy_lints/src/large_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
102102
"consider boxing the large fields to reduce the total size of the \
103103
enum",
104104
format!("Box<{}>", snip),
105-
Applicability::Unspecified,
105+
Applicability::MachineApplicable,
106106
);
107107
return;
108108
}

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
125125
span,
126126
"it is more idiomatic to write",
127127
sug,
128-
Applicability::Unspecified,
128+
Applicability::MaybeIncorrect,
129129
);
130130
if !mutability.is_empty() {
131131
db.note("you might not need `mut` at all");

clippy_lints/src/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
12061206
dots = dots,
12071207
start = start_snippet
12081208
),
1209-
Applicability::Unspecified,
1209+
Applicability::MaybeIncorrect,
12101210
);
12111211
},
12121212
);

clippy_lints/src/map_unit_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
232232
stmt.span,
233233
"try this",
234234
suggestion,
235-
Applicability::Unspecified,
235+
Applicability::MachineApplicable, // snippet
236236
);
237237
} else {
238238
let suggestion = format!("if let {0}({1}) = {2} {{ ... }}",

clippy_lints/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex
344344
expr.span,
345345
"consider using an if/else expression",
346346
sugg,
347-
Applicability::Unspecified,
347+
Applicability::MaybeIncorrect, // not sure
348348
);
349349
}
350350
}

clippy_lints/src/methods.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,13 +1132,13 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
11321132
expr.span,
11331133
"try dereferencing it",
11341134
format!("{}({}{}).clone()", refs, derefs, snip.deref()),
1135-
Applicability::Unspecified,
1135+
Applicability::MaybeIncorrect,
11361136
);
11371137
db.span_suggestion_with_applicability(
11381138
expr.span,
11391139
"or try being explicit about what type to clone",
11401140
explicit,
1141-
Applicability::Unspecified,
1141+
Applicability::MaybeIncorrect,
11421142
);
11431143
},
11441144
);
@@ -1659,7 +1659,7 @@ fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr,
16591659
expr.span,
16601660
"try using and_then instead",
16611661
hint,
1662-
Applicability::Unspecified,
1662+
Applicability::MachineApplicable, // snippet
16631663
);
16641664
});
16651665
}

clippy_lints/src/misc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
304304
tyopt=tyopt,
305305
initref=initref,
306306
),
307-
Applicability::Unspecified,
307+
Applicability::MachineApplicable, // snippet
308308
);
309309
}
310310
);
@@ -331,7 +331,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
331331
sugg,
332332
&snippet(cx, b.span, ".."),
333333
),
334-
Applicability::Unspecified,
334+
Applicability::MachineApplicable, // snippet
335335
);
336336
});
337337
}
@@ -381,7 +381,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
381381
expr.span,
382382
"consider comparing them within some error",
383383
format!("({}).abs() < error", lhs - rhs),
384-
Applicability::Unspecified,
384+
Applicability::MachineApplicable, // snippet
385385
);
386386
db.span_note(expr.span, "std::f32::EPSILON and std::f64::EPSILON are available.");
387387
});
@@ -553,7 +553,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
553553
expr.span,
554554
"try",
555555
snip.to_string(),
556-
Applicability::Unspecified,
556+
Applicability::MachineApplicable, // snippet
557557
);
558558
},
559559
);

clippy_lints/src/misc_early.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl EarlyLintPass for MiscEarly {
312312
expr.span,
313313
"Try doing something like: ",
314314
hint,
315-
Applicability::Unspecified,
315+
Applicability::MachineApplicable, // snippet
316316
);
317317
},
318318
);
@@ -402,13 +402,13 @@ impl MiscEarly {
402402
lit.span,
403403
"if you mean to use a decimal constant, remove the `0` to remove confusion",
404404
src.trim_left_matches(|c| c == '_' || c == '0').to_string(),
405-
Applicability::Unspecified,
405+
Applicability::MaybeIncorrect,
406406
);
407407
db.span_suggestion_with_applicability(
408408
lit.span,
409409
"if you mean to use an octal constant, use `0o`",
410410
format!("0o{}", src.trim_left_matches(|c| c == '_' || c == '0')),
411-
Applicability::Unspecified,
411+
Applicability::MaybeIncorrect,
412412
);
413413
});
414414
}

clippy_lints/src/needless_borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
8080
e.span,
8181
"change this to",
8282
snippet,
83-
Applicability::Unspecified,
83+
Applicability::MachineApplicable,
8484
);
8585
}
8686
},
@@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
113113
pat.span,
114114
"change this to",
115115
snippet,
116-
Applicability::Unspecified,
116+
Applicability::MachineApplicable,
117117
);
118118
}
119119
}

clippy_lints/src/needless_borrowed_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
8282
pat.span,
8383
"try removing the `&ref` part and just keep",
8484
hint,
85-
Applicability::Unspecified,
85+
Applicability::MachineApplicable, // snippet
8686
);
8787
});
8888
}

0 commit comments

Comments
 (0)