Skip to content

Commit cc5bfd4

Browse files
committed
Auto merge of #5888 - matthiaskrgr:lints, r=yaahc
make a bunch of lints texts adhere to rustc dev guide According to the rustc-dev guide: "The text should be matter of fact and avoid capitalization and periods, unless multiple sentences are needed" changelog: make some lint output adhere to the rustc-dev guide
2 parents 1683189 + 6d0b5e2 commit cc5bfd4

Some content is hidden

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

49 files changed

+193
-206
lines changed

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::as
605605
cx,
606606
EMPTY_LINE_AFTER_OUTER_ATTR,
607607
begin_of_attr_to_item,
608-
"Found an empty line after an outer attribute. \
608+
"found an empty line after an outer attribute. \
609609
Perhaps you forgot to add a `!` to make it an inner attribute?",
610610
);
611611
}

clippy_lints/src/bytecount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
8282
cx,
8383
NAIVE_BYTECOUNT,
8484
expr.span,
85-
"You appear to be counting bytes the naive way",
86-
"Consider using the bytecount crate",
85+
"you appear to be counting bytes the naive way",
86+
"consider using the bytecount crate",
8787
format!("bytecount::count({}, {})",
8888
snippet_with_applicability(cx, haystack.span, "..", &mut applicability),
8989
snippet_with_applicability(cx, needle.span, "..", &mut applicability)),

clippy_lints/src/checked_conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for CheckedConversions {
6666
cx,
6767
CHECKED_CONVERSIONS,
6868
item.span,
69-
"Checked cast can be simplified.",
69+
"checked cast can be simplified",
7070
"try",
7171
format!("{}::try_from({}).is_ok()", to_type, snippet),
7272
applicability,

clippy_lints/src/default_trait_access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultTraitAccess {
6161
cx,
6262
DEFAULT_TRAIT_ACCESS,
6363
expr.span,
64-
&format!("Calling `{}` is more clear than this expression", replacement),
64+
&format!("calling `{}` is more clear than this expression", replacement),
6565
"try",
6666
replacement,
6767
Applicability::Unspecified, // First resolve the TODO above

clippy_lints/src/double_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'tcx> DoubleComparisons {
6060
cx,
6161
DOUBLE_COMPARISONS,
6262
span,
63-
"This binary expression can be simplified",
63+
"this binary expression can be simplified",
6464
"try",
6565
sugg,
6666
applicability,

clippy_lints/src/double_parens.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,28 @@ impl EarlyLintPass for DoubleParens {
4545
return;
4646
}
4747

48+
let msg: &str = "consider removing unnecessary double parentheses";
49+
4850
match expr.kind {
4951
ExprKind::Paren(ref in_paren) => match in_paren.kind {
5052
ExprKind::Paren(_) | ExprKind::Tup(_) => {
51-
span_lint(
52-
cx,
53-
DOUBLE_PARENS,
54-
expr.span,
55-
"Consider removing unnecessary double parentheses",
56-
);
53+
span_lint(cx, DOUBLE_PARENS, expr.span, &msg);
5754
},
5855
_ => {},
5956
},
6057
ExprKind::Call(_, ref params) => {
6158
if params.len() == 1 {
6259
let param = &params[0];
6360
if let ExprKind::Paren(_) = param.kind {
64-
span_lint(
65-
cx,
66-
DOUBLE_PARENS,
67-
param.span,
68-
"Consider removing unnecessary double parentheses",
69-
);
61+
span_lint(cx, DOUBLE_PARENS, param.span, &msg);
7062
}
7163
}
7264
},
7365
ExprKind::MethodCall(_, ref params, _) => {
7466
if params.len() == 2 {
7567
let param = &params[1];
7668
if let ExprKind::Paren(_) = param.kind {
77-
span_lint(
78-
cx,
79-
DOUBLE_PARENS,
80-
param.span,
81-
"Consider removing unnecessary double parentheses",
82-
);
69+
span_lint(cx, DOUBLE_PARENS, param.span, &msg);
8370
}
8471
}
8572
},

clippy_lints/src/drop_bounds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ declare_clippy_lint! {
3333
/// ```
3434
pub DROP_BOUNDS,
3535
correctness,
36-
"Bounds of the form `T: Drop` are useless"
36+
"bounds of the form `T: Drop` are useless"
3737
}
3838

39-
const DROP_BOUNDS_SUMMARY: &str = "Bounds of the form `T: Drop` are useless. \
40-
Use `std::mem::needs_drop` to detect if a type has drop glue.";
39+
const DROP_BOUNDS_SUMMARY: &str = "bounds of the form `T: Drop` are useless, \
40+
use `std::mem::needs_drop` to detect if a type has drop glue";
4141

4242
declare_lint_pass!(DropBounds => [DROP_BOUNDS]);
4343

clippy_lints/src/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl<'tcx> Functions {
374374
}
375375

376376
if line_count > self.max_lines {
377-
span_lint(cx, TOO_MANY_LINES, span, "This function has a large number of lines.")
377+
span_lint(cx, TOO_MANY_LINES, span, "this function has a large number of lines")
378378
}
379379
}
380380

clippy_lints/src/misc_early.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl EarlyLintPass for MiscEarlyLints {
271271
cx,
272272
BUILTIN_TYPE_SHADOW,
273273
param.ident.span,
274-
&format!("This generic shadows the built-in type `{}`", name),
274+
&format!("this generic shadows the built-in type `{}`", name),
275275
);
276276
}
277277
}
@@ -298,9 +298,9 @@ impl EarlyLintPass for MiscEarlyLints {
298298
cx,
299299
UNNEEDED_FIELD_PATTERN,
300300
pat.span,
301-
"All the struct fields are matched to a wildcard pattern, consider using `..`.",
301+
"all the struct fields are matched to a wildcard pattern, consider using `..`",
302302
None,
303-
&format!("Try with `{} {{ .. }}` instead", type_name),
303+
&format!("try with `{} {{ .. }}` instead", type_name),
304304
);
305305
return;
306306
}
@@ -313,7 +313,7 @@ impl EarlyLintPass for MiscEarlyLints {
313313
cx,
314314
UNNEEDED_FIELD_PATTERN,
315315
field.span,
316-
"You matched a field with a wildcard pattern. Consider using `..` instead",
316+
"you matched a field with a wildcard pattern, consider using `..` instead",
317317
);
318318
} else {
319319
let mut normal = vec![];
@@ -333,10 +333,10 @@ impl EarlyLintPass for MiscEarlyLints {
333333
cx,
334334
UNNEEDED_FIELD_PATTERN,
335335
field.span,
336-
"You matched a field with a wildcard pattern. Consider using `..` \
336+
"you matched a field with a wildcard pattern, consider using `..` \
337337
instead",
338338
None,
339-
&format!("Try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")),
339+
&format!("try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")),
340340
);
341341
}
342342
}

clippy_lints/src/needless_bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fn check_comparison<'a, 'tcx>(
243243
cx,
244244
BOOL_COMPARISON,
245245
e.span,
246-
"This comparison might be written more concisely",
246+
"this comparison might be written more concisely",
247247
"try simplifying it as shown",
248248
format!(
249249
"{} != {}",

clippy_lints/src/neg_cmp_op_on_partial_ord.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
7979
cx,
8080
NEG_CMP_OP_ON_PARTIAL_ORD,
8181
expr.span,
82-
"The use of negated comparison operators on partially ordered \
83-
types produces code that is hard to read and refactor. Please \
82+
"the use of negated comparison operators on partially ordered \
83+
types produces code that is hard to read and refactor, please \
8484
consider using the `partial_cmp` method instead, to make it \
85-
clear that the two values could be incomparable."
85+
clear that the two values could be incomparable"
8686
)
8787
}
8888
}

clippy_lints/src/neg_multiply.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) {
4747
if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.typeck_results().expr_ty_opt(lit));
4848
if cx.typeck_results().expr_ty(exp).is_integral();
4949
then {
50-
span_lint(cx, NEG_MULTIPLY, span, "Negation by multiplying with `-1`");
50+
span_lint(cx, NEG_MULTIPLY, span, "negation by multiplying with `-1`");
5151
}
5252
}
5353
}

clippy_lints/src/overflow_check_conditional.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
4242
if let BinOpKind::Lt = op.node {
4343
if let BinOpKind::Add = op2.node {
4444
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
45-
"You are trying to use classic C overflow conditions that will fail in Rust.");
45+
"you are trying to use classic C overflow conditions that will fail in Rust");
4646
}
4747
}
4848
if let BinOpKind::Gt = op.node {
4949
if let BinOpKind::Sub = op2.node {
5050
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
51-
"You are trying to use classic C underflow conditions that will fail in Rust.");
51+
"you are trying to use classic C underflow conditions that will fail in Rust");
5252
}
5353
}
5454
}
@@ -67,13 +67,13 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
6767
if let BinOpKind::Gt = op.node {
6868
if let BinOpKind::Add = op2.node {
6969
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
70-
"You are trying to use classic C overflow conditions that will fail in Rust.");
70+
"you are trying to use classic C overflow conditions that will fail in Rust");
7171
}
7272
}
7373
if let BinOpKind::Lt = op.node {
7474
if let BinOpKind::Sub = op2.node {
7575
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
76-
"You are trying to use classic C underflow conditions that will fail in Rust.");
76+
"you are trying to use classic C underflow conditions that will fail in Rust");
7777
}
7878
}
7979
}

clippy_lints/src/path_buf_push_overwrite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for PathBufPushOverwrite {
6060
cx,
6161
PATH_BUF_PUSH_OVERWRITE,
6262
lit.span,
63-
"Calling `push` with '/' or '\\' (file system root) will overwrite the previous path definition",
63+
"calling `push` with '/' or '\\' (file system root) will overwrite the previous path definition",
6464
"try",
6565
format!("\"{}\"", pushed_path_lit.trim_start_matches(|c| c == '/' || c == '\\')),
6666
Applicability::MachineApplicable,

clippy_lints/src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
145145
cx,
146146
CMP_NULL,
147147
expr.span,
148-
"Comparing with null is better expressed by the `.is_null()` method",
148+
"comparing with null is better expressed by the `.is_null()` method",
149149
);
150150
}
151151
}

clippy_lints/src/ranges.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for Ranges {
160160
span_lint(cx,
161161
RANGE_ZIP_WITH_LEN,
162162
expr.span,
163-
&format!("It is more idiomatic to use `{}.iter().enumerate()`",
163+
&format!("it is more idiomatic to use `{}.iter().enumerate()`",
164164
snippet(cx, iter_args[0].span, "_")));
165165
}
166166
}

clippy_lints/src/redundant_static_lifetimes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ impl EarlyLintPass for RedundantStaticLifetimes {
8686
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
8787
if !item.span.from_expansion() {
8888
if let ItemKind::Const(_, ref var_type, _) = item.kind {
89-
self.visit_type(var_type, cx, "Constants have by default a `'static` lifetime");
89+
self.visit_type(var_type, cx, "constants have by default a `'static` lifetime");
9090
// Don't check associated consts because `'static` cannot be elided on those (issue
9191
// #2438)
9292
}
9393

9494
if let ItemKind::Static(ref var_type, _, _) = item.kind {
95-
self.visit_type(var_type, cx, "Statics have by default a `'static` lifetime");
95+
self.visit_type(var_type, cx, "statics have by default a `'static` lifetime");
9696
}
9797
}
9898
}

clippy_lints/src/reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl EarlyLintPass for RefInDeref {
9292
cx,
9393
REF_IN_DEREF,
9494
object.span,
95-
"Creating a reference that is immediately dereferenced.",
95+
"creating a reference that is immediately dereferenced",
9696
"try this",
9797
snippet_with_applicability(cx, inner.span, "_", &mut applicability).to_string(),
9898
applicability,

clippy_lints/src/suspicious_trait_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl {
9898
cx,
9999
SUSPICIOUS_ARITHMETIC_IMPL,
100100
binop.span,
101-
&format!(r#"Suspicious use of binary operator in `{}` impl"#, impl_trait),
101+
&format!("suspicious use of binary operator in `{}` impl", impl_trait),
102102
);
103103
}
104104

@@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl {
135135
cx,
136136
SUSPICIOUS_OP_ASSIGN_IMPL,
137137
binop.span,
138-
&format!(r#"Suspicious use of binary operator in `{}` impl"#, impl_trait),
138+
&format!("suspicious use of binary operator in `{}` impl", impl_trait),
139139
);
140140
}
141141
}

clippy_lints/src/unwrap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
181181
self.cx,
182182
UNNECESSARY_UNWRAP,
183183
expr.span,
184-
&format!("You checked before that `{}()` cannot fail. \
185-
Instead of checking and unwrapping, it's better to use `if let` or `match`.",
184+
&format!("you checked before that `{}()` cannot fail, \
185+
instead of checking and unwrapping, it's better to use `if let` or `match`",
186186
method_name.ident.name),
187187
|diag| { diag.span_label(unwrappable.check.span, "the check is happening here"); },
188188
);
@@ -191,7 +191,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
191191
self.cx,
192192
PANICKING_UNWRAP,
193193
expr.span,
194-
&format!("This call to `{}()` will always panic.",
194+
&format!("this call to `{}()` will always panic",
195195
method_name.ident.name),
196196
|diag| { diag.span_label(unwrappable.check.span, "because of this check"); },
197197
);

clippy_lints/src/utils/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ pub fn get_attr<'a>(
7575
})
7676
.map_or_else(
7777
|| {
78-
sess.span_err(attr_segments[1].ident.span, "Usage of unknown attribute");
78+
sess.span_err(attr_segments[1].ident.span, "usage of unknown attribute");
7979
false
8080
},
8181
|deprecation_status| {
8282
let mut diag =
83-
sess.struct_span_err(attr_segments[1].ident.span, "Usage of deprecated attribute");
83+
sess.struct_span_err(attr_segments[1].ident.span, "usage of deprecated attribute");
8484
match *deprecation_status {
8585
DeprecationStatus::Deprecated => {
8686
diag.emit();

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
412412
Lint {
413413
name: "drop_bounds",
414414
group: "correctness",
415-
desc: "Bounds of the form `T: Drop` are useless",
415+
desc: "bounds of the form `T: Drop` are useless",
416416
deprecation: None,
417417
module: "drop_bounds",
418418
},

tests/ui-toml/functions_maxlines/test.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: This function has a large number of lines.
1+
error: this function has a large number of lines
22
--> $DIR/test.rs:18:1
33
|
44
LL | / fn too_many_lines() {
@@ -9,7 +9,7 @@ LL | | }
99
|
1010
= note: `-D clippy::too-many-lines` implied by `-D warnings`
1111

12-
error: This function has a large number of lines.
12+
error: this function has a large number of lines
1313
--> $DIR/test.rs:38:1
1414
|
1515
LL | / fn comment_before_code() {

tests/ui/bool_comparison.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,25 @@ error: order comparisons between booleans can be simplified
8484
LL | if x > y {
8585
| ^^^^^ help: try simplifying it as shown: `x & !y`
8686

87-
error: This comparison might be written more concisely
87+
error: this comparison might be written more concisely
8888
--> $DIR/bool_comparison.rs:120:8
8989
|
9090
LL | if a == !b {};
9191
| ^^^^^^^ help: try simplifying it as shown: `a != b`
9292

93-
error: This comparison might be written more concisely
93+
error: this comparison might be written more concisely
9494
--> $DIR/bool_comparison.rs:121:8
9595
|
9696
LL | if !a == b {};
9797
| ^^^^^^^ help: try simplifying it as shown: `a != b`
9898

99-
error: This comparison might be written more concisely
99+
error: this comparison might be written more concisely
100100
--> $DIR/bool_comparison.rs:125:8
101101
|
102102
LL | if b == !a {};
103103
| ^^^^^^^ help: try simplifying it as shown: `b != a`
104104

105-
error: This comparison might be written more concisely
105+
error: this comparison might be written more concisely
106106
--> $DIR/bool_comparison.rs:126:8
107107
|
108108
LL | if !b == a {};

tests/ui/builtin-type-shadow.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: This generic shadows the built-in type `u32`
1+
error: this generic shadows the built-in type `u32`
22
--> $DIR/builtin-type-shadow.rs:4:8
33
|
44
LL | fn foo<u32>(a: u32) -> u32 {

0 commit comments

Comments
 (0)