Remove unnecessary .to_string()/.as_str()s

This commit is contained in:
trevyn 2024-02-02 15:16:05 -08:00
parent bf3c6c5bed
commit ef37dcb7db
10 changed files with 15 additions and 15 deletions

View File

@ -2440,7 +2440,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
"consider consuming the `{ty}` when turning it into an \ "consider consuming the `{ty}` when turning it into an \
`Iterator`", `Iterator`",
), ),
"into_iter".to_string(), "into_iter",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }

View File

@ -924,7 +924,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
expr.span.shrink_to_lo(), expr.span.shrink_to_lo(),
"use a mutable iterator instead", "use a mutable iterator instead",
"mut ".to_string(), "mut ",
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }

View File

@ -247,7 +247,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
err.span_suggestion_verbose( err.span_suggestion_verbose(
assoc_name.span, assoc_name.span,
fluent::hir_analysis_assoc_item_not_found_similar_in_other_trait_with_bound_sugg, fluent::hir_analysis_assoc_item_not_found_similar_in_other_trait_with_bound_sugg,
suggested_name.to_string(), suggested_name,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }

View File

@ -1000,7 +1000,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
lhs.span.shrink_to_hi(), lhs.span.shrink_to_hi(),
"you might have meant to write a semicolon here", "you might have meant to write a semicolon here",
";".to_string(), ";",
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
return true; return true;

View File

@ -1116,9 +1116,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item_name.span, item_name.span,
format!( format!(
"you might have meant to use `{}`", "you might have meant to use `{}`",
inherent_method.name.as_str() inherent_method.name
), ),
inherent_method.name.as_str(), inherent_method.name,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
break 'outer; break 'outer;
@ -2019,7 +2019,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
diag.span_suggestion_verbose( diag.span_suggestion_verbose(
sm.span_extend_while(seg1.ident.span.shrink_to_hi(), |c| c == ':').unwrap(), sm.span_extend_while(seg1.ident.span.shrink_to_hi(), |c| c == ':').unwrap(),
"you may have meant to call an instance method", "you may have meant to call an instance method",
".".to_string(), ".",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }

View File

@ -3288,7 +3288,7 @@ impl<'a> Parser<'a> {
} else { } else {
Applicability::MaybeIncorrect Applicability::MaybeIncorrect
}; };
err.span_suggestion_verbose(sugg_sp, msg, "=> ".to_string(), applicability); err.span_suggestion_verbose(sugg_sp, msg, "=> ", applicability);
} }
} }
err err

View File

@ -148,7 +148,7 @@ impl<'a> Parser<'a> {
.with_span_suggestion_verbose( .with_span_suggestion_verbose(
mistyped_const_ident.span, mistyped_const_ident.span,
"use the `const` keyword", "use the `const` keyword",
kw::Const.as_str(), kw::Const,
Applicability::MachineApplicable, Applicability::MachineApplicable,
) )
.emit(); .emit();

View File

@ -1453,7 +1453,7 @@ impl<'a> Parser<'a> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
prev_span, prev_span,
"perhaps you meant to use `struct` here", "perhaps you meant to use `struct` here",
"struct".to_string(), "struct",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }

View File

@ -699,7 +699,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.shrink_to_lo(), span.shrink_to_lo(),
msg, msg,
"self.".to_string(), "self.",
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }
@ -710,7 +710,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.shrink_to_lo(), span.shrink_to_lo(),
format!("you might have meant to {}", candidate.action()), format!("you might have meant to {}", candidate.action()),
"Self::".to_string(), "Self::",
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }

View File

@ -1288,7 +1288,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
obligation.cause.span.shrink_to_hi(), obligation.cause.span.shrink_to_hi(),
"consider using clone here", "consider using clone here",
".clone()".to_string(), ".clone()",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
return true; return true;
@ -3245,7 +3245,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
span, span,
"you can use `impl Trait` as the argument type", "you can use `impl Trait` as the argument type",
"impl ".to_string(), "impl ",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
let sugg = if !needs_parens { let sugg = if !needs_parens {
@ -5203,7 +5203,7 @@ fn point_at_assoc_type_restriction(
err.span_suggestion_verbose( err.span_suggestion_verbose(
path.span, path.span,
"replace the associated type with the type specified in this `impl`", "replace the associated type with the type specified in this `impl`",
tcx.type_of(new.def_id).skip_binder().to_string(), tcx.type_of(new.def_id).skip_binder(),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }