aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-13 10:47:31 +0100
committerAleksey Kladov <[email protected]>2020-08-13 10:48:26 +0100
commit479235ff0b25dbac977d28475b9203e3207b117b (patch)
tree82cc0adef2f2bc7378086fb639c62bd9c0384bdf /crates/ra_assists/src
parent80c241b39a02a949c745676e22b28db95186feda (diff)
Minor
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
index 6e9f2d0fc..b4e19b3dc 100644
--- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -6,7 +6,7 @@ use rustc_hash::FxHashSet;
6use syntax::{ 6use syntax::{
7 algo::find_node_at_offset, 7 algo::find_node_at_offset,
8 ast::{self, ArgListOwner, AstNode, NameOwner, VisibilityOwner}, 8 ast::{self, ArgListOwner, AstNode, NameOwner, VisibilityOwner},
9 SourceFile, SyntaxNode, TextRange, TextSize, 9 SourceFile, TextRange, TextSize,
10}; 10};
11 11
12use crate::{ 12use crate::{
@@ -72,7 +72,7 @@ pub(crate) fn extract_struct_from_enum_variant(
72 } 72 }
73 extract_struct_def( 73 extract_struct_def(
74 builder, 74 builder,
75 enum_ast.syntax(), 75 &enum_ast,
76 &variant_name, 76 &variant_name,
77 &field_list.to_string(), 77 &field_list.to_string(),
78 start_offset, 78 start_offset,
@@ -112,9 +112,10 @@ fn insert_import(
112 Some(()) 112 Some(())
113} 113}
114 114
115// FIXME: this should use strongly-typed `make`, rather than string manipulation1
115fn extract_struct_def( 116fn extract_struct_def(
116 builder: &mut AssistBuilder, 117 builder: &mut AssistBuilder,
117 enum_ast: &SyntaxNode, 118 enum_: &ast::Enum,
118 variant_name: &str, 119 variant_name: &str,
119 variant_list: &str, 120 variant_list: &str,
120 start_offset: TextSize, 121 start_offset: TextSize,
@@ -126,7 +127,7 @@ fn extract_struct_def(
126 } else { 127 } else {
127 "".to_string() 128 "".to_string()
128 }; 129 };
129 let indent = if let Some(indent) = leading_indent(enum_ast) { 130 let indent = if let Some(indent) = leading_indent(enum_.syntax()) {
130 indent.to_string() 131 indent.to_string()
131 } else { 132 } else {
132 "".to_string() 133 "".to_string()