@@ -40,10 +40,12 @@ use syntax::symbol::{sym, kw};
40
40
use syntax_pos:: { DUMMY_SP , Span , ExpnKind } ;
41
41
42
42
impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
43
- pub fn report_fulfillment_errors ( & self ,
44
- errors : & [ FulfillmentError < ' tcx > ] ,
45
- body_id : Option < hir:: BodyId > ,
46
- fallback_has_occurred : bool ) {
43
+ pub fn report_fulfillment_errors (
44
+ & self ,
45
+ errors : & [ FulfillmentError < ' tcx > ] ,
46
+ body_id : Option < hir:: BodyId > ,
47
+ fallback_has_occurred : bool ,
48
+ ) {
47
49
#[ derive( Debug ) ]
48
50
struct ErrorDescriptor < ' tcx > {
49
51
predicate : ty:: Predicate < ' tcx > ,
@@ -1053,6 +1055,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1053
1055
. filter ( |c| !c. is_whitespace ( ) )
1054
1056
. take_while ( |c| * c == '&' )
1055
1057
. count ( ) ;
1058
+ if let Some ( '\'' ) = snippet. chars ( )
1059
+ . filter ( |c| !c. is_whitespace ( ) )
1060
+ . skip ( refs_number)
1061
+ . next ( )
1062
+ { // Do not suggest removal of borrow from type arguments.
1063
+ return ;
1064
+ }
1056
1065
1057
1066
let mut trait_type = trait_ref. self_ty ( ) ;
1058
1067
@@ -1651,6 +1660,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1651
1660
err. note ( & msg) ;
1652
1661
}
1653
1662
}
1663
+ ObligationCauseCode :: BindingObligation ( item_def_id, span) => {
1664
+ let item_name = tcx. def_path_str ( item_def_id) ;
1665
+ let msg = format ! ( "required by this bound in `{}`" , item_name) ;
1666
+ if let Some ( ident) = tcx. opt_item_name ( item_def_id) {
1667
+ err. span_label ( ident. span , "" ) ;
1668
+ }
1669
+ if span != DUMMY_SP {
1670
+ err. span_label ( span, & msg) ;
1671
+ } else {
1672
+ err. note ( & msg) ;
1673
+ }
1674
+ }
1654
1675
ObligationCauseCode :: ObjectCastObligation ( object_ty) => {
1655
1676
err. note ( & format ! ( "required for the cast to the object type `{}`" ,
1656
1677
self . ty_to_string( object_ty) ) ) ;
0 commit comments