diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-09-29 11:29:33 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-29 11:29:33 +0100 |
commit | 18c62c8a39d95ce3bb10ff5446bb589b1128a090 (patch) | |
tree | f829779003722fb50082b5aa55a725aed841d449 /crates/syntax/src | |
parent | 7b674f9ab491fdd01278c21f539e65239518e296 (diff) | |
parent | f2ae412ccfa96c4bde42f0b004594c4d6fa54634 (diff) |
Merge #6019
6019: Remove make::path_from_text r=matklad a=Veykril
This removes the `make::path_from_text` function, which according to a note should've been private. I removed it since it didn't really serve a purpose as it was simply wrapping `make::ast_from_text`.
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/syntax/src')
-rw-r--r-- | crates/syntax/src/ast/make.rs | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 4a0ffcbb0..3a184094c 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -28,18 +28,41 @@ pub fn assoc_item_list() -> ast::AssocItemList { | |||
28 | pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { | 28 | pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { |
29 | ast_from_text(&format!("use {};", name_ref)) | 29 | ast_from_text(&format!("use {};", name_ref)) |
30 | } | 30 | } |
31 | |||
31 | pub fn path_segment_self() -> ast::PathSegment { | 32 | pub fn path_segment_self() -> ast::PathSegment { |
32 | ast_from_text("use self;") | 33 | ast_from_text("use self;") |
33 | } | 34 | } |
35 | |||
36 | pub fn path_segment_super() -> ast::PathSegment { | ||
37 | ast_from_text("use super;") | ||
38 | } | ||
39 | |||
40 | pub fn path_segment_crate() -> ast::PathSegment { | ||
41 | ast_from_text("use crate;") | ||
42 | } | ||
43 | |||
34 | pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path { | 44 | pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path { |
35 | path_from_text(&format!("use {}", segment)) | 45 | ast_from_text(&format!("use {}", segment)) |
36 | } | 46 | } |
47 | |||
37 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { | 48 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { |
38 | path_from_text(&format!("{}::{}", qual, segment)) | 49 | ast_from_text(&format!("{}::{}", qual, segment)) |
39 | } | 50 | } |
40 | // FIXME: make this private | 51 | |
41 | pub fn path_from_text(text: &str) -> ast::Path { | 52 | pub fn path_concat(first: ast::Path, second: ast::Path) -> ast::Path { |
42 | ast_from_text(text) | 53 | ast_from_text(&format!("{}::{}", first, second)) |
54 | } | ||
55 | |||
56 | pub fn path_from_segments( | ||
57 | segments: impl IntoIterator<Item = ast::PathSegment>, | ||
58 | is_abs: bool, | ||
59 | ) -> ast::Path { | ||
60 | let segments = segments.into_iter().map(|it| it.syntax().clone()).join("::"); | ||
61 | ast_from_text(&if is_abs { | ||
62 | format!("use ::{};", segments) | ||
63 | } else { | ||
64 | format!("use {};", segments) | ||
65 | }) | ||
43 | } | 66 | } |
44 | 67 | ||
45 | pub fn glob_use_tree() -> ast::UseTree { | 68 | pub fn glob_use_tree() -> ast::UseTree { |