Remove dead code

This commit is contained in:
Aleksey Kladov 2020-08-31 15:43:37 +02:00
parent ac4b134c6b
commit 60706fca8e

View file

@ -144,10 +144,6 @@ fn expr_from_text(text: &str) -> ast::Expr {
ast_from_text(&format!("const C: () = {};", text)) ast_from_text(&format!("const C: () = {};", text))
} }
pub fn try_expr_from_text(text: &str) -> Option<ast::Expr> {
try_ast_from_text(&format!("const C: () = {};", text))
}
pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition { pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition {
match pattern { match pattern {
None => ast_from_text(&format!("const _: () = while {} {{}};", expr)), None => ast_from_text(&format!("const _: () = while {} {{}};", expr)),
@ -332,16 +328,6 @@ fn ast_from_text<N: AstNode>(text: &str) -> N {
node node
} }
fn try_ast_from_text<N: AstNode>(text: &str) -> Option<N> {
let parse = SourceFile::parse(text);
let node = parse.tree().syntax().descendants().find_map(N::cast)?;
let node = node.syntax().clone();
let node = unroot(node);
let node = N::cast(node).unwrap();
assert_eq!(node.syntax().text_range().start(), 0.into());
Some(node)
}
fn unroot(n: SyntaxNode) -> SyntaxNode { fn unroot(n: SyntaxNode) -> SyntaxNode {
SyntaxNode::new_root(n.green().clone()) SyntaxNode::new_root(n.green().clone())
} }