diff --git a/generated_assists.adoc b/generated_assists.adoc index 9ceadab3..f318255e 100644 --- a/generated_assists.adoc +++ b/generated_assists.adoc @@ -118,7 +118,7 @@ impl Trait for () { [discrete] === `add_lifetime_to_type` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_lifetime_to_type.rs#L6[add_lifetime_to_type.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_lifetime_to_type.rs#L5[add_lifetime_to_type.rs] Adds a new lifetime to a struct, enum or union. @@ -1090,7 +1090,7 @@ fn main() { [discrete] === `merge_imports` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/merge_imports.rs#L13[merge_imports.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/merge_imports.rs#L10[merge_imports.rs] Merges two imports with a common prefix. @@ -1384,7 +1384,7 @@ fn main() { [discrete] === `reorder_fields` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/reorder_fields.rs#L10[reorder_fields.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/reorder_fields.rs#L7[reorder_fields.rs] Reorder the fields of record literals and record patterns in the same order as in the definition. diff --git a/generated_config.adoc b/generated_config.adoc index c2521289..871c65ad 100644 --- a/generated_config.adoc +++ b/generated_config.adoc @@ -206,10 +206,10 @@ Use markdown syntax for links in hover. -- Whether to show inlay type hints for method chains. -- -[[rust-analyzer.inlayHints.maxLength]]rust-analyzer.inlayHints.maxLength (default: `null`):: +[[rust-analyzer.inlayHints.maxLength]]rust-analyzer.inlayHints.maxLength (default: `25`):: + -- -Maximum length for inlay hints. Default is unlimited. +Maximum length for inlay hints. Set to null to have an unlimited length. -- [[rust-analyzer.inlayHints.parameterHints]]rust-analyzer.inlayHints.parameterHints (default: `true`):: + diff --git a/generated_diagnostic.adoc b/generated_diagnostic.adoc index 5780ba9e..a06de5c7 100644 --- a/generated_diagnostic.adoc +++ b/generated_diagnostic.adoc @@ -100,6 +100,13 @@ This diagnostic is triggered if created structure does not have field provided i This diagnostic is triggered when `.filter_map(..).next()` is used, rather than the more concise `.find_map(..)`. +=== unlinked-file +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/diagnostics/unlinked_file.rs#L23[unlinked_file.rs] + +This diagnostic is shown for files that are not included in any crate, or files that are part of +crates rust-analyzer failed to discover. The file will not have IDE features available. + + === unresolved-extern-crate **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L43[diagnostics.rs] diff --git a/generated_features.adoc b/generated_features.adoc index 283eba95..8756d3dd 100644 --- a/generated_features.adoc +++ b/generated_features.adoc @@ -137,7 +137,7 @@ The following postfix snippets are available: === Go to Definition -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_definition.rs#L19[goto_definition.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_definition.rs#L15[goto_definition.rs] Navigates to the definition of an identifier. @@ -173,7 +173,7 @@ Navigates to the type of an identifier. === Hover -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/hover.rs#L78[hover.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/hover.rs#L81[hover.rs] Shows additional information, like type of an expression or documentation for definition when "focusing" code. Focusing is usually hovering with a mouse, but can also be triggered with a shortcut. @@ -293,6 +293,19 @@ Clears rust-analyzer's internal database and prints memory usage statistics. |=== +=== Move Item +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/move_item.rs#L16[move_item.rs] + +Move item under cursor or selection up and down. + +|=== +| Editor | Action Name + +| VS Code | **Rust Analyzer: Move item up** +| VS Code | **Rust Analyzer: Move item down** +|=== + + === On Enter **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/typing/on_enter.rs#L15[on_enter.rs] @@ -346,7 +359,7 @@ Navigates to the parent module of the current module. === Related Tests -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/runnables.rs#L131[runnables.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/runnables.rs#L127[runnables.rs] Provides a sneak peek of all tests where the current item is used. @@ -362,7 +375,7 @@ The simplest way to use this feature is via the context menu: === Rename -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/references/rename.rs#L61[rename.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/references/rename.rs#L64[rename.rs] Renames the item below the cursor and all of its references @@ -374,7 +387,7 @@ Renames the item below the cursor and all of its references === Run -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/runnables.rs#L94[runnables.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/runnables.rs#L90[runnables.rs] Shows a popup suggesting to run a test/benchmark/binary **at the current cursor location**. Super useful for repeatedly running just a single test. Do bind this diff --git a/manual.adoc b/manual.adoc index dba2197d..b1beeb88 100644 --- a/manual.adoc +++ b/manual.adoc @@ -178,6 +178,15 @@ $ cargo xtask install --server If your editor can't find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn't see the same `$PATH` as the shell, see https://github.com/rust-analyzer/rust-analyzer/issues/1811[this issue]. On Unix, running the editor from a shell or changing the `.desktop` file to set the environment should help. +==== `rustup` + +`rust-analyzer` is available in `rustup`, but only in the nightly toolchain: + +[source,bash] +--- +$ rustup +nightly component add rust-analyzer-preview +--- + ==== Arch Linux The `rust-analyzer` binary can be installed from the repos or AUR (Arch User Repository): @@ -480,7 +489,7 @@ interface Crate { include_dirs: string[], exclude_dirs: string[], }, - /// The set of cfgs activated for a given crate, like `["unix", "feature=foo", "feature=bar"]`. + /// The set of cfgs activated for a given crate, like `["unix", "feature=\"foo\"", "feature=\"bar\""]`. cfg: string[]; /// Target triple for this Crate. /// @@ -516,6 +525,20 @@ See https://github.com/rust-analyzer/rust-project.json-example for a small examp You can set `RA_LOG` environmental variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading. +== Security + +At the moment, rust-analyzer assumes that all code is trusted. +Here is a **non-exhaustive** list of ways to make rust-analyzer execute arbitrary code: + +* proc macros and build scripts are executed by default +* `.cargo/config` can override `rustc` with an arbitrary executable +* VS Code plugin reads configuration from project directory, and that can be used to override paths to various executables, like `rustfmt` or `rust-analyzer` itself. +* rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety. + +rust-analyzer itself doesn't access the network. +The VS Code plugin doesn't access the network unless the nightly channel is selected in the settings. +In that case, the plugin uses the GitHub API to check for and download updates. + == Features include::./generated_features.adoc[] diff --git a/thisweek/_posts/2021-03-29-changelog-70.adoc b/thisweek/_posts/2021-03-29-changelog-70.adoc new file mode 100644 index 00000000..f488ca4d --- /dev/null +++ b/thisweek/_posts/2021-03-29-changelog-70.adoc @@ -0,0 +1,70 @@ += Changelog #70 +:sectanchors: +:page-layout: post + +Commit: commit:01dc53a31c39fe754c7228646c456325e49e8d09[] + +Release: release:2021-03-29[] + +== Sponsors + +**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or +https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. + +== New Features + +* pr:8054[] add Move item commands (LSP extension): ++ +image::https://user-images.githubusercontent.com/308347/112793739-7e052200-906e-11eb-9ed4-1b396ef7d6dc.gif[] + ++ +image::https://user-images.githubusercontent.com/308347/112793747-83626c80-906e-11eb-9a96-a075e8d38d6e.gif[] + +* pr:8178[] show item info when hovering intra-doc links: ++ +image::https://user-images.githubusercontent.com/3757771/112197618-91e2fb00-8c0c-11eb-9edc-a7923214d2b6.gif[] + +* pr:8056[] on completion, take into account whether types unify: ++ +image::https://user-images.githubusercontent.com/22216761/111338556-46d94e80-8634-11eb-9936-2b20eb9e6756.png[] + ++ +image::https://user-images.githubusercontent.com/22216761/111338598-4e005c80-8634-11eb-92e0-69c2c1cda6fc.png[] + +* pr:8212[] implement basic macros 2.0 support: ++ +image::https://user-images.githubusercontent.com/11014119/112712565-6eb99380-8f0b-11eb-88de-5d7f974dfe6d.png[] + +== Fixes + +* pr:8156[] correctly lower `TraitRef`s with default params. +* pr:8144[] (first contribution) fix crash when trying to display closure types. +* pr:8142[] hide incorrect ref match completions for struct fields/methods. +* pr:8138[] set up a search scope when searching for MBE macro references. +* pr:8159[] try to ignore proc-macro stdout to prevent IPC crashes. +* pr:8182[] trim down IPC JSON size. +* pr:8177[] limit hints size by default. +* pr:8183[] fix spurious "Missing command" lenses on macros. +* pr:8168[] fix "Convert to guarded return" for mutable bindings. +* pr:8189[] document `unlinked-file` diagnostic. +* pr:7907[] take visibility into account for autoderef. +* pr:8194[] finally fix version string display in release binaries. +* pr:8206[] ignore main functions outside of the root module. +* pr:8201[] fix recursive macro statements expansion. +* pr:8213[] include const generic in `impl` generation. +* pr:8214[] mention the `rustup` component in the installation instructions. +* pr:8221[] prefer adding `mod` declaration to `lib.rs` over `file.rs` in `unlinked-file` fix. +* pr:8141[] don't suggest long looping paths for imports. +* pr:8155[] fix confusion between functions and parameters. +* pr:8191[], pr:8209[] fix slight memory leak in syntax. + +== Internal Improvements + +* pr:8136[], pr:8190[] introduce `QuantifiedWhereClause` and `DynTy` analogous to Chalk. +* pr:8139[] align `Canonical` and `InEnvironment` with the Chalk versions. +* pr:8154[] rewrite "Merge use trees" assist using mutable syntax trees. +* pr:8165[] tweak assist API to fit mutable syntax trees. +* pr:8169[] make more use of the HIR in `rename::rename_to_self`. +* pr:8170[] merge bang-macros and derives in name resolution. +* pr:8187[] sweep the new `TraitEnvironmentQuery`. +* pr:8145[] document our security stance. +* pr:8146[] document patch policy.