diff options
Diffstat (limited to 'crates/syntax/src')
-rw-r--r-- | crates/syntax/src/ast/make.rs | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 7ba625990..c2c938ad1 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -33,6 +33,7 @@ pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path { | |||
33 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { | 33 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { |
34 | path_from_text(&format!("{}::{}", qual, segment)) | 34 | path_from_text(&format!("{}::{}", qual, segment)) |
35 | } | 35 | } |
36 | // FIXME: make this private | ||
36 | pub fn path_from_text(text: &str) -> ast::Path { | 37 | pub fn path_from_text(text: &str) -> ast::Path { |
37 | ast_from_text(text) | 38 | ast_from_text(text) |
38 | } | 39 | } |
@@ -144,10 +145,6 @@ fn expr_from_text(text: &str) -> ast::Expr { | |||
144 | ast_from_text(&format!("const C: () = {};", text)) | 145 | ast_from_text(&format!("const C: () = {};", text)) |
145 | } | 146 | } |
146 | 147 | ||
147 | pub fn try_expr_from_text(text: &str) -> Option<ast::Expr> { | ||
148 | try_ast_from_text(&format!("const C: () = {};", text)) | ||
149 | } | ||
150 | |||
151 | pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition { | 148 | pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition { |
152 | match pattern { | 149 | match pattern { |
153 | None => ast_from_text(&format!("const _: () = while {} {{}};", expr)), | 150 | None => ast_from_text(&format!("const _: () = while {} {{}};", expr)), |
@@ -332,16 +329,6 @@ fn ast_from_text<N: AstNode>(text: &str) -> N { | |||
332 | node | 329 | node |
333 | } | 330 | } |
334 | 331 | ||
335 | fn try_ast_from_text<N: AstNode>(text: &str) -> Option<N> { | ||
336 | let parse = SourceFile::parse(text); | ||
337 | let node = parse.tree().syntax().descendants().find_map(N::cast)?; | ||
338 | let node = node.syntax().clone(); | ||
339 | let node = unroot(node); | ||
340 | let node = N::cast(node).unwrap(); | ||
341 | assert_eq!(node.syntax().text_range().start(), 0.into()); | ||
342 | Some(node) | ||
343 | } | ||
344 | |||
345 | fn unroot(n: SyntaxNode) -> SyntaxNode { | 332 | fn unroot(n: SyntaxNode) -> SyntaxNode { |
346 | SyntaxNode::new_root(n.green().clone()) | 333 | SyntaxNode::new_root(n.green().clone()) |
347 | } | 334 | } |