mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
internal: remove one more immutable tree
This commit is contained in:
parent
ab528e85f7
commit
0650f77dd9
7 changed files with 57 additions and 56 deletions
|
@ -12,7 +12,7 @@
|
|||
use itertools::Itertools;
|
||||
use stdx::{format_to, never};
|
||||
|
||||
use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||
use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxToken};
|
||||
|
||||
/// While the parent module defines basic atomic "constructors", the `ext`
|
||||
/// module defines shortcuts for common things.
|
||||
|
@ -601,17 +601,11 @@ fn ast_from_text<N: AstNode>(text: &str) -> N {
|
|||
panic!("Failed to make ast node `{}` from text {}", std::any::type_name::<N>(), text)
|
||||
}
|
||||
};
|
||||
let node = node.syntax().clone();
|
||||
let node = unroot(node);
|
||||
let node = N::cast(node).unwrap();
|
||||
let node = node.clone_subtree();
|
||||
assert_eq!(node.syntax().text_range().start(), 0.into());
|
||||
node
|
||||
}
|
||||
|
||||
fn unroot(n: SyntaxNode) -> SyntaxNode {
|
||||
SyntaxNode::new_root(n.green().into())
|
||||
}
|
||||
|
||||
pub fn token(kind: SyntaxKind) -> SyntaxToken {
|
||||
tokens::SOURCE_FILE
|
||||
.tree()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue