diff options
Diffstat (limited to 'crates/syntax')
-rw-r--r-- | crates/syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index a6c294245..2106732cd 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml | |||
@@ -14,7 +14,7 @@ doctest = false | |||
14 | cov-mark = { version = "1.1", features = ["thread-local"] } | 14 | cov-mark = { version = "1.1", features = ["thread-local"] } |
15 | itertools = "0.10.0" | 15 | itertools = "0.10.0" |
16 | rowan = "=0.13.0-pre.6" | 16 | rowan = "=0.13.0-pre.6" |
17 | rustc_lexer = { version = "720.0.0", package = "rustc-ap-rustc_lexer" } | 17 | rustc_lexer = { version = "721.0.0", package = "rustc-ap-rustc_lexer" } |
18 | rustc-hash = "1.1.0" | 18 | rustc-hash = "1.1.0" |
19 | arrayvec = "0.7" | 19 | arrayvec = "0.7" |
20 | once_cell = "1.3.1" | 20 | once_cell = "1.3.1" |
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index df8f98b5b..884fe0739 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -243,6 +243,13 @@ impl ast::Path { | |||
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | pub fn as_single_name_ref(&self) -> Option<ast::NameRef> { | ||
247 | match self.qualifier() { | ||
248 | Some(_) => None, | ||
249 | None => self.segment()?.name_ref(), | ||
250 | } | ||
251 | } | ||
252 | |||
246 | pub fn first_qualifier_or_self(&self) -> ast::Path { | 253 | pub fn first_qualifier_or_self(&self) -> ast::Path { |
247 | successors(Some(self.clone()), ast::Path::qualifier).last().unwrap() | 254 | successors(Some(self.clone()), ast::Path::qualifier).last().unwrap() |
248 | } | 255 | } |