@@ -411,9 +411,6 @@ pub fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
411
411
pub fn type_needs_infer ( t : t ) -> bool {
412
412
tbox_has_flag ( get ( t) , needs_infer)
413
413
}
414
- pub fn type_has_regions ( t : t ) -> bool {
415
- tbox_has_flag ( get ( t) , has_regions)
416
- }
417
414
pub fn type_id ( t : t ) -> uint { get ( t) . id }
418
415
419
416
#[ deriving( Clone , Eq , TotalEq , Hash ) ]
@@ -1506,10 +1503,6 @@ pub fn walk_regions_and_ty(cx: &ctxt, ty: t, fldr: |r: Region|, fldt: |t: t|)
1506
1503
|t| { fldt ( t) ; t } ) . fold_ty ( ty)
1507
1504
}
1508
1505
1509
- pub fn fold_regions ( cx : & ctxt , ty : t , fldr: |r: Region | -> Region ) -> t {
1510
- ty_fold:: RegionFolder :: regions ( cx, fldr) . fold_ty ( ty)
1511
- }
1512
-
1513
1506
// Substitute *only* type parameters. Used in trans where regions are erased.
1514
1507
pub fn subst_tps ( tcx : & ctxt , tps : & [ t ] , self_ty_opt : Option < t > , typ : t ) -> t {
1515
1508
let mut subst = TpsSubst { tcx : tcx, self_ty_opt : self_ty_opt, tps : tps } ;
@@ -1623,27 +1616,13 @@ pub fn type_is_structural(ty: t) -> bool {
1623
1616
}
1624
1617
}
1625
1618
1626
- pub fn type_is_sequence ( ty : t ) -> bool {
1627
- match get ( ty) . sty {
1628
- ty_str( _) | ty_vec( _, _) => true ,
1629
- _ => false
1630
- }
1631
- }
1632
-
1633
1619
pub fn type_is_simd ( cx : & ctxt , ty : t ) -> bool {
1634
1620
match get ( ty) . sty {
1635
1621
ty_struct( did, _) => lookup_simd ( cx, did) ,
1636
1622
_ => false
1637
1623
}
1638
1624
}
1639
1625
1640
- pub fn type_is_str ( ty : t ) -> bool {
1641
- match get ( ty) . sty {
1642
- ty_str( _) => true ,
1643
- _ => false
1644
- }
1645
- }
1646
-
1647
1626
pub fn sequence_element_type ( cx : & ctxt , ty : t ) -> t {
1648
1627
match get ( ty) . sty {
1649
1628
ty_str( _) => return mk_mach_uint ( ast:: TyU8 ) ,
@@ -1672,20 +1651,6 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint {
1672
1651
}
1673
1652
}
1674
1653
1675
- pub fn get_element_type ( ty : t , i : uint ) -> t {
1676
- match get ( ty) . sty {
1677
- ty_tup( ref ts) => return * ts. get ( i) ,
1678
- _ => fail ! ( "get_element_type called on invalid type" )
1679
- }
1680
- }
1681
-
1682
- pub fn type_is_box ( ty : t ) -> bool {
1683
- match get ( ty) . sty {
1684
- ty_box( _) => return true ,
1685
- _ => return false
1686
- }
1687
- }
1688
-
1689
1654
pub fn type_is_boxed ( ty : t ) -> bool {
1690
1655
match get ( ty) . sty {
1691
1656
ty_box( _) => true ,
@@ -1700,35 +1665,13 @@ pub fn type_is_region_ptr(ty: t) -> bool {
1700
1665
}
1701
1666
}
1702
1667
1703
- pub fn type_is_slice ( ty : t ) -> bool {
1704
- match get ( ty) . sty {
1705
- ty_vec( _, vstore_slice( _) ) | ty_str( vstore_slice( _) ) => true ,
1706
- _ => return false
1707
- }
1708
- }
1709
-
1710
- pub fn type_is_unique_box ( ty : t ) -> bool {
1711
- match get ( ty) . sty {
1712
- ty_uniq( _) => return true ,
1713
- _ => return false
1714
- }
1715
- }
1716
-
1717
1668
pub fn type_is_unsafe_ptr ( ty : t ) -> bool {
1718
1669
match get ( ty) . sty {
1719
1670
ty_ptr( _) => return true ,
1720
1671
_ => return false
1721
1672
}
1722
1673
}
1723
1674
1724
- pub fn type_is_vec ( ty : t ) -> bool {
1725
- return match get ( ty) . sty {
1726
- ty_vec( _, _) | ty_unboxed_vec( _) => true ,
1727
- ty_str( _) => true ,
1728
- _ => false
1729
- } ;
1730
- }
1731
-
1732
1675
pub fn type_is_unique ( ty : t ) -> bool {
1733
1676
match get ( ty) . sty {
1734
1677
ty_uniq( _) | ty_vec( _, vstore_uniq) | ty_str( vstore_uniq) => true ,
@@ -1920,10 +1863,6 @@ def_type_content_sets!(
1920
1863
)
1921
1864
1922
1865
impl TypeContents {
1923
- pub fn meets_bounds ( & self , cx : & ctxt , bbs : BuiltinBounds ) -> bool {
1924
- bbs. iter ( ) . all ( |bb| self . meets_bound ( cx, bb) )
1925
- }
1926
-
1927
1866
pub fn meets_bound ( & self , cx : & ctxt , bb : BuiltinBound ) -> bool {
1928
1867
match bb {
1929
1868
BoundStatic => self . is_static ( cx) ,
@@ -2021,10 +1960,6 @@ impl TypeContents {
2021
1960
v. iter ( ) . fold ( TC :: None , |tc, t| tc | f ( t) )
2022
1961
}
2023
1962
2024
- pub fn inverse ( & self ) -> TypeContents {
2025
- TypeContents { bits : !self . bits }
2026
- }
2027
-
2028
1963
pub fn has_dtor ( & self ) -> bool {
2029
1964
self . intersects ( TC :: OwnsDtor )
2030
1965
}
@@ -2054,10 +1989,6 @@ impl fmt::Show for TypeContents {
2054
1989
}
2055
1990
}
2056
1991
2057
- pub fn type_has_dtor ( cx : & ctxt , t : ty:: t ) -> bool {
2058
- type_contents ( cx, t) . has_dtor ( )
2059
- }
2060
-
2061
1992
pub fn type_is_static ( cx : & ctxt , t : ty:: t ) -> bool {
2062
1993
type_contents ( cx, t) . is_static ( cx)
2063
1994
}
@@ -2642,14 +2573,8 @@ pub fn type_is_machine(ty: t) -> bool {
2642
2573
}
2643
2574
}
2644
2575
2645
- pub fn type_is_enum ( ty : t ) -> bool {
2646
- match get ( ty) . sty {
2647
- ty_enum( _, _) => return true ,
2648
- _ => return false
2649
- }
2650
- }
2651
-
2652
2576
// Is the type's representation size known at compile time?
2577
+ #[ allow( dead_code) ] // leaving in for DST
2653
2578
pub fn type_is_sized ( cx : & ctxt , ty : ty:: t ) -> bool {
2654
2579
match get ( ty) . sty {
2655
2580
// FIXME(#6308) add trait, vec, str, etc here.
@@ -2681,14 +2606,6 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: t) -> bool {
2681
2606
}
2682
2607
}
2683
2608
2684
- pub fn type_param ( ty : t ) -> Option < uint > {
2685
- match get ( ty) . sty {
2686
- ty_param( p) => return Some ( p. idx ) ,
2687
- _ => { /* fall through */ }
2688
- }
2689
- return None ;
2690
- }
2691
-
2692
2609
// Returns the type and mutability of *t.
2693
2610
//
2694
2611
// The parameter `explicit` indicates if this is an *explicit* dereference.
@@ -2751,10 +2668,6 @@ pub fn node_id_to_type_params(cx: &ctxt, id: ast::NodeId) -> Vec<t> {
2751
2668
}
2752
2669
}
2753
2670
2754
- fn node_id_has_type_params ( cx : & ctxt , id : ast:: NodeId ) -> bool {
2755
- cx. node_type_substs . borrow ( ) . contains_key ( & id)
2756
- }
2757
-
2758
2671
pub fn fn_is_variadic ( fty : t ) -> bool {
2759
2672
match get ( fty) . sty {
2760
2673
ty_bare_fn( ref f) => f. sig . variadic ,
@@ -2795,16 +2708,6 @@ pub fn ty_closure_sigil(fty: t) -> Sigil {
2795
2708
}
2796
2709
}
2797
2710
2798
- pub fn ty_fn_purity ( fty : t ) -> ast:: Purity {
2799
- match get ( fty) . sty {
2800
- ty_bare_fn( ref f) => f. purity ,
2801
- ty_closure( ref f) => f. purity ,
2802
- ref s => {
2803
- fail ! ( "ty_fn_purity() called on non-fn type: {:?}" , s)
2804
- }
2805
- }
2806
- }
2807
-
2808
2711
pub fn ty_fn_ret ( fty : t ) -> t {
2809
2712
match get ( fty) . sty {
2810
2713
ty_bare_fn( ref f) => f. sig . output ,
@@ -2823,14 +2726,6 @@ pub fn is_fn_ty(fty: t) -> bool {
2823
2726
}
2824
2727
}
2825
2728
2826
- pub fn ty_vstore ( ty : t ) -> vstore {
2827
- match get ( ty) . sty {
2828
- ty_vec( _, vstore) => vstore,
2829
- ty_str( vstore) => vstore,
2830
- ref s => fail ! ( "ty_vstore() called on invalid sty: {:?}" , s)
2831
- }
2832
- }
2833
-
2834
2729
pub fn ty_region ( tcx : & ctxt ,
2835
2730
span : Span ,
2836
2731
ty : t ) -> Region {
@@ -2846,49 +2741,6 @@ pub fn ty_region(tcx: &ctxt,
2846
2741
}
2847
2742
}
2848
2743
2849
- pub fn replace_fn_sig ( cx : & ctxt , fsty : & sty , new_sig : FnSig ) -> t {
2850
- match * fsty {
2851
- ty_bare_fn( ref f) => mk_bare_fn ( cx, BareFnTy { sig : new_sig, ..* f} ) ,
2852
- ty_closure( ref f) => mk_closure ( cx, ClosureTy { sig : new_sig, ..* * f} ) ,
2853
- ref s => {
2854
- cx. sess . bug (
2855
- format ! ( "ty_fn_sig() called on non-fn type: {:?}" , s) ) ;
2856
- }
2857
- }
2858
- }
2859
-
2860
- pub fn replace_closure_return_type ( tcx : & ctxt , fn_type : t , ret_type : t ) -> t {
2861
- /*!
2862
- *
2863
- * Returns a new function type based on `fn_type` but returning a value of
2864
- * type `ret_type` instead. */
2865
-
2866
- match ty:: get ( fn_type) . sty {
2867
- ty:: ty_closure( ref fty) => {
2868
- ty:: mk_closure ( tcx, ClosureTy {
2869
- sig : FnSig { output : ret_type, ..fty. sig . clone ( ) } ,
2870
- ..( * * fty) . clone ( )
2871
- } )
2872
- }
2873
- _ => {
2874
- tcx. sess . bug ( format ! (
2875
- "replace_fn_ret() invoked with non-fn-type: {}" ,
2876
- ty_to_str( tcx, fn_type) ) ) ;
2877
- }
2878
- }
2879
- }
2880
-
2881
- // Returns a vec of all the input and output types of fty.
2882
- pub fn tys_in_fn_sig ( sig : & FnSig ) -> Vec < t > {
2883
- sig. inputs . iter ( ) . map ( |a| * a) . collect :: < Vec < _ > > ( ) . append_one ( sig. output )
2884
- }
2885
-
2886
- // Type accessors for AST nodes
2887
- pub fn block_ty ( cx : & ctxt , b : & ast:: Block ) -> t {
2888
- return node_id_to_type ( cx, b. id ) ;
2889
- }
2890
-
2891
-
2892
2744
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
2893
2745
// doesn't provide type parameter substitutions.
2894
2746
pub fn pat_ty ( cx : & ctxt , pat : & ast:: Pat ) -> t {
@@ -3180,6 +3032,7 @@ pub struct ParamsTy {
3180
3032
pub ty : t
3181
3033
}
3182
3034
3035
+ #[ allow( dead_code) ] // this may be useful?
3183
3036
pub fn expr_ty_params_and_ty ( cx : & ctxt ,
3184
3037
expr : & ast:: Expr )
3185
3038
-> ParamsTy {
@@ -3189,10 +3042,6 @@ pub fn expr_ty_params_and_ty(cx: &ctxt,
3189
3042
}
3190
3043
}
3191
3044
3192
- pub fn expr_has_ty_params ( cx : & ctxt , expr : & ast:: Expr ) -> bool {
3193
- return node_id_has_type_params ( cx, expr. id ) ;
3194
- }
3195
-
3196
3045
pub fn method_call_type_param_defs ( tcx : & ctxt , origin : typeck:: MethodOrigin )
3197
3046
-> Rc < Vec < TypeParameterDef > > {
3198
3047
match origin {
@@ -3416,12 +3265,6 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId {
3416
3265
}
3417
3266
}
3418
3267
3419
- pub fn field_idx ( name : ast:: Name , fields : & [ field ] ) -> Option < uint > {
3420
- let mut i = 0 u;
3421
- for f in fields. iter ( ) { if f. ident . name == name { return Some ( i) ; } i += 1 u; }
3422
- return None ;
3423
- }
3424
-
3425
3268
pub fn field_idx_strict ( tcx : & ctxt , name : ast:: Name , fields : & [ field ] )
3426
3269
-> uint {
3427
3270
let mut i = 0 u;
@@ -3657,14 +3500,6 @@ pub fn note_and_explain_type_err(cx: &ctxt, err: &type_err) {
3657
3500
}
3658
3501
}
3659
3502
3660
- pub fn def_has_ty_params ( def : ast:: Def ) -> bool {
3661
- match def {
3662
- ast:: DefFn ( _, _) | ast:: DefVariant ( _, _, _) | ast:: DefStruct ( _)
3663
- => true ,
3664
- _ => false
3665
- }
3666
- }
3667
-
3668
3503
pub fn provided_source ( cx : & ctxt , id : ast:: DefId ) -> Option < ast:: DefId > {
3669
3504
cx. provided_method_sources . borrow ( ) . find ( & id) . map ( |x| * x)
3670
3505
}
@@ -3843,8 +3678,8 @@ pub fn try_add_builtin_trait(tcx: &ctxt,
3843
3678
3844
3679
pub fn ty_to_def_id ( ty : t ) -> Option < ast:: DefId > {
3845
3680
match get ( ty) . sty {
3846
- ty_trait( ~TyTrait { def_id : id, .. } ) | ty_struct( id, _) | ty_enum( id, _) => Some ( id) ,
3847
- _ => None
3681
+ ty_trait( ~TyTrait { def_id : id, .. } ) | ty_struct( id, _) | ty_enum( id, _) => Some ( id) ,
3682
+ _ => None
3848
3683
}
3849
3684
}
3850
3685
@@ -4240,18 +4075,6 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
4240
4075
}
4241
4076
}
4242
4077
4243
- pub fn lookup_struct_field ( cx : & ctxt ,
4244
- parent : ast:: DefId ,
4245
- field_id : ast:: DefId )
4246
- -> field_ty {
4247
- let r = lookup_struct_fields ( cx, parent) ;
4248
- match r. iter ( ) . find (
4249
- |f| f. id . node == field_id. node ) {
4250
- Some ( t) => * t,
4251
- None => cx. sess . bug ( "struct ID not found in parent's fields" )
4252
- }
4253
- }
4254
-
4255
4078
fn struct_field_tys ( fields : & [ StructField ] ) -> Vec < field_ty > {
4256
4079
fields. iter ( ) . map ( |field| {
4257
4080
match field. node . kind {
@@ -4361,13 +4184,6 @@ pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool {
4361
4184
return tbl[ tycat ( cx, ty) ] [ opcat ( op) ] ;
4362
4185
}
4363
4186
4364
- pub fn ty_params_to_tys ( tcx : & ctxt , generics : & ast:: Generics ) -> Vec < t > {
4365
- Vec :: from_fn ( generics. ty_params . len ( ) , |i| {
4366
- let id = generics. ty_params . get ( i) . id ;
4367
- ty:: mk_param ( tcx, i, ast_util:: local_def ( id) )
4368
- } )
4369
- }
4370
-
4371
4187
/// Returns an equivalent type with all the typedefs and self regions removed.
4372
4188
pub fn normalize_ty ( cx : & ctxt , t : t ) -> t {
4373
4189
let u = TypeNormalizer ( cx) . fold_ty ( t) ;
@@ -4547,19 +4363,6 @@ pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
4547
4363
return true ;
4548
4364
}
4549
4365
4550
- pub fn count_traits_and_supertraits ( tcx : & ctxt ,
4551
- type_param_defs : & [ TypeParameterDef ] ) -> uint {
4552
- let mut total = 0 ;
4553
- for type_param_def in type_param_defs. iter ( ) {
4554
- each_bound_trait_and_supertraits (
4555
- tcx, type_param_def. bounds . trait_bounds . as_slice ( ) , |_| {
4556
- total += 1 ;
4557
- true
4558
- } ) ;
4559
- }
4560
- return total;
4561
- }
4562
-
4563
4366
pub fn get_tydesc_ty ( tcx : & ctxt ) -> Result < t , ~str > {
4564
4367
tcx. lang_items . require ( TyDescStructLangItem ) . map ( |tydesc_lang_item| {
4565
4368
tcx. intrinsic_defs . borrow ( ) . find_copy ( & tydesc_lang_item)
@@ -5043,12 +4846,4 @@ impl BorrowKind {
5043
4846
UniqueImmBorrow => "uniquely immutable" ,
5044
4847
}
5045
4848
}
5046
-
5047
- pub fn to_short_str ( & self ) -> & ' static str {
5048
- match * self {
5049
- MutBorrow => "mut" ,
5050
- ImmBorrow => "imm" ,
5051
- UniqueImmBorrow => "own" ,
5052
- }
5053
- }
5054
4849
}
0 commit comments