From 3418890819df1272c684a19f7e20f900aeee8019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 13 Feb 2023 09:31:58 +0200 Subject: [PATCH] Changelog #168 --- generated_assists.adoc | 31 +++++++++++++- generated_config.adoc | 13 ++++++ generated_features.adoc | 2 +- manual.adoc | 33 ++++++++++----- thisweek/_posts/2023-02-13-changelog-168.adoc | 40 +++++++++++++++++++ 5 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 thisweek/_posts/2023-02-13-changelog-168.adoc diff --git a/generated_assists.adoc b/generated_assists.adoc index 35c6de7c..f2a4c101 100644 --- a/generated_assists.adoc +++ b/generated_assists.adoc @@ -1,5 +1,34 @@ //! Generated by `sourcegen_assists_docs`, do not edit by hand. +[discrete] +=== `add_braces` +**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_braces.rs#L8[add_braces.rs] + +Adds braces to lambda and match arm expressions. + +.Before +```rust +fn foo(n: i32) -> i32 { + match n { + 1 =>┃ n + 1, + _ => 0 + } +} +``` + +.After +```rust +fn foo(n: i32) -> i32 { + match n { + 1 => { + n + 1 + }, + _ => 0 + } +} +``` + + [discrete] === `add_explicit_type` **Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_explicit_type.rs#L7[add_explicit_type.rs] @@ -1717,7 +1746,7 @@ fn main() { [discrete] === `inline_macro` -**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_macro.rs#L5[inline_macro.rs] +**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_macro.rs#L6[inline_macro.rs] Takes a macro and inlines it one step. diff --git a/generated_config.adoc b/generated_config.adoc index 1bfb8a91..50e3670a 100644 --- a/generated_config.adoc +++ b/generated_config.adoc @@ -97,6 +97,14 @@ Relative path to the sysroot, or "discover" to try to automatically find it via Unsetting this disables sysroot loading. +This option does not take effect until rust-analyzer is restarted. +-- +[[rust-analyzer.cargo.sysrootSrc]]rust-analyzer.cargo.sysrootSrc (default: `null`):: ++ +-- +Relative path to the sysroot library sources. If left unset, this will default to +`{cargo.sysroot}/lib/rustlib/src/rust/library`. + This option does not take effect until rust-analyzer is restarted. -- [[rust-analyzer.cargo.target]]rust-analyzer.cargo.target (default: `null`):: @@ -219,6 +227,11 @@ with `self` prefixed to them when inside a method. -- Whether to add parenthesis and argument snippets when completing function. -- +[[rust-analyzer.completion.limit]]rust-analyzer.completion.limit (default: `null`):: ++ +-- +Maximum number of completions to return. If `None`, the limit is infinite. +-- [[rust-analyzer.completion.postfix.enable]]rust-analyzer.completion.postfix.enable (default: `true`):: + -- diff --git a/generated_features.adoc b/generated_features.adoc index 67fca1af..4806c0a4 100644 --- a/generated_features.adoc +++ b/generated_features.adoc @@ -341,7 +341,7 @@ image::https://user-images.githubusercontent.com/48062697/113020658-b5f98b80-917 === Inlay Hints -**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide/src/inlay_hints.rs#L336[inlay_hints.rs] +**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide/src/inlay_hints.rs#L343[inlay_hints.rs] rust-analyzer shows additional information inline with the source code. Editors usually render this using read-only virtual text snippets interspersed with code. diff --git a/manual.adoc b/manual.adoc index 82909ad7..cb96feeb 100644 --- a/manual.adoc +++ b/manual.adoc @@ -535,12 +535,6 @@ https://docs.helix-editor.com/[Helix] supports LSP by default. However, it won't install `rust-analyzer` automatically. You can follow instructions for installing <>. -=== Crates - -There is a package named `ra_ap_rust_analyzer` available on https://crates.io/crates/ra_ap_rust-analyzer[crates.io], for someone who wants to use it programmatically. - -For more details, see https://github.com/rust-lang/rust-analyzer/blob/master/.github/workflows/publish.yml[the publish workflow]. - === Visual Studio 2022 There are multiple rust-analyzer extensions for Visual Studio 2022 on Windows: @@ -577,6 +571,17 @@ https://github.com/sourcegear/rust-vs-extension[GitHub (docs, issues, discussion * Free (no-cost) * Supports all editions of Visual Studio 2022 on Windows: Community, Professional, or Enterprise +=== Lapce + +https://lapce.dev/[Lapce] has a Rust plugin which you can install directly. +Unfortunately, it downloads an old version of `rust-analyzer`, but you can set the server path under Settings. + +=== Crates + +There is a package named `ra_ap_rust_analyzer` available on https://crates.io/crates/ra_ap_rust-analyzer[crates.io], for someone who wants to use it programmatically. + +For more details, see https://github.com/rust-lang/rust-analyzer/blob/master/.github/workflows/publish.yml[the publish workflow]. + == Troubleshooting Start with looking at the rust-analyzer version. @@ -768,14 +773,18 @@ See https://github.com/rust-analyzer/rust-project.json-example for a small examp You can set the `RA_LOG` environment variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading. -Note that calls to `cargo check` are disabled when using `rust-project.json` by default, so compilation errors and warnings will no longer be sent to your LSP client. To enable these compilation errors you will need to specify explicitly what command rust-analyzer should run to perform the checks using the `checkOnSave.overrideCommand` configuration. As an example, the following configuration explicitly sets `cargo check` as the `checkOnSave` command. +Note that calls to `cargo check` are disabled when using `rust-project.json` by default, so compilation errors and warnings will no longer be sent to your LSP client. +To enable these compilation errors you will need to specify explicitly what command rust-analyzer should run to perform the checks using the `rust-analyzer.check.overrideCommand` configuration. +As an example, the following configuration explicitly sets `cargo check` as the `check` command. [source,json] ---- -{ "rust-analyzer.checkOnSave.overrideCommand": ["cargo", "check", "--message-format=json"] } +{ "rust-analyzer.check.overrideCommand": ["cargo", "check", "--message-format=json"] } ---- -The `checkOnSave.overrideCommand` requires the command specified to output json error messages for rust-analyzer to consume. The `--message-format=json` flag does this for `cargo check` so whichever command you use must also output errors in this format. See the <> section for more information. +`check.overrideCommand` requires the command specified to output json error messages for rust-analyzer to consume. +The `--message-format=json` flag does this for `cargo check` so whichever command you use must also output errors in this format. +See the <> section for more information. == Security @@ -816,6 +825,10 @@ include::./generated_assists.adoc[] While most errors and warnings provided by rust-analyzer come from the `cargo check` integration, there's a growing number of diagnostics implemented using rust-analyzer's own analysis. Some of these diagnostics don't respect `\#[allow]` or `\#[deny]` attributes yet, but can be turned off using the `rust-analyzer.diagnostics.enable`, `rust-analyzer.diagnostics.experimental.enable` or `rust-analyzer.diagnostics.disabled` settings. +=== Clippy + +To run `cargo clippy` instead of `cargo check`, you can set `"rust-analyzer.check.command": "clippy"`. + include::./generated_diagnostic.adoc[] == Editor Features @@ -948,7 +961,7 @@ Also note that a full runnable name is something like *run bin_or_example_name*, Instead of relying on the built-in `cargo check`, you can configure Code to run a command in the background and use the `$rustc-watch` problem matcher to generate inline error markers from its output. -To do this you need to create a new https://code.visualstudio.com/docs/editor/tasks[VS Code Task] and set `rust-analyzer.checkOnSave.enable: false` in preferences. +To do this you need to create a new https://code.visualstudio.com/docs/editor/tasks[VS Code Task] and set `"rust-analyzer.checkOnSave": false` in preferences. For example, if you want to run https://crates.io/crates/cargo-watch[`cargo watch`] instead, you might add the following to `.vscode/tasks.json`: diff --git a/thisweek/_posts/2023-02-13-changelog-168.adoc b/thisweek/_posts/2023-02-13-changelog-168.adoc new file mode 100644 index 00000000..8bfebbc8 --- /dev/null +++ b/thisweek/_posts/2023-02-13-changelog-168.adoc @@ -0,0 +1,40 @@ += Changelog #168 +:sectanchors: +:experimental: +:page-layout: post + +Commit: commit:646f97385709fab31db2f10661125c0bbbda6b7c[] + +Release: release:2023-02-13[] (`0.3.1402`) + +== New Features + +* pr:14095[] (first contribution) add `unsafe` postfix completions. +* pr:14098[] (first contribution) add support for `DidChangeWorkspaceFolders` notifications. +* pr:13991[] add an "Add braces" assist: ++ +image::https://user-images.githubusercontent.com/4973437/213783924-7c8a8ab5-6a52-4d80-837c-cf2a9b56f061.gif["Screen recording showing an assist that adds braces around the bodies of a closure and a `match` arm"] +* pr:14087[], pr:14094[] support computing layout of RPIT. +* pr:13986[] add a setting to limit the number of completions. +* pr:14127[] build `i686-pc-windows-msvc` binaries. +* pr:14135[] add Lapce installation instructions. +* pr:14134[] add clippy configuration section to the manual. + +== Fixes + +* pr:14114[] (first contribution) insert spaces when inlining macros. +* pr:14084[] fix parsing of nested tuple field accesses (in a cursed way). +* pr:14092[] don't panic on broken syntax trees in adjustment inlay hints. +* pr:14099[] properly use location links for type hints of `impl Future` and its associated type. +* pr:14103[] don't insert a semicolon when typing `=` if parse errors are encountered. +* pr:14110[] fix completions after functions with no bodies. +* pr:14111[] hide proc macro server version detection errors. +* pr:14125[] don't render bind pattern inlay hints for constants. +* pr:14116[] render discriminant inlay hints for mixed variants if at least one discriminant is specified. +* pr:13975[] suppress extra indent after the end of field and function chains. + +== Internal Improvements + +* pr:14091[] support sysroot library source being defined inside the workspace. +* pr:14100[] allow specifying what proc-macro server to run in `rust_analyzer::load_cargo`. +* pr:14119[] remove a few allocations in `hir_ty::utils`. +* pr:14090[] unify language configuration folding markers with server behaviour.