-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Rust: AST: add docs with examples for qltest #17432
Conversation
ba77817
to
52b77be
Compare
52b77be
to
11c2599
Compare
64320b4
to
280b119
Compare
@@ -119,15 +118,31 @@ class Function(Declaration): | |||
body: Expr | child | |||
|
|||
|
|||
# Missing, | |||
@rust.doc_test_signature("() -> ()") |
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.
hmm, maybe this should be the default, and there should be a pragma to not wrap the doc code in a function (for top-level declarations)?
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.
That would be handy indeed.
rust/schema.py
Outdated
let x = variable; | ||
let x = foo::bar; | ||
let y = <T>::foo | ||
let z = <Type as Trait>::foo |
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.
hmm, how does rust-analyzer and our extractor currently fare with undefined symbols like the ones here? Aren't we getting missing things rather than what we want to test? Also, there might be some semicolons missing.
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.
The extractor and rust-analyzer are fine with missing symbols. Things like jump to definition won't work in the IDE, but the code is still recognized as syntactically valid.
Yeah, I should have added those semicolons, but the parser is quite resilient, so I hadn't noticed. I think it would be nice to also generate a sort of coverage test query that checks that all things appear at least once in the examples.
280b119
to
1600090
Compare
1600090
to
292c6b6
Compare
For some reason the parser resolves the ambiguity between None as a PathPat or IdentPat differently on the Action runners vs local machine.
71d816c
to
d73d90d
Compare
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.
Terrific, looks good! I just would really rather not rename TypeRef
to Type
.
@@ -380,8 +380,8 @@ class MatchArm(AstNode): | |||
A match arm. For example: | |||
``` | |||
match x { | |||
Some(y) => y, | |||
None => 0, | |||
Option::Some(y) => y, |
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.
maybe another way of avoiding the ambiguity would be to fix the doc_test_signature
to (x: Option<i32>) -> ()
, here and in all other instances of this?
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.
That could work, although, does the parser really do name resolution? The strange thing is that on Action runners the same Rust code behaves differently than on macos ... I would like to figure out what on earth is causing the problem, but not for this pull request ;-)
@@ -63,50 +63,118 @@ class AstNode(Locatable): | |||
|
|||
|
|||
@qltest.skip | |||
class Unimplemented(AstNode): | |||
class Unimplemented(Element): |
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.
another approach that works (I used it in my draft type PR here) is to keep one Unimplmented
, but make it a subclass of every AST kind that can be unimplemented (e.g. Unimplemented(Declaration, TypeRef)
). That has the advantage that we can keep one emit_unimplemented
method in the translator.
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.
That's a good idea for a follow-up PR.
pass | ||
|
||
|
||
@qltest.skip | ||
@rust.doc_test_signature("() -> ()") |
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.
let's get this in, then I can make this the default and clean up
@redsun82 I agree that |
Yeah, I think it's a good idea to reuse ungram, but we should make sure the naming and structure there doesn't "pollute" our QL definitions. I think we can achieve that, maybe with some rust annotations on |
Thanks for this. This documentation is super helpful 👍 |
No description provided.