aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists/add_new.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-06 15:58:57 +0000
committerAleksey Kladov <[email protected]>2020-02-06 16:12:02 +0000
commitcf812c12d1ac7944d1c18877ee93bea02d91e99f (patch)
tree71e13733941e2c0520cfe5d16fb00f428f3233da /crates/ra_assists/src/assists/add_new.rs
parentf8965ffafd5cf467b3f0482ca962ba2bfd090161 (diff)
Assists are not generic
Diffstat (limited to 'crates/ra_assists/src/assists/add_new.rs')
-rw-r--r--crates/ra_assists/src/assists/add_new.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_assists/src/assists/add_new.rs b/crates/ra_assists/src/assists/add_new.rs
index 8db63f762..a08639311 100644
--- a/crates/ra_assists/src/assists/add_new.rs
+++ b/crates/ra_assists/src/assists/add_new.rs
@@ -1,5 +1,5 @@
1use format_buf::format; 1use format_buf::format;
2use hir::{db::HirDatabase, InFile}; 2use hir::InFile;
3use join_to_string::join; 3use join_to_string::join;
4use ra_syntax::{ 4use ra_syntax::{
5 ast::{ 5 ast::{
@@ -31,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId};
31// } 31// }
32// 32//
33// ``` 33// ```
34pub(crate) fn add_new(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 34pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> {
35 let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; 35 let strukt = ctx.find_node_at_offset::<ast::StructDef>()?;
36 36
37 // We want to only apply this to non-union structs with named fields 37 // We want to only apply this to non-union structs with named fields
@@ -128,10 +128,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
128// 128//
129// FIXME: change the new fn checking to a more semantic approach when that's more 129// FIXME: change the new fn checking to a more semantic approach when that's more
130// viable (e.g. we process proc macros, etc) 130// viable (e.g. we process proc macros, etc)
131fn find_struct_impl( 131fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplBlock>> {
132 ctx: &AssistCtx<impl HirDatabase>,
133 strukt: &ast::StructDef,
134) -> Option<Option<ast::ImplBlock>> {
135 let db = ctx.db; 132 let db = ctx.db;
136 let module = strukt.syntax().ancestors().find(|node| { 133 let module = strukt.syntax().ancestors().find(|node| {
137 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) 134 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())