Skip to content

Commit ebd8d31

Browse files
committed
Auto merge of #11055 - smoelius:try-this, r=dswij
"try this" -> "try" Current help messages contain a mix of "try", "try this", and one "try this instead". In the spirit of #10631, this PR adopts the first, as it is the most concise. It also updates the `lint_message_conventions` test to catch cases of "try this". (Aside: #10120 unfairly contained multiple changes in one PR. I am trying to break that PR up into smaller pieces.) changelog: Make help messages more concise ("try this" -> "try").
2 parents b46033e + 420f3d1 commit ebd8d31

File tree

105 files changed

+682
-680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+682
-680
lines changed

clippy_lints/src/dereference.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
589589
pat.spans,
590590
"this pattern creates a reference to a reference",
591591
|diag| {
592-
diag.multipart_suggestion("try this", replacements, app);
592+
diag.multipart_suggestion("try", replacements, app);
593593
},
594594
);
595595
}
@@ -1531,7 +1531,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data
15311531
Mutability::Not => "explicit `deref` method call",
15321532
Mutability::Mut => "explicit `deref_mut` method call",
15331533
},
1534-
"try this",
1534+
"try",
15351535
format!("{addr_of_str}{deref_str}{expr_str}"),
15361536
app,
15371537
);
@@ -1593,7 +1593,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data
15931593
} else {
15941594
format!("{prefix}{snip}")
15951595
};
1596-
diag.span_suggestion(data.span, "try this", sugg, app);
1596+
diag.span_suggestion(data.span, "try", sugg, app);
15971597
},
15981598
);
15991599
},
@@ -1620,7 +1620,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data
16201620
|diag| {
16211621
let mut app = Applicability::MachineApplicable;
16221622
let snip = snippet_with_context(cx, expr.span, data.span.ctxt(), "..", &mut app).0;
1623-
diag.span_suggestion(data.span, "try this", snip.into_owned(), app);
1623+
diag.span_suggestion(data.span, "try", snip.into_owned(), app);
16241624
},
16251625
);
16261626
},

clippy_lints/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass {
186186
MAP_ENTRY,
187187
expr.span,
188188
&format!("usage of `contains_key` followed by `insert` on a `{}`", map_ty.name()),
189-
"try this",
189+
"try",
190190
sugg,
191191
app,
192192
);

clippy_lints/src/explicit_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
100100
EXPLICIT_WRITE,
101101
expr.span,
102102
&format!("use of `{used}.unwrap()`"),
103-
"try this",
103+
"try",
104104
format!("{prefix}{sugg_mac}!({inputs_snippet})"),
105105
applicability,
106106
);

clippy_lints/src/init_numbered_fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
7171
INIT_NUMBERED_FIELDS,
7272
e.span,
7373
"used a field initializer for a tuple struct",
74-
"try this instead",
74+
"try",
7575
snippet,
7676
appl,
7777
);

clippy_lints/src/loops/missing_spin_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, cond: &'tcx Expr<'_>, body: &'
4343
MISSING_SPIN_LOOP,
4444
body.span,
4545
"busy-waiting loop should at least have a spin loop hint",
46-
"try this",
46+
"try",
4747
(if is_no_std_crate(cx) {
4848
"{ core::hint::spin_loop() }"
4949
} else {

clippy_lints/src/map_unit_fn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn lint_map_unit_fn(
226226
);
227227

228228
span_lint_and_then(cx, lint, expr.span, &msg, |diag| {
229-
diag.span_suggestion(stmt.span, "try this", suggestion, applicability);
229+
diag.span_suggestion(stmt.span, "try", suggestion, applicability);
230230
});
231231
} else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) {
232232
let msg = suggestion_msg("closure", map_type);
@@ -241,15 +241,15 @@ fn lint_map_unit_fn(
241241
snippet_with_applicability(cx, var_arg.span, "_", &mut applicability),
242242
snippet_with_context(cx, reduced_expr_span, var_arg.span.ctxt(), "_", &mut applicability).0,
243243
);
244-
diag.span_suggestion(stmt.span, "try this", suggestion, applicability);
244+
diag.span_suggestion(stmt.span, "try", suggestion, applicability);
245245
} else {
246246
let suggestion = format!(
247247
"if let {0}({1}) = {2} {{ ... }}",
248248
variant,
249249
snippet(cx, binding.pat.span, "_"),
250250
snippet(cx, var_arg.span, "_"),
251251
);
252-
diag.span_suggestion(stmt.span, "try this", suggestion, Applicability::HasPlaceholders);
252+
diag.span_suggestion(stmt.span, "try", suggestion, Applicability::HasPlaceholders);
253253
}
254254
});
255255
}

clippy_lints/src/matches/infallible_destructuring_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn check(cx: &LateContext<'_>, local: &Local<'_>) -> bool {
2828
local.span,
2929
"you seem to be trying to use `match` to destructure a single infallible pattern. \
3030
Consider using `let`",
31-
"try this",
31+
"try",
3232
format!(
3333
"let {}({}{}) = {};",
3434
snippet_with_applicability(cx, variant_name.span, "..", &mut applicability),

clippy_lints/src/matches/manual_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn check<'tcx>(
143143
MANUAL_FILTER,
144144
expr.span,
145145
"manual implementation of `Option::filter`",
146-
"try this",
146+
"try",
147147
if sugg_info.needs_brackets {
148148
format!(
149149
"{{ {}{}.filter({body_str}) }}",

clippy_lints/src/matches/manual_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn check<'tcx>(
5858
MANUAL_MAP,
5959
expr.span,
6060
"manual implementation of `Option::map`",
61-
"try this",
61+
"try",
6262
if sugg_info.needs_brackets {
6363
format!(
6464
"{{ {}{}.map({}) }}",

clippy_lints/src/matches/match_as_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr:
4646
MATCH_AS_REF,
4747
expr.span,
4848
&format!("use `{suggestion}()` instead"),
49-
"try this",
49+
"try",
5050
format!(
5151
"{}.{suggestion}(){cast}",
5252
snippet_with_applicability(cx, ex.span, "_", &mut applicability),

0 commit comments

Comments
 (0)