@@ -3273,26 +3273,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32733273 if let Err (
32743274 mut errors,
32753275 ) = self . fulfillment_cx . borrow_mut ( ) . select_where_possible ( self ) {
3276- if !sp. desugaring_kind ( ) . is_some ( ) {
3277- // We *do not* do this for desugared call spans to keep good diagnostics
3278- // involving try.
3279- for error in & mut errors {
3280- if let ty:: Predicate :: Trait ( predicate) = error. obligation . predicate {
3281- let mut referenced_in = vec ! [ ] ;
3282- for ( i, ty) in & final_arg_types {
3283- let ty = self . resolve_vars_if_possible ( ty) ;
3284- for ty in ty. walk ( ) {
3285- if ty == predicate. skip_binder ( ) . self_ty ( ) {
3286- referenced_in. push ( * i) ;
3287- }
3288- }
3289- }
3290- if referenced_in. len ( ) == 1 {
3291- error. obligation . cause . span = args[ referenced_in[ 0 ] ] . span ;
3292- }
3293- }
3294- }
3295- }
3276+ self . point_at_arg_instead_of_call_if_possible (
3277+ & mut errors,
3278+ & final_arg_types[ ..] ,
3279+ sp,
3280+ & args,
3281+ ) ;
32963282 self . report_fulfillment_errors ( & errors, self . inh . body_id , false ) ;
32973283 }
32983284 }
@@ -3387,6 +3373,35 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33873373 vec ! [ self . tcx. types. err; len]
33883374 }
33893375
3376+ fn point_at_arg_instead_of_call_if_possible (
3377+ & self ,
3378+ errors : & mut Vec < traits:: FulfillmentError < ' _ > > ,
3379+ final_arg_types : & [ ( usize , Ty < ' tcx > ) ] ,
3380+ call_sp : Span ,
3381+ args : & ' tcx [ hir:: Expr ] ,
3382+ ) {
3383+ if !call_sp. desugaring_kind ( ) . is_some ( ) {
3384+ // We *do not* do this for desugared call spans to keep good diagnostics when involving
3385+ // the `?` operator.
3386+ for error in errors {
3387+ if let ty:: Predicate :: Trait ( predicate) = error. obligation . predicate {
3388+ let mut referenced_in = vec ! [ ] ;
3389+ for ( i, ty) in final_arg_types {
3390+ let ty = self . resolve_vars_if_possible ( ty) ;
3391+ for ty in ty. walk ( ) {
3392+ if ty == predicate. skip_binder ( ) . self_ty ( ) {
3393+ referenced_in. push ( * i) ;
3394+ }
3395+ }
3396+ }
3397+ if referenced_in. len ( ) == 1 {
3398+ error. obligation . cause . span = args[ referenced_in[ 0 ] ] . span ;
3399+ }
3400+ }
3401+ }
3402+ }
3403+ }
3404+
33903405 // AST fragment checking
33913406 fn check_lit ( & self ,
33923407 lit : & hir:: Lit ,
0 commit comments