@@ -5,7 +5,7 @@ use hir::{HirId, OpaqueTyOrigin};
5
5
use rustc_data_structures:: sync:: Lrc ;
6
6
use rustc_data_structures:: vec_map:: VecMap ;
7
7
use rustc_hir as hir;
8
- use rustc_middle:: traits:: ObligationCause ;
8
+ use rustc_middle:: traits:: { ObligationCause , ObligationCauseCode } ;
9
9
use rustc_middle:: ty:: fold:: BottomUpFolder ;
10
10
use rustc_middle:: ty:: subst:: { GenericArgKind , Subst } ;
11
11
use rustc_middle:: ty:: {
@@ -46,6 +46,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
46
46
value : T ,
47
47
body_id : HirId ,
48
48
span : Span ,
49
+ code : ObligationCauseCode < ' tcx > ,
49
50
param_env : ty:: ParamEnv < ' tcx > ,
50
51
) -> InferOk < ' tcx , T > {
51
52
if !value. has_opaque_types ( ) {
@@ -68,10 +69,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
68
69
) =>
69
70
{
70
71
let span = if span. is_dummy ( ) { self . tcx . def_span ( def_id) } else { span } ;
71
- let cause = ObligationCause :: misc ( span, body_id) ;
72
+ let cause = ObligationCause :: new ( span, body_id, code. clone ( ) ) ;
73
+ // FIXME(compiler-errors): We probably should add a new TypeVariableOriginKind
74
+ // for opaque types, and then use that kind to fix the spans for type errors
75
+ // that we see later on.
72
76
let ty_var = self . next_ty_var ( TypeVariableOrigin {
73
77
kind : TypeVariableOriginKind :: TypeInference ,
74
- span : cause . span ,
78
+ span,
75
79
} ) ;
76
80
obligations. extend (
77
81
self . handle_opaque_type ( ty, ty_var, true , & cause, param_env)
0 commit comments