From fc0035306cc3128da369985ac0cd48ec4144f222 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 19 Jul 2021 23:27:11 +1000 Subject: [PATCH] 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. --- BUILD.bazel | 6 ------ defs.bzl | 2 +- docs/development.md | 18 +++++++++++------- scripts/vscode-rust | 7 ------- 4 files changed, 12 insertions(+), 21 deletions(-) delete mode 100755 scripts/vscode-rust diff --git a/BUILD.bazel b/BUILD.bazel index d85cc6356..f97f95162 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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"]) diff --git a/defs.bzl b/defs.bzl index f65f0b02a..d12635177 100644 --- a/defs.bzl +++ b/defs.bzl @@ -20,7 +20,7 @@ def setup_deps(): rust_repositories( edition = "2018", - include_rustc_srcs = True, + include_rustc_srcs = False, ) raze_fetch_remote_crates() diff --git a/docs/development.md b/docs/development.md index f9247906e..1a9671e84 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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 diff --git a/scripts/vscode-rust b/scripts/vscode-rust deleted file mode 100755 index 72423a132..000000000 --- a/scripts/vscode-rust +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -bazel run @rules_rust//tools/rust_analyzer:gen_rust_project -code . -