@@ -139,45 +139,42 @@ impl flags::Scip {
139139 let mut occurrences = Vec :: new ( ) ;
140140 let mut symbols = Vec :: new ( ) ;
141141
142- tokens . into_iter ( ) . for_each ( | ( text_range, id) | {
142+ for ( text_range, id) in tokens . into_iter ( ) {
143143 let token = si. tokens . get ( id) . unwrap ( ) ;
144144
145- let ( symbol, enclosing_symbol, is_inherent_impl) =
146- if let Some ( TokenSymbols { symbol, enclosing_symbol, is_inherent_impl } ) =
147- symbol_generator. token_symbols ( id, token)
148- {
149- ( symbol, enclosing_symbol, is_inherent_impl)
150- } else {
151- ( "" . to_owned ( ) , None , false )
152- } ;
145+ let Some ( TokenSymbols { symbol, enclosing_symbol, is_inherent_impl } ) =
146+ symbol_generator. token_symbols ( id, token)
147+ else {
148+ // token did not have a moniker, so there is no reasonable occurrence to emit
149+ // see ide::moniker::def_to_moniker
150+ continue ;
151+ } ;
153152
154- if !symbol. is_empty ( ) {
155- let is_defined_in_this_document = match token. definition {
156- Some ( def) => def. file_id == file_id,
157- _ => false ,
158- } ;
159- if is_defined_in_this_document {
160- if token_ids_emitted. insert ( id) {
161- // token_ids_emitted does deduplication. This checks that this results
162- // in unique emitted symbols, as otherwise references are ambiguous.
163- let should_emit = record_error_if_symbol_already_used (
153+ let is_defined_in_this_document = match token. definition {
154+ Some ( def) => def. file_id == file_id,
155+ _ => false ,
156+ } ;
157+ if is_defined_in_this_document {
158+ if token_ids_emitted. insert ( id) {
159+ // token_ids_emitted does deduplication. This checks that this results
160+ // in unique emitted symbols, as otherwise references are ambiguous.
161+ let should_emit = record_error_if_symbol_already_used (
162+ symbol. clone ( ) ,
163+ is_inherent_impl,
164+ relative_path. as_str ( ) ,
165+ & line_index,
166+ text_range,
167+ ) ;
168+ if should_emit {
169+ symbols. push ( compute_symbol_info (
164170 symbol. clone ( ) ,
165- is_inherent_impl,
166- relative_path. as_str ( ) ,
167- & line_index,
168- text_range,
169- ) ;
170- if should_emit {
171- symbols. push ( compute_symbol_info (
172- symbol. clone ( ) ,
173- enclosing_symbol,
174- token,
175- ) ) ;
176- }
171+ enclosing_symbol,
172+ token,
173+ ) ) ;
177174 }
178- } else {
179- token_ids_referenced. insert ( id) ;
180175 }
176+ } else {
177+ token_ids_referenced. insert ( id) ;
181178 }
182179
183180 // If the range of the def and the range of the token are the same, this must be the definition.
@@ -202,7 +199,7 @@ impl flags::Scip {
202199 special_fields : Default :: default ( ) ,
203200 enclosing_range : Vec :: new ( ) ,
204201 } ) ;
205- } ) ;
202+ }
206203
207204 if occurrences. is_empty ( ) {
208205 continue ;
0 commit comments