@@ -206,8 +206,9 @@ pub struct CommonTypes<'tcx> {
206206
207207#[ derive( RustcEncodable , RustcDecodable ) ]
208208pub struct TypeckTables < ' tcx > {
209- /// Resolved definitions for `<T>::X` associated paths.
210- pub type_relative_path_defs : NodeMap < Def > ,
209+ /// Resolved definitions for `<T>::X` associated paths and
210+ /// method calls, including those of overloaded operators.
211+ pub type_dependent_defs : NodeMap < Def > ,
211212
212213 /// Stores the types for various nodes in the AST. Note that this table
213214 /// is not guaranteed to be populated until after typeck. See
@@ -222,8 +223,6 @@ pub struct TypeckTables<'tcx> {
222223
223224 pub adjustments : NodeMap < ty:: adjustment:: Adjustment < ' tcx > > ,
224225
225- pub method_map : NodeMap < ty:: MethodCallee < ' tcx > > ,
226-
227226 /// Borrows
228227 pub upvar_capture_map : ty:: UpvarCaptureMap < ' tcx > ,
229228
@@ -271,11 +270,10 @@ pub struct TypeckTables<'tcx> {
271270impl < ' tcx > TypeckTables < ' tcx > {
272271 pub fn empty ( ) -> TypeckTables < ' tcx > {
273272 TypeckTables {
274- type_relative_path_defs : NodeMap ( ) ,
273+ type_dependent_defs : NodeMap ( ) ,
275274 node_types : FxHashMap ( ) ,
276275 node_substs : NodeMap ( ) ,
277276 adjustments : NodeMap ( ) ,
278- method_map : FxHashMap ( ) ,
279277 upvar_capture_map : FxHashMap ( ) ,
280278 closure_tys : NodeMap ( ) ,
281279 closure_kinds : NodeMap ( ) ,
@@ -294,7 +292,7 @@ impl<'tcx> TypeckTables<'tcx> {
294292 match * qpath {
295293 hir:: QPath :: Resolved ( _, ref path) => path. def ,
296294 hir:: QPath :: TypeRelative ( ..) => {
297- self . type_relative_path_defs . get ( & id) . cloned ( ) . unwrap_or ( Def :: Err )
295+ self . type_dependent_defs . get ( & id) . cloned ( ) . unwrap_or ( Def :: Err )
298296 }
299297 }
300298 }
@@ -357,8 +355,17 @@ impl<'tcx> TypeckTables<'tcx> {
357355 . map ( |adj| adj. target ) . or_else ( || self . expr_ty_opt ( expr) )
358356 }
359357
360- pub fn is_method_call ( & self , expr_id : NodeId ) -> bool {
361- self . method_map . contains_key ( & expr_id)
358+ pub fn is_method_call ( & self , expr : & hir:: Expr ) -> bool {
359+ // Only paths and method calls/overloaded operators have
360+ // entries in type_dependent_defs, ignore the former here.
361+ if let hir:: ExprPath ( _) = expr. node {
362+ return false ;
363+ }
364+
365+ match self . type_dependent_defs . get ( & expr. id ) {
366+ Some ( & Def :: Method ( _) ) => true ,
367+ _ => false
368+ }
362369 }
363370
364371 pub fn upvar_capture ( & self , upvar_id : ty:: UpvarId ) -> Option < ty:: UpvarCapture < ' tcx > > {
0 commit comments