Rust: Upgrade to rust-analyzer 0.328#21714
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…scripts - Fix Meta usage: Meta is now abstract with subtypes (PathMeta, KeyValueMeta, TokenTreeMeta, etc.) - Fix FormatArgsArg: getName() replaced by getArgName() returning FormatArgsArgName - Add upgrade script (old → new) and downgrade script (new → old) - Update Definitions.qll, PathResolution.qll, BadCtorInitialization.ql, FormatTemplateVariableAccessConstructor.qll Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Re-run cargo fmt after clippy --fix to ensure consistent formatting. Re-run codegen to update generated file tracking for MetaImpl.qll. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Setting proc_macro_processes to 0 causes an index-out-of-bounds panic in ProcMacroServerPool::new when the proc macro server is enabled. Use the same defaults as rust-analyzer itself (1 each). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove format_args_arg_names from upgrade delete list (table exists in both schemas with different columns) - Accept updated .expected files for schema changes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Exclude macro-expanded and attribute paths from PathResolutionConsistency (tokio::main and similar attribute macros resolve to multiple proc macro fns) - Exclude "macro expansion failed" warnings from ExtractionConsistency (compile_error! and undefined macros are expected to fail expansion) - Update pre-existing consistency expectations (net multipleResolvedTargets) - Update type-inference.expected for new RA results Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c990d17 to
ac27c20
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
geoffw0
left a comment
There was a problem hiding this comment.
Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300).
Yeah, I feel that, though I suspect some of these files visible in the diff are generated code not marked as such. I've skimmed through all the changes anyway, but I'll have to rely mostly on testing (automated and manual) to build confidence here.
Can I get confirmation:
- that the Copilot-written changes have been reviewed by the author?
- that the upgrade / downgrade scripts have been tested?
Adds upgrade.ql with transformations for all schema changes from rust-analyzer 0.0.301 to 0.0.328: - Meta split into PathMeta/KeyValueMeta/TokenTreeMeta/UnsafeMeta - TraitAlias merged into Trait - BlockExpr.isTry() -> TryBlockModifier - StructField.getDefault() -> getDefaultVal() returning ConstArg - Variant.getDiscriminant() -> getConstArg() returning ConstArg - FormatArgsArg.getName() -> getArgName() returning FormatArgsArgName Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rerun has been triggered: 4 restarted 🚀 |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
geoffw0
left a comment
There was a problem hiding this comment.
New commits (the full upgrade / downgrade scripts) LGTM, though it's fiddly code - I'm glad you created tests for them.
I've made a couple of new comments, and there are still some incomplete discussions above I think.
| @@ -15855,3 +15847,18 @@ inferType | |||
| | regressions.rs:179:24:179:27 | S(...) | T | {EXTERNAL LOCATION} | i32 | | |||
| | regressions.rs:179:26:179:26 | 1 | | {EXTERNAL LOCATION} | i32 | | |||
| testFailures | |||
| | main.rs:1308:44:1308:62 | //... | Missing result: target=default | | |||
There was a problem hiding this comment.
We lose a bunch of results for this type inference test. Whether or not they're important results (@hvitved), we should update the expectation comments to MISSING:.
There was a problem hiding this comment.
I believe this is because derive macros are not properly expanded; should definitely be fixed before merging.
| subpaths | ||
| testFailures | ||
| | main.rs:58:47:58:57 | //... | Missing result: Source | | ||
| | main.rs:59:25:59:56 | //... | Missing result: Alert[rust/insecure-cookie] | |
There was a problem hiding this comment.
We appear to be losing all many query results for this query. Unless you already have an intuition what's wrong here, I should probably look into it.
There was a problem hiding this comment.
... I got as far as determining that the source and sinks are recognized, but flow is lost because we're missing some calls to clone() in the database ...
hvitved
left a comment
There was a problem hiding this comment.
It appears there are various macro expansion issues that need to be resolved.
| @@ -4,9 +4,6 @@ | |||
| | lib.rs:1:1:1:18 | mod anonymous | test::anonymous | | |||
| | lib.rs:2:1:2:16 | mod regular | test::regular | | |||
| | regular.rs:1:1:2:18 | struct Struct | test::regular::Struct | | |||
| | regular.rs:2:12:2:17 | fn eq | <test::regular::Struct as core::cmp::PartialEq>::eq | | |||
| | regular.rs:2:12:2:17 | impl ...::Eq for Struct::<...> { ... } | <test::regular::Struct as core::cmp::Eq> | | |||
| | regular.rs:2:12:2:17 | impl ...::PartialEq for Struct::<...> { ... } | <test::regular::Struct as core::cmp::PartialEq> | | |||
There was a problem hiding this comment.
It looks like derive macros are no longer expanded; getDeriveMacroExpansion does not have any results on this test case.
| @@ -15855,3 +15847,18 @@ inferType | |||
| | regressions.rs:179:24:179:27 | S(...) | T | {EXTERNAL LOCATION} | i32 | | |||
| | regressions.rs:179:26:179:26 | 1 | | {EXTERNAL LOCATION} | i32 | | |||
| testFailures | |||
| | main.rs:1308:44:1308:62 | //... | Missing result: target=default | | |||
There was a problem hiding this comment.
I believe this is because derive macros are not properly expanded; should definitely be fixed before merging.
…-to-rust-analyzer-0.0.328
|
I dug a bit more into this, and I think the missing derive expansions are actually expected with this rust-analyzer version (although it is a bit unfortunate for our current extraction model). The relevant bit seems to be the new built-in derive fast path. In That also explains the exact shape of the diff here: custom proc-macro derives still go through a real There is semantic information available for these impls through
Trying to recreate the old AST expansion in the extractor looks possible in theory, but pretty risky in practice, since we would be duplicating rust-analyzer's built-in derive expansion/token-tree setup and could easily drift from it. cc @geoffw0 |
Thanks for investigating, Paolo. We don't really need the bodies of the derived |
|
@hvitved: derive impls always have the signature from the trait definition. We should see if we can have a fallback to that in QL, and failing that in the extractor. As there's no overloading, a simple name search in the trait should do, so I have the feeling a simple QL fallback (impl has no signature -> get signature from implemented trait looking up the method by name). Wdyt? |
While we can certainly do it in QL, it would complicate things quite a lot; so far we have relied on everything being |
|
hmm, two options then I think:
I'll mull this over |
WIP. Let's see what the CI thinks of this. (For the avoidance of doubt, Copilot wrote all of the code, and I'm still working my way through the changes themselves.)