@@ -276,49 +276,39 @@ fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
276
276
277
277
enum mode { m_collect, m_check, m_check_tyvar( @fn_ctxt ) , }
278
278
279
- fn ast_region_to_region ( tcx : ty:: ctxt ,
280
- region : ast:: region ) -> ty:: region {
281
- alt region . node {
282
- ast:: re_inferred {
283
- // this must be replaced later by a fixup_regions() pass
284
- ty : : re_default
279
+ fn ast_ty_vstore_to_vstore ( tcx : ty:: ctxt , ty : @ast :: ty ,
280
+ v : ast:: vstore ) -> ty:: vstore {
281
+ alt v {
282
+ ast : : vstore_fixed ( none ) {
283
+ tcx . sess . span_bug ( ty . span ,
284
+ "implied fixed length in ast_ty_vstore_to_vstore" ) ;
285
285
}
286
- ast:: re_self | ast :: re_named ( _ ) {
287
- tcx . region_map . ast_type_to_region . get ( region . id )
286
+ ast:: vstore_fixed ( some ( u ) ) {
287
+ ty :: vstore_fixed ( u )
288
288
}
289
- ast:: re_static {
290
- ty : : re_static
289
+ ast:: vstore_uniq { ty : : vstore_uniq }
290
+ ast:: vstore_box { ty : : vstore_box }
291
+ ast:: vstore_slice ( r) {
292
+ ty:: vstore_slice ( tcx. region_map . ast_type_to_region . get ( ty. id ) )
291
293
}
292
294
}
293
295
}
294
296
295
- fn ast_vstore_to_vstore ( tcx : ty :: ctxt , span : span , n : option < uint > ,
296
- v : ast:: vstore ) -> ty:: vstore {
297
+ fn ast_expr_vstore_to_vstore ( fcx : @ fn_ctxt , e : @ast :: expr , n : uint ,
298
+ v : ast:: vstore ) -> ty:: vstore {
297
299
alt v {
298
- ast : : vstore_fixed ( none) {
299
- alt n {
300
- some( n) { ty:: vstore_fixed ( n) }
301
- none {
302
- tcx. sess . bug ( "implied fixed length in ast_vstore_to_vstore with \
303
- no default length")
304
- }
305
- }
306
- }
300
+ ast : : vstore_fixed ( none) { ty:: vstore_fixed ( n) }
307
301
ast:: vstore_fixed ( some ( u) ) {
308
- alt n {
309
- some( n) if n != u {
310
- tcx. sess . span_err ( span,
311
- #fmt ( "fixed-size sequence mismatch: %u vs. %u" ,
312
- u, n) ) ;
313
- }
314
- _ { }
302
+ if n != u {
303
+ let s = #fmt ( "fixed-size sequence mismatch: %u vs. %u" , u, n) ;
304
+ fcx. ccx . tcx . sess . span_err ( e. span , s) ;
315
305
}
316
306
ty:: vstore_fixed ( u)
317
307
}
318
308
ast:: vstore_uniq { ty : : vstore_uniq }
319
309
ast:: vstore_box { ty : : vstore_box }
320
- ast:: vstore_slice ( region ) {
321
- ty:: vstore_slice ( ast_region_to_region ( tcx , region ) )
310
+ ast:: vstore_slice ( r ) {
311
+ ty:: vstore_slice ( region_of ( fcx , e ) )
322
312
}
323
313
}
324
314
}
@@ -408,7 +398,7 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
408
398
ty:: mk_ptr ( tcx, ast_mt_to_mt ( tcx, mode, mt) )
409
399
}
410
400
ast:: ty_rptr ( region, mt) {
411
- let region = ast_region_to_region ( tcx, region ) ;
401
+ let region = tcx. region_map . ast_type_to_region . get ( ast_ty . id ) ;
412
402
ty:: mk_rptr ( tcx, region, ast_mt_to_mt ( tcx, mode, mt) )
413
403
}
414
404
ast:: ty_tup ( fields) {
@@ -473,16 +463,17 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
473
463
}
474
464
}
475
465
ast:: ty_vstore ( t, vst) {
476
- let vst = ast_vstore_to_vstore ( tcx, ast_ty. span , none , vst) ;
477
- alt ty:: get ( do_ast_ty_to_ty ( tcx, mode, t) ) . struct {
466
+ let vst = ast_ty_vstore_to_vstore ( tcx, ast_ty, vst) ;
467
+ let ty = alt ty:: get ( do_ast_ty_to_ty ( tcx, mode, t) ) . struct {
478
468
ty:: ty_vec ( mt) { ty:: mk_evec ( tcx, mt, vst) }
479
469
ty:: ty_str { ty : : mk_estr ( tcx, vst) }
480
470
_ {
481
471
tcx. sess . span_fatal ( ast_ty. span ,
482
472
"found sequence storage modifier \
483
473
on non-sequence type") ;
484
474
}
485
- }
475
+ } ;
476
+ fixup_regions_to_block ( tcx, ty, ast_ty)
486
477
}
487
478
ast:: ty_constr ( t, cs) {
488
479
let mut out_cs = [ ] ;
@@ -2512,8 +2503,7 @@ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region {
2512
2503
}
2513
2504
}
2514
2505
_ {
2515
- let blk_id = fcx. ccx. tcx. region_map. rvalue_to_block. get( expr. id) ;
2516
- ret ty:: re_scope( blk_id) ;
2506
+ ret fcx. ccx. tcx. region_map. rvalue_to_region. get( expr. id) ;
2517
2507
}
2518
2508
}
2519
2509
}
@@ -2849,27 +2839,32 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2849
2839
alt expr. node {
2850
2840
2851
2841
ast:: expr_vstore( ev, vst) {
2852
- alt ev. node {
2842
+ let mut typ = alt ev. node {
2853
2843
ast:: expr_lit( @{ node: ast:: lit_str( s) , span: _} ) {
2854
- let tt = ast_vstore_to_vstore( tcx, expr. span,
2855
- some( str :: len( s) ) , vst) ;
2856
- let typ = ty:: mk_estr( tcx, tt) ;
2857
- fcx. write_ty( ev. id, typ) ;
2858
- fcx. write_ty( id, typ) ;
2844
+ let tt = ast_expr_vstore_to_vstore( fcx, ev,
2845
+ str :: len( s) , vst) ;
2846
+ ty:: mk_estr( tcx, tt)
2859
2847
}
2860
2848
ast:: expr_vec( args, mutbl) {
2861
- let tt = ast_vstore_to_vstore ( tcx , expr . span ,
2862
- some ( vec:: len( args) ) , vst) ;
2849
+ let tt = ast_expr_vstore_to_vstore ( fcx , ev ,
2850
+ vec:: len( args) , vst) ;
2863
2851
let t: ty:: t = next_ty_var( fcx) ;
2864
2852
for args. each { |e| bot |= check_expr_with( fcx, e, t) ; }
2865
- let typ = ty:: mk_evec( tcx, { ty: t, mutbl: mutbl} , tt) ;
2866
- fcx. write_ty( ev. id, typ) ;
2867
- fcx. write_ty( id, typ) ;
2853
+ ty:: mk_evec( tcx, { ty: t, mutbl: mutbl} , tt)
2868
2854
}
2869
2855
_ {
2870
- tcx. sess. span_err( expr. span, "vstore modifier on non-sequence" ) ;
2856
+ tcx. sess. span_bug( expr. span, "vstore modifier on non-sequence" )
2857
+ }
2858
+ } ;
2859
+ alt vst {
2860
+ ast:: vstore_slice( _) {
2861
+ let region = fcx. ccx. tcx. region_map. rvalue_to_region. get( ev. id) ;
2862
+ typ = replace_default_region( tcx, region, typ) ;
2871
2863
}
2864
+ _ { }
2872
2865
}
2866
+ fcx. write_ty( ev. id, typ) ;
2867
+ fcx. write_ty( id, typ) ;
2873
2868
}
2874
2869
2875
2870
ast:: expr_lit( lit) {
@@ -3075,7 +3070,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
3075
3070
let pattern_ty = next_ty_var( fcx) ;
3076
3071
bot = check_expr_with( fcx, discrim, pattern_ty) ;
3077
3072
3078
- let parent_block = tcx. region_map. rvalue_to_block . get( discrim. id) ;
3073
+ let parent_region = tcx. region_map. rvalue_to_region . get( discrim. id) ;
3079
3074
3080
3075
// Typecheck the patterns first, so that we get types for all the
3081
3076
// bindings.
@@ -3084,9 +3079,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
3084
3079
let pcx = {
3085
3080
fcx: fcx,
3086
3081
map: pat_util:: pat_id_map( tcx. def_map, arm. pats[ 0 ] ) ,
3087
- alt_region: ty :: re_scope ( parent_block ) ,
3082
+ alt_region: parent_region ,
3088
3083
block_region: ty:: re_scope( arm. body. node. id) ,
3089
- pat_region: ty :: re_scope ( parent_block )
3084
+ pat_region: parent_region
3090
3085
} ;
3091
3086
3092
3087
for arm. pats. each { |p| check_pat( pcx, p, pattern_ty) ; }
@@ -3529,8 +3524,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
3529
3524
_ { /* fall through */ }
3530
3525
}
3531
3526
3532
- let block_id = fcx. ccx. tcx. region_map. rvalue_to_block. get( local. node. id) ;
3533
- let region = ty:: re_scope( block_id) ;
3527
+ let region = fcx. ccx. tcx. region_map. rvalue_to_region. get( local. node. id) ;
3534
3528
let pcx = {
3535
3529
fcx: fcx,
3536
3530
map: pat_util:: pat_id_map( fcx. ccx. tcx. def_map, local. node. pat) ,
0 commit comments