aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-29 11:29:33 +0100
committerGitHub <[email protected]>2020-09-29 11:29:33 +0100
commit18c62c8a39d95ce3bb10ff5446bb589b1128a090 (patch)
treef829779003722fb50082b5aa55a725aed841d449 /crates/syntax/src
parent7b674f9ab491fdd01278c21f539e65239518e296 (diff)
parentf2ae412ccfa96c4bde42f0b004594c4d6fa54634 (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.rs33
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 {
28pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { 28pub 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
31pub fn path_segment_self() -> ast::PathSegment { 32pub fn path_segment_self() -> ast::PathSegment {
32 ast_from_text("use self;") 33 ast_from_text("use self;")
33} 34}
35
36pub fn path_segment_super() -> ast::PathSegment {
37 ast_from_text("use super;")
38}
39
40pub fn path_segment_crate() -> ast::PathSegment {
41 ast_from_text("use crate;")
42}
43
34pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path { 44pub 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
37pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { 48pub 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
41pub fn path_from_text(text: &str) -> ast::Path { 52pub 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
56pub 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
45pub fn glob_use_tree() -> ast::UseTree { 68pub fn glob_use_tree() -> ast::UseTree {