Skip to content

Commit

Permalink
Auto merge of #5888 - matthiaskrgr:lints, r=yaahc
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 10, 2020
2 parents 1683189 + 6d0b5e2 commit cc5bfd4
Show file tree
Hide file tree
Showing 49 changed files with 193 additions and 206 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::as
cx,
EMPTY_LINE_AFTER_OUTER_ATTR,
begin_of_attr_to_item,
"Found an empty line after an outer attribute. \
"found an empty line after an outer attribute. \
Perhaps you forgot to add a `!` to make it an inner attribute?",
);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
cx,
NAIVE_BYTECOUNT,
expr.span,
"You appear to be counting bytes the naive way",
"Consider using the bytecount crate",
"you appear to be counting bytes the naive way",
"consider using the bytecount crate",
format!("bytecount::count({}, {})",
snippet_with_applicability(cx, haystack.span, "..", &mut applicability),
snippet_with_applicability(cx, needle.span, "..", &mut applicability)),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/checked_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for CheckedConversions {
cx,
CHECKED_CONVERSIONS,
item.span,
"Checked cast can be simplified.",
"checked cast can be simplified",
"try",
format!("{}::try_from({}).is_ok()", to_type, snippet),
applicability,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default_trait_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultTraitAccess {
cx,
DEFAULT_TRAIT_ACCESS,
expr.span,
&format!("Calling `{}` is more clear than this expression", replacement),
&format!("calling `{}` is more clear than this expression", replacement),
"try",
replacement,
Applicability::Unspecified, // First resolve the TODO above
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/double_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'tcx> DoubleComparisons {
cx,
DOUBLE_COMPARISONS,
span,
"This binary expression can be simplified",
"this binary expression can be simplified",
"try",
sugg,
applicability,
Expand Down
23 changes: 5 additions & 18 deletions clippy_lints/src/double_parens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,28 @@ impl EarlyLintPass for DoubleParens {
return;
}

let msg: &str = "consider removing unnecessary double parentheses";

match expr.kind {
ExprKind::Paren(ref in_paren) => match in_paren.kind {
ExprKind::Paren(_) | ExprKind::Tup(_) => {
span_lint(
cx,
DOUBLE_PARENS,
expr.span,
"Consider removing unnecessary double parentheses",
);
span_lint(cx, DOUBLE_PARENS, expr.span, &msg);
},
_ => {},
},
ExprKind::Call(_, ref params) => {
if params.len() == 1 {
let param = &params[0];
if let ExprKind::Paren(_) = param.kind {
span_lint(
cx,
DOUBLE_PARENS,
param.span,
"Consider removing unnecessary double parentheses",
);
span_lint(cx, DOUBLE_PARENS, param.span, &msg);
}
}
},
ExprKind::MethodCall(_, ref params, _) => {
if params.len() == 2 {
let param = &params[1];
if let ExprKind::Paren(_) = param.kind {
span_lint(
cx,
DOUBLE_PARENS,
param.span,
"Consider removing unnecessary double parentheses",
);
span_lint(cx, DOUBLE_PARENS, param.span, &msg);
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/drop_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ declare_clippy_lint! {
/// ```
pub DROP_BOUNDS,
correctness,
"Bounds of the form `T: Drop` are useless"
"bounds of the form `T: Drop` are useless"
}

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

declare_lint_pass!(DropBounds => [DROP_BOUNDS]);

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl<'tcx> Functions {
}

if line_count > self.max_lines {
span_lint(cx, TOO_MANY_LINES, span, "This function has a large number of lines.")
span_lint(cx, TOO_MANY_LINES, span, "this function has a large number of lines")
}
}

Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/misc_early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
BUILTIN_TYPE_SHADOW,
param.ident.span,
&format!("This generic shadows the built-in type `{}`", name),
&format!("this generic shadows the built-in type `{}`", name),
);
}
}
Expand All @@ -298,9 +298,9 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
UNNEEDED_FIELD_PATTERN,
pat.span,
"All the struct fields are matched to a wildcard pattern, consider using `..`.",
"all the struct fields are matched to a wildcard pattern, consider using `..`",
None,
&format!("Try with `{} {{ .. }}` instead", type_name),
&format!("try with `{} {{ .. }}` instead", type_name),
);
return;
}
Expand All @@ -313,7 +313,7 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
UNNEEDED_FIELD_PATTERN,
field.span,
"You matched a field with a wildcard pattern. Consider using `..` instead",
"you matched a field with a wildcard pattern, consider using `..` instead",
);
} else {
let mut normal = vec![];
Expand All @@ -333,10 +333,10 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
UNNEEDED_FIELD_PATTERN,
field.span,
"You matched a field with a wildcard pattern. Consider using `..` \
"you matched a field with a wildcard pattern, consider using `..` \
instead",
None,
&format!("Try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")),
&format!("try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ fn check_comparison<'a, 'tcx>(
cx,
BOOL_COMPARISON,
e.span,
"This comparison might be written more concisely",
"this comparison might be written more concisely",
"try simplifying it as shown",
format!(
"{} != {}",
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/neg_cmp_op_on_partial_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
cx,
NEG_CMP_OP_ON_PARTIAL_ORD,
expr.span,
"The use of negated comparison operators on partially ordered \
types produces code that is hard to read and refactor. Please \
"the use of negated comparison operators on partially ordered \
types produces code that is hard to read and refactor, please \
consider using the `partial_cmp` method instead, to make it \
clear that the two values could be incomparable."
clear that the two values could be incomparable"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/neg_multiply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) {
if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.typeck_results().expr_ty_opt(lit));
if cx.typeck_results().expr_ty(exp).is_integral();
then {
span_lint(cx, NEG_MULTIPLY, span, "Negation by multiplying with `-1`");
span_lint(cx, NEG_MULTIPLY, span, "negation by multiplying with `-1`");
}
}
}
8 changes: 4 additions & 4 deletions clippy_lints/src/overflow_check_conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
if let BinOpKind::Lt = op.node {
if let BinOpKind::Add = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C overflow conditions that will fail in Rust.");
"you are trying to use classic C overflow conditions that will fail in Rust");
}
}
if let BinOpKind::Gt = op.node {
if let BinOpKind::Sub = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C underflow conditions that will fail in Rust.");
"you are trying to use classic C underflow conditions that will fail in Rust");
}
}
}
Expand All @@ -67,13 +67,13 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
if let BinOpKind::Gt = op.node {
if let BinOpKind::Add = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C overflow conditions that will fail in Rust.");
"you are trying to use classic C overflow conditions that will fail in Rust");
}
}
if let BinOpKind::Lt = op.node {
if let BinOpKind::Sub = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C underflow conditions that will fail in Rust.");
"you are trying to use classic C underflow conditions that will fail in Rust");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/path_buf_push_overwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for PathBufPushOverwrite {
cx,
PATH_BUF_PUSH_OVERWRITE,
lit.span,
"Calling `push` with '/' or '\\' (file system root) will overwrite the previous path definition",
"calling `push` with '/' or '\\' (file system root) will overwrite the previous path definition",
"try",
format!("\"{}\"", pushed_path_lit.trim_start_matches(|c| c == '/' || c == '\\')),
Applicability::MachineApplicable,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
cx,
CMP_NULL,
expr.span,
"Comparing with null is better expressed by the `.is_null()` method",
"comparing with null is better expressed by the `.is_null()` method",
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for Ranges {
span_lint(cx,
RANGE_ZIP_WITH_LEN,
expr.span,
&format!("It is more idiomatic to use `{}.iter().enumerate()`",
&format!("it is more idiomatic to use `{}.iter().enumerate()`",
snippet(cx, iter_args[0].span, "_")));
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/redundant_static_lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ impl EarlyLintPass for RedundantStaticLifetimes {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if !item.span.from_expansion() {
if let ItemKind::Const(_, ref var_type, _) = item.kind {
self.visit_type(var_type, cx, "Constants have by default a `'static` lifetime");
self.visit_type(var_type, cx, "constants have by default a `'static` lifetime");
// Don't check associated consts because `'static` cannot be elided on those (issue
// #2438)
}

if let ItemKind::Static(ref var_type, _, _) = item.kind {
self.visit_type(var_type, cx, "Statics have by default a `'static` lifetime");
self.visit_type(var_type, cx, "statics have by default a `'static` lifetime");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl EarlyLintPass for RefInDeref {
cx,
REF_IN_DEREF,
object.span,
"Creating a reference that is immediately dereferenced.",
"creating a reference that is immediately dereferenced",
"try this",
snippet_with_applicability(cx, inner.span, "_", &mut applicability).to_string(),
applicability,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/suspicious_trait_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl {
cx,
SUSPICIOUS_ARITHMETIC_IMPL,
binop.span,
&format!(r#"Suspicious use of binary operator in `{}` impl"#, impl_trait),
&format!("suspicious use of binary operator in `{}` impl", impl_trait),
);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl {
cx,
SUSPICIOUS_OP_ASSIGN_IMPL,
binop.span,
&format!(r#"Suspicious use of binary operator in `{}` impl"#, impl_trait),
&format!("suspicious use of binary operator in `{}` impl", impl_trait),
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
self.cx,
UNNECESSARY_UNWRAP,
expr.span,
&format!("You checked before that `{}()` cannot fail. \
Instead of checking and unwrapping, it's better to use `if let` or `match`.",
&format!("you checked before that `{}()` cannot fail, \
instead of checking and unwrapping, it's better to use `if let` or `match`",
method_name.ident.name),
|diag| { diag.span_label(unwrappable.check.span, "the check is happening here"); },
);
Expand All @@ -191,7 +191,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
self.cx,
PANICKING_UNWRAP,
expr.span,
&format!("This call to `{}()` will always panic.",
&format!("this call to `{}()` will always panic",
method_name.ident.name),
|diag| { diag.span_label(unwrappable.check.span, "because of this check"); },
);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ pub fn get_attr<'a>(
})
.map_or_else(
|| {
sess.span_err(attr_segments[1].ident.span, "Usage of unknown attribute");
sess.span_err(attr_segments[1].ident.span, "usage of unknown attribute");
false
},
|deprecation_status| {
let mut diag =
sess.struct_span_err(attr_segments[1].ident.span, "Usage of deprecated attribute");
sess.struct_span_err(attr_segments[1].ident.span, "usage of deprecated attribute");
match *deprecation_status {
DeprecationStatus::Deprecated => {
diag.emit();
Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
Lint {
name: "drop_bounds",
group: "correctness",
desc: "Bounds of the form `T: Drop` are useless",
desc: "bounds of the form `T: Drop` are useless",
deprecation: None,
module: "drop_bounds",
},
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-toml/functions_maxlines/test.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: This function has a large number of lines.
error: this function has a large number of lines
--> $DIR/test.rs:18:1
|
LL | / fn too_many_lines() {
Expand All @@ -9,7 +9,7 @@ LL | | }
|
= note: `-D clippy::too-many-lines` implied by `-D warnings`

error: This function has a large number of lines.
error: this function has a large number of lines
--> $DIR/test.rs:38:1
|
LL | / fn comment_before_code() {
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/bool_comparison.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,25 @@ error: order comparisons between booleans can be simplified
LL | if x > y {
| ^^^^^ help: try simplifying it as shown: `x & !y`

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

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

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

error: This comparison might be written more concisely
error: this comparison might be written more concisely
--> $DIR/bool_comparison.rs:126:8
|
LL | if !b == a {};
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/builtin-type-shadow.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: This generic shadows the built-in type `u32`
error: this generic shadows the built-in type `u32`
--> $DIR/builtin-type-shadow.rs:4:8
|
LL | fn foo<u32>(a: u32) -> u32 {
Expand Down
Loading

0 comments on commit cc5bfd4

Please sign in to comment.