Rust: update rust-analyzer to 0.0.347 - #22346
Open
redsun82 wants to merge 22 commits into
Open
Conversation
Update hand-written library predicates for the 0.0.347 AST changes: - FormatArgsArg.getArgName() -> getName() (the arg name is now a Name, carrying text, instead of the text-less FormatArgsArgName placeholder). - Visibility.getPath()/hasPath() -> getVisibilityInner().getPath(); the path now hangs off an intermediate VisibilityInner node. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
The ra_ap 0.0.347 builtin format_args! expander needs a newer std than 0.0.328, so the QL test toolchain is bumped to 1.97 (matching the root dev toolchain). Generated extractor-test expectations are regenerated for the new schema fields (asm attrs, Trait impl_restriction, Struct/TupleField mut_restriction, Visibility visibility_inner, FormatArgsArg name) and for the std sysroot dependency churn that comes with the newer toolchain. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
The schema delta for ra_ap 0.0.347 adds the new node kinds DerefPat, ImplRestriction, IncludeBytesExpr, MutRestriction, NotNull, PatternTypeRepr and VisibilityInner, moves a Visibility path onto the new VisibilityInner, replaces the text-less FormatArgsArgName placeholder with a Name, and adds attrs to the inline assembly nodes, mut_restriction to Struct/TupleField and impl_restriction to Trait. The upgrade repurposes the old format-arg placeholder ids as Name ids (avoiding dangling refs) and synthesises a VisibilityInner per visibility with a path. The downgrade rejoins the visibility path, repurposes ids back to the placeholder, and scrubs the locations of the deleted node kinds. compatibility is partial: the new node kinds are empty on old DBs, so a rebuild yields strictly-better results while existing queries keep working. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
Regenerate the Rust translator so codegen emits the current Translator<'_> impl signature. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rust 1.97 reports redundant formatting borrows and map iteration warnings under -D warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A full new->old->new dataset upgrade/downgrade round-trip surfaced dangling references: deleting the new node kinds left `macro_call_macro_call_expansions` rows (and potentially `comments` rows) pointing at now-undefined `@ast_node`s. These are the only two relations with a generic `@ast_node`-typed value column, so the downgrade now drops rows in both that reference a deleted node, alongside the existing `locatable_locations` scrub. `codeql dataset check` is now clean at every stage of the round-trip. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
The template emitted `impl Translator<'_>` (one lifetime) while `base.rs` declares `Translator<'a, 'db>`, so regenerating produced a `generated.rs` that did not compile. Update the template to two lifetimes and regenerate. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
The `rules_rust` 0.69 -> 0.73 bump changes the vendored file format and repo layout, invalidating the previously vendored files. Regenerate them all via the umbrella `update_cargo_deps.sh` (py_deps + tree_sitter_extractors_deps). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
`rules_rust` 0.73 vendors crates as subpackages of a single `@vendor_ts` repo (a per-crate alias) rather than one repo per crate. `rust.ungram` is only exported from the crate's own vendored repo, so derive that repo from the crate label instead of assuming the crate sits at a repo root. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
Add QLDoc annotations for the AST nodes introduced by ra_ap 0.0.347 (`DerefPat`, `ImplRestriction`, `IncludeBytesExpr`, `MutRestriction`, `NotNull`, `PatternTypeRepr`, `VisibilityInner`). `DerefPat`, `IncludeBytesExpr` and `NotNull` keep `cfg=True` so annotating them does not drop their CFG nodes. The example snippets double as generated extractor tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
…ernTypeRepr` These nodes represent experimental, mostly compiler-internal Rust features that cannot be written directly in stable Rust. The docs now say so and note that the examples use rust-analyzer's canonical `builtin#` syntax. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
The new nightly toolchain rejects let-chains in edition 2021 and enables deny-by-default lints (e.g. `dangerous_implicit_autorefs`) that fail extraction of valid test sources. Add a `qltest_edition` option so individual tests can opt into a newer edition, and pass `--cap-lints=allow` to the qltest cargo check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
Use edition 2024 for the let-chain fixtures (`dataflow/local`, `variables`, `unusedentities`). Drop stale `MISSING` markers in `type-inference` where the new inference now resolves the types, and mark the `System` `alloc`/`alloc_zeroed`/`realloc` alerts in CWE-770 as `MISSING` since rust-analyzer 0.0.347 no longer resolves those `GlobalAlloc` sinks. The regression is called out with inline comments in the fixture. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
Resolve MODULE.bazel conflict: keep `rules_rust` 0.73.0 (this branch) and `rules_swift` 4.0.0-rc5-codeql.1 plus the `apple_support` removal (main). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
1.96 turned `use SomeStruct::{self};` into a hard error (E0432), which broke
the path-resolution test. 1.95 is the newest stable that still accepts it while
also expanding the builtin `format_args!` macro against std. Re-accept the
std-snapshot and format-arg/panic expansion changes that follow from the
ra_ap 0.0.347 upgrade at this toolchain.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
The new `DerefPat` node from ra_ap 0.0.347 had no case in the pattern CFG builder, leaving the enclosing function's CFG disconnected and tripping `CfgConsistency` (a `deadEnd`). Wire it like `BoxPat`, since it wraps a single inner pattern via `getPat()`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the Rust extractor's
rust-analyzer(ra_ap_*) dependencies from 0.0.328 to 0.0.347, followingrust/README.md→ "Updatingrust-analyzer".What's in here
cargo upgrade --incompatible --pinned; allra_ap_*crates landed on 0.0.347.bazel run //rust/codegen.rust/schema/ast.pychanged, so this also includes the schema/library follow-up below.nightly/2026-07-15andrules_rust0.73.0 inMODULE.bazel(with regeneratedsha256s); rootrust-toolchain.tomlto 1.97.Visibilitypath now viaVisibilityInner,FormatArgsArg.getName()returns aName, etc.).Schema delta (0.0.328 → 0.0.347)
DerefPat,ImplRestriction,IncludeBytesExpr,MutRestriction,NotNull,PatternTypeRepr,VisibilityInner.FormatArgsArgNameremoved in favour ofFormatArgsArg.getName()(now aNamecarrying the identifier text — the old placeholder was text-less, so this is strictly more information).Visibility.getPath()moved onto the newVisibilityInner(Visibility.getVisibilityInner()).attrson the inline-assembly nodes,getMutRestriction()onStructField/TupleField,getImplRestriction()onTrait.The upgrade/downgrade scripts are
compatibility: partial: the new node kinds are empty on databases built with the old extractor, so a rebuild yields strictly-better results while existing queries keep working.Testing
Extractor + QL tests. Local
codeql test runoverrust/ql/test/extractor-tests/: 312 passed; the 10.expectedupdates in this PR are the benign consequences of the new schema fields plus the std-sysroot dependency churn from the newer toolchain (no logic regressions). All 27 nightly qltests pass with zero failure rows in every changed.expected.DB upgrade/downgrade round-trip. Validated the schema-migration scripts end to end on a real database, not just by inspection. Built a Rust DB exercising the affected relations (
pub(crate)visibility paths, named format args, struct fields) and ran the fullnew → downgrade → old → upgrade → newcycle withcodeql dataset checkat each stage — 0 consistency violations throughout. Confirmed the recoverable data survives the round-trip byte-for-byte (visibility_inners,visibility_inner_paths, and the format-arg names all identical before and after), while the genuinely-new node kinds are dropped on downgrade as thepartialcontract intends.That round-trip surfaced and fixed two real bugs the scripts would otherwise have shipped:
@namerefs. The first upgrade synthesised fresh@nameentities for format-arg names but never added them to thenamesentity-defining table, leaving dangling references. Fixed by repurposing the old text-less@format_args_arg_nameids into@name(the precedent idiom) instead of minting new ones.@ast_noderefs. Deleting the new node kinds (which are members of the polymorphic@ast_nodeunion) left dangling references in the two relations with a generic@ast_nodevalue column —macro_call_macro_call_expansions(30 dangling values on the test DB) andcomments. Fixed by scrubbing both relations, pluslocatable_locations, for deleted nodes.Toolchain-window note. 0.0.347 drops support for sysroots older than Rust 1.94.0, so format-macro (
format_args!/println!/…) resolution requires Rust ≥ 1.94 (hence the test-toolchain bump 1.90 → 1.97). Two coupled upstream changes cause this: rust-analyzer #22784 (first inra_ap0.0.343) stopped injecting#[macro_use]on the sysroot crates, following rust-lang/rust #139493 which moved the std macros to the prelude in 1.94.0; and rust-analyzer363940dc("Remove format_args lowering for toolchains prior to 1.94.0", first in 0.0.344) removed the oldformat_args!compat lowering, leaving only the Rust 1.93+ bytecode form (rust-lang/rust #148789). ThreeSystemGlobalAllocsinks (alloc/alloc_zeroed/realloc) are no longer resolved by 0.0.347's std resolution and are tracked asMISSINGin the CWE-770 fixture with an inline comment, so the regression is an explicit, reviewable decision rather than a buried.expecteddiff.