mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
fix: Simplify macro statement expansion handling
This commit is contained in:
parent
f8c416e1b9
commit
531e152390
10 changed files with 155 additions and 110 deletions
|
@ -67,6 +67,13 @@ impl<N: AstNode> AstPtr<N> {
|
|||
Some(AstPtr { raw: self.raw, _ty: PhantomData })
|
||||
}
|
||||
|
||||
pub fn upcast<M: AstNode>(self) -> AstPtr<M>
|
||||
where
|
||||
N: Into<M>,
|
||||
{
|
||||
AstPtr { raw: self.raw, _ty: PhantomData }
|
||||
}
|
||||
|
||||
/// Like `SyntaxNodePtr::cast` but the trait bounds work out.
|
||||
pub fn try_from_raw(raw: SyntaxNodePtr) -> Option<AstPtr<N>> {
|
||||
N::can_cast(raw.kind()).then(|| AstPtr { raw, _ty: PhantomData })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue