-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: upgrade to rust-analyzer 0.0.300 #20055
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
base: main
Are you sure you want to change the base?
Conversation
toBeTested(x) and not x.isUnknown() and getExtendedCanonicalPath = x.getExtendedCanonicalPath() | ||
} | ||
|
||
query predicate getCrateOrigin(AsmExpr x, string getCrateOrigin) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
import codeql.rust.elements.FieldExpr | ||
import codeql.rust.elements.FieldList | ||
import codeql.rust.elements.FnPtrTypeRepr | ||
import codeql.rust.elements.ForBinder |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.ClosureExpr
Redundant import, the module is already imported inside
codeql.rust.elements.ForTypeRepr
Redundant import, the module is already imported inside
codeql.rust.elements.TypeBound
Redundant import, the module is already imported inside
codeql.rust.elements.WherePred
@@ -4,6 +4,20 @@ | |||
|
|||
query predicate instances(AsmExpr x) { toBeTested(x) and not x.isUnknown() } | |||
|
|||
query predicate getExtendedCanonicalPath(AsmExpr x, string getExtendedCanonicalPath) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
toBeTested(x) and not x.isUnknown() and getExtendedCanonicalPath = x.getExtendedCanonicalPath() | ||
} | ||
|
||
query predicate getCrateOrigin(AsmExpr x, string getCrateOrigin) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
toBeTested(x) and not x.isUnknown() and getCrateOrigin = x.getCrateOrigin() | ||
} | ||
|
||
query predicate getAttributeMacroExpansion(AsmExpr x, MacroItems getAttributeMacroExpansion) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
@@ -37,8 +37,8 @@ | |||
toBeTested(x) and not x.isUnknown() and getBody = x.getBody() | |||
} | |||
|
|||
query predicate getClosureBinder(ClosureExpr x, ClosureBinder getClosureBinder) { | |||
toBeTested(x) and not x.isUnknown() and getClosureBinder = x.getClosureBinder() | |||
query predicate getForBinder(ClosureExpr x, ForBinder getForBinder) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
|
||
query predicate instances(ForBinder x) { toBeTested(x) and not x.isUnknown() } | ||
|
||
query predicate getGenericParamList(ForBinder x, GenericParamList getGenericParamList) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
@@ -4,8 +4,8 @@ | |||
|
|||
query predicate instances(ForTypeRepr x) { toBeTested(x) and not x.isUnknown() } | |||
|
|||
query predicate getGenericParamList(ForTypeRepr x, GenericParamList getGenericParamList) { | |||
toBeTested(x) and not x.isUnknown() and getGenericParamList = x.getGenericParamList() | |||
query predicate getForBinder(ForTypeRepr x, ForBinder getForBinder) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
@@ -13,6 +13,10 @@ | |||
if x.isConst() then isConst = "yes" else isConst = "no" | |||
} | |||
|
|||
query predicate getForBinder(TypeBound x, ForBinder getForBinder) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
@@ -4,8 +4,8 @@ | |||
|
|||
query predicate instances(WherePred x) { toBeTested(x) and not x.isUnknown() } | |||
|
|||
query predicate getGenericParamList(WherePred x, GenericParamList getGenericParamList) { | |||
toBeTested(x) and not x.isUnknown() and getGenericParamList = x.getGenericParamList() | |||
query predicate getForBinder(WherePred x, ForBinder getForBinder) { |
Check warning
Code scanning / CodeQL
Predicates starting with "get" or "as" should return a value Warning generated test
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.
Pull Request Overview
This PR upgrades the rust-analyzer version from 0.0.299 to 0.0.300 as indicated by the title. The upgrade brings updates to the Rust AST schema and affects test expectations across various CodeQL test suites due to improved location precision and renamed AST nodes.
- Updates the Rust AST schema with structural changes including renaming
ClosureBinder
toForBinder
- Introduces the
ForBinder
as a more general construct for closure and type parameter bindings - Updates dependency versions and test expectations to match the improved rust-analyzer output
Reviewed Changes
Copilot reviewed 204 out of 251 changed files in this pull request and generated no comments.
File | Description |
---|---|
shared/tree-sitter-extractor/Cargo.toml | Updates the rand dependency from version 0.9.1 to 0.9.2 |
rust/schema/ast.py | Major AST schema changes: renames ClosureBinder to ForBinder , adds Item inheritance to AsmExpr , and updates field references |
rust/schema/annotations.py | Updates documentation and annotations to reflect the renaming from ClosureBinder to ForBinder |
Multiple .expected files | Updates test expectations to reflect improved location precision from the rust-analyzer upgrade |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
@@ -1 +1,2 @@ | |||
| gen_asm_clobber_abi.rs:8:14:8:29 | AsmClobberAbi | | |||
| gen_asm_clobber_abi.rs:8:14:8:29 | AsmClobberAbi | |
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.
This looks like a duplicate database element. Any idea what this is about?
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.
I think it has to do with how the asm!
macro is expanded. Might be good to have a look at the AST
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.
seems like asm!
expands to a MacroBlockExpr
that has both its TailExpr
and its Statement
populated with a copy of the AsmExpr
each 😕
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 sounds like a potential bug. The parser is implemented by hand, so it is possible they made a mistake.
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.
well, it's not the parser populating that, but the asm!
special case of macro expansion (so even more ripe for possible errors)
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.
Or more likely the tail_expr()
and statements()
methods are wrong. These are typically implemented as "find first child with matching type" and because AsmExpr is now also an Item the statements()
method will pick it up too. See also:
Not sure if you want to file a bug report, a PR to fix it, or whether to patch things up in the extractor or in QL.
Having duplicated nodes is not great, but asm
stuff is fairly rare and we don't do much with it so having a bad AST temporarily shouldn't be too much of a problem.
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.
uh, I think I see what's happening. This is equivalent to that weird situation we have for path segments, where there's a roundabout way of getting the types from it.
When asking for the repeated Stmt
children of a MacroBlock
, the library just looks at the children for a matching type. Now, because AsmExpr
now are also Item
s, and Item
s are Stmt
s, an AsmExpr
will match both as the Stmt*
children and as the Expr?
one. So this stems from a limitation of the ast
library in rust-analyzer
...
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.
:jinx-coke:
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.
can fix that in the extractor
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.
filed an issue in rust-lang/rust-analyzer#20485
The upgrade script is particularly complex. To test it out, I have:
main
ForTypeRepr
,WherePred
andTypeBound
tests. The only change I observed were locations (forForBinder
instances reconstructed with the upgrade script, the location does not include thefor
keyword).