@@ -65,6 +65,7 @@ export mk_ctxt;
65
65
export mk_float;
66
66
export mk_fn;
67
67
export mk_imm_box;
68
+ export mk_imm_uniq;
68
69
export mk_mut_ptr;
69
70
export mk_int;
70
71
export mk_str;
@@ -251,7 +252,7 @@ tag sty {
251
252
ty_str;
252
253
ty_tag ( def_id, [ t] ) ;
253
254
ty_box ( mt) ;
254
- ty_uniq ( t ) ;
255
+ ty_uniq ( mt ) ;
255
256
ty_vec ( mt) ;
256
257
ty_ptr ( mt) ;
257
258
ty_rec ( [ field] ) ;
@@ -448,7 +449,7 @@ fn mk_raw_ty(cx: ctxt, st: sty, _in_cname: option::t<str>) -> @raw_t {
448
449
for tt: t in tys { derive_flags_t ( cx, has_params, has_vars, tt) ; }
449
450
}
450
451
ty_box ( m) { derive_flags_mt ( cx, has_params, has_vars, m) ; }
451
- ty_uniq ( tt ) { derive_flags_t ( cx, has_params, has_vars, tt ) ; }
452
+ ty_uniq ( m ) { derive_flags_mt ( cx, has_params, has_vars, m ) ; }
452
453
ty_vec ( m) { derive_flags_mt ( cx, has_params, has_vars, m) ; }
453
454
ty_ptr ( m) { derive_flags_mt ( cx, has_params, has_vars, m) ; }
454
455
ty_rec ( flds) {
@@ -534,7 +535,11 @@ fn mk_tag(cx: ctxt, did: ast::def_id, tys: [t]) -> t {
534
535
535
536
fn mk_box ( cx : ctxt , tm : mt ) -> t { ret gen_ty ( cx, ty_box ( tm) ) ; }
536
537
537
- fn mk_uniq ( cx : ctxt , typ : t ) -> t { ret gen_ty ( cx, ty_uniq ( typ) ) ; }
538
+ fn mk_uniq ( cx : ctxt , tm : mt ) -> t { ret gen_ty ( cx, ty_uniq ( tm) ) ; }
539
+
540
+ fn mk_imm_uniq ( cx : ctxt , ty : t ) -> t {
541
+ ret mk_uniq ( cx, { ty: ty, mut : ast:: imm} ) ;
542
+ }
538
543
539
544
fn mk_ptr ( cx : ctxt , tm : mt ) -> t { ret gen_ty ( cx, ty_ptr ( tm) ) ; }
540
545
@@ -643,7 +648,7 @@ fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
643
648
ty_constr ( sub, _) { walk_ty ( cx, walker, sub) ; }
644
649
ty_var ( _) { /* no-op */ }
645
650
ty_param ( _, _) { /* no-op */ }
646
- ty_uniq ( sub ) { walk_ty ( cx, walker, sub ) ; }
651
+ ty_uniq ( tm ) { walk_ty ( cx, walker, tm . ty ) ; }
647
652
}
648
653
walker ( ty) ;
649
654
}
@@ -678,7 +683,9 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
678
683
ty_box ( tm) {
679
684
ty = mk_box ( cx, { ty: fold_ty ( cx, fld, tm. ty ) , mut: tm. mut } ) ;
680
685
}
681
- ty_uniq ( subty) { ty = mk_uniq ( cx, fold_ty ( cx, fld, subty) ) ; }
686
+ ty_uniq ( tm) {
687
+ ty = mk_uniq ( cx, { ty: fold_ty ( cx, fld, tm. ty ) , mut: tm. mut } ) ;
688
+ }
682
689
ty_ptr ( tm) {
683
690
ty = mk_ptr ( cx, { ty: fold_ty ( cx, fld, tm. ty ) , mut: tm. mut } ) ;
684
691
}
@@ -1420,7 +1427,7 @@ fn hash_type_structure(st: sty) -> uint {
1420
1427
for c: @type_constr in cs { h += h << 5 u + hash_type_constr ( h, c) ; }
1421
1428
ret h;
1422
1429
}
1423
- ty_uniq ( t ) { let h = 37 u; h += h << 5 u + hash_ty ( t ) ; ret h; }
1430
+ ty_uniq ( mt ) { let h = 37 u; h += h << 5 u + hash_ty ( mt . ty ) ; ret h; }
1424
1431
}
1425
1432
}
1426
1433
@@ -2184,13 +2191,20 @@ mod unify {
2184
2191
_ { ret ures_err ( terr_mismatch) ; }
2185
2192
}
2186
2193
}
2187
- ty:: ty_uniq ( expected_sub ) {
2194
+ ty:: ty_uniq ( expected_mt ) {
2188
2195
alt struct( cx. tcx , actual) {
2189
- ty:: ty_uniq ( actual_sub) {
2190
- let result = unify_step ( cx, expected_sub, actual_sub) ;
2196
+ ty:: ty_uniq ( actual_mt) {
2197
+ let mut = expected_mt. mut ;
2198
+ // FIXME (409) Write a test then uncomment
2199
+ /*alt unify_mut(expected_mt.mut, actual_mt.mut) {
2200
+ none. { ret ures_err(terr_box_mutability); }
2201
+ some(m) { mut = m; }
2202
+ }*/
2203
+ let result = unify_step ( cx, expected_mt. ty , actual_mt. ty ) ;
2191
2204
alt result {
2192
- ures_ok( result_sub) {
2193
- ret ures_ok ( mk_uniq ( cx. tcx , result_sub) ) ;
2205
+ ures_ok( result_mt) {
2206
+ let mt = { ty: result_mt, mut : mut } ;
2207
+ ret ures_ok( mk_uniq ( cx. tcx , mt) ) ;
2194
2208
}
2195
2209
_ { ret result; }
2196
2210
}
0 commit comments