diff options
Diffstat (limited to 'crates/ide_assists/src/handlers')
3 files changed, 14 insertions, 33 deletions
diff --git a/crates/ide_assists/src/handlers/expand_glob_import.rs b/crates/ide_assists/src/handlers/expand_glob_import.rs index 5b540df5c..83aa11d52 100644 --- a/crates/ide_assists/src/handlers/expand_glob_import.rs +++ b/crates/ide_assists/src/handlers/expand_glob_import.rs | |||
@@ -73,8 +73,8 @@ fn find_parent_and_path( | |||
73 | ) -> Option<(Either<ast::UseTree, ast::UseTreeList>, ast::Path)> { | 73 | ) -> Option<(Either<ast::UseTree, ast::UseTreeList>, ast::Path)> { |
74 | return star.ancestors().find_map(|n| { | 74 | return star.ancestors().find_map(|n| { |
75 | find_use_tree_list(n.clone()) | 75 | find_use_tree_list(n.clone()) |
76 | .and_then(|(u, p)| Some((Either::Right(u), p))) | 76 | .map(|(u, p)| (Either::Right(u), p)) |
77 | .or_else(|| find_use_tree(n).and_then(|(u, p)| Some((Either::Left(u), p)))) | 77 | .or_else(|| find_use_tree(n).map(|(u, p)| (Either::Left(u), p))) |
78 | }); | 78 | }); |
79 | 79 | ||
80 | fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> { | 80 | fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> { |
diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs index 335e0ed95..596c536a7 100644 --- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -145,11 +145,8 @@ fn insert_import( | |||
145 | variant_hir_name: &Name, | 145 | variant_hir_name: &Name, |
146 | ) -> Option<()> { | 146 | ) -> Option<()> { |
147 | let db = ctx.db(); | 147 | let db = ctx.db(); |
148 | let mod_path = module.find_use_path_prefixed( | 148 | let mod_path = |
149 | db, | 149 | module.find_use_path_prefixed(db, *enum_module_def, ctx.config.insert_use.prefix_kind); |
150 | enum_module_def.clone(), | ||
151 | ctx.config.insert_use.prefix_kind, | ||
152 | ); | ||
153 | if let Some(mut mod_path) = mod_path { | 150 | if let Some(mut mod_path) = mod_path { |
154 | mod_path.pop_segment(); | 151 | mod_path.pop_segment(); |
155 | mod_path.push_segment(variant_hir_name.clone()); | 152 | mod_path.push_segment(variant_hir_name.clone()); |
diff --git a/crates/ide_assists/src/handlers/move_bounds.rs b/crates/ide_assists/src/handlers/move_bounds.rs index 48efa67ed..9ad0c9816 100644 --- a/crates/ide_assists/src/handlers/move_bounds.rs +++ b/crates/ide_assists/src/handlers/move_bounds.rs | |||
@@ -40,9 +40,9 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext | |||
40 | let where_clause: ast::WhereClause = match_ast! { | 40 | let where_clause: ast::WhereClause = match_ast! { |
41 | match parent { | 41 | match parent { |
42 | ast::Fn(it) => it.get_or_create_where_clause(), | 42 | ast::Fn(it) => it.get_or_create_where_clause(), |
43 | // ast::Trait(it) => it.get_or_create_where_clause(), | 43 | ast::Trait(it) => it.get_or_create_where_clause(), |
44 | ast::Impl(it) => it.get_or_create_where_clause(), | 44 | ast::Impl(it) => it.get_or_create_where_clause(), |
45 | // ast::Enum(it) => it.get_or_create_where_clause(), | 45 | ast::Enum(it) => it.get_or_create_where_clause(), |
46 | ast::Struct(it) => it.get_or_create_where_clause(), | 46 | ast::Struct(it) => it.get_or_create_where_clause(), |
47 | _ => return, | 47 | _ => return, |
48 | } | 48 | } |
@@ -82,12 +82,8 @@ mod tests { | |||
82 | fn move_bounds_to_where_clause_fn() { | 82 | fn move_bounds_to_where_clause_fn() { |
83 | check_assist( | 83 | check_assist( |
84 | move_bounds_to_where_clause, | 84 | move_bounds_to_where_clause, |
85 | r#" | 85 | r#"fn foo<T: u32, $0F: FnOnce(T) -> T>() {}"#, |
86 | fn foo<T: u32, $0F: FnOnce(T) -> T>() {} | 86 | r#"fn foo<T, F>() where T: u32, F: FnOnce(T) -> T {}"#, |
87 | "#, | ||
88 | r#" | ||
89 | fn foo<T, F>() where T: u32, F: FnOnce(T) -> T {} | ||
90 | "#, | ||
91 | ); | 87 | ); |
92 | } | 88 | } |
93 | 89 | ||
@@ -95,12 +91,8 @@ mod tests { | |||
95 | fn move_bounds_to_where_clause_impl() { | 91 | fn move_bounds_to_where_clause_impl() { |
96 | check_assist( | 92 | check_assist( |
97 | move_bounds_to_where_clause, | 93 | move_bounds_to_where_clause, |
98 | r#" | 94 | r#"impl<U: u32, $0T> A<U, T> {}"#, |
99 | impl<U: u32, $0T> A<U, T> {} | 95 | r#"impl<U, T> A<U, T> where U: u32 {}"#, |
100 | "#, | ||
101 | r#" | ||
102 | impl<U, T> A<U, T> where U: u32 {} | ||
103 | "#, | ||
104 | ); | 96 | ); |
105 | } | 97 | } |
106 | 98 | ||
@@ -108,12 +100,8 @@ mod tests { | |||
108 | fn move_bounds_to_where_clause_struct() { | 100 | fn move_bounds_to_where_clause_struct() { |
109 | check_assist( | 101 | check_assist( |
110 | move_bounds_to_where_clause, | 102 | move_bounds_to_where_clause, |
111 | r#" | 103 | r#"struct A<$0T: Iterator<Item = u32>> {}"#, |
112 | struct A<$0T: Iterator<Item = u32>> {} | 104 | r#"struct A<T> where T: Iterator<Item = u32> {}"#, |
113 | "#, | ||
114 | r#" | ||
115 | struct A<T> where T: Iterator<Item = u32> {} | ||
116 | "#, | ||
117 | ); | 105 | ); |
118 | } | 106 | } |
119 | 107 | ||
@@ -121,12 +109,8 @@ mod tests { | |||
121 | fn move_bounds_to_where_clause_tuple_struct() { | 109 | fn move_bounds_to_where_clause_tuple_struct() { |
122 | check_assist( | 110 | check_assist( |
123 | move_bounds_to_where_clause, | 111 | move_bounds_to_where_clause, |
124 | r#" | 112 | r#"struct Pair<$0T: u32>(T, T);"#, |
125 | struct Pair<$0T: u32>(T, T); | 113 | r#"struct Pair<T>(T, T) where T: u32;"#, |
126 | "#, | ||
127 | r#" | ||
128 | struct Pair<T>(T, T) where T: u32; | ||
129 | "#, | ||
130 | ); | 114 | ); |
131 | } | 115 | } |
132 | } | 116 | } |