]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide_completion/src/render/const_.rs
Replace some String usages with SmolStr in completions
[rust.git] / crates / ide_completion / src / render / const_.rs
index 241e0043c9c5222e8fd458625e7f76b4499ad12d..707b6533b5423e6a6556c5a07d377da56e97c2e9 100644 (file)
@@ -2,10 +2,7 @@
 
 use hir::{AsAssocItem, HasSource};
 use ide_db::SymbolKind;
-use syntax::{
-    ast::{Const, HasName},
-    display::const_label,
-};
+use syntax::{ast::Const, display::const_label};
 
 use crate::{item::CompletionItem, render::RenderContext};
 
@@ -27,7 +24,7 @@ fn new(ctx: RenderContext<'a>, const_: hir::Const) -> Option<ConstRender<'a>> {
     }
 
     fn render(self) -> Option<CompletionItem> {
-        let name = self.name()?;
+        let name = self.const_.name(self.ctx.db())?.to_smol_str();
         let detail = self.detail();
 
         let mut item =
@@ -42,7 +39,7 @@ fn render(self) -> Option<CompletionItem> {
         let db = self.ctx.db();
         if let Some(actm) = self.const_.as_assoc_item(db) {
             if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
-                item.trait_name(trt.name(db).to_string());
+                item.trait_name(trt.name(db).to_smol_str());
                 item.insert_text(name);
             }
         }
@@ -50,10 +47,6 @@ fn render(self) -> Option<CompletionItem> {
         Some(item.build())
     }
 
-    fn name(&self) -> Option<String> {
-        self.ast_node.name().map(|name| name.text().to_string())
-    }
-
     fn detail(&self) -> String {
         const_label(&self.ast_node)
     }