mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Put leading |
in patterns under OrPat
Previously it was one level above, and that caused problems with macros that expand to it, because macros expect to get only one top-level node.
This commit is contained in:
parent
6a67a4d3cd
commit
e12a001b55
11 changed files with 87 additions and 31 deletions
|
@ -1283,6 +1283,8 @@ pub struct OrPat {
|
|||
impl OrPat {
|
||||
#[inline]
|
||||
pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn pipe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![|]) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -1140,3 +1140,13 @@ impl From<ast::AssocItem> for ast::AnyHasAttrs {
|
|||
Self::new(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::OrPat {
|
||||
pub fn leading_pipe(&self) -> Option<SyntaxToken> {
|
||||
self.syntax
|
||||
.children_with_tokens()
|
||||
.find(|it| !it.kind().is_trivia())
|
||||
.and_then(NodeOrToken::into_token)
|
||||
.filter(|it| it.kind() == T![|])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue