From 4f3c0adc5aafea465c71c85f36484da970df1ba2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 9 May 2021 19:51:06 +0300 Subject: 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. --- crates/ide_db/src/helpers/merge_imports.rs | 2 +- crates/ide_db/src/ty_filter.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ide_db/src') 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( None, false, ); - use_trees.insert(idx, make::glob_use_tree()); + use_trees.insert(idx, make::use_tree_glob()); continue; } 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 { pub fn sad_pattern(self) -> ast::Pat { match self { TryEnum::Result => make::tuple_struct_pat( - make::path_unqualified(make::path_segment(make::name_ref("Err"))), + make::ext::ident_path("Err"), iter::once(make::wildcard_pat().into()), ) .into(), @@ -54,12 +54,12 @@ impl TryEnum { pub fn happy_pattern(self) -> ast::Pat { match self { TryEnum::Result => make::tuple_struct_pat( - make::path_unqualified(make::path_segment(make::name_ref("Ok"))), + make::ext::ident_path("Ok"), iter::once(make::wildcard_pat().into()), ) .into(), TryEnum::Option => make::tuple_struct_pat( - make::path_unqualified(make::path_segment(make::name_ref("Some"))), + make::ext::ident_path("Some"), iter::once(make::wildcard_pat().into()), ) .into(), -- cgit v1.2.3