@@ -5,7 +5,7 @@ use hir::{HirId, OpaqueTyOrigin};
55use rustc_data_structures:: sync:: Lrc ;
66use rustc_data_structures:: vec_map:: VecMap ;
77use rustc_hir as hir;
8- use rustc_middle:: traits:: ObligationCause ;
8+ use rustc_middle:: traits:: { ObligationCause , ObligationCauseCode } ;
99use rustc_middle:: ty:: fold:: BottomUpFolder ;
1010use rustc_middle:: ty:: subst:: { GenericArgKind , Subst } ;
1111use rustc_middle:: ty:: {
@@ -46,6 +46,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
4646 value : T ,
4747 body_id : HirId ,
4848 span : Span ,
49+ code : ObligationCauseCode < ' tcx > ,
4950 param_env : ty:: ParamEnv < ' tcx > ,
5051 ) -> InferOk < ' tcx , T > {
5152 if !value. has_opaque_types ( ) {
@@ -68,10 +69,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
6869 ) =>
6970 {
7071 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.
7276 let ty_var = self . next_ty_var ( TypeVariableOrigin {
7377 kind : TypeVariableOriginKind :: TypeInference ,
74- span : cause . span ,
78+ span,
7579 } ) ;
7680 obligations. extend (
7781 self . handle_opaque_type ( ty, ty_var, true , & cause, param_env)
0 commit comments