@@ -40,10 +40,12 @@ use syntax::symbol::{sym, kw};
4040use syntax_pos:: { DUMMY_SP , Span , ExpnKind } ;
4141
4242impl < ' 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+ ) {
4749 #[ derive( Debug ) ]
4850 struct ErrorDescriptor < ' tcx > {
4951 predicate : ty:: Predicate < ' tcx > ,
@@ -1053,6 +1055,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10531055 . filter ( |c| !c. is_whitespace ( ) )
10541056 . take_while ( |c| * c == '&' )
10551057 . 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+ }
10561065
10571066 let mut trait_type = trait_ref. self_ty ( ) ;
10581067
@@ -1651,6 +1660,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
16511660 err. note ( & msg) ;
16521661 }
16531662 }
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+ }
16541675 ObligationCauseCode :: ObjectCastObligation ( object_ty) => {
16551676 err. note ( & format ! ( "required for the cast to the object type `{}`" ,
16561677 self . ty_to_string( object_ty) ) ) ;
0 commit comments