@@ -626,6 +626,25 @@ pure fn struct(cx: ctxt, typ: t) -> sty {
626
626
}
627
627
}
628
628
629
+ // Returns struact(cx, typ) but replaces all occurences of platform
630
+ // dependent primitive types with their machine type equivalent
631
+ pure fn mach_struct ( cx : ctxt , cfg : @session:: config , typ : t ) -> sty {
632
+ alt interner:: get ( * cx. ts , typ) . struct {
633
+ ty_named ( t, _) { mach_struct ( cx, cfg, t) }
634
+ s { mach_sty( cfg, s) }
635
+ }
636
+ }
637
+
638
+ // Converts s to its machine type equivalent
639
+ pure fn mach_sty ( cfg : @session:: config , s : sty ) -> sty {
640
+ alt s {
641
+ ty_int( ast:: ty_i. ) { ty_int ( cfg. int_type ) }
642
+ ty_uint ( ast:: ty_u. ) { ty_uint ( cfg. uint_type ) }
643
+ ty_float ( ast:: ty_f. ) { ty_float ( cfg. float_type ) }
644
+ s { s }
645
+ }
646
+ }
647
+
629
648
pure fn ty_name ( cx: ctxt, typ: t) -> option:: t<@str> {
630
649
alt interner:: get ( * cx. ts , typ) . struct {
631
650
ty_named ( _, n) { some ( n) }
@@ -1758,7 +1777,9 @@ mod unify {
1758
1777
1759
1778
// Simple structural type comparison.
1760
1779
fn struct_cmp ( cx : @ctxt , expected : t , actual : t ) -> result {
1761
- if struct ( cx. tcx , expected) == struct ( cx. tcx , actual) {
1780
+ let tcx = cx. tcx ;
1781
+ let cfg = tcx. sess . get_targ_cfg ( ) ;
1782
+ if mach_struct ( tcx, cfg, expected) == mach_struct ( tcx, cfg, actual) {
1762
1783
ret ures_ok ( expected) ;
1763
1784
}
1764
1785
ret ures_err( terr_mismatch) ;
0 commit comments