diff options
author | Aleksey Kladov <[email protected]> | 2021-05-09 17:51:06 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-05-09 17:55:43 +0100 |
commit | 4f3c0adc5aafea465c71c85f36484da970df1ba2 (patch) | |
tree | 4cb502a6c345c3ecfb4090067ab1de2cfd69ed55 /crates/ide_db | |
parent | 680a0d54e4d2d474ae41f4f4a95c749495a02883 (diff) |
internal: introduce `ast::make::ext` module with common shortcuts
There's a tension between keeping a well-architectured minimal
orthogonal set of constructs, and providing convenience functions.
Relieve this pressure by introducing an dedicated module for
non-orthogonal shortcuts.
This is inspired by the django.shortcuts module which serves a similar
purpose architecturally.
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/helpers/merge_imports.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/ty_filter.rs | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/ide_db/src/helpers/merge_imports.rs b/crates/ide_db/src/helpers/merge_imports.rs index 3f5bbef7f..148297279 100644 --- a/crates/ide_db/src/helpers/merge_imports.rs +++ b/crates/ide_db/src/helpers/merge_imports.rs | |||
@@ -137,7 +137,7 @@ fn recursive_merge( | |||
137 | None, | 137 | None, |
138 | false, | 138 | false, |
139 | ); | 139 | ); |
140 | use_trees.insert(idx, make::glob_use_tree()); | 140 | use_trees.insert(idx, make::use_tree_glob()); |
141 | continue; | 141 | continue; |
142 | } | 142 | } |
143 | 143 | ||
diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs index 988ecd060..00678bf3e 100644 --- a/crates/ide_db/src/ty_filter.rs +++ b/crates/ide_db/src/ty_filter.rs | |||
@@ -43,7 +43,7 @@ impl TryEnum { | |||
43 | pub fn sad_pattern(self) -> ast::Pat { | 43 | pub fn sad_pattern(self) -> ast::Pat { |
44 | match self { | 44 | match self { |
45 | TryEnum::Result => make::tuple_struct_pat( | 45 | TryEnum::Result => make::tuple_struct_pat( |
46 | make::path_unqualified(make::path_segment(make::name_ref("Err"))), | 46 | make::ext::ident_path("Err"), |
47 | iter::once(make::wildcard_pat().into()), | 47 | iter::once(make::wildcard_pat().into()), |
48 | ) | 48 | ) |
49 | .into(), | 49 | .into(), |
@@ -54,12 +54,12 @@ impl TryEnum { | |||
54 | pub fn happy_pattern(self) -> ast::Pat { | 54 | pub fn happy_pattern(self) -> ast::Pat { |
55 | match self { | 55 | match self { |
56 | TryEnum::Result => make::tuple_struct_pat( | 56 | TryEnum::Result => make::tuple_struct_pat( |
57 | make::path_unqualified(make::path_segment(make::name_ref("Ok"))), | 57 | make::ext::ident_path("Ok"), |
58 | iter::once(make::wildcard_pat().into()), | 58 | iter::once(make::wildcard_pat().into()), |
59 | ) | 59 | ) |
60 | .into(), | 60 | .into(), |
61 | TryEnum::Option => make::tuple_struct_pat( | 61 | TryEnum::Option => make::tuple_struct_pat( |
62 | make::path_unqualified(make::path_segment(make::name_ref("Some"))), | 62 | make::ext::ident_path("Some"), |
63 | iter::once(make::wildcard_pat().into()), | 63 | iter::once(make::wildcard_pat().into()), |
64 | ) | 64 | ) |
65 | .into(), | 65 | .into(), |