Skip to content

Commit 2d921a6

Browse files
authored
Rollup merge of rust-lang#99837 - TaKO8Ki:avoid-symbol-to-string-conversions, r=fee1-dead
Avoid `Symbol` to `String` conversions follow-up to rust-lang#99508
2 parents 6f7fe3b + 3cbc944 commit 2d921a6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_expand/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn get_features(
129129
.span_suggestion(
130130
mi.span(),
131131
"expected just one word",
132-
format!("{}", ident.name),
132+
ident.name,
133133
Applicability::MaybeIncorrect,
134134
)
135135
.emit();

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub trait InferCtxtExt<'tcx> {
184184
trait_pred: ty::PolyTraitPredicate<'tcx>,
185185
) -> bool;
186186

187-
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String>;
187+
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol>;
188188

189189
fn suggest_fn_call(
190190
&self,
@@ -737,13 +737,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
737737
/// Given a closure's `DefId`, return the given name of the closure.
738738
///
739739
/// This doesn't account for reassignments, but it's only used for suggestions.
740-
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String> {
741-
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<String> {
740+
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol> {
741+
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<Symbol> {
742742
// Get the local name of this closure. This can be inaccurate because
743743
// of the possibility of reassignment, but this should be good enough.
744744
match &kind {
745-
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
746-
Some(format!("{}", name))
745+
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) => {
746+
Some(ident.name)
747747
}
748748
_ => {
749749
err.note(msg);

0 commit comments

Comments
 (0)