33use std:: assert_matches:: debug_assert_matches;
44use std:: borrow:: Cow ;
55use std:: iter;
6+ use std:: path:: PathBuf ;
67
78use itertools:: { EitherOrBoth , Itertools } ;
89use rustc_abi:: ExternAbi ;
@@ -1369,17 +1370,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13691370 ) ;
13701371 let self_ty_str =
13711372 self . tcx . short_string ( old_pred. self_ty ( ) . skip_binder ( ) , err. long_ty_path ( ) ) ;
1373+ let trait_path = self
1374+ . tcx
1375+ . short_string ( old_pred. print_modifiers_and_trait_path ( ) , err. long_ty_path ( ) ) ;
1376+
13721377 if has_custom_message {
13731378 err. note ( msg) ;
13741379 } else {
13751380 err. messages = vec ! [ ( rustc_errors:: DiagMessage :: from( msg) , Style :: NoStyle ) ] ;
13761381 }
13771382 err. span_label (
13781383 span,
1379- format ! (
1380- "the trait `{}` is not implemented for `{self_ty_str}`" ,
1381- old_pred. print_modifiers_and_trait_path( )
1382- ) ,
1384+ format ! ( "the trait `{trait_path}` is not implemented for `{self_ty_str}`" ) ,
13831385 ) ;
13841386 } ;
13851387
@@ -5366,6 +5368,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53665368 obligation : & PredicateObligation < ' tcx > ,
53675369 trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
53685370 pre_message : String ,
5371+ file : & mut Option < PathBuf > ,
53695372) -> String {
53705373 if let ObligationCauseCode :: MainFunctionType = obligation. cause . code ( ) {
53715374 "consider using `()`, or a `Result`" . to_owned ( )
@@ -5384,7 +5387,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53845387 format ! (
53855388 "{pre_message}the trait `{}` is not implemented for{desc} `{}`" ,
53865389 trait_predicate. print_modifiers_and_trait_path( ) ,
5387- tcx. short_string( trait_predicate. self_ty( ) . skip_binder( ) , & mut None ) ,
5390+ tcx. short_string( trait_predicate. self_ty( ) . skip_binder( ) , file ) ,
53885391 )
53895392 } else {
53905393 // "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
0 commit comments