@@ -12,6 +12,7 @@ use rustc::hir::{self, PatKind};
1212use rustc:: hir:: def:: { Def , CtorKind } ;
1313use rustc:: hir:: pat_util:: EnumerateAndAdjustIterator ;
1414use rustc:: infer;
15+ use rustc:: infer:: type_variable:: TypeVariableOrigin ;
1516use rustc:: traits:: ObligationCauseCode ;
1617use rustc:: ty:: { self , Ty , TypeFoldable , LvaluePreference } ;
1718use check:: { FnCtxt , Expectation , Diverges } ;
@@ -162,7 +163,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
162163 }
163164 let max_len = cmp:: max ( expected_len, elements. len ( ) ) ;
164165
165- let element_tys_iter = ( 0 ..max_len) . map ( |_| self . next_ty_var ( ) ) ;
166+ let element_tys_iter = ( 0 ..max_len) . map ( |_| self . next_ty_var (
167+ // FIXME: MiscVariable for now, obtaining the span and name information
168+ // from all tuple elements isn't trivial.
169+ TypeVariableOrigin :: TypeInference ( pat. span ) ) ) ;
166170 let element_tys = tcx. mk_type_list ( element_tys_iter) ;
167171 let pat_ty = tcx. mk_ty ( ty:: TyTuple ( element_tys) ) ;
168172 self . demand_eqtype ( pat. span , expected, pat_ty) ;
@@ -172,7 +176,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
172176 pat_ty
173177 }
174178 PatKind :: Box ( ref inner) => {
175- let inner_ty = self . next_ty_var ( ) ;
179+ let inner_ty = self . next_ty_var ( TypeVariableOrigin :: TypeInference ( inner . span ) ) ;
176180 let uniq_ty = tcx. mk_box ( inner_ty) ;
177181
178182 if self . check_dereferencable ( pat. span , expected, & inner) {
@@ -203,7 +207,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
203207 ( expected, mt. ty )
204208 }
205209 _ => {
206- let inner_ty = self . next_ty_var ( ) ;
210+ let inner_ty = self . next_ty_var (
211+ TypeVariableOrigin :: TypeInference ( inner. span ) ) ;
207212 let mt = ty:: TypeAndMut { ty : inner_ty, mutbl : mutbl } ;
208213 let region = self . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
209214 let rptr_ty = tcx. mk_ref ( region, mt) ;
@@ -379,7 +384,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
379384 // ...but otherwise we want to use any supertype of the
380385 // discriminant. This is sort of a workaround, see note (*) in
381386 // `check_pat` for some details.
382- discrim_ty = self . next_ty_var ( ) ;
387+ discrim_ty = self . next_ty_var ( TypeVariableOrigin :: TypeInference ( discrim . span ) ) ;
383388 self . check_expr_has_type ( discrim, discrim_ty) ;
384389 } ;
385390 let discrim_diverges = self . diverges . get ( ) ;
@@ -407,7 +412,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
407412 // of execution reach it, we will panic, so bottom is an appropriate
408413 // type in that case)
409414 let expected = expected. adjust_for_branches ( self ) ;
410- let mut result_ty = self . next_diverging_ty_var ( ) ;
415+ let mut result_ty = self . next_diverging_ty_var (
416+ TypeVariableOrigin :: DivergingBlockExpr ( expr. span ) ) ;
411417 let mut all_arms_diverge = Diverges :: WarnedAlways ;
412418 let coerce_first = match expected {
413419 // We don't coerce to `()` so that if the match expression is a
0 commit comments