Skip to content

Commit

Permalink
Auto merge of #5000 - JohnTitor:backticks, r=flip1995
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 7, 2020
2 parents fdccfe7 + abc49c3 commit c092068
Show file tree
Hide file tree
Showing 112 changed files with 680 additions and 674 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ declare_clippy_lint! {
/// ```
pub DEPRECATED_CFG_ATTR,
complexity,
"usage of `cfg_attr(rustfmt)` instead of `tool_attributes`"
"usage of `cfg_attr(rustfmt)` instead of tool attributes"
}

declare_lint_pass!(Attributes => [
Expand Down Expand Up @@ -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?",
);
}
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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! {
Expand All @@ -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! {
Expand Down Expand Up @@ -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",
);
Expand Down Expand Up @@ -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",
);
Expand Down Expand Up @@ -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
),
);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/default_trait_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/drop_forget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/else_if_without_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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",
);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/if_not_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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`",
);
},
_ => (),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/implicit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/infallible_destructuring_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inherent_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/int_plus_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/large_stack_arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[...]")
),
);
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -44,15 +44,15 @@ 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) {
span_help_and_lint(
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"
)
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/map_unit_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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
)
}
Expand Down
Loading

0 comments on commit c092068

Please sign in to comment.