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