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 \
`Iterator`",
),
"into_iter".to_string(),
"into_iter",
Applicability::MaybeIncorrect,
);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1288,7 +1288,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.span_suggestion_verbose(
obligation.cause.span.shrink_to_hi(),
"consider using clone here",
".clone()".to_string(),
".clone()",
Applicability::MaybeIncorrect,
);
return true;
@ -3245,7 +3245,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.span_suggestion_verbose(
span,
"you can use `impl Trait` as the argument type",
"impl ".to_string(),
"impl ",
Applicability::MaybeIncorrect,
);
let sugg = if !needs_parens {
@ -5203,7 +5203,7 @@ fn point_at_assoc_type_restriction(
err.span_suggestion_verbose(
path.span,
"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,
);
}