diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-07-28 16:38:34 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-28 16:38:34 +0530 |
| commit | 3a37c9a47eaf55cc76f313331f375559993b3ab1 (patch) | |
| tree | 1253ed68d592637b85960228267000b638fcc5f6 | |
| parent | 3c4a66d04e2c3e6cd87a5c89f0a6c8905caaa976 (diff) | |
| parent | 3cbc94427cb00ff53b0b085acacc7219a32a444f (diff) | |
| download | rust-3a37c9a47eaf55cc76f313331f375559993b3ab1.tar.gz rust-3a37c9a47eaf55cc76f313331f375559993b3ab1.zip | |
Rollup merge of #99837 - TaKO8Ki:avoid-symbol-to-string-conversions, r=fee1-dead
Avoid `Symbol` to `String` conversions follow-up to #99508
| -rw-r--r-- | compiler/rustc_expand/src/config.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index 2b941ec6809..ccc29adc015 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -129,7 +129,7 @@ fn get_features( .span_suggestion( mi.span(), "expected just one word", - format!("{}", ident.name), + ident.name, Applicability::MaybeIncorrect, ) .emit(); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 89d7c050c40..6c8faed0df4 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -184,7 +184,7 @@ pub trait InferCtxtExt<'tcx> { trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool; - fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String>; + fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol>; fn suggest_fn_call( &self, @@ -737,13 +737,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { /// Given a closure's `DefId`, return the given name of the closure. /// /// This doesn't account for reassignments, but it's only used for suggestions. - fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String> { - let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<String> { + fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol> { + let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<Symbol> { // Get the local name of this closure. This can be inaccurate because // of the possibility of reassignment, but this should be good enough. match &kind { - hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => { - Some(format!("{}", name)) + hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) => { + Some(ident.name) } _ => { err.note(msg); |
