Skip to content

Commit b6c413b

Browse files
committed
Rust: Wrap lines at consistent column
1 parent 8b8e4ec commit b6c413b

1 file changed

Lines changed: 41 additions & 24 deletions

File tree

‎rust/updating-rust-analyzer.md‎

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Updating rust-analyzer
22

3-
Here's a rundown of the typical actions to perform to do a rust-analyzer (and other dependencies) update. A one-time setup consists in
4-
installing [`cargo-edit`](https://crates.io/crates/cargo-edit) with `cargo install cargo-edit`. On Ubuntu that also requires
5-
`sudo apt install libssl-dev pkg-config`.
3+
Here's a rundown of the typical actions to perform to do a rust-analyzer (and
4+
other dependencies) update. A one-time setup consists in installing
5+
[`cargo-edit`](https://crates.io/crates/cargo-edit) with `cargo install
6+
cargo-edit`. On Ubuntu that also requires `sudo apt install libssl-dev
7+
pkg-config`.
68

79
> [!TIP]
810
> All steps up to and including running `bazel run //rust:install` are (barring
@@ -14,10 +16,13 @@ installing [`cargo-edit`](https://crates.io/crates/cargo-edit) with `cargo insta
1416
```
1517
cargo upgrade --incompatible --pinned
1618
```
17-
2. Look at a diff of the `Cargo.toml` files: if all `ra_ap_` prefixed dependencies have been updated to the same number, go on to the next step.
18-
Otherwise, it means the latest `rust-analyzer` update has not been fully rolled out to all its crates in `crates.io`.
19-
_All `ra_ap_` versions must agree!_
20-
Downgrade by hand to the minimum one you see, and run a `cargo update` after that to fix the `Cargo.lock` file.
19+
2. Look at a diff of the `Cargo.toml` files: if all `ra_ap_` prefixed
20+
dependencies have been updated to the same number, go on to the next
21+
step. Otherwise, it means the latest `rust-analyzer` update has not been
22+
fully rolled out to all its crates in `crates.io`. _All `ra_ap_` versions
23+
must agree!_
24+
Downgrade by hand to the minimum one you see, and run a `cargo update`
25+
after that to fix the `Cargo.lock` file.
2126
3. Commit the changes, skipping `pre-commit` hooks if you have them enabled:
2227
```
2328
git commit -am 'Cargo: upgrade dependencies' --no-verify
@@ -41,10 +46,13 @@ installing [`cargo-edit`](https://crates.io/crates/cargo-edit) with `cargo insta
4146
git commit -am 'Bazel: regenerate vendored cargo dependencies' --no-verify
4247
```
4348
> [!NOTE]
44-
> If in step 5 you also bump `rules_rust` or the Rust toolchain used for building the extractor, those changes invalidate _all_ vendored files (including the
45-
> Python ones under `misc/bazel/3rdparty/py_deps`), not just the tree-sitter ones. In that case run the umbrella script
46-
> `misc/bazel/3rdparty/update_cargo_deps.sh` instead (it regenerates both `py_deps` and `tree_sitter_extractors_deps`, and runs
47-
> `bazel mod tidy`), then commit all the regenerated files.
49+
> If in step 5 you also bump `rules_rust` or the Rust toolchain used for
50+
> building the extractor, those changes invalidate _all_ vendored files
51+
> (including the Python ones under `misc/bazel/3rdparty/py_deps`), not just
52+
> the tree-sitter ones. In that case run the umbrella script
53+
> `misc/bazel/3rdparty/update_cargo_deps.sh` instead (it regenerates both
54+
> `py_deps` and `tree_sitter_extractors_deps`, and runs `bazel mod tidy`),
55+
> then commit all the regenerated files.
4856
4957
4. Run codegen
5058
```
@@ -67,19 +75,28 @@ installing [`cargo-edit`](https://crates.io/crates/cargo-edit) with `cargo insta
6775
bazel run //rust:install
6876
```
6977
* if it succeeds: good! You can move on to the next step.
70-
* if it fails while compiling rust-analyzer dependencies, you need to update the Rust toolchain. Sometimes the error will tell you
71-
so explicitly, but it may happen that the error is more obscure. To update the rust toolchain:
72-
* you will need to open a PR on the internal repo updating `RUST_VERSION` in `MODULE.bazel`. In general you can have this merged
73-
independently of the changes in `codeql`.
74-
* in `codeql`, update both `RUST_VERSION` in `MODULE.bazel` _and_ `rust-toolchain.toml` files. You may want to also update the
75-
nightly toolchain in `rust/extractor/src/nightly-toolchain/rust-toolchain.toml` to a more recent date while you're at it.
76-
* a toolchain and/or `rules_rust` bump invalidates the vendored files, so re-run `misc/bazel/3rdparty/update_cargo_deps.sh`
77-
(see the note in step 4) and commit the regenerated files.
78-
* if it fails while compiling rust extractor code, you will need to adapt it to the new library version.
79-
* for example updating annotations in `annotations.py`, adding / removing generated tests.
80-
81-
If you had to do any changes, commit them. If you updated the rust toolchain, running `rust/lint.py` might reformat or apply new
82-
lints to the code.
78+
* if it fails while compiling rust-analyzer dependencies, you need to update
79+
the Rust toolchain. Sometimes the error will tell you so explicitly, but
80+
it may happen that the error is more obscure. To update the rust
81+
toolchain:
82+
* you will need to open a PR on the internal repo updating `RUST_VERSION`
83+
in `MODULE.bazel`. In general you can have this merged independently of
84+
the changes in `codeql`.
85+
* in `codeql`, update both `RUST_VERSION` in `MODULE.bazel` _and_
86+
`rust-toolchain.toml` files. You may want to also update the nightly
87+
toolchain in `rust/extractor/src/nightly-toolchain/rust-toolchain.toml`
88+
to a more recent date while you're at it.
89+
* a toolchain and/or `rules_rust` bump invalidates the vendored files, so
90+
re-run `misc/bazel/3rdparty/update_cargo_deps.sh` (see the note in step
91+
4) and commit the regenerated files.
92+
* if it fails while compiling rust extractor code, you will need to adapt it
93+
to the new library version.
94+
* for example updating annotations in `annotations.py`, adding / removing
95+
generated tests.
96+
97+
If you had to do any changes, commit them. If you updated the rust
98+
toolchain, running `rust/lint.py` might reformat or apply new lints to the
99+
code.
83100
84101
6. Check with CI if everything is in order.
85102

0 commit comments

Comments
 (0)