]> git.lizzy.rs Git - rust.git/commitdiff
Normalize lint messages
authorYuki Okushi <huyuumi.dev@gmail.com>
Mon, 6 Jan 2020 06:30:43 +0000 (15:30 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Tue, 7 Jan 2020 09:26:55 +0000 (18:26 +0900)
45 files changed:
clippy_lints/src/assign_ops.rs
clippy_lints/src/attrs.rs
clippy_lints/src/block_in_if_condition.rs
clippy_lints/src/collapsible_if.rs
clippy_lints/src/copies.rs
clippy_lints/src/default_trait_access.rs
clippy_lints/src/drop_forget_ref.rs
clippy_lints/src/else_if_without_else.rs
clippy_lints/src/format.rs
clippy_lints/src/if_not_else.rs
clippy_lints/src/implicit_return.rs
clippy_lints/src/infallible_destructuring_match.rs
clippy_lints/src/inherent_to_string.rs
clippy_lints/src/int_plus_one.rs
clippy_lints/src/large_stack_arrays.rs
clippy_lints/src/let_underscore.rs
clippy_lints/src/loops.rs
clippy_lints/src/map_clone.rs
clippy_lints/src/map_unit_fn.rs
clippy_lints/src/matches.rs
clippy_lints/src/mem_discriminant.rs
clippy_lints/src/mem_forget.rs
clippy_lints/src/methods/mod.rs
clippy_lints/src/methods/option_map_unwrap_or.rs
clippy_lints/src/minmax.rs
clippy_lints/src/misc.rs
clippy_lints/src/missing_const_for_fn.rs
clippy_lints/src/missing_inline.rs
clippy_lints/src/mul_add.rs
clippy_lints/src/mut_key.rs
clippy_lints/src/mutex_atomic.rs
clippy_lints/src/needless_bool.rs
clippy_lints/src/needless_continue.rs
clippy_lints/src/needless_pass_by_value.rs
clippy_lints/src/neg_multiply.rs
clippy_lints/src/non_copy_const.rs
clippy_lints/src/open_options.rs
clippy_lints/src/ptr.rs
clippy_lints/src/ranges.rs
clippy_lints/src/returns.rs
clippy_lints/src/tabs_in_doc_comments.rs
clippy_lints/src/types.rs
clippy_lints/src/unsafe_removed_from_name.rs
clippy_lints/src/unwrap.rs
clippy_lints/src/zero_div_zero.rs

index f0a2ebfcf3c3449af95702a01112f84e08af816d..e2de7f8296e5129fdb91c818eed43e138c24b11b 100644 (file)
@@ -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(),
index ff5688f5b7ca3bdd908bf5394d9e5a56fde900fc..2939a71a5111ff519a9425728aae6d5cd24d929f 100644 (file)
@@ -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 @@ fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {
                     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,
index 2224054af3556bb9cf109cd3b32b6ccf83da6e42..76b5c5d8f15d60cdfec957e104dd00ac213d96b6 100644 (file)
@@ -68,8 +68,8 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, '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<'_>) {
index 0fd0abdc39d2326d5087aa875580cf21f4e134c6..e34dfc9d9993665f8078cb0266165ef436a05e59 100644 (file)
@@ -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(
index c4778c6cf43abf3af9a96ca8e2efa5f277e7abea..5d04286575ad8265f6dd15844569edc853b9ee39 100644 (file)
@@ -38,7 +38,7 @@
     /// ```
     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 @@
     /// ```
     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! {
     /// ```
     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 same_bindings<'tcx>(
                         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
                             ),
                         );
index 62f80ef7652b8110b00bd0c42a9649ddf058a534..253d9b8d542fa64012d2b5a91a0506b86baca812 100644 (file)
@@ -26,7 +26,7 @@
     /// ```
     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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                                 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
index 324c3f309a4ff0a1d33d072533f3f48d3b6ab275..d8ce2fcf661a7c06795eae33bc7bf61566859b62 100644 (file)
                                 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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                                        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;
index 9e8ab0b2920b2470e6269f83dece85e8900bd757..8043a8c855558194b83e0e44fa15b27eb3badedd 100644 (file)
@@ -43,7 +43,7 @@
     /// ```
     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 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, mut item: &Expr) {
                     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",
                 );
             }
index 28b4760f05362649d672e3fbf0b5190ef4018307..bd0e1ab290931f854b6f182641455e5639481c1c 100644 (file)
@@ -46,9 +46,9 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
 
         // 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);
         }
     }
 }
index 7019cfa8cc8f120715eeb8060dbe223456ca5143..a266d7c2434493b8404df3a5674a27ed1b25a349 100644 (file)
@@ -61,7 +61,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) {
                             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 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) {
                             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`",
                         );
                     },
                     _ => (),
index f5633d51aa4ebe045f1f6878b7f9e62ee2accb89..7ea329fae6b748d589d66351c96463758e42139e 100644 (file)
@@ -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
index c75aa8a30e49b1a402c59c3e34d20cb58d698d52..d70b45eaecb82590aca833a4e46cbbf9fb2a12b4 100644 (file)
@@ -38,7 +38,7 @@
     /// ```
     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 @@ fn check_local(&mut self, cx: &LateContext<'a, 'tcx>, local: &'tcx Local<'_>) {
                     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!(
index 01e81762b4c1e6e1d03d59d4dfd61f3b32f53cd2..9d7c3b46fed5678489f1e5206324f52c4a53f9f0 100644 (file)
@@ -88,7 +88,7 @@
     /// ```
     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]);
index 9a039929e67bcbf757465de445063423d6da8acb..d9dd13923604d62d74aa2979f718cf9178464fc7 100644 (file)
@@ -32,7 +32,7 @@
     /// ```
     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]);
index 86abf72e06d06caf858e4a0f99022f177d3f1dc6..eef583a6e6251ef87f365bf18c77058382bcd288 100644 (file)
@@ -59,7 +59,7 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
                         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, "[...]")
                     ),
                 );
index f75711a28c3f3abae624c7f5e1f555e4caf07b9b..7787a55a2bb68d7d22bce576a9b30d2d1d6f444f 100644 (file)
@@ -27,7 +27,7 @@
     /// ```
     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 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, stmt: &Stmt<'_>) {
                         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 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, stmt: &Stmt<'_>) {
                         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"
                     )
                 }
index acff3e2f7409c81c616fc8d92885c3f8cac274d4..d63255408efe11d9f8c7aabf7cb93cfbada47a1a 100644 (file)
@@ -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,
index 0c66ce5dde55070c45d09c3ab8dae2d71651a66d..ae2d0830128513a2e6d68c97cd9dea128b3e7ba6 100644 (file)
@@ -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,
     )
index d0164e5e2907f10e9e7ee006864a39a4f1b2e105..3855b5a21f99fcb66763bed4111ffe000edb8c3b 100644 (file)
@@ -48,7 +48,7 @@
     /// ```
     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 @@
     /// ```
     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
     )
 }
index 476051500f56987d3e425f328a7e9ad522519636..3200de1cfc1726ab79889a805dfd4889d7370d01 100644 (file)
@@ -37,7 +37,7 @@
     /// ```
     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 @@
     /// ```
     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 @@
     /// ```
     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! {
     /// ```
     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! {
     /// ```
     pub MATCH_OVERLAPPING_ARM,
     style,
-    "a match with overlapping arms"
+    "a `match` with overlapping arms"
 }
 
 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! {
     /// ```
     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!(
                     "{}.{}(){}",
index 22797c3b754cb0bd00dc5f5c8b896be60012dba4..636c0f97578993eabac6eac3dbe5ff73a07f5458 100644 (file)
@@ -25,7 +25,7 @@
     /// ```
     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]);
index 974f6419ee693d83834045a7bc063858a3f46802..4172ea33950c4bd183f4afb17a19f245aac71aee 100644 (file)
@@ -35,7 +35,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
                         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");
                         }
                     }
                 }
index c33dae6c283d00c41c7105f0699b16298e595b7e..419522f0d27f74923ba007d04fb48699fa035c8a 100644 (file)
@@ -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",
index c9cb17e965ebb5c41fcc20b4f43cdcf4f2cadcb5..f440d864570effae25ae335700c8efdd1b808047 100644 (file)
@@ -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
         );
index 4e2948620e2d55275d7a9d37aa48f1fa69fc216d..749f6b9251512cb8b2810edf361d4217b75f5cfb 100644 (file)
@@ -45,7 +45,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                             cx,
                             MIN_MAX,
                             expr.span,
-                            "this min/max combination leads to constant result",
+                            "this `min`/`max` combination leads to constant result",
                         );
                     },
                 }
index 202fb4cdcf7fefb9393c540167041f93c0234f02..6fd83cf6ac0fdcc57dfe1238a7e64ac96925749e 100644 (file)
@@ -63,7 +63,7 @@
     /// ```
     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! {
     /// ```
     pub ZERO_PTR,
     style,
-    "using 0 as *{const, mut} T"
+    "using `0 as *{const, mut} T`"
 }
 
 declare_clippy_lint! {
@@ -370,9 +370,9 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                         }
                     }
                     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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                             ),
                             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",
                 );
             }
         }
index 980812c9e0ca0cba90476981e44ce10448034b61..cdd9e5a90a80671f8a1fac4fa4606d10600a1138 100644 (file)
@@ -113,7 +113,7 @@ fn check_fn(
                 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`");
         }
     }
 }
index 1ad3dff531dc6705085810707b70c2ab5896ae79..c25131c520cba775d97c9e8ba0e7d0ae0305fe61 100644 (file)
@@ -54,7 +54,7 @@
     /// ```
     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) {
index 1f4f0d53cccb1b916a41fd3337767f8faba6c6aa..27f598c141e11c835dc822e1acfe564e5713258f 100644 (file)
@@ -75,7 +75,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                             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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                             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({}, {})",
index 367f8638dc78839fa58078af5dc383b031b1a70d..a64467ef6a241cb4a9e3538bdfc7873cb73b6c6c 100644 (file)
@@ -47,7 +47,7 @@
     /// ```
     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 ]);
index fb3c767caca59da49830bee17493155d63d274ea..e04bd56e054f26c7cf2e4296ebf5ea4c2613b584 100644 (file)
@@ -63,8 +63,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                 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 {
index c11e6bf25f4320bf4120bb0e89b367a0a0c7e7cb..78c121b6dd8afa20be37b3cf92be17e11537cd25 100644 (file)
@@ -113,7 +113,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
                     _ => (),
                 }
             } else {
-                panic!("IfExpr 'then' node is not an ExprKind::Block");
+                panic!("IfExpr `then` node is not an `ExprKind::Block`");
             }
         }
     }
index e5ba77d21f69d697015ff42f1cfb84a83f6fcebc..f35b84c449b20f51d9d5f1892fac19028e8bbe8b 100644 (file)
@@ -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) {
index c580715a1b2184ba36793222b030e609015b3201..2a58f6c3dc25f52ea2d118a376f3ef8d9d37b88d 100644 (file)
@@ -206,7 +206,7 @@ fn check_fn(
                         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`");
                                 }
                             }
                         }
index 9757d1c01b950a44892e1f9614e22716b23ed185..6e77a7a77fa002de2bd3bd50a55208e159f97e40 100644 (file)
@@ -21,7 +21,7 @@
     /// ```
     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`");
         }
     }
 }
index 039de766c086a91b6b3c093aad8dee5e14c1826f..6ffad405c2a2db4aaacb1d2d179e9e2ad1b926c8 100644 (file)
@@ -49,7 +49,7 @@
     /// ```
     pub DECLARE_INTERIOR_MUTABLE_CONST,
     correctness,
-    "declaring const with interior mutability"
+    "declaring `const` with interior mutability"
 }
 
 declare_clippy_lint! {
@@ -81,7 +81,7 @@
     /// ```
     pub BORROW_INTERIOR_MUTABLE_CONST,
     correctness,
-    "referencing const with interior mutability"
+    "referencing `const` with interior mutability"
 }
 
 #[allow(dead_code)]
@@ -98,12 +98,12 @@ fn lint(&self) -> (&'static Lint, &'static str, Span) {
         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,
             ),
         }
index 7ae73edc0164f261e7809524def03678c07c9a13..f41ac30c4815ebe2998e9dbcc292cb4921839e4a 100644 (file)
@@ -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`",
         );
     }
 }
index 87a487c3b9eb28d3aa7d2f2b6655c7c64062f5ee..907a46846d07a60162aead762feb9fa7de60b1b0 100644 (file)
@@ -137,7 +137,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                     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",
                 );
             }
         }
index 7787aa3266136a2c0a97f4b031cd6c9b65c1630a..a5e61da6740115c39cdf45e35255369251deae46 100644 (file)
@@ -112,7 +112,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                          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, "_")));
                     }
                 }
index 6c2d2103ef4b0a0840bbd7a7a5f042d0995d82ce..ced784ca4917464838bd0afd28f417cdca4a15fa 100644 (file)
@@ -154,7 +154,7 @@ fn emit_return_lint(cx: &EarlyContext<'_>, ret_span: Span, inner_span: Option<Sp
                     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 @@ fn emit_return_lint(cx: &EarlyContext<'_>, ret_span: Span, inner_span: Option<Sp
             },
             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 @@ fn emit_return_lint(cx: &EarlyContext<'_>, ret_span: Span, inner_span: Option<Sp
                     });
                 },
                 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 @@ fn check_let_return(cx: &EarlyContext<'_>, block: &ast::Block) {
                     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(
index d6e0ab183c33b1f288ba0bb17570c8034f8146c5..9d211b7b93516708d919e732b47cd18478abc0d5 100644 (file)
@@ -36,7 +36,7 @@
     /// ```
     ///
     /// Will be converted to:
-     /// ```rust
+    /// ```rust
     /// ///
     /// /// Struct to hold two strings:
     /// ///     - first        one
index 7d49b31d99f59afab14ad182231c0dc1b877aeb2..fadac06c10f62eb4cbd6c783c7c216055c78b06c 100644 (file)
     /// ```
     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 @@ enum if you need to distinguish all 3 cases",
                         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 @@ fn is_any_trait(t: &hir::Ty<'_>) -> bool {
     /// ```
     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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                                 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 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
     /// ```
     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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                         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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                     };
 
                     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 @@ fn cmp_s_u(s: i128, u: u128) -> Ordering {
 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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                     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`",
                 );
             }
         }
index e4b0a37739699fd8f0a9378d3767f2cf28a2e63c..008dc578bf905c7236b2dc5f072bf5f625df1d1b 100644 (file)
@@ -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
             ),
         );
index e9b4b1a5051a928d89b4427c52cbfd60d89c3a7c..7f127350ba92ac9c61a5798c55b42c3e2d945ddd 100644 (file)
@@ -35,7 +35,7 @@
     /// ```
     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 @@
     /// 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.
index fc46da2c720b173e75aac9465372f43057a9b589..11cc594fb5dc56e55b37427f30a5b5b65c177268 100644 (file)
@@ -20,7 +20,7 @@
     /// ```
     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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
                     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,