@@ -144,7 +144,6 @@ export type_kind;
144
144
export type_err;
145
145
export type_err_to_str;
146
146
export type_has_dynamic_size;
147
- export type_has_pointers;
148
147
export type_needs_drop;
149
148
export type_is_bool;
150
149
export type_is_bot;
@@ -213,7 +212,7 @@ type ctxt =
213
212
tcache : type_cache ,
214
213
rcache : creader_cache ,
215
214
short_names_cache : hashmap < t , @str > ,
216
- has_pointer_cache : hashmap < t , bool > ,
215
+ needs_drop_cache : hashmap < t , bool > ,
217
216
kind_cache : hashmap < t , ast:: kind > ,
218
217
ast_ty_to_ty_cache : hashmap < @ast:: ty , option:: t < t > > } ;
219
218
@@ -400,7 +399,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map,
400
399
tcache: tcache,
401
400
rcache: mk_rcache ( ) ,
402
401
short_names_cache: map:: mk_hashmap ( ty:: hash_ty, ty:: eq_ty) ,
403
- has_pointer_cache : map:: mk_hashmap ( ty:: hash_ty, ty:: eq_ty) ,
402
+ needs_drop_cache : map:: mk_hashmap ( ty:: hash_ty, ty:: eq_ty) ,
404
403
kind_cache: map:: mk_hashmap ( ty:: hash_ty, ty:: eq_ty) ,
405
404
ast_ty_to_ty_cache:
406
405
map:: mk_hashmap ( ast_util:: hash_ty, ast_util:: eq_ty) } ;
@@ -925,63 +924,44 @@ fn type_is_immediate(cx: ctxt, ty: t) -> bool {
925
924
type_is_unique ( cx, ty) || type_is_native ( cx, ty) ;
926
925
}
927
926
928
- fn type_has_pointers ( cx : ctxt , ty : t ) -> bool {
929
- alt cx. has_pointer_cache . find ( ty) {
927
+ fn type_needs_drop ( cx : ctxt , ty : t ) -> bool {
928
+ alt cx. needs_drop_cache . find ( ty) {
930
929
some ( result) { ret result; }
931
930
none. { /* fall through */ }
932
931
}
933
932
934
- let result = false ;
935
- alt struct( cx, ty) {
933
+ let accum = false ;
934
+ let result = alt struct ( cx, ty) {
936
935
// scalar types
937
- ty_nil. { /* no-op */ }
938
- ty_bot. { /* no-op */ }
939
- ty_bool. { /* no-op */ }
940
- ty_int. { /* no-op */ }
941
- ty_float. { /* no-op */ }
942
- ty_uint. { /* no-op */ }
943
- ty_machine ( _) { /* no-op */ }
944
- ty_char. { /* no-op */ }
945
- ty_type. { /* no-op */ }
946
- ty_native ( _) { /* no-op */ }
936
+ ty_nil. | ty_bot . | ty_bool . | ty_int . | ty_float . | ty_uint . |
937
+ ty_machine ( _) | ty_char. | ty_type. | ty_native ( _) | ty_ptr ( _) { false }
947
938
ty_rec ( flds) {
948
- for f: field in flds {
949
- if type_has_pointers ( cx, f. mt . ty ) { result = true ; break ; }
950
- }
939
+ for f in flds { if type_needs_drop ( cx, f. mt . ty ) { accum = true ; } }
940
+ accum
951
941
}
952
942
ty_tup ( elts) {
953
- for m in elts { if type_has_pointers ( cx, m) { result = true ; } }
943
+ for m in elts { if type_needs_drop ( cx, m) { accum = true ; } }
944
+ accum
954
945
}
955
946
ty_tag ( did, tps) {
956
947
let variants = tag_variants ( cx, did) ;
957
- for variant: variant_info in variants {
958
- for aty: t in variant. args {
948
+ for variant in variants {
949
+ for aty in variant. args {
959
950
// Perform any type parameter substitutions.
960
951
let arg_ty = substitute_type_params ( cx, tps, aty) ;
961
- if type_has_pointers ( cx, arg_ty) { result = true ; break ; }
952
+ if type_needs_drop ( cx, arg_ty) { accum = true ; }
962
953
}
963
- if result { break ; }
954
+ if accum { break ; }
964
955
}
956
+ accum
965
957
}
966
- ty_res ( did, inner, tps) {
967
- result =
968
- type_has_pointers ( cx, substitute_type_params ( cx, tps, inner) ) ;
969
- }
970
- _ { result = true ; }
971
- }
958
+ _ { true }
959
+ } ;
972
960
973
- cx. has_pointer_cache . insert ( ty, result) ;
961
+ cx. needs_drop_cache . insert ( ty, result) ;
974
962
ret result;
975
963
}
976
964
977
- fn type_needs_drop ( cx : ctxt , ty : t ) -> bool {
978
- ret alt struct ( cx, ty) {
979
- ty_res ( _, _, _) { true }
980
- ty_param ( _, _) { true }
981
- _ { type_has_pointers( cx, ty) }
982
- } ;
983
- }
984
-
985
965
fn kind_lteq ( a : kind , b : kind ) -> bool {
986
966
alt a {
987
967
kind_noncopyable. { true }
0 commit comments