@@ -45,7 +45,8 @@ use syntax_pos::{DUMMY_SP, Span};
4545
4646impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
4747 pub fn report_fulfillment_errors ( & self ,
48- errors : & Vec < FulfillmentError < ' tcx > > ) {
48+ errors : & Vec < FulfillmentError < ' tcx > > ,
49+ body_id : Option < hir:: BodyId > ) {
4950 #[ derive( Debug ) ]
5051 struct ErrorDescriptor < ' tcx > {
5152 predicate : ty:: Predicate < ' tcx > ,
@@ -105,7 +106,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
105106
106107 for ( error, suppressed) in errors. iter ( ) . zip ( is_suppressed) {
107108 if !suppressed {
108- self . report_fulfillment_error ( error) ;
109+ self . report_fulfillment_error ( error, body_id ) ;
109110 }
110111 }
111112 }
@@ -148,7 +149,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
148149 false
149150 }
150151
151- fn report_fulfillment_error ( & self , error : & FulfillmentError < ' tcx > ) {
152+ fn report_fulfillment_error ( & self , error : & FulfillmentError < ' tcx > ,
153+ body_id : Option < hir:: BodyId > ) {
152154 debug ! ( "report_fulfillment_errors({:?})" , error) ;
153155 match error. code {
154156 FulfillmentErrorCode :: CodeSelectionError ( ref e) => {
@@ -158,7 +160,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
158160 self . report_projection_error ( & error. obligation , e) ;
159161 }
160162 FulfillmentErrorCode :: CodeAmbiguity => {
161- self . maybe_report_ambiguity ( & error. obligation ) ;
163+ self . maybe_report_ambiguity ( & error. obligation , body_id ) ;
162164 }
163165 FulfillmentErrorCode :: CodeSubtypeError ( ref expected_found, ref err) => {
164166 self . report_mismatched_types ( & error. obligation . cause ,
@@ -869,14 +871,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
869871}
870872
871873impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
872- fn maybe_report_ambiguity ( & self , obligation : & PredicateObligation < ' tcx > ) {
874+ fn maybe_report_ambiguity ( & self , obligation : & PredicateObligation < ' tcx > ,
875+ body_id : Option < hir:: BodyId > ) {
873876 // Unable to successfully determine, probably means
874877 // insufficient type information, but could mean
875878 // ambiguous impls. The latter *ought* to be a
876879 // coherence violation, so we don't report it here.
877880
878881 let predicate = self . resolve_type_vars_if_possible ( & obligation. predicate ) ;
879- let body_id = hir:: BodyId { node_id : obligation. cause . body_id } ;
880882 let span = obligation. cause . span ;
881883
882884 debug ! ( "maybe_report_ambiguity(predicate={:?}, obligation={:?})" ,
@@ -953,7 +955,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
953955 let & SubtypePredicate { a_is_expected : _, a, b } = data. skip_binder ( ) ;
954956 // both must be type variables, or the other would've been instantiated
955957 assert ! ( a. is_ty_var( ) && b. is_ty_var( ) ) ;
956- self . need_type_info ( hir :: BodyId { node_id : obligation . cause . body_id } ,
958+ self . need_type_info ( body_id,
957959 obligation. cause . span ,
958960 a) ;
959961 }
0 commit comments