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

+1-1
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

+3-3
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

+2-2
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

+1-1
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

+6-6
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

+2-2
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

+3-3
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

+2-2
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

+2-2
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

+2-2
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
_ => (),

clippy_lints/src/implicit_return.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str)
5151
let outer_span = outer_span.source_callsite();
5252
let inner_span = inner_span.source_callsite();
5353

54-
span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing return statement", |db| {
54+
span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing `return` statement", |db| {
5555
if let Some(snippet) = snippet_opt(cx, inner_span) {
5656
db.span_suggestion(
5757
outer_span,
@@ -102,7 +102,7 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
102102
expr_match(cx, &arm.body);
103103
}
104104
} else {
105-
expr_match(cx, &arms.first().expect("if let doesn't have a single arm").body);
105+
expr_match(cx, &arms.first().expect("`if let` doesn't have a single arm").body);
106106
}
107107
},
108108
// skip if it already has a return statement

clippy_lints/src/infallible_destructuring_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare_clippy_lint! {
3838
/// ```
3939
pub INFALLIBLE_DESTRUCTURING_MATCH,
4040
style,
41-
"a match statement with a single infallible arm instead of a `let`"
41+
"a `match` statement with a single infallible arm instead of a `let`"
4242
}
4343

4444
declare_lint_pass!(InfallibleDestructingMatch => [INFALLIBLE_DESTRUCTURING_MATCH]);
@@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InfallibleDestructingMatch {
6161
cx,
6262
INFALLIBLE_DESTRUCTURING_MATCH,
6363
local.span,
64-
"you seem to be trying to use match to destructure a single infallible pattern. \
64+
"you seem to be trying to use `match` to destructure a single infallible pattern. \
6565
Consider using `let`",
6666
"try this",
6767
format!(

clippy_lints/src/inherent_to_string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ declare_clippy_lint! {
8888
/// ```
8989
pub INHERENT_TO_STRING_SHADOW_DISPLAY,
9090
correctness,
91-
"type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait "
91+
"type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait"
9292
}
9393

9494
declare_lint_pass!(InherentToString => [INHERENT_TO_STRING, INHERENT_TO_STRING_SHADOW_DISPLAY]);

clippy_lints/src/int_plus_one.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ declare_clippy_lint! {
3232
/// ```
3333
pub INT_PLUS_ONE,
3434
complexity,
35-
"instead of using x >= y + 1, use x > y"
35+
"instead of using `x >= y + 1`, use `x > y`"
3636
}
3737

3838
declare_lint_pass!(IntPlusOne => [INT_PLUS_ONE]);

clippy_lints/src/large_stack_arrays.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeStackArrays {
5959
self.maximum_allowed_size
6060
),
6161
&format!(
62-
"consider allocating on the heap with vec!{}.into_boxed_slice()",
62+
"consider allocating on the heap with `vec!{}.into_boxed_slice()`",
6363
snippet(cx, expr.span, "[...]")
6464
),
6565
);

clippy_lints/src/let_underscore.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_clippy_lint! {
2727
/// ```
2828
pub LET_UNDERSCORE_MUST_USE,
2929
restriction,
30-
"non-binding let on a #[must_use] expression"
30+
"non-binding let on a `#[must_use]` expression"
3131
}
3232

3333
declare_lint_pass!(LetUnderscore => [LET_UNDERSCORE_MUST_USE]);
@@ -44,15 +44,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnderscore {
4444
cx,
4545
LET_UNDERSCORE_MUST_USE,
4646
stmt.span,
47-
"non-binding let on an expression with #[must_use] type",
47+
"non-binding let on an expression with `#[must_use]` type",
4848
"consider explicitly using expression value"
4949
)
5050
} else if is_must_use_func_call(cx, init) {
5151
span_help_and_lint(
5252
cx,
5353
LET_UNDERSCORE_MUST_USE,
5454
stmt.span,
55-
"non-binding let on a result of a #[must_use] function",
55+
"non-binding let on a result of a `#[must_use]` function",
5656
"consider explicitly using function result"
5757
)
5858
}

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat<'_>, arg: &Expr<'_>, e
13531353
EXPLICIT_INTO_ITER_LOOP,
13541354
arg.span,
13551355
"it is more concise to loop over containers instead of using explicit \
1356-
iteration methods`",
1356+
iteration methods",
13571357
"to write this more concisely, try",
13581358
object.to_string(),
13591359
applicability,

clippy_lints/src/map_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn lint_needless_cloning(cx: &LateContext<'_, '_>, root: Span, receiver: Span) {
112112
MAP_CLONE,
113113
root.trim_start(receiver).unwrap(),
114114
"You are needlessly cloning iterator elements",
115-
"Remove the map call",
115+
"Remove the `map` call",
116116
String::new(),
117117
Applicability::MachineApplicable,
118118
)

clippy_lints/src/map_unit_fn.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ declare_clippy_lint! {
4848
/// ```
4949
pub OPTION_MAP_UNIT_FN,
5050
complexity,
51-
"using `option.map(f)`, where f is a function or closure that returns ()"
51+
"using `option.map(f)`, where `f` is a function or closure that returns `()`"
5252
}
5353

5454
declare_clippy_lint! {
@@ -89,7 +89,7 @@ declare_clippy_lint! {
8989
/// ```
9090
pub RESULT_MAP_UNIT_FN,
9191
complexity,
92-
"using `result.map(f)`, where f is a function or closure that returns ()"
92+
"using `result.map(f)`, where `f` is a function or closure that returns `()`"
9393
}
9494

9595
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
199199
#[must_use]
200200
fn suggestion_msg(function_type: &str, map_type: &str) -> String {
201201
format!(
202-
"called `map(f)` on an {0} value where `f` is a unit {1}",
202+
"called `map(f)` on an `{0}` value where `f` is a unit {1}",
203203
map_type, function_type
204204
)
205205
}

0 commit comments

Comments
 (0)