Skip to content

Commit c092068

Browse files
committed
Auto merge of #5000 - JohnTitor:backticks, r=flip1995
Normalize lint messages On rustc diagnostics, we prefer to use backticks over `'`, `"`, or something else. I think we should follow their manner here. In first commit, normalizes lint messages with backticks. In second commit, updates all stderrs. In third commit, updates descriptions on lintlist. changelog: none
2 parents fdccfe7 + abc49c3 commit c092068

File tree

112 files changed

+680
-674
lines changed

Some content is hidden

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

112 files changed

+680
-674
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn lint_misrefactored_assign_op(
209209
db.span_suggestion(
210210
expr.span,
211211
&format!(
212-
"Did you mean {} = {} {} {} or {}? Consider replacing it with",
212+
"Did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
213213
snip_a,
214214
snip_a,
215215
op.node.as_str(),

clippy_lints/src/attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ declare_clippy_lint! {
187187
/// ```
188188
pub DEPRECATED_CFG_ATTR,
189189
complexity,
190-
"usage of `cfg_attr(rustfmt)` instead of `tool_attributes`"
190+
"usage of `cfg_attr(rustfmt)` instead of tool attributes"
191191
}
192192

193193
declare_lint_pass!(Attributes => [
@@ -449,7 +449,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
449449
EMPTY_LINE_AFTER_OUTER_ATTR,
450450
begin_of_attr_to_item,
451451
"Found an empty line after an outer attribute. \
452-
Perhaps you forgot to add a '!' to make it an inner attribute?",
452+
Perhaps you forgot to add a `!` to make it an inner attribute?",
453453
);
454454
}
455455
}
@@ -520,7 +520,7 @@ impl EarlyLintPass for DeprecatedCfgAttribute {
520520
cx,
521521
DEPRECATED_CFG_ATTR,
522522
attr.span,
523-
"`cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes",
523+
"`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes",
524524
"use",
525525
"#[rustfmt::skip]".to_string(),
526526
Applicability::MachineApplicable,

clippy_lints/src/block_in_if_condition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
6868
}
6969

7070
const BRACED_EXPR_MESSAGE: &str = "omit braces around single expression condition";
71-
const COMPLEX_BLOCK_MESSAGE: &str = "in an 'if' condition, avoid complex blocks or closures with blocks; \
72-
instead, move the block or closure higher and bind it with a 'let'";
71+
const COMPLEX_BLOCK_MESSAGE: &str = "in an `if` condition, avoid complex blocks or closures with blocks; \
72+
instead, move the block or closure higher and bind it with a `let`";
7373

7474
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
7575
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {

clippy_lints/src/collapsible_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
138138
if expr.span.ctxt() != inner.span.ctxt() {
139139
return;
140140
}
141-
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this if statement can be collapsed", |db| {
141+
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |db| {
142142
let lhs = Sugg::ast(cx, check, "..");
143143
let rhs = Sugg::ast(cx, check_inner, "..");
144144
db.span_suggestion(

clippy_lints/src/copies.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare_clippy_lint! {
3838
/// ```
3939
pub IFS_SAME_COND,
4040
correctness,
41-
"consecutive `ifs` with the same condition"
41+
"consecutive `if`s with the same condition"
4242
}
4343

4444
declare_clippy_lint! {
@@ -85,7 +85,7 @@ declare_clippy_lint! {
8585
/// ```
8686
pub SAME_FUNCTIONS_IN_IF_CONDITION,
8787
pedantic,
88-
"consecutive `ifs` with the same function call"
88+
"consecutive `if`s with the same function call"
8989
}
9090

9191
declare_clippy_lint! {
@@ -106,7 +106,7 @@ declare_clippy_lint! {
106106
/// ```
107107
pub IF_SAME_THEN_ELSE,
108108
correctness,
109-
"if with the same *then* and *else* blocks"
109+
"`if` with the same `then` and `else` blocks"
110110
}
111111

112112
declare_clippy_lint! {
@@ -206,7 +206,7 @@ fn lint_same_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
206206
cx,
207207
IFS_SAME_COND,
208208
j.span,
209-
"this `if` has the same condition as a previous if",
209+
"this `if` has the same condition as a previous `if`",
210210
i.span,
211211
"same as this",
212212
);
@@ -234,7 +234,7 @@ fn lint_same_fns_in_if_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
234234
cx,
235235
SAME_FUNCTIONS_IN_IF_CONDITION,
236236
j.span,
237-
"this `if` has the same function call as a previous if",
237+
"this `if` has the same function call as a previous `if`",
238238
i.span,
239239
"same as this",
240240
);
@@ -300,7 +300,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) {
300300
db.span_note(
301301
i.body.span,
302302
&format!(
303-
"`{}` has the same arm body as the `_` wildcard, consider removing it`",
303+
"`{}` has the same arm body as the `_` wildcard, consider removing it",
304304
lhs
305305
),
306306
);

clippy_lints/src/default_trait_access.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare_clippy_lint! {
2626
/// ```
2727
pub DEFAULT_TRAIT_ACCESS,
2828
pedantic,
29-
"checks for literal calls to Default::default()"
29+
"checks for literal calls to `Default::default()`"
3030
}
3131

3232
declare_lint_pass!(DefaultTraitAccess => [DEFAULT_TRAIT_ACCESS]);
@@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
6262
cx,
6363
DEFAULT_TRAIT_ACCESS,
6464
expr.span,
65-
&format!("Calling {} is more clear than this expression", replacement),
65+
&format!("Calling `{}` is more clear than this expression", replacement),
6666
"try",
6767
replacement,
6868
Applicability::Unspecified, // First resolve the TODO above

clippy_lints/src/drop_forget_ref.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ const DROP_REF_SUMMARY: &str = "calls to `std::mem::drop` with a reference inste
102102
Dropping a reference does nothing.";
103103
const FORGET_REF_SUMMARY: &str = "calls to `std::mem::forget` with a reference instead of an owned value. \
104104
Forgetting a reference does nothing.";
105-
const DROP_COPY_SUMMARY: &str = "calls to `std::mem::drop` with a value that implements Copy. \
105+
const DROP_COPY_SUMMARY: &str = "calls to `std::mem::drop` with a value that implements `Copy`. \
106106
Dropping a copy leaves the original intact.";
107-
const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements Copy. \
107+
const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements `Copy`. \
108108
Forgetting a copy leaves the original intact.";
109109

110110
declare_lint_pass!(DropForgetRef => [DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY]);
@@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef {
137137
expr.span,
138138
&msg,
139139
arg.span,
140-
&format!("argument has type {}", arg_ty));
140+
&format!("argument has type `{}`", arg_ty));
141141
} else if is_copy(cx, arg_ty) {
142142
if match_def_path(cx, def_id, &paths::DROP) {
143143
lint = DROP_COPY;

clippy_lints/src/else_if_without_else.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare_clippy_lint! {
4343
/// ```
4444
pub ELSE_IF_WITHOUT_ELSE,
4545
restriction,
46-
"if expression with an `else if`, but without a final `else` branch"
46+
"`if` expression with an `else if`, but without a final `else` branch"
4747
}
4848

4949
declare_lint_pass!(ElseIfWithoutElse => [ELSE_IF_WITHOUT_ELSE]);
@@ -60,7 +60,7 @@ impl EarlyLintPass for ElseIfWithoutElse {
6060
cx,
6161
ELSE_IF_WITHOUT_ELSE,
6262
els.span,
63-
"if expression with an `else if`, but without a final `else`",
63+
"`if` expression with an `else if`, but without a final `else`",
6464
"add an `else` block here",
6565
);
6666
}

clippy_lints/src/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessFormat {
4646

4747
// Operate on the only argument of `alloc::fmt::format`.
4848
if let Some(sugg) = on_new_v1(cx, expr) {
49-
span_useless_format(cx, span, "consider using .to_string()", sugg);
49+
span_useless_format(cx, span, "consider using `.to_string()`", sugg);
5050
} else if let Some(sugg) = on_new_v1_fmt(cx, expr) {
51-
span_useless_format(cx, span, "consider using .to_string()", sugg);
51+
span_useless_format(cx, span, "consider using `.to_string()`", sugg);
5252
}
5353
}
5454
}

clippy_lints/src/if_not_else.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl EarlyLintPass for IfNotElse {
6161
IF_NOT_ELSE,
6262
item.span,
6363
"Unnecessary boolean `not` operation",
64-
"remove the `!` and swap the blocks of the if/else",
64+
"remove the `!` and swap the blocks of the `if`/`else`",
6565
);
6666
},
6767
ExprKind::Binary(ref kind, _, _) if kind.node == BinOpKind::Ne => {
@@ -70,7 +70,7 @@ impl EarlyLintPass for IfNotElse {
7070
IF_NOT_ELSE,
7171
item.span,
7272
"Unnecessary `!=` operation",
73-
"change to `==` and swap the blocks of the if/else",
73+
"change to `==` and swap the blocks of the `if`/`else`",
7474
);
7575
},
7676
_ => (),

0 commit comments

Comments
 (0)