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 ;
@@ -1368,17 +1369,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13681369 ) ;
13691370 let self_ty_str =
13701371 self . tcx . short_string ( old_pred. self_ty ( ) . skip_binder ( ) , err. long_ty_path ( ) ) ;
1372+ let trait_path = self
1373+ . tcx
1374+ . short_string ( old_pred. print_modifiers_and_trait_path ( ) , err. long_ty_path ( ) ) ;
1375+
13711376 if has_custom_message {
13721377 err. note ( msg) ;
13731378 } else {
13741379 err. messages = vec ! [ ( rustc_errors:: DiagMessage :: from( msg) , Style :: NoStyle ) ] ;
13751380 }
13761381 err. span_label (
13771382 span,
1378- format ! (
1379- "the trait `{}` is not implemented for `{self_ty_str}`" ,
1380- old_pred. print_modifiers_and_trait_path( )
1381- ) ,
1383+ format ! ( "the trait `{trait_path}` is not implemented for `{self_ty_str}`" ) ,
13821384 ) ;
13831385 } ;
13841386
@@ -5356,6 +5358,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53565358 obligation : & PredicateObligation < ' tcx > ,
53575359 trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
53585360 pre_message : String ,
5361+ file : & mut Option < PathBuf > ,
53595362) -> String {
53605363 if let ObligationCauseCode :: MainFunctionType = obligation. cause . code ( ) {
53615364 "consider using `()`, or a `Result`" . to_owned ( )
@@ -5374,7 +5377,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53745377 format ! (
53755378 "{pre_message}the trait `{}` is not implemented for{desc} `{}`" ,
53765379 trait_predicate. print_modifiers_and_trait_path( ) ,
5377- tcx. short_string( trait_predicate. self_ty( ) . skip_binder( ) , & mut None ) ,
5380+ tcx. short_string( trait_predicate. self_ty( ) . skip_binder( ) , file ) ,
53785381 )
53795382 } else {
53805383 // "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
0 commit comments