Skip to content

Commit 680fade

Browse files
committed
update the lint messages and tests
1 parent b03105b commit 680fade

Some content is hidden

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

54 files changed

+315
-315
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn lint_misrefactored_assign_op(
209209
diag.span_suggestion(
210210
expr.span,
211211
&format!(
212-
"Did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
212+
"did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
213213
snip_a,
214214
snip_a,
215215
op.node.as_str(),

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
639639
diag.span_suggestion(span, "try", sugg, Applicability::MaybeIncorrect);
640640

641641
if !unix_suggested && is_unix(os) {
642-
diag.help("Did you mean `unix`?");
642+
diag.help("did you mean `unix`?");
643643
unix_suggested = true;
644644
}
645645
}

clippy_lints/src/await_holding_invalid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType
116116
cx,
117117
AWAIT_HOLDING_LOCK,
118118
ty_cause.span,
119-
"this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await.",
119+
"this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await",
120120
ty_cause.scope_span.or(Some(span)),
121121
"these are all the await points this lock is held through",
122122
);
@@ -126,7 +126,7 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType
126126
cx,
127127
AWAIT_HOLDING_REFCELL_REF,
128128
ty_cause.span,
129-
"this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.",
129+
"this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await",
130130
ty_cause.scope_span.or(Some(span)),
131131
"these are all the await points this ref is held through",
132132
);

clippy_lints/src/comparison_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
117117
expr.span,
118118
"`if` chain can be rewritten with `match`",
119119
None,
120-
"Consider rewriting the `if` chain to use `cmp` and `match`.",
120+
"consider rewriting the `if` chain to use `cmp` and `match`",
121121
)
122122
}
123123
}

clippy_lints/src/drop_forget_ref.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ declare_clippy_lint! {
9898
}
9999

100100
const DROP_REF_SUMMARY: &str = "calls to `std::mem::drop` with a reference instead of an owned value. \
101-
Dropping a reference does nothing.";
101+
Dropping a reference does nothing";
102102
const FORGET_REF_SUMMARY: &str = "calls to `std::mem::forget` with a reference instead of an owned value. \
103-
Forgetting a reference does nothing.";
103+
Forgetting a reference does nothing";
104104
const DROP_COPY_SUMMARY: &str = "calls to `std::mem::drop` with a value that implements `Copy`. \
105-
Dropping a copy leaves the original intact.";
105+
Dropping a copy leaves the original intact";
106106
const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements `Copy`. \
107-
Forgetting a copy leaves the original intact.";
107+
Forgetting a copy leaves the original intact";
108108

109109
declare_lint_pass!(DropForgetRef => [DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY]);
110110

clippy_lints/src/fallible_impl_from.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h
135135
move |diag| {
136136
diag.help(
137137
"`From` is intended for infallible conversions only. \
138-
Use `TryFrom` if there's a possibility for the conversion to fail.");
138+
Use `TryFrom` if there's a possibility for the conversion to fail");
139139
diag.span_note(fpu.result, "potential failure(s)");
140140
});
141141
}

clippy_lints/src/indexing_slicing.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
132132
}
133133

134134
let help_msg = match (range.start, range.end) {
135-
(None, Some(_)) => "Consider using `.get(..n)`or `.get_mut(..n)` instead",
136-
(Some(_), None) => "Consider using `.get(n..)` or .get_mut(n..)` instead",
137-
(Some(_), Some(_)) => "Consider using `.get(n..m)` or `.get_mut(n..m)` instead",
135+
(None, Some(_)) => "consider using `.get(..n)`or `.get_mut(..n)` instead",
136+
(Some(_), None) => "consider using `.get(n..)` or .get_mut(n..)` instead",
137+
(Some(_), Some(_)) => "consider using `.get(n..m)` or `.get_mut(n..m)` instead",
138138
(None, None) => return, // [..] is ok.
139139
};
140140

141-
span_lint_and_help(cx, INDEXING_SLICING, expr.span, "slicing may panic.", None, help_msg);
141+
span_lint_and_help(cx, INDEXING_SLICING, expr.span, "slicing may panic", None, help_msg);
142142
} else {
143143
// Catchall non-range index, i.e., [n] or [n << m]
144144
if let ty::Array(..) = ty.kind() {
@@ -153,9 +153,9 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
153153
cx,
154154
INDEXING_SLICING,
155155
expr.span,
156-
"indexing may panic.",
156+
"indexing may panic",
157157
None,
158-
"Consider using `.get(n)` or `.get_mut(n)` instead",
158+
"consider using `.get(n)` or `.get_mut(n)` instead",
159159
);
160160
}
161161
}

clippy_lints/src/integer_division.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'tcx> LateLintPass<'tcx> for IntegerDivision {
3939
expr.span,
4040
"integer division",
4141
None,
42-
"division of integers may cause loss of precision. consider using floats.",
42+
"division of integers may cause loss of precision. consider using floats",
4343
);
4444
}
4545
}

clippy_lints/src/loops.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,10 +1625,7 @@ fn check_for_loop_range<'tcx>(
16251625
cx,
16261626
NEEDLESS_RANGE_LOOP,
16271627
expr.span,
1628-
&format!(
1629-
"the loop variable `{}` is only used to index `{}`.",
1630-
ident.name, indexed
1631-
),
1628+
&format!("the loop variable `{}` is only used to index `{}`", ident.name, indexed),
16321629
|diag| {
16331630
multispan_sugg(
16341631
diag,
@@ -1763,7 +1760,7 @@ fn check_arg_type(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) {
17631760
arg.span,
17641761
&format!(
17651762
"for loop over `{0}`, which is an `Option`. This is more readably written as an \
1766-
`if let` statement.",
1763+
`if let` statement",
17671764
snippet(cx, arg.span, "_")
17681765
),
17691766
None,
@@ -1780,7 +1777,7 @@ fn check_arg_type(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) {
17801777
arg.span,
17811778
&format!(
17821779
"for loop over `{0}`, which is a `Result`. This is more readably written as an \
1783-
`if let` statement.",
1780+
`if let` statement",
17841781
snippet(cx, arg.span, "_")
17851782
),
17861783
None,
@@ -1826,7 +1823,7 @@ fn check_for_loop_explicit_counter<'tcx>(
18261823
cx,
18271824
EXPLICIT_COUNTER_LOOP,
18281825
for_span.with_hi(arg.span.hi()),
1829-
&format!("the variable `{}` is used as a loop counter.", name),
1826+
&format!("the variable `{}` is used as a loop counter", name),
18301827
"consider using",
18311828
format!(
18321829
"for ({}, {}) in {}.enumerate()",
@@ -3055,16 +3052,16 @@ impl IterFunction {
30553052
fn get_suggestion_text(&self) -> &'static str {
30563053
match &self.func {
30573054
IterFunctionKind::IntoIter => {
3058-
"Use the original Iterator instead of collecting it and then producing a new one"
3055+
"use the original Iterator instead of collecting it and then producing a new one"
30593056
},
30603057
IterFunctionKind::Len => {
3061-
"Take the original Iterator's count instead of collecting it and finding the length"
3058+
"take the original Iterator's count instead of collecting it and finding the length"
30623059
},
30633060
IterFunctionKind::IsEmpty => {
3064-
"Check if the original Iterator has anything instead of collecting it and seeing if it's empty"
3061+
"check if the original Iterator has anything instead of collecting it and seeing if it's empty"
30653062
},
30663063
IterFunctionKind::Contains(_) => {
3067-
"Check if the original Iterator contains an element instead of collecting then checking"
3064+
"check if the original Iterator contains an element instead of collecting then checking"
30683065
},
30693066
}
30703067
}

clippy_lints/src/matches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,9 @@ fn check_wild_in_or_pats(cx: &LateContext<'_>, arms: &[Arm<'_>]) {
11731173
cx,
11741174
WILDCARD_IN_OR_PATTERNS,
11751175
arm.pat.span,
1176-
"wildcard pattern covers any other pattern as it will match anyway.",
1176+
"wildcard pattern covers any other pattern as it will match anyway",
11771177
None,
1178-
"Consider handling `_` separately.",
1178+
"consider handling `_` separately",
11791179
);
11801180
}
11811181
}

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,7 +3037,7 @@ fn lint_filter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, fil
30373037
// lint if caller of `.filter().next()` is an Iterator
30383038
if match_trait_method(cx, expr, &paths::ITERATOR) {
30393039
let msg = "called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling \
3040-
`.find(..)` instead.";
3040+
`.find(..)` instead";
30413041
let filter_snippet = snippet(cx, filter_args[1].span, "..");
30423042
if filter_snippet.lines().count() <= 1 {
30433043
let iter_snippet = snippet(cx, filter_args[0].span, "..");
@@ -3165,7 +3165,7 @@ fn lint_filter_map_next<'tcx>(
31653165
}
31663166

31673167
let msg = "called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling \
3168-
`.find_map(..)` instead.";
3168+
`.find_map(..)` instead";
31693169
let filter_snippet = snippet(cx, filter_args[1].span, "..");
31703170
if filter_snippet.lines().count() <= 1 {
31713171
let iter_snippet = snippet(cx, filter_args[0].span, "..");

clippy_lints/src/methods/unnecessary_lazy_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(super) fn lint<'tcx>(
5050
UNNECESSARY_LAZY_EVALUATIONS,
5151
expr.span,
5252
msg,
53-
&format!("Use `{}` instead", simplify_using),
53+
&format!("use `{}` instead", simplify_using),
5454
format!(
5555
"{0}.{1}({2})",
5656
snippet(cx, args[0].span, ".."),

clippy_lints/src/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints {
292292
TOPLEVEL_REF_ARG,
293293
arg.pat.span,
294294
"`ref` directly on a function argument is ignored. \
295-
Consider using a reference type instead.",
295+
Consider using a reference type instead",
296296
);
297297
}
298298
}
@@ -422,7 +422,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints {
422422
expr.span,
423423
&format!(
424424
"used binding `{}` which is prefixed with an underscore. A leading \
425-
underscore signals that a binding will not be used.",
425+
underscore signals that a binding will not be used",
426426
binding
427427
),
428428
);

clippy_lints/src/needless_question_mark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn emit_lint(cx: &LateContext<'_>, expr: &SomeOkCall<'_>) {
142142
cx,
143143
NEEDLESS_QUESTION_MARK,
144144
entire_expr.span,
145-
"Question mark operator is useless here",
145+
"question mark operator is useless here",
146146
"try",
147147
format!("{}", utils::snippet(cx, inner_expr.span, r#""...""#)),
148148
Applicability::MachineApplicable,

clippy_lints/src/ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id:
188188
PTR_ARG,
189189
arg.span,
190190
"writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used \
191-
with non-Vec-based slices.",
191+
with non-Vec-based slices",
192192
|diag| {
193193
if let Some(ref snippet) = get_only_generic_arg_snippet(cx, arg) {
194194
diag.span_suggestion(
@@ -217,7 +217,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id:
217217
cx,
218218
PTR_ARG,
219219
arg.span,
220-
"writing `&String` instead of `&str` involves a new object where a slice will do.",
220+
"writing `&String` instead of `&str` involves a new object where a slice will do",
221221
|diag| {
222222
diag.span_suggestion(arg.span, "change this to", "&str".into(), Applicability::Unspecified);
223223
for (clonespan, suggestion) in spans {
@@ -239,7 +239,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id:
239239
cx,
240240
PTR_ARG,
241241
arg.span,
242-
"writing `&PathBuf` instead of `&Path` involves a new object where a slice will do.",
242+
"writing `&PathBuf` instead of `&Path` involves a new object where a slice will do",
243243
|diag| {
244244
diag.span_suggestion(
245245
arg.span,
@@ -278,7 +278,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id:
278278
cx,
279279
PTR_ARG,
280280
arg.span,
281-
"using a reference to `Cow` is not recommended.",
281+
"using a reference to `Cow` is not recommended",
282282
"change this to",
283283
"&".to_owned() + &r,
284284
Applicability::Unspecified,

clippy_lints/src/suspicious_operation_groupings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn emit_suggestion(cx: &EarlyContext<'_>, span: Span, sugg: String, applicabilit
261261
cx,
262262
SUSPICIOUS_OPERATION_GROUPINGS,
263263
span,
264-
"This sequence of operators looks suspiciously like a bug.",
264+
"this sequence of operators looks suspiciously like a bug",
265265
"I think you meant",
266266
sugg,
267267
applicability,

clippy_lints/src/transmuting_null.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_clippy_lint! {
2727

2828
declare_lint_pass!(TransmutingNull => [TRANSMUTING_NULL]);
2929

30-
const LINT_MSG: &str = "transmuting a known null pointer into a reference.";
30+
const LINT_MSG: &str = "transmuting a known null pointer into a reference";
3131

3232
impl<'tcx> LateLintPass<'tcx> for TransmutingNull {
3333
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {

clippy_lints/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl Types {
388388
hir_ty.span,
389389
"you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`",
390390
None,
391-
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.",
391+
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation",
392392
);
393393
return; // don't recurse into the type
394394
}
@@ -554,7 +554,7 @@ impl Types {
554554
cx,
555555
VEC_BOX,
556556
hir_ty.span,
557-
"`Vec<T>` is already on the heap, the boxing is unnecessary.",
557+
"`Vec<T>` is already on the heap, the boxing is unnecessary",
558558
"try",
559559
format!("Vec<{}>", snippet(cx, boxed_ty.span, "..")),
560560
Applicability::MachineApplicable,

clippy_lints/src/zero_div_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for ZeroDiv {
5555
"constant division of `0.0` with `0.0` will always result in NaN",
5656
None,
5757
&format!(
58-
"Consider using `{}::NAN` if you would like a constant representing NaN",
58+
"consider using `{}::NAN` if you would like a constant representing NaN",
5959
float_type,
6060
),
6161
);

tests/lint_message_convention.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ impl Message {
3838
r".*the arguments may be inverted...",
3939
r".*Intel x86 assembly syntax used",
4040
r".*AT&T x86 assembly syntax used",
41-
r".*remove .* the return type...",
41+
r".*remove .*the return type...",
4242
r"note: Clippy version: .*",
43+
r"the compiler unexpectedly panicked. this is a bug.",
44+
r".*help: I think you meant: .*",
45+
r"Iterator.* will panic at runtime",
4346
])
4447
.unwrap();
4548

@@ -96,7 +99,7 @@ fn lint_message_convention() {
9699

97100
eprintln!("\n\n\nLint message should not start with a capital letter and should not have punctuation at the end of the message unless multiple sentences are needed.");
98101
eprintln!("Check out the rustc-dev-guide for more information:");
99-
eprintln!("https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure");
102+
eprintln!("https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure\n\n\n");
100103

101104
assert!(bad_tests.is_empty());
102105
}

tests/ui-toml/vec_box_sized/test.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
1+
error: `Vec<T>` is already on the heap, the boxing is unnecessary
22
--> $DIR/test.rs:9:12
33
|
44
LL | struct Foo(Vec<Box<u8>>);
55
| ^^^^^^^^^^^^ help: try: `Vec<u8>`
66
|
77
= note: `-D clippy::vec-box` implied by `-D warnings`
88

9-
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
9+
error: `Vec<T>` is already on the heap, the boxing is unnecessary
1010
--> $DIR/test.rs:10:12
1111
|
1212
LL | struct Bar(Vec<Box<u32>>);
1313
| ^^^^^^^^^^^^^ help: try: `Vec<u32>`
1414

15-
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
15+
error: `Vec<T>` is already on the heap, the boxing is unnecessary
1616
--> $DIR/test.rs:13:18
1717
|
1818
LL | struct FooBarBaz(Vec<Box<C>>);

0 commit comments

Comments
 (0)