diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index f0a2ebfcf..e2de7f829 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -209,7 +209,7 @@ fn lint_misrefactored_assign_op( db.span_suggestion( expr.span, &format!( - "Did you mean {} = {} {} {} or {}? Consider replacing it with", + "Did you mean `{} = {} {} {}` or `{}`? Consider replacing it with", snip_a, snip_a, op.node.as_str(), diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index ff5688f5b..2939a71a5 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -449,7 +449,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib EMPTY_LINE_AFTER_OUTER_ATTR, begin_of_attr_to_item, "Found an empty line after an outer attribute. \ - Perhaps you forgot to add a '!' to make it an inner attribute?", + Perhaps you forgot to add a `!` to make it an inner attribute?", ); } } @@ -520,7 +520,7 @@ impl EarlyLintPass for DeprecatedCfgAttribute { cx, DEPRECATED_CFG_ATTR, attr.span, - "`cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes", + "`cfg_attr` is deprecated for rustfmt and got replaced by `tool_attributes`", "use", "#[rustfmt::skip]".to_string(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index 2224054af..76b5c5d8f 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -68,8 +68,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> { } const BRACED_EXPR_MESSAGE: &str = "omit braces around single expression condition"; -const COMPLEX_BLOCK_MESSAGE: &str = "in an 'if' condition, avoid complex blocks or closures with blocks; \ - instead, move the block or closure higher and bind it with a 'let'"; +const COMPLEX_BLOCK_MESSAGE: &str = "in an `if` condition, avoid complex blocks or closures with blocks; \ + instead, move the block or closure higher and bind it with a `let`"; impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 0fd0abdc3..e34dfc9d9 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -138,7 +138,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: & if expr.span.ctxt() != inner.span.ctxt() { return; } - span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this if statement can be collapsed", |db| { + span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |db| { let lhs = Sugg::ast(cx, check, ".."); let rhs = Sugg::ast(cx, check_inner, ".."); db.span_suggestion( diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index c4778c6cf..5d0428657 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -38,7 +38,7 @@ declare_clippy_lint! { /// ``` pub IFS_SAME_COND, correctness, - "consecutive `ifs` with the same condition" + "consecutive `if`s with the same condition" } declare_clippy_lint! { @@ -85,7 +85,7 @@ declare_clippy_lint! { /// ``` pub SAME_FUNCTIONS_IN_IF_CONDITION, pedantic, - "consecutive `ifs` with the same function call" + "consecutive `if`s with the same function call" } declare_clippy_lint! { @@ -106,7 +106,7 @@ declare_clippy_lint! { /// ``` pub IF_SAME_THEN_ELSE, correctness, - "if with the same *then* and *else* blocks" + "`if` with the same `then` and `else` blocks" } declare_clippy_lint! { @@ -206,7 +206,7 @@ fn lint_same_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) { cx, IFS_SAME_COND, j.span, - "this `if` has the same condition as a previous if", + "this `if` has the same condition as a previous `if`", i.span, "same as this", ); @@ -234,7 +234,7 @@ fn lint_same_fns_in_if_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) { cx, SAME_FUNCTIONS_IN_IF_CONDITION, j.span, - "this `if` has the same function call as a previous if", + "this `if` has the same function call as a previous `if`", i.span, "same as this", ); @@ -300,7 +300,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) { db.span_note( i.body.span, &format!( - "`{}` has the same arm body as the `_` wildcard, consider removing it`", + "`{}` has the same arm body as the `_` wildcard, consider removing it", lhs ), ); diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index 62f80ef76..253d9b8d5 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -26,7 +26,7 @@ declare_clippy_lint! { /// ``` pub DEFAULT_TRAIT_ACCESS, pedantic, - "checks for literal calls to Default::default()" + "checks for literal calls to `Default::default()`" } declare_lint_pass!(DefaultTraitAccess => [DEFAULT_TRAIT_ACCESS]); @@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, '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 diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 324c3f309..d8ce2fcf6 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -102,9 +102,9 @@ const DROP_REF_SUMMARY: &str = "calls to `std::mem::drop` with a reference inste Dropping a reference does nothing."; const FORGET_REF_SUMMARY: &str = "calls to `std::mem::forget` with a reference instead of an owned value. \ Forgetting a reference does nothing."; -const DROP_COPY_SUMMARY: &str = "calls to `std::mem::drop` with a value that implements Copy. \ +const DROP_COPY_SUMMARY: &str = "calls to `std::mem::drop` with a value that implements `Copy`. \ Dropping a copy leaves the original intact."; -const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements Copy. \ +const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements `Copy`. \ Forgetting a copy leaves the original intact."; declare_lint_pass!(DropForgetRef => [DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY]); @@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef { expr.span, &msg, arg.span, - &format!("argument has type {}", arg_ty)); + &format!("argument has type `{}`", arg_ty)); } else if is_copy(cx, arg_ty) { if match_def_path(cx, def_id, &paths::DROP) { lint = DROP_COPY; diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 9e8ab0b29..8043a8c85 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -43,7 +43,7 @@ declare_clippy_lint! { /// ``` pub ELSE_IF_WITHOUT_ELSE, restriction, - "if expression with an `else if`, but without a final `else` branch" + "`if` expression with an `else if`, but without a final `else` branch" } declare_lint_pass!(ElseIfWithoutElse => [ELSE_IF_WITHOUT_ELSE]); @@ -60,7 +60,7 @@ impl EarlyLintPass for ElseIfWithoutElse { cx, ELSE_IF_WITHOUT_ELSE, els.span, - "if expression with an `else if`, but without a final `else`", + "`if` expression with an `else if`, but without a final `else`", "add an `else` block here", ); } diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 28b4760f0..bd0e1ab29 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -46,9 +46,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessFormat { // Operate on the only argument of `alloc::fmt::format`. if let Some(sugg) = on_new_v1(cx, expr) { - span_useless_format(cx, span, "consider using .to_string()", sugg); + span_useless_format(cx, span, "consider using `.to_string()`", sugg); } else if let Some(sugg) = on_new_v1_fmt(cx, expr) { - span_useless_format(cx, span, "consider using .to_string()", sugg); + span_useless_format(cx, span, "consider using `.to_string()`", sugg); } } } diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index 7019cfa8c..a266d7c24 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -61,7 +61,7 @@ impl EarlyLintPass for IfNotElse { IF_NOT_ELSE, item.span, "Unnecessary boolean `not` operation", - "remove the `!` and swap the blocks of the if/else", + "remove the `!` and swap the blocks of the `if`/`else`", ); }, ExprKind::Binary(ref kind, _, _) if kind.node == BinOpKind::Ne => { @@ -70,7 +70,7 @@ impl EarlyLintPass for IfNotElse { IF_NOT_ELSE, item.span, "Unnecessary `!=` operation", - "change to `==` and swap the blocks of the if/else", + "change to `==` and swap the blocks of the `if`/`else`", ); }, _ => (), diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index f5633d51a..7ea329fae 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -51,7 +51,7 @@ fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str) let outer_span = outer_span.source_callsite(); let inner_span = inner_span.source_callsite(); - span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing return statement", |db| { + span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing `return` statement", |db| { if let Some(snippet) = snippet_opt(cx, inner_span) { db.span_suggestion( outer_span, @@ -102,7 +102,7 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr<'_>) { expr_match(cx, &arm.body); } } else { - expr_match(cx, &arms.first().expect("if let doesn't have a single arm").body); + expr_match(cx, &arms.first().expect("`if let` doesn't have a single arm").body); } }, // skip if it already has a return statement diff --git a/clippy_lints/src/infallible_destructuring_match.rs b/clippy_lints/src/infallible_destructuring_match.rs index c75aa8a30..d70b45eae 100644 --- a/clippy_lints/src/infallible_destructuring_match.rs +++ b/clippy_lints/src/infallible_destructuring_match.rs @@ -38,7 +38,7 @@ declare_clippy_lint! { /// ``` pub INFALLIBLE_DESTRUCTURING_MATCH, style, - "a match statement with a single infallible arm instead of a `let`" + "a `match` statement with a single infallible arm instead of a `let`" } declare_lint_pass!(InfallibleDestructingMatch => [INFALLIBLE_DESTRUCTURING_MATCH]); @@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InfallibleDestructingMatch { cx, INFALLIBLE_DESTRUCTURING_MATCH, local.span, - "you seem to be trying to use match to destructure a single infallible pattern. \ + "you seem to be trying to use `match` to destructure a single infallible pattern. \ Consider using `let`", "try this", format!( diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 01e81762b..9d7c3b46f 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -88,7 +88,7 @@ declare_clippy_lint! { /// ``` pub INHERENT_TO_STRING_SHADOW_DISPLAY, correctness, - "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait " + "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait" } declare_lint_pass!(InherentToString => [INHERENT_TO_STRING, INHERENT_TO_STRING_SHADOW_DISPLAY]); diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 9a039929e..d9dd13923 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -32,7 +32,7 @@ declare_clippy_lint! { /// ``` pub INT_PLUS_ONE, complexity, - "instead of using x >= y + 1, use x > y" + "instead of using `x >= y + 1`, use `x > y`" } declare_lint_pass!(IntPlusOne => [INT_PLUS_ONE]); diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index 86abf72e0..eef583a6e 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeStackArrays { self.maximum_allowed_size ), &format!( - "consider allocating on the heap with vec!{}.into_boxed_slice()", + "consider allocating on the heap with `vec!{}.into_boxed_slice()`", snippet(cx, expr.span, "[...]") ), ); diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index f75711a28..7787a55a2 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -27,7 +27,7 @@ declare_clippy_lint! { /// ``` pub LET_UNDERSCORE_MUST_USE, restriction, - "non-binding let on a #[must_use] expression" + "non-binding let on a `#[must_use]` expression" } declare_lint_pass!(LetUnderscore => [LET_UNDERSCORE_MUST_USE]); @@ -44,7 +44,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnderscore { cx, LET_UNDERSCORE_MUST_USE, stmt.span, - "non-binding let on an expression with #[must_use] type", + "non-binding let on an expression with `#[must_use]` type", "consider explicitly using expression value" ) } else if is_must_use_func_call(cx, init) { @@ -52,7 +52,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnderscore { cx, LET_UNDERSCORE_MUST_USE, stmt.span, - "non-binding let on a result of a #[must_use] function", + "non-binding let on a result of a `#[must_use]` function", "consider explicitly using function result" ) } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index acff3e2f7..d63255408 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1353,7 +1353,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat<'_>, arg: &Expr<'_>, e EXPLICIT_INTO_ITER_LOOP, arg.span, "it is more concise to loop over containers instead of using explicit \ - iteration methods`", + iteration methods", "to write this more concisely, try", object.to_string(), applicability, diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 0c66ce5dd..ae2d08301 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -112,7 +112,7 @@ fn lint_needless_cloning(cx: &LateContext<'_, '_>, root: Span, receiver: Span) { MAP_CLONE, root.trim_start(receiver).unwrap(), "You are needlessly cloning iterator elements", - "Remove the map call", + "Remove the `map` call", String::new(), Applicability::MachineApplicable, ) diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index d0164e5e2..3855b5a21 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -48,7 +48,7 @@ declare_clippy_lint! { /// ``` pub OPTION_MAP_UNIT_FN, complexity, - "using `option.map(f)`, where f is a function or closure that returns ()" + "using `option.map(f)`, where `f` is a function or closure that returns `()`" } declare_clippy_lint! { @@ -89,7 +89,7 @@ declare_clippy_lint! { /// ``` pub RESULT_MAP_UNIT_FN, complexity, - "using `result.map(f)`, where f is a function or closure that returns ()" + "using `result.map(f)`, where `f` is a function or closure that returns `()`" } declare_lint_pass!(MapUnit => [OPTION_MAP_UNIT_FN, RESULT_MAP_UNIT_FN]); @@ -199,7 +199,7 @@ fn let_binding_name(cx: &LateContext<'_, '_>, var_arg: &hir::Expr<'_>) -> String #[must_use] fn suggestion_msg(function_type: &str, map_type: &str) -> String { format!( - "called `map(f)` on an {0} value where `f` is a unit {1}", + "called `map(f)` on an `{0}` value where `f` is a unit {1}", map_type, function_type ) } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 476051500..3200de1cf 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -37,7 +37,7 @@ declare_clippy_lint! { /// ``` pub SINGLE_MATCH, style, - "a match statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`" + "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`" } declare_clippy_lint! { @@ -76,7 +76,7 @@ declare_clippy_lint! { /// ``` pub SINGLE_MATCH_ELSE, pedantic, - "a match statement with two arms where the second arm's pattern is a placeholder instead of a specific match pattern" + "a `match` statement with two arms where the second arm's pattern is a placeholder instead of a specific match pattern" } declare_clippy_lint! { @@ -99,7 +99,7 @@ declare_clippy_lint! { /// ``` pub MATCH_REF_PATS, style, - "a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression" + "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression" } declare_clippy_lint! { @@ -133,7 +133,7 @@ declare_clippy_lint! { /// ``` pub MATCH_BOOL, style, - "a match on a boolean expression instead of an `if..else` block" + "a `match` on a boolean expression instead of an `if..else` block" } declare_clippy_lint! { @@ -155,7 +155,7 @@ declare_clippy_lint! { /// ``` pub MATCH_OVERLAPPING_ARM, style, - "a match with overlapping arms" + "a `match` with overlapping arms" } declare_clippy_lint! { @@ -177,7 +177,7 @@ declare_clippy_lint! { /// ``` pub MATCH_WILD_ERR_ARM, style, - "a match with `Err(_)` arm and take drastic actions" + "a `match` with `Err(_)` arm and take drastic actions" } declare_clippy_lint! { @@ -198,7 +198,7 @@ declare_clippy_lint! { /// ``` pub MATCH_AS_REF, complexity, - "a match on an Option value instead of using `as_ref()` or `as_mut`" + "a `match` on an Option value instead of using `as_ref()` or `as_mut`" } declare_clippy_lint! { @@ -407,7 +407,7 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>], e if let Some(sugg) = sugg { db.span_suggestion( expr.span, - "consider using an if/else expression", + "consider using an `if`/`else` expression", sugg, Applicability::HasPlaceholders, ); @@ -461,10 +461,10 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>]) span_note_and_lint(cx, MATCH_WILD_ERR_ARM, arm.pat.span, - "Err(_) will match all errors, maybe not a good idea", + "`Err(_)` will match all errors, maybe not a good idea", arm.pat.span, "to remove this warning, match each error separately \ - or use unreachable macro"); + or use `unreachable!` macro"); } } } @@ -650,7 +650,7 @@ fn check_match_as_ref(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>], cx, MATCH_AS_REF, expr.span, - &format!("use {}() instead", suggestion), + &format!("use `{}()` instead", suggestion), "try this", format!( "{}.{}(){}", diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index 22797c3b7..636c0f975 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -25,7 +25,7 @@ declare_clippy_lint! { /// ``` pub MEM_DISCRIMINANT_NON_ENUM, correctness, - "calling mem::descriminant on non-enum type" + "calling `mem::descriminant` on non-enum type" } declare_lint_pass!(MemDiscriminant => [MEM_DISCRIMINANT_NON_ENUM]); diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index 974f6419e..4172ea339 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget { let forgot_ty = cx.tables.expr_ty(&args[0]); if forgot_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) { - span_lint(cx, MEM_FORGET, e.span, "usage of mem::forget on Drop type"); + span_lint(cx, MEM_FORGET, e.span, "usage of `mem::forget` on `Drop` type"); } } } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index c33dae6c2..419522f0d 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1828,7 +1828,7 @@ fn lint_clone_on_ref_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, arg: &h cx, CLONE_ON_REF_PTR, expr.span, - "using '.clone()' on a ref-counted pointer", + "using `.clone()` on a ref-counted pointer", "try this", format!( "{}::<{}>::clone(&{})", @@ -2220,8 +2220,8 @@ fn lint_unwrap(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, unwrap_args: &[hi lint, expr.span, &format!( - "used unwrap() on {} value. If you don't want to handle the {} case gracefully, consider \ - using expect() to provide a better panic \ + "used `unwrap()` on `{}` value. If you don't want to handle the `{}` case gracefully, consider \ + using `expect()` to provide a better panic \ message", kind, none_value ), @@ -2247,7 +2247,7 @@ fn lint_expect(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, expect_args: &[hi lint, expr.span, &format!( - "used expect() on {} value. If this value is an {} it will panic", + "used `expect()` on `{}` value. If this value is an `{}` it will panic", kind, none_value ), ); @@ -2268,7 +2268,7 @@ fn lint_ok_expect(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, ok_args: &[hir cx, OK_EXPECT, expr.span, - "called `ok().expect()` on a Result value. You can call `expect` directly on the `Result`", + "called `ok().expect()` on a `Result` value. You can call `expect()` directly on the `Result`", ); } } @@ -2286,7 +2286,7 @@ fn lint_map_flatten<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr< span_lint_and_then(cx, MAP_FLATTEN, expr.span, msg, |db| { db.span_suggestion( expr.span, - "try using flat_map instead", + "try using `flat_map` instead", hint, Applicability::MachineApplicable, ); @@ -2320,10 +2320,10 @@ fn lint_map_unwrap_or_else<'a, 'tcx>( // lint message let msg = if is_option { - "called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling \ + "called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling \ `map_or_else(g, f)` instead" } else { - "called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling \ + "called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling \ `.map_or_else(g, f)` instead" }; // get snippets for args to map() and unwrap_or_else() @@ -2380,7 +2380,7 @@ fn lint_map_or_none<'a, 'tcx>( if map_or_arg_is_none { // lint message - let msg = "called `map_or(None, f)` on an Option value. This can be done more directly by calling \ + let msg = "called `map_or(None, f)` on an `Option` value. This can be done more directly by calling \ `and_then(f)` instead"; let map_or_self_snippet = snippet(cx, map_or_args[0].span, ".."); let map_or_func_snippet = snippet(cx, map_or_args[2].span, ".."); @@ -2388,7 +2388,7 @@ fn lint_map_or_none<'a, 'tcx>( span_lint_and_then(cx, OPTION_MAP_OR_NONE, expr.span, msg, |db| { db.span_suggestion( expr.span, - "try using and_then instead", + "try using `and_then` instead", hint, Applicability::MachineApplicable, // snippet ); @@ -2860,7 +2860,7 @@ fn lint_single_char_pattern<'a, 'tcx>( SINGLE_CHAR_PATTERN, arg.span, "single-character string constant used as pattern", - "try using a char instead", + "try using a `char` instead", hint, applicability, ); @@ -2928,7 +2928,7 @@ fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, self_ref_ty: T INTO_ITER_ON_REF, method_span, &format!( - "this .into_iter() call is equivalent to .{}() and will not move the {}", + "this `.into_iter()` call is equivalent to `.{}()` and will not move the `{}`", method_name, kind, ), "call directly", diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index c9cb17e96..f440d8645 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -60,7 +60,7 @@ pub(super) fn lint<'a, 'tcx>( "map_or(a, f)" }; let msg = &format!( - "called `map(f).unwrap_or({})` on an Option value. \ + "called `map(f).unwrap_or({})` on an `Option` value. \ This can be done more directly by calling `{}` instead", arg, suggest ); diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 4e2948620..749f6b925 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MinMaxPass { cx, MIN_MAX, expr.span, - "this min/max combination leads to constant result", + "this `min`/`max` combination leads to constant result", ); }, } diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 202fb4cdc..6fd83cf6a 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -63,7 +63,7 @@ declare_clippy_lint! { /// ``` pub CMP_NAN, correctness, - "comparisons to NAN, which will always return false, probably not intended" + "comparisons to `NAN`, which will always return false, probably not intended" } declare_clippy_lint! { @@ -194,7 +194,7 @@ declare_clippy_lint! { /// ``` pub ZERO_PTR, style, - "using 0 as *{const, mut} T" + "using `0 as *{const, mut} T`" } declare_clippy_lint! { @@ -370,9 +370,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { } } let (lint, msg) = if is_named_constant(cx, left) || is_named_constant(cx, right) { - (FLOAT_CMP_CONST, "strict comparison of f32 or f64 constant") + (FLOAT_CMP_CONST, "strict comparison of `f32` or `f64` constant") } else { - (FLOAT_CMP, "strict comparison of f32 or f64") + (FLOAT_CMP, "strict comparison of `f32` or `f64`") }; span_lint_and_then(cx, lint, expr.span, msg, |db| { let lhs = Sugg::hir(cx, left, ".."); @@ -388,7 +388,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { ), Applicability::HasPlaceholders, // snippet ); - db.span_note(expr.span, "std::f32::EPSILON and std::f64::EPSILON are available."); + db.span_note(expr.span, "`std::f32::EPSILON` and `std::f64::EPSILON` are available."); }); } else if op == BinOpKind::Rem && is_integer_const(cx, right, 1) { span_lint(cx, MODULO_ONE, expr.span, "any number modulo 1 will be 0"); @@ -456,7 +456,7 @@ fn check_nan(cx: &LateContext<'_, '_>, expr: &Expr<'_>, cmp_expr: &Expr<'_>) { cx, CMP_NAN, cmp_expr.span, - "doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead", + "doomed comparison with `NAN`, use `std::{f32,f64}::is_nan()` instead", ); } } diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 980812c9e..cdd9e5a90 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingConstForFn { cx.tcx.sess.span_err(span, &err); } } else { - span_lint(cx, MISSING_CONST_FOR_FN, span, "this could be a const_fn"); + span_lint(cx, MISSING_CONST_FOR_FN, span, "this could be a `const_fn`"); } } } diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 1ad3dff53..c25131c52 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -54,7 +54,7 @@ declare_clippy_lint! { /// ``` pub MISSING_INLINE_IN_PUBLIC_ITEMS, restriction, - "detects missing #[inline] attribute for public callables (functions, trait methods, methods...)" + "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)" } fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, attrs: &[ast::Attribute], sp: Span, desc: &'static str) { diff --git a/clippy_lints/src/mul_add.rs b/clippy_lints/src/mul_add.rs index 1f4f0d53c..27f598c14 100644 --- a/clippy_lints/src/mul_add.rs +++ b/clippy_lints/src/mul_add.rs @@ -75,7 +75,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MulAddCheck { cx, MANUAL_MUL_ADD, expr.span, - "consider using mul_add() for better numerical precision", + "consider using `mul_add()` for better numerical precision", "try", format!( "{}.mul_add({}, {})", @@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MulAddCheck { cx, MANUAL_MUL_ADD, expr.span, - "consider using mul_add() for better numerical precision", + "consider using `mul_add()` for better numerical precision", "try", format!( "{}.mul_add({}, {})", diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 367f8638d..a64467ef6 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -47,7 +47,7 @@ declare_clippy_lint! { /// ``` pub MUTABLE_KEY_TYPE, correctness, - "Check for mutable Map/Set key type" + "Check for mutable `Map`/`Set` key type" } declare_lint_pass!(MutableKeyType => [ MUTABLE_KEY_TYPE ]); diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index fb3c767ca..e04bd56e0 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -63,8 +63,8 @@ impl<'a, 'tcx> LateLintPass<'a, '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 \ - behaviour 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 { diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index c11e6bf25..78c121b6d 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { _ => (), } } else { - panic!("IfExpr 'then' node is not an ExprKind::Block"); + panic!("IfExpr `then` node is not an `ExprKind::Block`"); } } } diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index e5ba77d21..f35b84c44 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -274,15 +274,15 @@ struct LintData<'a> { block_stmts: &'a [ast::Stmt], } -const MSG_REDUNDANT_ELSE_BLOCK: &str = "This else block is redundant.\n"; +const MSG_REDUNDANT_ELSE_BLOCK: &str = "This `else` block is redundant.\n"; const MSG_ELSE_BLOCK_NOT_NEEDED: &str = "There is no need for an explicit `else` block for this `if` \ expression\n"; -const DROP_ELSE_BLOCK_AND_MERGE_MSG: &str = "Consider dropping the else clause and merging the code that \ - follows (in the loop) with the if block, like so:\n"; +const DROP_ELSE_BLOCK_AND_MERGE_MSG: &str = "Consider dropping the `else` clause and merging the code that \ + follows (in the loop) with the `if` block, like so:\n"; -const DROP_ELSE_BLOCK_MSG: &str = "Consider dropping the else clause, and moving out the code in the else \ +const DROP_ELSE_BLOCK_MSG: &str = "Consider dropping the `else` clause, and moving out the code in the `else` \ block, like so:\n"; fn emit_warning<'a>(ctx: &EarlyContext<'_>, data: &'a LintData<'_>, header: &str, typ: LintType) { diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index c580715a1..2a58f6c3d 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -206,7 +206,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { if let ty::Adt(def, ..) = ty.kind { if let Some(span) = cx.tcx.hir().span_if_local(def.did) { if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() { - db.span_help(span, "consider marking this type as Copy"); + db.span_help(span, "consider marking this type as `Copy`"); } } } diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 9757d1c01..6e77a7a77 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -21,7 +21,7 @@ declare_clippy_lint! { /// ``` pub NEG_MULTIPLY, style, - "multiplying integers with -1" + "multiplying integers with `-1`" } declare_lint_pass!(NegMultiply => [NEG_MULTIPLY]); @@ -48,7 +48,7 @@ fn check_mul(cx: &LateContext<'_, '_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_ if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.tables.expr_ty_opt(lit)); if cx.tables.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`"); } } } diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 039de766c..6ffad405c 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -49,7 +49,7 @@ declare_clippy_lint! { /// ``` pub DECLARE_INTERIOR_MUTABLE_CONST, correctness, - "declaring const with interior mutability" + "declaring `const` with interior mutability" } declare_clippy_lint! { @@ -81,7 +81,7 @@ declare_clippy_lint! { /// ``` pub BORROW_INTERIOR_MUTABLE_CONST, correctness, - "referencing const with interior mutability" + "referencing `const` with interior mutability" } #[allow(dead_code)] @@ -98,12 +98,12 @@ impl Source { match self { Self::Item { item } | Self::Assoc { item, .. } => ( DECLARE_INTERIOR_MUTABLE_CONST, - "a const item should never be interior mutable", + "a `const` item should never be interior mutable", *item, ), Self::Expr { expr } => ( BORROW_INTERIOR_MUTABLE_CONST, - "a const item with interior mutability should not be borrowed", + "a `const` item with interior mutability should not be borrowed", *expr, ), } diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 7ae73edc0..f41ac30c4 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -123,7 +123,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "the method \"create\" is called more than once", + "the method `create` is called more than once", ); } else { create = true @@ -136,7 +136,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "the method \"append\" is called more than once", + "the method `append` is called more than once", ); } else { append = true @@ -149,7 +149,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "the method \"truncate\" is called more than once", + "the method `truncate` is called more than once", ); } else { truncate = true @@ -162,7 +162,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "the method \"read\" is called more than once", + "the method `read` is called more than once", ); } else { read = true @@ -175,7 +175,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "the method \"write\" is called more than once", + "the method `write` is called more than once", ); } else { write = true @@ -190,7 +190,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "file opened with \"truncate\" and \"read\"", + "file opened with `truncate` and `read`", ); } if append && truncate && append_arg && truncate_arg { @@ -198,7 +198,7 @@ fn check_open_options(cx: &LateContext<'_, '_>, options: &[(OpenOption, Argument cx, NONSENSICAL_OPEN_OPTIONS, span, - "file opened with \"append\" and \"truncate\"", + "file opened with `append` and `truncate`", ); } } diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 87a487c3b..907a46846 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, '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", ); } } diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 7787aa326..a5e61da67 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -112,7 +112,7 @@ impl<'a, 'tcx> LateLintPass<'a, '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, "_"))); } } diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 6c2d2103e..ced784ca4 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -154,7 +154,7 @@ impl Return { return; } - span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded return statement", |db| { + span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded `return` statement", |db| { if let Some(snippet) = snippet_opt(cx, inner_span) { db.span_suggestion(ret_span, "remove `return`", snippet, Applicability::MachineApplicable); } @@ -162,7 +162,7 @@ impl Return { }, None => match replacement { RetReplacement::Empty => { - span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded return statement", |db| { + span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded `return` statement", |db| { db.span_suggestion( ret_span, "remove `return`", @@ -172,7 +172,7 @@ impl Return { }); }, RetReplacement::Block => { - span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded return statement", |db| { + span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded `return` statement", |db| { db.span_suggestion( ret_span, "replace `return` with an empty block", @@ -211,9 +211,9 @@ impl Return { cx, LET_AND_RETURN, retexpr.span, - "returning the result of a let binding from a block", + "returning the result of a `let` binding from a block", |err| { - err.span_label(local.span, "unnecessary let binding"); + err.span_label(local.span, "unnecessary `let` binding"); if let Some(snippet) = snippet_opt(cx, initexpr.span) { err.multipart_suggestion( diff --git a/clippy_lints/src/tabs_in_doc_comments.rs b/clippy_lints/src/tabs_in_doc_comments.rs index d6e0ab183..9d211b7b9 100644 --- a/clippy_lints/src/tabs_in_doc_comments.rs +++ b/clippy_lints/src/tabs_in_doc_comments.rs @@ -36,7 +36,7 @@ declare_clippy_lint! { /// ``` /// /// Will be converted to: - /// ```rust + /// ```rust /// /// /// /// Struct to hold two strings: /// /// - first one diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 7d49b31d9..fadac06c1 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -141,7 +141,7 @@ declare_clippy_lint! { /// ``` pub LINKEDLIST, pedantic, - "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a VecDeque" + "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`" } declare_clippy_lint! { @@ -316,7 +316,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty<'_>, is_local: bool) { LINKEDLIST, hir_ty.span, "I see you're using a LinkedList! Perhaps you meant some other data structure?", - "a VecDeque might work", + "a `VecDeque` might work", ); return; // don't recurse into the type } @@ -464,7 +464,7 @@ declare_clippy_lint! { /// ``` pub LET_UNIT_VALUE, style, - "creating a let binding to a value of unit type, which usually can't be used afterwards" + "creating a `let` binding to a value of unit type, which usually can't be used afterwards" } declare_lint_pass!(LetUnitValue => [LET_UNIT_VALUE]); @@ -998,7 +998,7 @@ fn span_lossless_lint(cx: &LateContext<'_, '_>, expr: &Expr<'_>, op: &Expr<'_>, CAST_LOSSLESS, expr.span, &format!( - "casting {} to {} may become silently lossy if you later change the type", + "casting `{}` to `{}` may become silently lossy if you later change the type", cast_from, cast_to ), "try", @@ -1053,7 +1053,10 @@ fn check_loss_of_sign(cx: &LateContext<'_, '_>, expr: &Expr<'_>, op: &Expr<'_>, cx, CAST_SIGN_LOSS, expr.span, - &format!("casting {} to {} may lose the sign of the value", cast_from, cast_to), + &format!( + "casting `{}` to `{}` may lose the sign of the value", + cast_from, cast_to + ), ); } @@ -1098,7 +1101,7 @@ fn check_truncation_and_wrapping(cx: &LateContext<'_, '_>, expr: &Expr<'_>, cast CAST_POSSIBLE_TRUNCATION, expr.span, &format!( - "casting {} to {} may truncate the value{}", + "casting `{}` to `{}` may truncate the value{}", cast_from, cast_to, match suffix_truncation { @@ -1115,7 +1118,7 @@ fn check_truncation_and_wrapping(cx: &LateContext<'_, '_>, expr: &Expr<'_>, cast CAST_POSSIBLE_WRAP, expr.span, &format!( - "casting {} to {} may wrap around the value{}", + "casting `{}` to `{}` may wrap around the value{}", cast_from, cast_to, match suffix_wrap { @@ -1194,7 +1197,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts { cx, UNNECESSARY_CAST, expr.span, - &format!("casting integer literal to {} is unnecessary", cast_to), + &format!("casting integer literal to `{}` is unnecessary", cast_to), "try", format!("{}_{}", n, cast_to), Applicability::MachineApplicable, @@ -1256,14 +1259,17 @@ fn lint_numeric_casts<'tcx>( cx, CAST_POSSIBLE_TRUNCATION, expr.span, - &format!("casting {} to {} may truncate the value", cast_from, cast_to), + &format!("casting `{}` to `{}` may truncate the value", cast_from, cast_to), ); if !cast_to.is_signed() { span_lint( cx, CAST_SIGN_LOSS, expr.span, - &format!("casting {} to {} may lose the sign of the value", cast_from, cast_to), + &format!( + "casting `{}` to `{}` may lose the sign of the value", + cast_from, cast_to + ), ); } }, @@ -1278,7 +1284,7 @@ fn lint_numeric_casts<'tcx>( cx, CAST_POSSIBLE_TRUNCATION, expr.span, - "casting f64 to f32 may truncate the value", + "casting `f64` to `f32` may truncate the value", ); } if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.kind, &cast_to.kind) { @@ -1550,7 +1556,7 @@ declare_clippy_lint! { /// ``` pub CHAR_LIT_AS_U8, complexity, - "casting a character literal to u8 truncates" + "casting a character literal to `u8` truncates" } declare_lint_pass!(CharLitAsU8 => [CHAR_LIT_AS_U8]); @@ -1742,7 +1748,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AbsurdExtremeComparisons { AlwaysFalse => "this comparison is always false".to_owned(), AlwaysTrue => "this comparison is always true".to_owned(), InequalityImpossible => format!( - "the case where the two sides are not equal never occurs, consider using {} == {} \ + "the case where the two sides are not equal never occurs, consider using `{} == {}` \ instead", snippet(cx, lhs.span, "lhs"), snippet(cx, rhs.span, "rhs") @@ -1750,7 +1756,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AbsurdExtremeComparisons { }; let help = format!( - "because {} is the {} value for this type, {}", + "because `{}` is the {} value for this type, {}", snippet(cx, culprit.expr.span, "x"), match culprit.which { Minimum => "minimum", @@ -1813,7 +1819,7 @@ impl FullInt { impl PartialEq for FullInt { #[must_use] fn eq(&self, other: &Self) -> bool { - self.partial_cmp(other).expect("partial_cmp only returns Some(_)") == Ordering::Equal + self.partial_cmp(other).expect("`partial_cmp` only returns `Some(_)`") == Ordering::Equal } } @@ -1832,7 +1838,7 @@ impl Ord for FullInt { #[must_use] fn cmp(&self, other: &Self) -> Ordering { self.partial_cmp(other) - .expect("partial_cmp for FullInt can never return None") + .expect("`partial_cmp` for FullInt can never return `None`") } } @@ -2404,7 +2410,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RefToMut { cx, CAST_REF_TO_MUT, expr.span, - "casting &T to &mut T may cause undefined behaviour, consider instead using an UnsafeCell", + "casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell`", ); } } diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index e4b0a3773..008dc578b 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -66,7 +66,7 @@ fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext<'_>, UNSAFE_REMOVED_FROM_NAME, span, &format!( - "removed \"unsafe\" from the name of `{}` in use as `{}`", + "removed `unsafe` from the name of `{}` in use as `{}`", old_str, new_str ), ); diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index e9b4b1a50..7f127350b 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -35,7 +35,7 @@ declare_clippy_lint! { /// ``` pub UNNECESSARY_UNWRAP, complexity, - "checks for calls of unwrap[_err]() that cannot fail" + "checks for calls of `unwrap[_err]()` that cannot fail" } declare_clippy_lint! { @@ -58,7 +58,7 @@ declare_clippy_lint! { /// This code will always panic. The if condition should probably be inverted. pub PANICKING_UNWRAP, correctness, - "checks for calls of unwrap[_err]() that will always fail" + "checks for calls of `unwrap[_err]()` that will always fail" } /// Visitor that keeps track of which variables are unwrappable. diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index fc46da2c7..11cc594fb 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -20,7 +20,7 @@ declare_clippy_lint! { /// ``` pub ZERO_DIVIDED_BY_ZERO, complexity, - "usage of `0.0 / 0.0` to obtain NaN instead of std::f32::NaN or std::f64::NaN" + "usage of `0.0 / 0.0` to obtain NaN instead of `std::f32::NAN` or `std::f64::NAN`" } declare_lint_pass!(ZeroDiv => [ZERO_DIVIDED_BY_ZERO]); @@ -50,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ZeroDiv { cx, ZERO_DIVIDED_BY_ZERO, expr.span, - "constant division of 0.0 with 0.0 will always result in NaN", + "constant division of `0.0` with `0.0` will always result in NaN", &format!( "Consider using `std::{}::NAN` if you would like a constant representing NaN", float_type,