@@ -62,6 +62,13 @@ impl MarkSymbolVisitor {
6262 }
6363 }
6464
65+ fn check_def_id ( & mut self , def_id : ast:: DefId ) {
66+ if should_explore ( self . tcx , def_id) {
67+ self . worklist . push ( def_id. node ) ;
68+ }
69+ self . live_symbols . insert ( def_id. node ) ;
70+ }
71+
6572 fn lookup_and_handle_definition ( & mut self , id : & ast:: NodeId ) {
6673 let def_map = self . tcx . def_map . borrow ( ) ;
6774 let def = match def_map. get ( ) . find ( id) {
@@ -74,13 +81,44 @@ impl MarkSymbolVisitor {
7481 _ => Some ( def_id_of_def ( def) ) ,
7582 } ;
7683 match def_id {
77- Some ( def_id) => {
78- if should_explore ( self . tcx , def_id) {
79- self . worklist . push ( def_id. node ) ;
84+ Some ( def_id) => self . check_def_id ( def_id) ,
85+ None => ( ) ,
86+ }
87+ }
88+
89+ fn lookup_and_handle_method ( & mut self , id : & ast:: NodeId ,
90+ span : codemap:: Span ) {
91+ let method_map = self . method_map . borrow ( ) ;
92+ match method_map. get ( ) . find ( id) {
93+ Some ( & typeck:: method_map_entry { origin, .. } ) => {
94+ match origin {
95+ typeck:: method_static( def_id) => {
96+ match ty:: provided_source ( self . tcx , def_id) {
97+ Some ( p_did) => self . check_def_id ( p_did) ,
98+ None => self . check_def_id ( def_id)
99+ }
100+ }
101+ typeck:: method_param( typeck:: method_param {
102+ trait_id : trait_id,
103+ method_num : index,
104+ ..
105+ } )
106+ | typeck:: method_object( typeck:: method_object {
107+ trait_id : trait_id,
108+ method_num : index,
109+ ..
110+ } ) => {
111+ let def_id = ty:: trait_method ( self . tcx ,
112+ trait_id, index) . def_id ;
113+ self . check_def_id ( def_id) ;
114+ }
80115 }
81- self . live_symbols . insert ( def_id. node ) ;
82116 }
83- None => ( ) ,
117+ None => {
118+ self . tcx . sess . span_bug ( span,
119+ "method call expression not \
120+ in method map?!")
121+ }
84122 }
85123 }
86124
@@ -135,24 +173,7 @@ impl Visitor<()> for MarkSymbolVisitor {
135173 fn visit_expr ( & mut self , expr : @ast:: Expr , _: ( ) ) {
136174 match expr. node {
137175 ast:: ExprMethodCall ( ..) => {
138- let method_map = self . method_map . borrow ( ) ;
139- match method_map. get ( ) . find ( & expr. id ) {
140- Some ( & typeck:: method_map_entry {
141- origin : typeck:: method_static( def_id) ,
142- ..
143- } ) => {
144- if should_explore ( self . tcx , def_id) {
145- self . worklist . push ( def_id. node ) ;
146- }
147- self . live_symbols . insert ( def_id. node ) ;
148- }
149- Some ( _) => ( ) ,
150- None => {
151- self . tcx . sess . span_bug ( expr. span ,
152- "method call expression not \
153- in method map?!")
154- }
155- }
176+ self . lookup_and_handle_method ( & expr. id , expr. span ) ;
156177 }
157178 _ => ( )
158179 }
0 commit comments