Implement infer await from async func

This commit is contained in:
Edwin Cheng 2019-12-24 19:45:28 +08:00
parent 60aa4d12f9
commit 0edb5b4a50
7 changed files with 112 additions and 5 deletions

View file

@ -1129,6 +1129,7 @@ impl ast::NameOwner for FnDef {}
impl ast::TypeParamsOwner for FnDef {}
impl ast::AttrsOwner for FnDef {}
impl ast::DocCommentsOwner for FnDef {}
impl ast::AsyncOwner for FnDef {}
impl FnDef {
pub fn param_list(&self) -> Option<ParamList> {
AstChildren::new(&self.syntax).next()

View file

@ -8,6 +8,7 @@ use crate::{
ast::{self, child_opt, children, AstChildren, AstNode, AstToken},
match_ast,
syntax_node::{SyntaxElementChildren, SyntaxNodeChildren},
SyntaxKind,
};
pub trait TypeAscriptionOwner: AstNode {
@ -105,6 +106,12 @@ pub trait AttrsOwner: AstNode {
}
}
pub trait AsyncOwner: AstNode {
fn is_async(&self) -> bool {
self.syntax().children_with_tokens().any(|t| t.kind() == SyntaxKind::ASYNC_KW)
}
}
pub trait DocCommentsOwner: AstNode {
fn doc_comments(&self) -> CommentIter {
CommentIter { iter: self.syntax().children_with_tokens() }