Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix remaining lint messages #5893

Merged
merged 13 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_lints/src/duration_subsec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for DurationSubsec {
cx,
DURATION_SUBSEC,
expr.span,
&format!("Calling `{}()` is more concise than this calculation", suggested_fn),
&format!("calling `{}()` is more concise than this calculation", suggested_fn),
"try",
format!(
"{}.{}()",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
cx,
ENUM_CLIKE_UNPORTABLE_VARIANT,
var.span,
"Clike enum variant discriminant is not portable to 32-bit targets",
"C-like enum variant discriminant is not portable to 32-bit targets",
);
};
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/enum_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ fn check_variant(
&& name.chars().nth(item_name_chars).map_or(false, |c| !c.is_lowercase())
&& name.chars().nth(item_name_chars + 1).map_or(false, |c| !c.is_numeric())
{
span_lint(cx, lint, var.span, "Variant name starts with the enum's name");
span_lint(cx, lint, var.span, "variant name starts with the enum's name");
}
if partial_rmatch(item_name, &name) == item_name_chars {
span_lint(cx, lint, var.span, "Variant name ends with the enum's name");
span_lint(cx, lint, var.span, "variant name ends with the enum's name");
}
}
let first = &def.variants[0].ident.name.as_str();
Expand Down Expand Up @@ -227,7 +227,7 @@ fn check_variant(
cx,
lint,
span,
&format!("All variants have the same {}fix: `{}`", what, value),
&format!("all variants have the same {}fix: `{}`", what, value),
None,
&format!(
"remove the {}fixes and use full paths to \
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/if_let_some_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ impl<'tcx> LateLintPass<'tcx> for OkIfLet {
cx,
IF_LET_SOME_RESULT,
expr.span.with_hi(op.span.hi()),
"Matching on `Some` with `ok()` is redundant",
&format!("Consider matching on `Ok({})` and removing the call to `ok` instead", some_expr_string),
"matching on `Some` with `ok()` is redundant",
&format!("consider matching on `Ok({})` and removing the call to `ok` instead", some_expr_string),
sugg,
applicability,
);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/if_not_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl EarlyLintPass for IfNotElse {
cx,
IF_NOT_ELSE,
item.span,
"Unnecessary boolean `not` operation",
"unnecessary boolean `not` operation",
None,
"remove the `!` and swap the blocks of the `if`/`else`",
);
Expand All @@ -70,7 +70,7 @@ impl EarlyLintPass for IfNotElse {
cx,
IF_NOT_ELSE,
item.span,
"Unnecessary `!=` operation",
"unnecessary `!=` operation",
None,
"change to `==` and swap the blocks of the `if`/`else`",
);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/implicit_saturating_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ fn print_lint_and_sugg(cx: &LateContext<'_>, var_name: &str, expr: &Expr<'_>) {
cx,
IMPLICIT_SATURATING_SUB,
expr.span,
"Implicitly performing saturating subtraction",
"implicitly performing saturating subtraction",
"try",
format!("{} = {}.saturating_sub({});", var_name, var_name, 1.to_string()),
format!("{} = {}.saturating_sub({});", var_name, var_name, '1'),
Applicability::MachineApplicable,
);
}
4 changes: 2 additions & 2 deletions clippy_lints/src/inherent_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
cx,
MULTIPLE_INHERENT_IMPL,
*additional_span,
"Multiple implementations of this structure",
"multiple implementations of this structure",
|diag| {
diag.span_note(*initial_span, "First implementation here");
diag.span_note(*initial_span, "first implementation here");
},
)
})
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/int_plus_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl IntPlusOne {
cx,
INT_PLUS_ONE,
block.span,
"Unnecessary `>= y + 1` or `x - 1 >=`",
"unnecessary `>= y + 1` or `x - 1 >=`",
"change it to",
recommendation,
Applicability::MachineApplicable, // snippet
Expand All @@ -163,8 +163,8 @@ impl IntPlusOne {
impl EarlyLintPass for IntPlusOne {
fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) {
if let ExprKind::Binary(ref kind, ref lhs, ref rhs) = item.kind {
if let Some(ref rec) = Self::check_binop(cx, kind.node, lhs, rhs) {
Self::emit_warning(cx, item, rec.clone());
if let Some(rec) = Self::check_binop(cx, kind.node, lhs, rhs) {
Self::emit_warning(cx, item, rec);
Comment on lines -166 to +167
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, I like the cleanup sneaking in the PR

👍

}
}
}
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
cx,
MAP_CLONE,
root.trim_start(receiver).unwrap(),
"You are needlessly cloning iterator elements",
"Remove the `map` call",
"you are needlessly cloning iterator elements",
"remove the `map` call",
String::new(),
Applicability::MachineApplicable,
)
Expand All @@ -125,8 +125,8 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
cx,
MAP_CLONE,
replace,
"You are using an explicit closure for copying elements",
"Consider calling the dedicated `copied` method",
"you are using an explicit closure for copying elements",
"consider calling the dedicated `copied` method",
format!(
"{}.copied()",
snippet_with_applicability(cx, root, "..", &mut applicability)
Expand All @@ -138,8 +138,8 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
cx,
MAP_CLONE,
replace,
"You are using an explicit closure for cloning elements",
"Consider calling the dedicated `cloned` method",
"you are using an explicit closure for cloning elements",
"consider calling the dedicated `cloned` method",
format!(
"{}.cloned()",
snippet_with_applicability(cx, root, "..", &mut applicability)
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2280,7 +2280,7 @@ fn lint_iter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, iter_
cx,
ITER_NEXT_SLICE,
expr.span,
"Using `.iter().next()` on a Slice without end index.",
"using `.iter().next()` on a Slice without end index",
"try calling",
format!("{}.get({})", snippet_with_applicability(cx, caller_var.span, "..", &mut applicability), start_idx),
applicability,
Expand All @@ -2299,7 +2299,7 @@ fn lint_iter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, iter_
cx,
ITER_NEXT_SLICE,
expr.span,
"Using `.iter().next()` on an array",
"using `.iter().next()` on an array",
"try calling",
format!(
"{}.get(0)",
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/mutex_atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl<'tcx> LateLintPass<'tcx> for Mutex {
let mutex_param = subst.type_at(0);
if let Some(atomic_name) = get_atomic_name(mutex_param) {
let msg = format!(
"Consider using an `{}` instead of a `Mutex` here. If you just want the locking \
behavior and not the internal type, consider using `Mutex<()>`.",
"consider using an `{}` instead of a `Mutex` here; if you just want the locking \
behavior and not the internal type, consider using `Mutex<()>`",
atomic_name
);
match mutex_param.kind {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/stable_sort_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ impl LateLintPass<'_> for StableSortPrimitive {
STABLE_SORT_PRIMITIVE,
expr.span,
format!(
"Use {} instead of {}",
detection.method.unstable_name(),
detection.method.stable_name()
"used {} instead of {}",
detection.method.stable_name(),
detection.method.unstable_name()
)
.as_str(),
"try",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ declare_clippy_lint! {
/// ```
pub USE_SELF,
nursery,
"Unnecessary structure name repetition whereas `Self` is applicable"
"unnecessary structure name repetition whereas `Self` is applicable"
}

declare_lint_pass!(UseSelf => [USE_SELF]);
Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
Lint {
name: "use_self",
group: "nursery",
desc: "Unnecessary structure name repetition whereas `Self` is applicable",
desc: "unnecessary structure name repetition whereas `Self` is applicable",
deprecation: None,
module: "use_self",
},
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/duration_subsec.stderr
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
error: Calling `subsec_millis()` is more concise than this calculation
error: calling `subsec_millis()` is more concise than this calculation
--> $DIR/duration_subsec.rs:10:24
|
LL | let bad_millis_1 = dur.subsec_micros() / 1_000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()`
|
= note: `-D clippy::duration-subsec` implied by `-D warnings`

error: Calling `subsec_millis()` is more concise than this calculation
error: calling `subsec_millis()` is more concise than this calculation
--> $DIR/duration_subsec.rs:11:24
|
LL | let bad_millis_2 = dur.subsec_nanos() / 1_000_000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()`

error: Calling `subsec_micros()` is more concise than this calculation
error: calling `subsec_micros()` is more concise than this calculation
--> $DIR/duration_subsec.rs:16:22
|
LL | let bad_micros = dur.subsec_nanos() / 1_000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()`

error: Calling `subsec_micros()` is more concise than this calculation
error: calling `subsec_micros()` is more concise than this calculation
--> $DIR/duration_subsec.rs:21:13
|
LL | let _ = (&dur).subsec_nanos() / 1_000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()`

error: Calling `subsec_micros()` is more concise than this calculation
error: calling `subsec_micros()` is more concise than this calculation
--> $DIR/duration_subsec.rs:25:13
|
LL | let _ = dur.subsec_nanos() / NANOS_IN_MICRO;
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/enum_clike_unportable_variant.stderr
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:8:5
|
LL | X = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings`

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:15:5
|
LL | X = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:18:5
|
LL | A = 0xFFFF_FFFF,
| ^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:25:5
|
LL | Z = 0xFFFF_FFFF,
| ^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:26:5
|
LL | A = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:28:5
|
LL | C = (i32::MIN as isize) - 1,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:34:5
|
LL | Z = 0xFFFF_FFFF,
| ^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:35:5
|
LL | A = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
error: C-like enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:40:5
|
LL | X = <usize as Trait>::Number,
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/enum_variants.stderr
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
error: Variant name ends with the enum's name
error: variant name ends with the enum's name
--> $DIR/enum_variants.rs:16:5
|
LL | cFoo,
| ^^^^
|
= note: `-D clippy::enum-variant-names` implied by `-D warnings`

error: Variant name starts with the enum's name
error: variant name starts with the enum's name
--> $DIR/enum_variants.rs:27:5
|
LL | FoodGood,
| ^^^^^^^^

error: Variant name starts with the enum's name
error: variant name starts with the enum's name
--> $DIR/enum_variants.rs:28:5
|
LL | FoodMiddle,
| ^^^^^^^^^^

error: Variant name starts with the enum's name
error: variant name starts with the enum's name
--> $DIR/enum_variants.rs:29:5
|
LL | FoodBad,
| ^^^^^^^

error: All variants have the same prefix: `Food`
error: all variants have the same prefix: `Food`
--> $DIR/enum_variants.rs:26:1
|
LL | / enum Food {
Expand All @@ -36,7 +36,7 @@ LL | | }
|
= help: remove the prefixes and use full paths to the variants instead of glob imports

error: All variants have the same prefix: `CallType`
error: all variants have the same prefix: `CallType`
--> $DIR/enum_variants.rs:36:1
|
LL | / enum BadCallType {
Expand All @@ -48,7 +48,7 @@ LL | | }
|
= help: remove the prefixes and use full paths to the variants instead of glob imports

error: All variants have the same prefix: `Constant`
error: all variants have the same prefix: `Constant`
--> $DIR/enum_variants.rs:48:1
|
LL | / enum Consts {
Expand All @@ -60,7 +60,7 @@ LL | | }
|
= help: remove the prefixes and use full paths to the variants instead of glob imports

error: All variants have the same prefix: `With`
error: all variants have the same prefix: `With`
--> $DIR/enum_variants.rs:82:1
|
LL | / enum Seallll {
Expand All @@ -72,7 +72,7 @@ LL | | }
|
= help: remove the prefixes and use full paths to the variants instead of glob imports

error: All variants have the same prefix: `Prefix`
error: all variants have the same prefix: `Prefix`
--> $DIR/enum_variants.rs:88:1
|
LL | / enum NonCaps {
Expand All @@ -84,7 +84,7 @@ LL | | }
|
= help: remove the prefixes and use full paths to the variants instead of glob imports

error: All variants have the same prefix: `With`
error: all variants have the same prefix: `With`
--> $DIR/enum_variants.rs:94:1
|
LL | / pub enum PubSeall {
Expand Down
Loading