Skip to content

Commit

Permalink
Rollup merge of rust-lang#99837 - TaKO8Ki:avoid-symbol-to-string-conv…
Browse files Browse the repository at this point in the history
…ersions, r=fee1-dead

Avoid `Symbol` to `String` conversions

follow-up to rust-lang#99508
  • Loading branch information
Dylan-DPC authored Jul 28, 2022
2 parents 6f7fe3b + 3cbc944 commit 2d921a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn get_features(
.span_suggestion(
mi.span(),
"expected just one word",
format!("{}", ident.name),
ident.name,
Applicability::MaybeIncorrect,
)
.emit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2d921a6

Please sign in to comment.