Skip to content

Commit 99423e8

Browse files
committed
Auto merge of #12170 - GuillaumeGomez:improve-suggestions-wording, r=llogiq
Improve wording for suggestion messages Follow-up of #12140. r? `@llogiq` changelog: Improve wording for suggestion messages
2 parents 64d08a8 + 38d9585 commit 99423e8

21 files changed

+117
-117
lines changed

clippy_lints/src/loops/same_item_push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(super) fn check<'tcx>(
3131
vec.span,
3232
"it looks like the same item is being pushed into this Vec",
3333
None,
34-
&format!("try using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"),
34+
&format!("consider using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"),
3535
);
3636
}
3737

clippy_lints/src/methods/join_absolute_paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, join_a
4242
)
4343
.span_suggestion(
4444
expr_span,
45-
"if this is intentional, try using `Path::new` instead",
45+
"if this is intentional, consider using `Path::new`",
4646
format!("PathBuf::from({arg_str})"),
4747
Applicability::Unspecified,
4848
);

clippy_lints/src/methods/manual_saturating_arithmetic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn check(
5050
super::MANUAL_SATURATING_ARITHMETIC,
5151
expr.span,
5252
"manual saturating arithmetic",
53-
&format!("try using `saturating_{arith}`"),
53+
&format!("consider using `saturating_{arith}`"),
5454
format!(
5555
"{}.saturating_{arith}({})",
5656
snippet_with_applicability(cx, arith_lhs.span, "..", &mut applicability),

clippy_lints/src/methods/option_as_ref_deref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub(super) fn check(
9797
};
9898
let method_hint = if is_mut { "as_deref_mut" } else { "as_deref" };
9999
let hint = format!("{}.{method_hint}()", snippet(cx, as_ref_recv.span, ".."));
100-
let suggestion = format!("try using {method_hint} instead");
100+
let suggestion = format!("consider using {method_hint}");
101101

102102
let msg = format!("called `{current_method}` on an `Option` value");
103103
span_lint_and_sugg(

clippy_lints/src/methods/option_map_or_err_ok.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(super) fn check<'tcx>(
3333
OPTION_MAP_OR_ERR_OK,
3434
expr.span,
3535
msg,
36-
"try using `ok_or` instead",
36+
"consider using `ok_or`",
3737
format!("{self_snippet}.ok_or({err_snippet})"),
3838
Applicability::MachineApplicable,
3939
);

clippy_lints/src/methods/option_map_or_none.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub(super) fn check<'tcx>(
7272
OPTION_MAP_OR_NONE,
7373
expr.span,
7474
msg,
75-
"try using `map` instead",
75+
"consider using `map`",
7676
format!("{self_snippet}.map({arg_snippet} {func_snippet})"),
7777
Applicability::MachineApplicable,
7878
);
@@ -85,7 +85,7 @@ pub(super) fn check<'tcx>(
8585
OPTION_MAP_OR_NONE,
8686
expr.span,
8787
msg,
88-
"try using `and_then` instead",
88+
"consider using `and_then`",
8989
format!("{self_snippet}.and_then({func_snippet})"),
9090
Applicability::MachineApplicable,
9191
);
@@ -97,7 +97,7 @@ pub(super) fn check<'tcx>(
9797
RESULT_MAP_OR_INTO_OPTION,
9898
expr.span,
9999
msg,
100-
"try using `ok` instead",
100+
"consider using `ok`",
101101
format!("{self_snippet}.ok()"),
102102
Applicability::MachineApplicable,
103103
);

clippy_lints/src/methods/result_map_or_else_none.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(super) fn check<'tcx>(
3434
RESULT_MAP_OR_INTO_OPTION,
3535
expr.span,
3636
msg,
37-
"try using `ok` instead",
37+
"consider using `ok`",
3838
format!("{self_snippet}.ok()"),
3939
Applicability::MachineApplicable,
4040
);

clippy_lints/src/methods/single_char_pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(super) fn check(
5757
SINGLE_CHAR_PATTERN,
5858
arg.span,
5959
"single-character string constant used as pattern",
60-
"try using a `char` instead",
60+
"consider using a `char`",
6161
hint,
6262
applicability,
6363
);

clippy_lints/src/methods/unnecessary_join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(super) fn check<'tcx>(
3232
UNNECESSARY_JOIN,
3333
span.with_hi(expr.span.hi()),
3434
r#"called `.collect::<Vec<String>>().join("")` on an iterator"#,
35-
"try using",
35+
"consider using",
3636
"collect::<String>()".to_owned(),
3737
applicability,
3838
);

clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for AlmostStandardFormulation {
6666
ident.span,
6767
"non-standard lint formulation",
6868
None,
69-
&format!("try using `{}` instead", formulation.correction),
69+
&format!("consider using `{}`", formulation.correction),
7070
);
7171
}
7272
return;

tests/ui-internal/check_formulation.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: non-standard lint formulation
44
LL | /// Check for lint formulations that are correct
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: try using `Checks for` instead
7+
= help: consider using `Checks for`
88
= note: `-D clippy::almost-standard-lint-formulation` implied by `-D warnings`
99
= help: to override `-D warnings` add `#[allow(clippy::almost_standard_lint_formulation)]`
1010

@@ -14,7 +14,7 @@ error: non-standard lint formulation
1414
LL | /// Detects uses of incorrect formulations
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616
|
17-
= help: try using `Checks for` instead
17+
= help: consider using `Checks for`
1818

1919
error: aborting due to 2 previous errors
2020

tests/ui/join_absolute_paths.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ help: if this is unintentional, try removing the starting separator
1111
|
1212
LL | path.join("sh");
1313
| ~~~~
14-
help: if this is intentional, try using `Path::new` instead
14+
help: if this is intentional, consider using `Path::new`
1515
|
1616
LL | PathBuf::from("/sh");
1717
| ~~~~~~~~~~~~~~~~~~~~
@@ -27,7 +27,7 @@ help: if this is unintentional, try removing the starting separator
2727
|
2828
LL | path.join("\user");
2929
| ~~~~~~~
30-
help: if this is intentional, try using `Path::new` instead
30+
help: if this is intentional, consider using `Path::new`
3131
|
3232
LL | PathBuf::from("\\user");
3333
| ~~~~~~~~~~~~~~~~~~~~~~~
@@ -43,7 +43,7 @@ help: if this is unintentional, try removing the starting separator
4343
|
4444
LL | path.join("sh");
4545
| ~~~~
46-
help: if this is intentional, try using `Path::new` instead
46+
help: if this is intentional, consider using `Path::new`
4747
|
4848
LL | PathBuf::from("/sh");
4949
| ~~~~~~~~~~~~~~~~~~~~
@@ -59,7 +59,7 @@ help: if this is unintentional, try removing the starting separator
5959
|
6060
LL | path.join(r#"sh"#);
6161
| ~~~~~~~
62-
help: if this is intentional, try using `Path::new` instead
62+
help: if this is intentional, consider using `Path::new`
6363
|
6464
LL | PathBuf::from(r#"/sh"#);
6565
| ~~~~~~~~~~~~~~~~~~~~~~~

tests/ui/manual_ok_or.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error: called `map_or(Err(_), Ok)` on an `Option` value
1717
--> $DIR/manual_ok_or.rs:14:5
1818
|
1919
LL | foo.map_or(Err("error"), Ok);
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `ok_or` instead: `foo.ok_or("error")`
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `foo.ok_or("error")`
2121
|
2222
= note: `-D clippy::option-map-or-err-ok` implied by `-D warnings`
2323
= help: to override `-D warnings` add `#[allow(clippy::option_map_or_err_ok)]`

tests/ui/manual_saturating_arithmetic.stderr

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: manual saturating arithmetic
22
--> $DIR/manual_saturating_arithmetic.rs:6:13
33
|
44
LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u32.saturating_add(1)`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)`
66
|
77
= note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]`
@@ -11,13 +11,13 @@ error: manual saturating arithmetic
1111
--> $DIR/manual_saturating_arithmetic.rs:7:13
1212
|
1313
LL | let _ = 1u32.checked_add(1).unwrap_or(u32::MAX);
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u32.saturating_add(1)`
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)`
1515

1616
error: manual saturating arithmetic
1717
--> $DIR/manual_saturating_arithmetic.rs:8:13
1818
|
1919
LL | let _ = 1u8.checked_add(1).unwrap_or(255);
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u8.saturating_add(1)`
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u8.saturating_add(1)`
2121

2222
error: manual saturating arithmetic
2323
--> $DIR/manual_saturating_arithmetic.rs:9:13
@@ -26,49 +26,49 @@ LL | let _ = 1u128
2626
| _____________^
2727
LL | | .checked_add(1)
2828
LL | | .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455);
29-
| |_______________________________________________________________________^ help: try using `saturating_add`: `1u128.saturating_add(1)`
29+
| |_______________________________________________________________________^ help: consider using `saturating_add`: `1u128.saturating_add(1)`
3030

3131
error: manual saturating arithmetic
3232
--> $DIR/manual_saturating_arithmetic.rs:14:13
3333
|
3434
LL | let _ = 1u32.checked_mul(1).unwrap_or(u32::MAX);
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_mul`: `1u32.saturating_mul(1)`
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `1u32.saturating_mul(1)`
3636

3737
error: manual saturating arithmetic
3838
--> $DIR/manual_saturating_arithmetic.rs:16:13
3939
|
4040
LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::min_value());
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1u32.saturating_sub(1)`
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)`
4242

4343
error: manual saturating arithmetic
4444
--> $DIR/manual_saturating_arithmetic.rs:17:13
4545
|
4646
LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::MIN);
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1u32.saturating_sub(1)`
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)`
4848

4949
error: manual saturating arithmetic
5050
--> $DIR/manual_saturating_arithmetic.rs:18:13
5151
|
5252
LL | let _ = 1u8.checked_sub(1).unwrap_or(0);
53-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1u8.saturating_sub(1)`
53+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u8.saturating_sub(1)`
5454

5555
error: manual saturating arithmetic
5656
--> $DIR/manual_saturating_arithmetic.rs:22:13
5757
|
5858
LL | let _ = 1i32.checked_add(1).unwrap_or(i32::max_value());
59-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(1)`
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)`
6060

6161
error: manual saturating arithmetic
6262
--> $DIR/manual_saturating_arithmetic.rs:23:13
6363
|
6464
LL | let _ = 1i32.checked_add(1).unwrap_or(i32::MAX);
65-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(1)`
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)`
6666

6767
error: manual saturating arithmetic
6868
--> $DIR/manual_saturating_arithmetic.rs:24:13
6969
|
7070
LL | let _ = 1i8.checked_add(1).unwrap_or(127);
71-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i8.saturating_add(1)`
71+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(1)`
7272

7373
error: manual saturating arithmetic
7474
--> $DIR/manual_saturating_arithmetic.rs:25:13
@@ -77,25 +77,25 @@ LL | let _ = 1i128
7777
| _____________^
7878
LL | | .checked_add(1)
7979
LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727);
80-
| |_______________________________________________________________________^ help: try using `saturating_add`: `1i128.saturating_add(1)`
80+
| |_______________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(1)`
8181

8282
error: manual saturating arithmetic
8383
--> $DIR/manual_saturating_arithmetic.rs:28:13
8484
|
8585
LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value());
86-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(-1)`
86+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)`
8787

8888
error: manual saturating arithmetic
8989
--> $DIR/manual_saturating_arithmetic.rs:29:13
9090
|
9191
LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::MIN);
92-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(-1)`
92+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)`
9393

9494
error: manual saturating arithmetic
9595
--> $DIR/manual_saturating_arithmetic.rs:30:13
9696
|
9797
LL | let _ = 1i8.checked_add(-1).unwrap_or(-128);
98-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i8.saturating_add(-1)`
98+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(-1)`
9999

100100
error: manual saturating arithmetic
101101
--> $DIR/manual_saturating_arithmetic.rs:31:13
@@ -104,25 +104,25 @@ LL | let _ = 1i128
104104
| _____________^
105105
LL | | .checked_add(-1)
106106
LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728);
107-
| |________________________________________________________________________^ help: try using `saturating_add`: `1i128.saturating_add(-1)`
107+
| |________________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(-1)`
108108

109109
error: manual saturating arithmetic
110110
--> $DIR/manual_saturating_arithmetic.rs:38:13
111111
|
112112
LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::min_value());
113-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(1)`
113+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)`
114114

115115
error: manual saturating arithmetic
116116
--> $DIR/manual_saturating_arithmetic.rs:39:13
117117
|
118118
LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::MIN);
119-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(1)`
119+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)`
120120

121121
error: manual saturating arithmetic
122122
--> $DIR/manual_saturating_arithmetic.rs:40:13
123123
|
124124
LL | let _ = 1i8.checked_sub(1).unwrap_or(-128);
125-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i8.saturating_sub(1)`
125+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(1)`
126126

127127
error: manual saturating arithmetic
128128
--> $DIR/manual_saturating_arithmetic.rs:41:13
@@ -131,25 +131,25 @@ LL | let _ = 1i128
131131
| _____________^
132132
LL | | .checked_sub(1)
133133
LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728);
134-
| |________________________________________________________________________^ help: try using `saturating_sub`: `1i128.saturating_sub(1)`
134+
| |________________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(1)`
135135

136136
error: manual saturating arithmetic
137137
--> $DIR/manual_saturating_arithmetic.rs:44:13
138138
|
139139
LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value());
140-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(-1)`
140+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)`
141141

142142
error: manual saturating arithmetic
143143
--> $DIR/manual_saturating_arithmetic.rs:45:13
144144
|
145145
LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::MAX);
146-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(-1)`
146+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)`
147147

148148
error: manual saturating arithmetic
149149
--> $DIR/manual_saturating_arithmetic.rs:46:13
150150
|
151151
LL | let _ = 1i8.checked_sub(-1).unwrap_or(127);
152-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i8.saturating_sub(-1)`
152+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(-1)`
153153

154154
error: manual saturating arithmetic
155155
--> $DIR/manual_saturating_arithmetic.rs:47:13
@@ -158,7 +158,7 @@ LL | let _ = 1i128
158158
| _____________^
159159
LL | | .checked_sub(-1)
160160
LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727);
161-
| |_______________________________________________________________________^ help: try using `saturating_sub`: `1i128.saturating_sub(-1)`
161+
| |_______________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(-1)`
162162

163163
error: aborting due to 24 previous errors
164164

0 commit comments

Comments
 (0)