several highlighting cleanups
* make stuff more type-safe by using `BindPat` instead of just `Pat` * don't add `mut` into binding hash * reset shadow counter when we enter a function
This commit is contained in:
@@ -60,6 +60,17 @@ impl<N: AstNode> AstPtr<N> {
|
||||
pub fn syntax_node_ptr(self) -> SyntaxNodePtr {
|
||||
self.raw
|
||||
}
|
||||
|
||||
// FIXME: extend AstNode to do this safely
|
||||
pub fn cast_checking_kind<U: AstNode>(
|
||||
self,
|
||||
cond: impl FnOnce(SyntaxKind) -> bool,
|
||||
) -> Option<AstPtr<U>> {
|
||||
if !cond(self.raw.kind()) {
|
||||
return None;
|
||||
}
|
||||
Some(AstPtr { raw: self.raw, _ty: PhantomData })
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr {
|
||||
|
||||
Reference in New Issue
Block a user