From f89d64d7aa91f7ba5ca4ffd4eb6ab42cf61b12c0 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 8 Apr 2022 23:06:20 +0200 Subject: Use def_key in `tcx.item_name` when possible. --- .../src/traits/error_reporting/suggestions.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_trait_selection/src') 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 7c3f306717a..c920c80d1bb 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2064,7 +2064,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ObligationCauseCode::BindingObligation(item_def_id, span) => { let item_name = tcx.def_path_str(item_def_id); let mut multispan = MultiSpan::from(span); - if let Some(ident) = tcx.opt_item_name(item_def_id) { + if let Some(ident) = tcx.opt_item_ident(item_def_id) { let sm = tcx.sess.source_map(); let same_line = match (sm.lookup_line(ident.span.hi()), sm.lookup_line(span.lo())) { @@ -2267,7 +2267,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if !is_upvar_tys_infer_tuple { let msg = format!("required because it appears within the type `{}`", ty); match ty.kind() { - ty::Adt(def, _) => match self.tcx.opt_item_name(def.did()) { + ty::Adt(def, _) => match self.tcx.opt_item_ident(def.did()) { Some(ident) => err.span_note(ident.span, &msg), None => err.note(&msg), }, @@ -2475,7 +2475,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ); let sp = self .tcx - .opt_item_name(trait_item_def_id) + .opt_item_ident(trait_item_def_id) .map(|i| i.span) .unwrap_or_else(|| self.tcx.def_span(trait_item_def_id)); let mut assoc_span: MultiSpan = sp.into(); @@ -2486,7 +2486,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if let Some(ident) = self .tcx .opt_associated_item(trait_item_def_id) - .and_then(|i| self.tcx.opt_item_name(i.container.id())) + .and_then(|i| self.tcx.opt_item_ident(i.container.id())) { assoc_span.push_span_label(ident.span, "in this trait"); } @@ -2511,7 +2511,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if let Some(ident) = self .tcx .opt_associated_item(trait_item_def_id) - .and_then(|i| self.tcx.opt_item_name(i.container.id())) + .and_then(|i| self.tcx.opt_item_ident(i.container.id())) { assoc_span.push_span_label(ident.span, "in this trait"); } -- cgit 1.4.1-3-g733a5