drop Rust Analyzer Bazel rule

With proper excludes set up, starting it outside of Bazel is similarly
fast, and unit tests work correctly. It also makes initial Bazel startup
faster, as the Rust sources no longer need to be fetched.
This commit is contained in:
Damien Elmes 2021-07-19 23:27:11 +10:00
parent bbddc79da4
commit fc0035306c
4 changed files with 12 additions and 21 deletions

View file

@ -1,5 +1,4 @@
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@rules_rust//rust:defs.bzl", "rust_analyzer")
config_setting(
name = "release",
@ -40,10 +39,5 @@ pkg_tar(
tags = ["manual"],
)
rust_analyzer(
name = "rust_analyzer",
targets = ["//rslib:anki"],
)
# for version info
exports_files(["defs.bzl"])

View file

@ -20,7 +20,7 @@ def setup_deps():
rust_repositories(
edition = "2018",
include_rustc_srcs = True,
include_rustc_srcs = False,
)
raze_fetch_remote_crates()

View file

@ -173,15 +173,19 @@ CPU usage, but Pylance doesn't do a great job understanding the type annotations
## Rust editing
Rust editor support is still fairly new, but currently Visual Studio Code + Rust
Analyzer seems to be the least-bad option. Once Rust Analyzer is installed,
you'll want to enable the options to expand proc macros, and run cargo check on
startup.
Currently Visual Studio Code + Rust Analyzer seems to be the best option out
there. Once Rust Analyzer is installed, you'll want to enable the options to
expand proc macros and build scripts, and run cargo check on startup. Adding
`+nightly` as an extra arg to rustfmt will get you nicer automatic formatting
of `use` statements.
After running 'code rslib' from the project root, it may take Rust Analyzer a
while to become ready - if you check the running processes on your machine you should
see it running in the background for a while.
The Bazel build products will make RA start up slowly out of the box. For a much
nicer experience, add each of the bazel-* folders to Rust Analyzer's excludeDirs
settings, and ts/node_modules. Wildcards don't work unfortunately. Then adjust
VS Code's "watcher exclude", and add `**/bazel-*`.
After running 'code' from the project root, it may take a minute or two to be
ready.
## TypeScript editing
Visual Studio Code seems to give the best experience. Use 'code ts' from the project

View file

@ -1,7 +0,0 @@
#!/bin/bash
set -e
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
code .