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 ;
@@ -1368,17 +1369,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1368
1369
) ;
1369
1370
let self_ty_str =
1370
1371
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
+
1371
1376
if has_custom_message {
1372
1377
err. note ( msg) ;
1373
1378
} else {
1374
1379
err. messages = vec ! [ ( rustc_errors:: DiagMessage :: from( msg) , Style :: NoStyle ) ] ;
1375
1380
}
1376
1381
err. span_label (
1377
1382
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}`" ) ,
1382
1384
) ;
1383
1385
} ;
1384
1386
@@ -5356,6 +5358,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
5356
5358
obligation : & PredicateObligation < ' tcx > ,
5357
5359
trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
5358
5360
pre_message : String ,
5361
+ file : & mut Option < PathBuf > ,
5359
5362
) -> String {
5360
5363
if let ObligationCauseCode :: MainFunctionType = obligation. cause . code ( ) {
5361
5364
"consider using `()`, or a `Result`" . to_owned ( )
@@ -5374,7 +5377,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
5374
5377
format ! (
5375
5378
"{pre_message}the trait `{}` is not implemented for{desc} `{}`" ,
5376
5379
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 ) ,
5378
5381
)
5379
5382
} else {
5380
5383
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
0 commit comments