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 <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2020-09-29 10:29:33 +00:00 committed by GitHub
commit 18c62c8a39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 47 deletions

View file

@ -28,18 +28,41 @@ pub fn assoc_item_list() -> ast::AssocItemList {
pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment {
ast_from_text(&format!("use {};", name_ref))
}
pub fn path_segment_self() -> ast::PathSegment {
ast_from_text("use self;")
}
pub fn path_segment_super() -> ast::PathSegment {
ast_from_text("use super;")
}
pub fn path_segment_crate() -> ast::PathSegment {
ast_from_text("use crate;")
}
pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path {
path_from_text(&format!("use {}", segment))
ast_from_text(&format!("use {}", segment))
}
pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path {
path_from_text(&format!("{}::{}", qual, segment))
ast_from_text(&format!("{}::{}", qual, segment))
}
// FIXME: make this private
pub fn path_from_text(text: &str) -> ast::Path {
ast_from_text(text)
pub fn path_concat(first: ast::Path, second: ast::Path) -> ast::Path {
ast_from_text(&format!("{}::{}", first, second))
}
pub fn path_from_segments(
segments: impl IntoIterator<Item = ast::PathSegment>,
is_abs: bool,
) -> ast::Path {
let segments = segments.into_iter().map(|it| it.syntax().clone()).join("::");
ast_from_text(&if is_abs {
format!("use ::{};", segments)
} else {
format!("use {};", segments)
})
}
pub fn glob_use_tree() -> ast::UseTree {