3
3
use std:: assert_matches:: debug_assert_matches;
4
4
use std:: borrow:: Cow ;
5
5
use std:: iter;
6
+ use std:: path:: PathBuf ;
6
7
7
8
use itertools:: { EitherOrBoth , Itertools } ;
8
9
use rustc_abi:: ExternAbi ;
@@ -1369,17 +1370,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1369
1370
) ;
1370
1371
let self_ty_str =
1371
1372
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
+
1372
1377
if has_custom_message {
1373
1378
err. note ( msg) ;
1374
1379
} else {
1375
1380
err. messages = vec ! [ ( rustc_errors:: DiagMessage :: from( msg) , Style :: NoStyle ) ] ;
1376
1381
}
1377
1382
err. span_label (
1378
1383
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}`" ) ,
1383
1385
) ;
1384
1386
} ;
1385
1387
@@ -5366,6 +5368,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
5366
5368
obligation : & PredicateObligation < ' tcx > ,
5367
5369
trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
5368
5370
pre_message : String ,
5371
+ file : & mut Option < PathBuf > ,
5369
5372
) -> String {
5370
5373
if let ObligationCauseCode :: MainFunctionType = obligation. cause . code ( ) {
5371
5374
"consider using `()`, or a `Result`" . to_owned ( )
@@ -5384,7 +5387,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
5384
5387
format ! (
5385
5388
"{pre_message}the trait `{}` is not implemented for{desc} `{}`" ,
5386
5389
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 ) ,
5388
5391
)
5389
5392
} else {
5390
5393
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
0 commit comments