From cd21b0e9c1c99f777c6559ca850f2ea0d247b881 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 19 Jan 2021 22:11:42 +0300 Subject: :arrow_up: rowan --- crates/syntax/Cargo.toml | 2 +- crates/syntax/src/algo.rs | 7 ++++--- crates/syntax/src/ast/make.rs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/syntax') diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 52394b337..37d3faa03 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] itertools = "0.10.0" -rowan = "0.10.3" +rowan = "0.11" rustc_lexer = { version = "697.0.0", package = "rustc-ap-rustc_lexer" } rustc-hash = "1.1.0" arrayvec = "0.5.1" diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 827ae78f9..2ff92f9f6 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs @@ -4,6 +4,7 @@ use std::{ fmt, hash::BuildHasherDefault, ops::{self, RangeInclusive}, + ptr, }; use indexmap::IndexMap; @@ -171,7 +172,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { && lhs.text_range().len() == rhs.text_range().len() && match (&lhs, &rhs) { (NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => { - lhs.green() == rhs.green() || lhs.text() == rhs.text() + ptr::eq(lhs.green(), rhs.green()) || lhs.text() == rhs.text() } (NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(), _ => false, @@ -566,7 +567,7 @@ impl<'a> SyntaxRewriter<'a> { fn element_to_green(element: SyntaxElement) -> NodeOrToken { match element { - NodeOrToken::Node(it) => NodeOrToken::Node(it.green().clone()), + NodeOrToken::Node(it) => NodeOrToken::Node(it.green().to_owned()), NodeOrToken::Token(it) => NodeOrToken::Token(it.green().clone()), } } @@ -624,7 +625,7 @@ fn position_of_child(parent: &SyntaxNode, child: SyntaxElement) -> usize { fn to_green_element(element: SyntaxElement) -> NodeOrToken { match element { - NodeOrToken::Node(it) => it.green().clone().into(), + NodeOrToken::Node(it) => it.green().to_owned().into(), NodeOrToken::Token(it) => it.green().clone().into(), } } diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 9ffc3ae11..cc1717237 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -478,7 +478,7 @@ fn ast_from_text(text: &str) -> N { } fn unroot(n: SyntaxNode) -> SyntaxNode { - SyntaxNode::new_root(n.green().clone()) + SyntaxNode::new_root(n.green().to_owned()) } pub mod tokens { -- cgit v1.2.3