@@ -34,7 +34,7 @@ use util::nodemap::FnvHashMap;
3434
3535use serialize:: { self , Encodable , Encoder } ;
3636use std:: borrow:: Cow ;
37- use std:: cell:: { Cell , RefCell } ;
37+ use std:: cell:: { Cell , RefCell , Ref } ;
3838use std:: hash:: { Hash , Hasher } ;
3939use std:: iter;
4040use std:: ops:: Deref ;
@@ -2119,52 +2119,8 @@ impl BorrowKind {
21192119}
21202120
21212121impl < ' 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 ( )
21682124 }
21692125
21702126 /// Returns the type of `expr`, considering any `AutoAdjustment`
@@ -2177,21 +2133,21 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
21772133 /// unless it was to fix it properly, which seemed a distraction from the
21782134 /// thread at hand! -nmatsakis
21792135 pub fn expr_ty_adjusted ( self , expr : & hir:: Expr ) -> Ty < ' gcx > {
2180- self . expr_ty ( expr)
2136+ self . tables ( ) . expr_ty ( expr)
21812137 . adjust ( self . global_tcx ( ) , expr. span , expr. id ,
2182- self . tables . borrow ( ) . adjustments . get ( & expr. id ) ,
2138+ self . tables ( ) . adjustments . get ( & expr. id ) ,
21832139 |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 )
21852141 } )
21862142 }
21872143
21882144 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 ( ) ,
21902146 expr. span ,
21912147 expr. id ,
2192- self . tables . borrow ( ) . adjustments . get ( & expr. id ) ,
2148+ self . tables ( ) . adjustments . get ( & expr. id ) ,
21932149 |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 )
21952151 } ) )
21962152 }
21972153
@@ -2894,19 +2850,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
28942850 self . mk_region ( ty:: ReScope ( self . region_maps . node_extent ( id) ) )
28952851 }
28962852
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-
29102853 pub fn visit_all_items_in_krate < V , F > ( self ,
29112854 dep_node_fn : F ,
29122855 visitor : & mut V )
0 commit comments