@@ -737,7 +737,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
737
737
let is_try = self . tcx . sess . source_map ( ) . span_to_snippet ( span)
738
738
. map ( |s| & s == "?" )
739
739
. unwrap_or ( false ) ;
740
- let is_from = format ! ( "{}" , trait_ref) . starts_with ( "std::convert::From<" ) ;
740
+ let is_from =
741
+ format ! ( "{}" , trait_ref. print_only_trait_path( ) )
742
+ . starts_with ( "std::convert::From<" ) ;
741
743
let ( message, note) = if is_try && is_from {
742
744
( Some ( format ! (
743
745
"`?` couldn't convert the error to `{}`" ,
@@ -768,7 +770,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
768
770
format ! (
769
771
"{}the trait `{}` is not implemented for `{}`" ,
770
772
pre_message,
771
- trait_ref,
773
+ trait_ref. print_only_trait_path ( ) ,
772
774
trait_ref. self_ty( ) ,
773
775
)
774
776
} ;
@@ -1189,7 +1191,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1189
1191
if param_ty => {
1190
1192
// Missing generic type parameter bound.
1191
1193
let param_name = self_ty. to_string ( ) ;
1192
- let constraint = trait_ref. to_string ( ) ;
1194
+ let constraint = trait_ref. print_only_trait_path ( ) . to_string ( ) ;
1193
1195
if suggest_constraining_type_param (
1194
1196
generics,
1195
1197
& mut err,
@@ -1416,7 +1418,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1416
1418
let msg = format ! (
1417
1419
"the trait bound `{}: {}` is not satisfied" ,
1418
1420
found,
1419
- obligation. parent_trait_ref. skip_binder( ) ,
1421
+ obligation. parent_trait_ref. skip_binder( ) . print_only_trait_path ( ) ,
1420
1422
) ;
1421
1423
if has_custom_message {
1422
1424
err. note ( & msg) ;
@@ -1430,7 +1432,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1430
1432
}
1431
1433
err. span_label ( span, & format ! (
1432
1434
"expected an implementor of trait `{}`" ,
1433
- obligation. parent_trait_ref. skip_binder( ) ,
1435
+ obligation. parent_trait_ref. skip_binder( ) . print_only_trait_path ( ) ,
1434
1436
) ) ;
1435
1437
err. span_suggestion (
1436
1438
span,
@@ -1562,7 +1564,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1562
1564
} else {
1563
1565
err. note ( & format ! (
1564
1566
"`{}` is implemented for `{:?}`, but not for `{:?}`" ,
1565
- trait_ref,
1567
+ trait_ref. print_only_trait_path ( ) ,
1566
1568
trait_type,
1567
1569
trait_ref. skip_binder( ) . self_ty( ) ,
1568
1570
) ) ;
@@ -2226,7 +2228,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2226
2228
2227
2229
err. span_note ( span, & format ! (
2228
2230
"future does not implement `{}` as this value is used across an await" ,
2229
- trait_ref,
2231
+ trait_ref. print_only_trait_path ( ) ,
2230
2232
) ) ;
2231
2233
2232
2234
// Add a note for the item obligation that remains - normally a note pointing to the
@@ -2409,7 +2411,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2409
2411
let parent_trait_ref = self . resolve_vars_if_possible ( & data. parent_trait_ref ) ;
2410
2412
err. note (
2411
2413
& format ! ( "required because of the requirements on the impl of `{}` for `{}`" ,
2412
- parent_trait_ref,
2414
+ parent_trait_ref. print_only_trait_path ( ) ,
2413
2415
parent_trait_ref. skip_binder( ) . self_ty( ) ) ) ;
2414
2416
let parent_predicate = parent_trait_ref. to_predicate ( ) ;
2415
2417
self . note_obligation_cause_code ( err,
0 commit comments