@@ -45,7 +45,8 @@ use syntax_pos::{DUMMY_SP, Span};
45
45
46
46
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
47
47
pub fn report_fulfillment_errors ( & self ,
48
- errors : & Vec < FulfillmentError < ' tcx > > ) {
48
+ errors : & Vec < FulfillmentError < ' tcx > > ,
49
+ body_id : Option < hir:: BodyId > ) {
49
50
#[ derive( Debug ) ]
50
51
struct ErrorDescriptor < ' tcx > {
51
52
predicate : ty:: Predicate < ' tcx > ,
@@ -105,7 +106,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
105
106
106
107
for ( error, suppressed) in errors. iter ( ) . zip ( is_suppressed) {
107
108
if !suppressed {
108
- self . report_fulfillment_error ( error) ;
109
+ self . report_fulfillment_error ( error, body_id ) ;
109
110
}
110
111
}
111
112
}
@@ -148,7 +149,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
148
149
false
149
150
}
150
151
151
- fn report_fulfillment_error ( & self , error : & FulfillmentError < ' tcx > ) {
152
+ fn report_fulfillment_error ( & self , error : & FulfillmentError < ' tcx > ,
153
+ body_id : Option < hir:: BodyId > ) {
152
154
debug ! ( "report_fulfillment_errors({:?})" , error) ;
153
155
match error. code {
154
156
FulfillmentErrorCode :: CodeSelectionError ( ref e) => {
@@ -158,7 +160,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
158
160
self . report_projection_error ( & error. obligation , e) ;
159
161
}
160
162
FulfillmentErrorCode :: CodeAmbiguity => {
161
- self . maybe_report_ambiguity ( & error. obligation ) ;
163
+ self . maybe_report_ambiguity ( & error. obligation , body_id ) ;
162
164
}
163
165
FulfillmentErrorCode :: CodeSubtypeError ( ref expected_found, ref err) => {
164
166
self . report_mismatched_types ( & error. obligation . cause ,
@@ -869,14 +871,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
869
871
}
870
872
871
873
impl < ' 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 > ) {
873
876
// Unable to successfully determine, probably means
874
877
// insufficient type information, but could mean
875
878
// ambiguous impls. The latter *ought* to be a
876
879
// coherence violation, so we don't report it here.
877
880
878
881
let predicate = self . resolve_type_vars_if_possible ( & obligation. predicate ) ;
879
- let body_id = hir:: BodyId { node_id : obligation. cause . body_id } ;
880
882
let span = obligation. cause . span ;
881
883
882
884
debug ! ( "maybe_report_ambiguity(predicate={:?}, obligation={:?})" ,
@@ -953,7 +955,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
953
955
let & SubtypePredicate { a_is_expected : _, a, b } = data. skip_binder ( ) ;
954
956
// both must be type variables, or the other would've been instantiated
955
957
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,
957
959
obligation. cause . span ,
958
960
a) ;
959
961
}
0 commit comments