X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_trait_selection%2Fsrc%2Ftraits%2Ferror_reporting%2Fsuggestions.rs;h=9f5814a6bda738c7e275c6f2a7d935c0e87a5d9e;hb=2cd2070af7643ad88d280a4933bc4fb60451e521;hp=443d57aaf3dce8cc63b9606b1786b5be6d963e14;hpb=b12b83674f310b85f49ba799e51f9b9f1824870c;p=rust.git 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 443d57aaf3d..9f5814a6bda 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -36,7 +36,7 @@ use super::InferCtxtPrivExt; use crate::infer::InferCtxtExt as _; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; -use rustc_middle::ty::print::with_no_trimmed_paths; +use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths}; #[derive(Debug)] pub enum GeneratorInteriorOrUpvar { @@ -2412,6 +2412,7 @@ fn note_obligation_cause_code( ObligationCauseCode::BindingObligation(item_def_id, span) | ObligationCauseCode::ExprBindingObligation(item_def_id, span, ..) => { let item_name = tcx.def_path_str(item_def_id); + let short_item_name = with_forced_trimmed_paths!(tcx.def_path_str(item_def_id)); let mut multispan = MultiSpan::from(span); let sm = tcx.sess.source_map(); if let Some(ident) = tcx.opt_item_ident(item_def_id) { @@ -2424,9 +2425,9 @@ fn note_obligation_cause_code( multispan.push_span_label(ident.span, "required by a bound in this"); } } - let descr = format!("required by a bound in `{}`", item_name); + let descr = format!("required by a bound in `{item_name}`"); if span.is_visible(sm) { - let msg = format!("required by this bound in `{}`", item_name); + let msg = format!("required by this bound in `{short_item_name}`"); multispan.push_span_label(span, msg); err.span_note(multispan, &descr); } else {