Improve help message for search_is_some lint

This commit is contained in:
Guillaume Gomez 2024-01-12 22:48:09 +01:00
parent 7eca5afd34
commit 68aceeed03

View file

@ -63,7 +63,7 @@ pub(super) fn check<'tcx>(
SEARCH_IS_SOME, SEARCH_IS_SOME,
method_span.with_hi(expr.span.hi()), method_span.with_hi(expr.span.hi()),
&msg, &msg,
"use `any()` instead", "consider using",
format!( format!(
"any({})", "any({})",
any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str) any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str)
@ -77,7 +77,7 @@ pub(super) fn check<'tcx>(
SEARCH_IS_SOME, SEARCH_IS_SOME,
expr.span, expr.span,
&msg, &msg,
"use `!_.any()` instead", "consider using",
format!( format!(
"!{iter}.any({})", "!{iter}.any({})",
any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str) any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str)
@ -118,7 +118,7 @@ pub(super) fn check<'tcx>(
SEARCH_IS_SOME, SEARCH_IS_SOME,
method_span.with_hi(expr.span.hi()), method_span.with_hi(expr.span.hi()),
&msg, &msg,
"use `contains()` instead", "consider using",
format!("contains({find_arg})"), format!("contains({find_arg})"),
applicability, applicability,
); );
@ -132,7 +132,7 @@ pub(super) fn check<'tcx>(
SEARCH_IS_SOME, SEARCH_IS_SOME,
expr.span, expr.span,
&msg, &msg,
"use `!_.contains()` instead", "consider using",
format!("!{string}.contains({find_arg})"), format!("!{string}.contains({find_arg})"),
applicability, applicability,
); );