@@ -467,8 +467,6 @@ pub fn check_fn(ccx: @mut CrateCtxt,
467
467
let pcx = pat_ctxt {
468
468
fcx : fcx,
469
469
map : pat_id_map ( tcx. def_map , input. pat ) ,
470
- match_region : region,
471
- block_region : region,
472
470
} ;
473
471
_match:: check_pat ( & pcx, input. pat , * arg_ty) ;
474
472
}
@@ -686,9 +684,14 @@ impl FnCtxt {
686
684
result:: Ok ( self . block_region ( ) )
687
685
} else {
688
686
result:: Err ( RegionError {
689
- msg : fmt ! ( "named region `%s` not in scope here" ,
690
- bound_region_ptr_to_str( self . tcx( ) , br) ) ,
691
- replacement : self . infcx ( ) . next_region_var_nb ( span)
687
+ msg : {
688
+ fmt ! ( "named region `%s` not in scope here" ,
689
+ bound_region_to_str( self . tcx( ) , br) )
690
+ } ,
691
+ replacement : {
692
+ self . infcx ( ) . next_region_var (
693
+ infer:: BoundRegionError ( span) )
694
+ }
692
695
} )
693
696
}
694
697
}
@@ -698,7 +701,7 @@ impl FnCtxt {
698
701
699
702
impl region_scope for FnCtxt {
700
703
fn anon_region ( & self , span : span ) -> Result < ty:: Region , RegionError > {
701
- result:: Ok ( self . infcx ( ) . next_region_var_nb ( span) )
704
+ result:: Ok ( self . infcx ( ) . next_region_var ( infer :: MiscVariable ( span) ) )
702
705
}
703
706
fn self_region ( & self , span : span ) -> Result < ty:: Region , RegionError > {
704
707
self . search_in_scope_regions ( span, ty:: br_self)
@@ -845,21 +848,28 @@ impl FnCtxt {
845
848
846
849
pub fn mk_subty ( & self ,
847
850
a_is_expected : bool ,
848
- span : span ,
851
+ origin : infer :: SubtypeOrigin ,
849
852
sub : ty:: t ,
850
853
sup : ty:: t )
851
854
-> Result < ( ) , ty:: type_err > {
852
- infer:: mk_subty ( self . infcx ( ) , a_is_expected, span , sub, sup)
855
+ infer:: mk_subty ( self . infcx ( ) , a_is_expected, origin , sub, sup)
853
856
}
854
857
855
858
pub fn can_mk_subty ( & self , sub : ty:: t , sup : ty:: t )
856
859
-> Result < ( ) , ty:: type_err > {
857
860
infer:: can_mk_subty ( self . infcx ( ) , sub, sup)
858
861
}
859
862
860
- pub fn mk_assignty ( & self , expr : @ast:: expr , sub : ty:: t , sup : ty:: t )
863
+ pub fn mk_assignty ( & self ,
864
+ expr : @ast:: expr ,
865
+ sub : ty:: t ,
866
+ sup : ty:: t )
861
867
-> Result < ( ) , ty:: type_err > {
862
- match infer:: mk_coercety ( self . infcx ( ) , false , expr. span , sub, sup) {
868
+ match infer:: mk_coercety ( self . infcx ( ) ,
869
+ false ,
870
+ infer:: ExprAssignable ( expr) ,
871
+ sub,
872
+ sup) {
863
873
Ok ( None ) => result:: Ok ( ( ) ) ,
864
874
Err ( ref e) => result:: Err ( ( * e) ) ,
865
875
Ok ( Some ( adjustment) ) => {
@@ -876,20 +886,19 @@ impl FnCtxt {
876
886
877
887
pub fn mk_eqty ( & self ,
878
888
a_is_expected : bool ,
879
- span : span ,
889
+ origin : infer :: SubtypeOrigin ,
880
890
sub : ty:: t ,
881
891
sup : ty:: t )
882
892
-> Result < ( ) , ty:: type_err > {
883
- infer:: mk_eqty ( self . infcx ( ) , a_is_expected, span , sub, sup)
893
+ infer:: mk_eqty ( self . infcx ( ) , a_is_expected, origin , sub, sup)
884
894
}
885
895
886
896
pub fn mk_subr ( & self ,
887
897
a_is_expected : bool ,
888
- span : span ,
898
+ origin : infer :: SubregionOrigin ,
889
899
sub : ty:: Region ,
890
- sup : ty:: Region )
891
- -> Result < ( ) , ty:: type_err > {
892
- infer:: mk_subr ( self . infcx ( ) , a_is_expected, span, sub, sup)
900
+ sup : ty:: Region ) {
901
+ infer:: mk_subr ( self . infcx ( ) , a_is_expected, origin, sub, sup)
893
902
}
894
903
895
904
pub fn with_region_lb < R > ( @mut self , lb : ast:: node_id , f : & fn ( ) -> R )
@@ -905,7 +914,9 @@ impl FnCtxt {
905
914
rp : Option < ty:: region_variance > ,
906
915
span : span )
907
916
-> Option < ty:: Region > {
908
- rp. map ( |_rp| self . infcx ( ) . next_region_var_nb ( span) )
917
+ rp. map (
918
+ |_| self . infcx ( ) . next_region_var (
919
+ infer:: BoundRegionInTypeOrImpl ( span) ) )
909
920
}
910
921
911
922
pub fn type_error_message ( & self ,
@@ -1089,7 +1100,8 @@ pub fn impl_self_ty(vcx: &VtableContext,
1089
1100
} ;
1090
1101
1091
1102
let self_r = if region_param. is_some ( ) {
1092
- Some ( vcx. infcx . next_region_var_nb ( location_info. span ) )
1103
+ Some ( vcx. infcx . next_region_var (
1104
+ infer:: BoundRegionInTypeOrImpl ( location_info. span ) ) )
1093
1105
} else {
1094
1106
None
1095
1107
} ;
@@ -1352,7 +1364,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
1352
1364
let ( _, _, fn_sig) =
1353
1365
replace_bound_regions_in_fn_sig (
1354
1366
fcx. tcx ( ) , @Nil , None , & fn_sig,
1355
- |_br| fcx. infcx ( ) . next_region_var_nb ( call_expr. span ) ) ;
1367
+ |br| fcx. infcx ( ) . next_region_var (
1368
+ infer:: BoundRegionInFnCall ( call_expr. span , br) ) ) ;
1356
1369
1357
1370
// Call the generic checker.
1358
1371
check_argument_types ( fcx, call_expr. span , fn_sig. inputs , f,
@@ -2085,7 +2098,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
2085
2098
let expected_sty = unpack_expected ( fcx, expected, |x| Some ( copy * x) ) ;
2086
2099
let inner_ty = match expected_sty {
2087
2100
Some ( ty:: ty_closure( ref fty) ) => {
2088
- match fcx. mk_subty ( false , expr. span ,
2101
+ match fcx. mk_subty ( false , infer :: Misc ( expr. span ) ,
2089
2102
fty. sig . output , ty:: mk_bool ( ) ) {
2090
2103
result:: Ok ( _) => {
2091
2104
ty:: mk_closure ( tcx, ty:: ClosureTy {
@@ -2395,7 +2408,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
2395
2408
// Finally, borrowck is charged with guaranteeing that the
2396
2409
// value whose address was taken can actually be made to live
2397
2410
// as long as it needs to live.
2398
- let region = fcx. infcx( ) . next_region_var_nb( expr. span) ;
2411
+ let region = fcx. infcx( ) . next_region_var(
2412
+ infer:: AddrOfRegion ( expr. span) ) ;
2399
2413
2400
2414
let tm = ty:: mt { ty : fcx. expr_ty( oprnd) , mutbl : mutbl } ;
2401
2415
let oprnd_t = if ty:: type_is_error( tm. ty) {
@@ -2437,7 +2451,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
2437
2451
Some ( t) => t, None => fcx. ret_ty
2438
2452
} ;
2439
2453
match expr_opt {
2440
- None => match fcx. mk_eqty( false , expr. span,
2454
+ None => match fcx. mk_eqty( false , infer :: Misc ( expr. span) ,
2441
2455
ret_ty, ty:: mk_nil( ) ) {
2442
2456
result:: Ok ( _) => { /* fall through */ }
2443
2457
result:: Err ( _) => {
@@ -2686,7 +2700,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
2686
2700
let el = ty:: sequence_element_type ( fcx. tcx ( ) ,
2687
2701
t1) ;
2688
2702
infer:: mk_eqty ( fcx. infcx ( ) , false ,
2689
- sp , el, t2) . is_ok ( )
2703
+ infer :: Misc ( sp ) , el, t2) . is_ok ( )
2690
2704
}
2691
2705
}
2692
2706
@@ -2907,8 +2921,6 @@ pub fn check_decl_local(fcx: @mut FnCtxt, local: @ast::local) {
2907
2921
let pcx = pat_ctxt {
2908
2922
fcx : fcx,
2909
2923
map : pat_id_map ( tcx. def_map , local. node . pat ) ,
2910
- match_region : region,
2911
- block_region : region,
2912
2924
} ;
2913
2925
_match:: check_pat ( & pcx, local. node . pat , t) ;
2914
2926
let pat_ty = fcx. node_ty ( local. node . pat . id ) ;
@@ -3412,7 +3424,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: @mut FnCtxt,
3412
3424
ast:: expr_vstore_uniq => ty:: vstore_uniq,
3413
3425
ast:: expr_vstore_box | ast:: expr_vstore_mut_box => ty:: vstore_box,
3414
3426
ast:: expr_vstore_slice | ast:: expr_vstore_mut_slice => {
3415
- let r = fcx. infcx ( ) . next_region_var_nb ( e. span ) ;
3427
+ let r = fcx. infcx ( ) . next_region_var ( infer :: AddrOfSlice ( e. span ) ) ;
3416
3428
ty:: vstore_slice ( r)
3417
3429
}
3418
3430
}
0 commit comments