-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle async
functions in traits
#2786
Conversation
We usually only create a node for a given syntax tree component, the Even though This means we should modify the parsing stage to accept the Hopefully this is clearer ? |
yes, this is clearer. Thanks for help. |
async
function declarations in traitsasync
functions in traits
Fixes Rust-GCC#2785 gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Added check for `async` functions inside trait. * parse/rust-parse-impl.h (Parser::parse_trait_item): Added switch-case for ASYNC token. gcc/testsuite/ChangeLog: * rust/compile/issue-2785.rs: New test. Signed-off-by: Kushal Pal <[email protected]>
@P-E-P is this PR good to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great to me! thanks!
gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Enclose const in single quotes. gcc/testsuite/ChangeLog: * rust/compile/const_trait_fn.rs: Enclose const in single quotes. Signed-off-by: Kushal Pal <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot!
Fixes #2785
I opened this pull request because I have some doubts.
So I created a switch-case for
async
keyword when reading trait items. I generate an error (I know its not the right way) and return nullptr.The returning nullptr generates additional errors that results in the test case failing.
The correct way to generate error would be to add check in
ASTValidation::visit (AST::TraitFunctionDecl &decl)
function but it won't work right now because we never made the AST node.To solve this problem I think we need to implement
parse_trait_async()
and to implement this function we need to make an AST nodeAST::TraitItemAsync
.But this node will be pretty much useless as
async
isn't allowed inside traits so I don't know if this is the right way to approach this problem@CohenArthur Is there any other way to solve this problem, I am sorry if I failed to reach an obvious solution, lemme know.