@@ -34,7 +34,7 @@ use util::nodemap::FnvHashMap;
34
34
35
35
use serialize:: { self , Encodable , Encoder } ;
36
36
use std:: borrow:: Cow ;
37
- use std:: cell:: { Cell , RefCell } ;
37
+ use std:: cell:: { Cell , RefCell , Ref } ;
38
38
use std:: hash:: { Hash , Hasher } ;
39
39
use std:: iter;
40
40
use std:: ops:: Deref ;
@@ -2119,52 +2119,8 @@ impl BorrowKind {
2119
2119
}
2120
2120
2121
2121
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
2122
- pub fn node_id_to_type ( self , id : NodeId ) -> Ty < ' gcx > {
2123
- match self . node_id_to_type_opt ( id) {
2124
- Some ( ty) => ty,
2125
- None => bug ! ( "node_id_to_type: no type for node `{}`" ,
2126
- self . map. node_to_string( id) )
2127
- }
2128
- }
2129
-
2130
- pub fn node_id_to_type_opt ( self , id : NodeId ) -> Option < Ty < ' gcx > > {
2131
- self . tables . borrow ( ) . node_types . get ( & id) . cloned ( )
2132
- }
2133
-
2134
- pub fn node_id_item_substs ( self , id : NodeId ) -> ItemSubsts < ' gcx > {
2135
- match self . tables . borrow ( ) . item_substs . get ( & id) {
2136
- None => ItemSubsts {
2137
- substs : self . global_tcx ( ) . intern_substs ( & [ ] )
2138
- } ,
2139
- Some ( ts) => ts. clone ( ) ,
2140
- }
2141
- }
2142
-
2143
- // Returns the type of a pattern as a monotype. Like @expr_ty, this function
2144
- // doesn't provide type parameter substitutions.
2145
- pub fn pat_ty ( self , pat : & hir:: Pat ) -> Ty < ' gcx > {
2146
- self . node_id_to_type ( pat. id )
2147
- }
2148
- pub fn pat_ty_opt ( self , pat : & hir:: Pat ) -> Option < Ty < ' gcx > > {
2149
- self . node_id_to_type_opt ( pat. id )
2150
- }
2151
-
2152
- // Returns the type of an expression as a monotype.
2153
- //
2154
- // NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in
2155
- // some cases, we insert `AutoAdjustment` annotations such as auto-deref or
2156
- // auto-ref. The type returned by this function does not consider such
2157
- // adjustments. See `expr_ty_adjusted()` instead.
2158
- //
2159
- // NB (2): This type doesn't provide type parameter substitutions; e.g. if you
2160
- // ask for the type of "id" in "id(3)", it will return "fn(&isize) -> isize"
2161
- // instead of "fn(ty) -> T with T = isize".
2162
- pub fn expr_ty ( self , expr : & hir:: Expr ) -> Ty < ' gcx > {
2163
- self . node_id_to_type ( expr. id )
2164
- }
2165
-
2166
- pub fn expr_ty_opt ( self , expr : & hir:: Expr ) -> Option < Ty < ' gcx > > {
2167
- self . node_id_to_type_opt ( expr. id )
2122
+ pub fn tables ( self ) -> Ref < ' a , Tables < ' gcx > > {
2123
+ self . tables . borrow ( )
2168
2124
}
2169
2125
2170
2126
/// Returns the type of `expr`, considering any `AutoAdjustment`
@@ -2177,21 +2133,21 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2177
2133
/// unless it was to fix it properly, which seemed a distraction from the
2178
2134
/// thread at hand! -nmatsakis
2179
2135
pub fn expr_ty_adjusted ( self , expr : & hir:: Expr ) -> Ty < ' gcx > {
2180
- self . expr_ty ( expr)
2136
+ self . tables ( ) . expr_ty ( expr)
2181
2137
. adjust ( self . global_tcx ( ) , expr. span , expr. id ,
2182
- self . tables . borrow ( ) . adjustments . get ( & expr. id ) ,
2138
+ self . tables ( ) . adjustments . get ( & expr. id ) ,
2183
2139
|method_call| {
2184
- self . tables . borrow ( ) . method_map . get ( & method_call) . map ( |method| method. ty )
2140
+ self . tables ( ) . method_map . get ( & method_call) . map ( |method| method. ty )
2185
2141
} )
2186
2142
}
2187
2143
2188
2144
pub fn expr_ty_adjusted_opt ( self , expr : & hir:: Expr ) -> Option < Ty < ' gcx > > {
2189
- self . expr_ty_opt ( expr) . map ( |t| t. adjust ( self . global_tcx ( ) ,
2145
+ self . tables ( ) . expr_ty_opt ( expr) . map ( |t| t. adjust ( self . global_tcx ( ) ,
2190
2146
expr. span ,
2191
2147
expr. id ,
2192
- self . tables . borrow ( ) . adjustments . get ( & expr. id ) ,
2148
+ self . tables ( ) . adjustments . get ( & expr. id ) ,
2193
2149
|method_call| {
2194
- self . tables . borrow ( ) . method_map . get ( & method_call) . map ( |method| method. ty )
2150
+ self . tables ( ) . method_map . get ( & method_call) . map ( |method| method. ty )
2195
2151
} ) )
2196
2152
}
2197
2153
@@ -2894,19 +2850,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2894
2850
self . mk_region ( ty:: ReScope ( self . region_maps . node_extent ( id) ) )
2895
2851
}
2896
2852
2897
- pub fn is_method_call ( self , expr_id : NodeId ) -> bool {
2898
- self . tables . borrow ( ) . method_map . contains_key ( & MethodCall :: expr ( expr_id) )
2899
- }
2900
-
2901
- pub fn is_overloaded_autoderef ( self , expr_id : NodeId , autoderefs : u32 ) -> bool {
2902
- self . tables . borrow ( ) . method_map . contains_key ( & MethodCall :: autoderef ( expr_id,
2903
- autoderefs) )
2904
- }
2905
-
2906
- pub fn upvar_capture ( self , upvar_id : ty:: UpvarId ) -> Option < ty:: UpvarCapture < ' tcx > > {
2907
- Some ( self . tables . borrow ( ) . upvar_capture_map . get ( & upvar_id) . unwrap ( ) . clone ( ) )
2908
- }
2909
-
2910
2853
pub fn visit_all_items_in_krate < V , F > ( self ,
2911
2854
dep_node_fn : F ,
2912
2855
visitor : & mut V )
0 commit comments