diff options
author | Domantas Jadenkus <[email protected]> | 2021-02-13 20:38:52 +0000 |
---|---|---|
committer | Domantas Jadenkus <[email protected]> | 2021-02-13 20:45:22 +0000 |
commit | 3364ac8b1106f6f0d8a52a8981c6c598152b5642 (patch) | |
tree | e68744a8faf0ba5762df77e7e2d6670ae432a496 /crates/assists/src/utils.rs | |
parent | ff7ea7c30843e576be6ab3fb70f79d8053006652 (diff) |
use generate_impl_text in generate_impl
Diffstat (limited to 'crates/assists/src/utils.rs')
-rw-r--r-- | crates/assists/src/utils.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 69c107f63..b51d703db 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs | |||
@@ -379,7 +379,14 @@ pub(crate) fn generate_trait_impl_text(adt: &ast::Adt, trait_text: &str, code: & | |||
379 | fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str) -> String { | 379 | fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str) -> String { |
380 | let type_params = adt.generic_param_list(); | 380 | let type_params = adt.generic_param_list(); |
381 | let mut buf = String::with_capacity(code.len()); | 381 | let mut buf = String::with_capacity(code.len()); |
382 | buf.push_str("\n\nimpl"); | 382 | buf.push_str("\n\n"); |
383 | adt | ||
384 | .attrs() | ||
385 | .filter(|attr| { | ||
386 | attr.as_simple_call().map(|(name, _arg)| name == "cfg").unwrap_or(false) | ||
387 | }) | ||
388 | .for_each(|attr| buf.push_str(format!("{}\n", attr.to_string()).as_str())); | ||
389 | buf.push_str("impl"); | ||
383 | if let Some(type_params) = &type_params { | 390 | if let Some(type_params) = &type_params { |
384 | format_to!(buf, "{}", type_params.syntax()); | 391 | format_to!(buf, "{}", type_params.syntax()); |
385 | } | 392 | } |