aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-05-10 17:04:41 +0100
committerAleksey Kladov <[email protected]>2021-05-14 14:19:27 +0100
commit0650f77dd9defaf352f81c5ee4ee73a1eae942b7 (patch)
tree4758b6ea999292cf18a078dd942f51621a2d68ea /crates/syntax/src/ast
parentab528e85f71da188722ae031b31a3a70bac1cadd (diff)
internal: remove one more immutable tree
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r--crates/syntax/src/ast/make.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index 1998ad1f6..de04c8620 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -12,7 +12,7 @@
12use itertools::Itertools; 12use itertools::Itertools;
13use stdx::{format_to, never}; 13use stdx::{format_to, never};
14 14
15use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken}; 15use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxToken};
16 16
17/// While the parent module defines basic atomic "constructors", the `ext` 17/// While the parent module defines basic atomic "constructors", the `ext`
18/// module defines shortcuts for common things. 18/// module defines shortcuts for common things.
@@ -601,17 +601,11 @@ fn ast_from_text<N: AstNode>(text: &str) -> N {
601 panic!("Failed to make ast node `{}` from text {}", std::any::type_name::<N>(), text) 601 panic!("Failed to make ast node `{}` from text {}", std::any::type_name::<N>(), text)
602 } 602 }
603 }; 603 };
604 let node = node.syntax().clone(); 604 let node = node.clone_subtree();
605 let node = unroot(node);
606 let node = N::cast(node).unwrap();
607 assert_eq!(node.syntax().text_range().start(), 0.into()); 605 assert_eq!(node.syntax().text_range().start(), 0.into());
608 node 606 node
609} 607}
610 608
611fn unroot(n: SyntaxNode) -> SyntaxNode {
612 SyntaxNode::new_root(n.green().into())
613}
614
615pub fn token(kind: SyntaxKind) -> SyntaxToken { 609pub fn token(kind: SyntaxKind) -> SyntaxToken {
616 tokens::SOURCE_FILE 610 tokens::SOURCE_FILE
617 .tree() 611 .tree()