Improve wording for suggestion messages
This commit is contained in:
parent
70573af31e
commit
49b0c3f4f1
@ -31,7 +31,7 @@ pub(super) fn check<'tcx>(
|
||||
vec.span,
|
||||
"it looks like the same item is being pushed into this Vec",
|
||||
None,
|
||||
&format!("try using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"),
|
||||
&format!("consider using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, join_a
|
||||
)
|
||||
.span_suggestion(
|
||||
expr_span,
|
||||
"if this is intentional, try using `Path::new` instead",
|
||||
"if this is intentional, consider using `Path::new`",
|
||||
format!("PathBuf::from({arg_str})"),
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
|
@ -50,7 +50,7 @@ pub fn check(
|
||||
super::MANUAL_SATURATING_ARITHMETIC,
|
||||
expr.span,
|
||||
"manual saturating arithmetic",
|
||||
&format!("try using `saturating_{arith}`"),
|
||||
&format!("consider using `saturating_{arith}`"),
|
||||
format!(
|
||||
"{}.saturating_{arith}({})",
|
||||
snippet_with_applicability(cx, arith_lhs.span, "..", &mut applicability),
|
||||
|
@ -97,7 +97,7 @@ pub(super) fn check(
|
||||
};
|
||||
let method_hint = if is_mut { "as_deref_mut" } else { "as_deref" };
|
||||
let hint = format!("{}.{method_hint}()", snippet(cx, as_ref_recv.span, ".."));
|
||||
let suggestion = format!("try using {method_hint} instead");
|
||||
let suggestion = format!("consider using {method_hint}");
|
||||
|
||||
let msg = format!("called `{current_method}` on an `Option` value");
|
||||
span_lint_and_sugg(
|
||||
|
@ -33,7 +33,7 @@ pub(super) fn check<'tcx>(
|
||||
OPTION_MAP_OR_ERR_OK,
|
||||
expr.span,
|
||||
msg,
|
||||
"try using `ok_or` instead",
|
||||
"consider using `ok_or`",
|
||||
format!("{self_snippet}.ok_or({err_snippet})"),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
@ -72,7 +72,7 @@ pub(super) fn check<'tcx>(
|
||||
OPTION_MAP_OR_NONE,
|
||||
expr.span,
|
||||
msg,
|
||||
"try using `map` instead",
|
||||
"consider using `map`",
|
||||
format!("{self_snippet}.map({arg_snippet} {func_snippet})"),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
@ -85,7 +85,7 @@ pub(super) fn check<'tcx>(
|
||||
OPTION_MAP_OR_NONE,
|
||||
expr.span,
|
||||
msg,
|
||||
"try using `and_then` instead",
|
||||
"consider using `and_then`",
|
||||
format!("{self_snippet}.and_then({func_snippet})"),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
@ -97,7 +97,7 @@ pub(super) fn check<'tcx>(
|
||||
RESULT_MAP_OR_INTO_OPTION,
|
||||
expr.span,
|
||||
msg,
|
||||
"try using `ok` instead",
|
||||
"consider using `ok`",
|
||||
format!("{self_snippet}.ok()"),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
@ -34,7 +34,7 @@ pub(super) fn check<'tcx>(
|
||||
RESULT_MAP_OR_INTO_OPTION,
|
||||
expr.span,
|
||||
msg,
|
||||
"try using `ok` instead",
|
||||
"consider using `ok`",
|
||||
format!("{self_snippet}.ok()"),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
@ -57,7 +57,7 @@ pub(super) fn check(
|
||||
SINGLE_CHAR_PATTERN,
|
||||
arg.span,
|
||||
"single-character string constant used as pattern",
|
||||
"try using a `char` instead",
|
||||
"consider using a `char`",
|
||||
hint,
|
||||
applicability,
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ pub(super) fn check<'tcx>(
|
||||
UNNECESSARY_JOIN,
|
||||
span.with_hi(expr.span.hi()),
|
||||
r#"called `.collect::<Vec<String>>().join("")` on an iterator"#,
|
||||
"try using",
|
||||
"consider using",
|
||||
"collect::<String>()".to_owned(),
|
||||
applicability,
|
||||
);
|
||||
|
@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for AlmostStandardFormulation {
|
||||
ident.span,
|
||||
"non-standard lint formulation",
|
||||
None,
|
||||
&format!("try using `{}` instead", formulation.correction),
|
||||
&format!("consider using `{}`", formulation.correction),
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user