9939: feat: Adding extract_module assist r=Veykril a=feniljain

Should solve https://github.com/rust-analyzer/rust-analyzer/issues/9591

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2021-10-22 09:29:16 +00:00 committed by GitHub
commit a75353e8ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1446 additions and 1 deletions

View file

@ -196,6 +196,12 @@ pub fn path_from_segments(
format!("use {};", segments)
})
}
pub fn join_paths(paths: impl IntoIterator<Item = ast::Path>) -> ast::Path {
let paths = paths.into_iter().map(|it| it.syntax().clone()).join("::");
ast_from_text(&format!("use {};", paths))
}
// FIXME: should not be pub
pub fn path_from_text(text: &str) -> ast::Path {
ast_from_text(&format!("fn main() {{ let test = {}; }}", text))