@@ -18,7 +18,7 @@ use hir_ty::{
1818} ;
1919use intern:: Symbol ;
2020use rustc_hash:: FxHashMap ;
21- use syntax:: { AstNode , AstPtr , SmolStr , SyntaxNode , SyntaxNodePtr , ToSmolStr , ast:: HasName } ;
21+ use syntax:: { AstNode , AstPtr , SyntaxNode , SyntaxNodePtr , ToSmolStr , ast:: HasName } ;
2222
2323use crate :: { HasCrate , Module , ModuleDef , Semantics } ;
2424
@@ -29,7 +29,7 @@ pub struct FileSymbol {
2929 pub name : Symbol ,
3030 pub def : ModuleDef ,
3131 pub loc : DeclarationLocation ,
32- pub container_name : Option < SmolStr > ,
32+ pub container_name : Option < Symbol > ,
3333 /// Whether this symbol is a doc alias for the original symbol.
3434 pub is_alias : bool ,
3535 pub is_assoc : bool ,
@@ -65,7 +65,7 @@ pub struct SymbolCollector<'a> {
6565 db : & ' a dyn HirDatabase ,
6666 symbols : FxIndexSet < FileSymbol > ,
6767 work : Vec < SymbolCollectorWork > ,
68- current_container_name : Option < SmolStr > ,
68+ current_container_name : Option < Symbol > ,
6969}
7070
7171/// Given a [`ModuleId`] and a [`HirDatabase`], use the DefMap for the module's crate to collect
@@ -108,7 +108,7 @@ impl<'a> SymbolCollector<'a> {
108108 tracing:: info!( ?work, "SymbolCollector::do_work" ) ;
109109 self . db . unwind_if_revision_cancelled ( ) ;
110110
111- let parent_name = work. parent . map ( |name| name. as_str ( ) . to_smolstr ( ) ) ;
111+ let parent_name = work. parent . map ( |name| Symbol :: intern ( name. as_str ( ) ) ) ;
112112 self . with_container_name ( parent_name, |s| s. collect_from_module ( work. module_id ) ) ;
113113 }
114114
@@ -125,7 +125,7 @@ impl<'a> SymbolCollector<'a> {
125125 }
126126 ModuleDefId :: AdtId ( AdtId :: EnumId ( id) ) => {
127127 this. push_decl ( id, name, false , None ) ;
128- let enum_name = this. db . enum_signature ( id) . name . as_str ( ) . to_smolstr ( ) ;
128+ let enum_name = Symbol :: intern ( this. db . enum_signature ( id) . name . as_str ( ) ) ;
129129 this. with_container_name ( Some ( enum_name) , |this| {
130130 let variants = id. enum_variants ( this. db ) ;
131131 for ( variant_id, variant_name, _) in & variants. variants {
@@ -328,7 +328,7 @@ impl<'a> SymbolCollector<'a> {
328328 )
329329 . to_smolstr ( ) ,
330330 ) ;
331- self . with_container_name ( impl_name, |s| {
331+ self . with_container_name ( impl_name. as_deref ( ) . map ( Symbol :: intern ) , |s| {
332332 for & ( ref name, assoc_item_id) in & impl_id. impl_items ( self . db ) . items {
333333 s. push_assoc_item ( assoc_item_id, name, None )
334334 }
@@ -337,14 +337,14 @@ impl<'a> SymbolCollector<'a> {
337337
338338 fn collect_from_trait ( & mut self , trait_id : TraitId , trait_do_not_complete : Complete ) {
339339 let trait_data = self . db . trait_signature ( trait_id) ;
340- self . with_container_name ( Some ( trait_data. name . as_str ( ) . into ( ) ) , |s| {
340+ self . with_container_name ( Some ( Symbol :: intern ( trait_data. name . as_str ( ) ) ) , |s| {
341341 for & ( ref name, assoc_item_id) in & trait_id. trait_items ( self . db ) . items {
342342 s. push_assoc_item ( assoc_item_id, name, Some ( trait_do_not_complete) ) ;
343343 }
344344 } ) ;
345345 }
346346
347- fn with_container_name ( & mut self , container_name : Option < SmolStr > , f : impl FnOnce ( & mut Self ) ) {
347+ fn with_container_name ( & mut self , container_name : Option < Symbol > , f : impl FnOnce ( & mut Self ) ) {
348348 if let Some ( container_name) = container_name {
349349 let prev = self . current_container_name . replace ( container_name) ;
350350 f ( self ) ;
0 commit comments