diff --git a/generated_assists.adoc b/generated_assists.adoc index 336dbbca..9ceadab3 100644 --- a/generated_assists.adoc +++ b/generated_assists.adoc @@ -331,7 +331,7 @@ fn qux(bar: Bar, baz: Baz) {} [discrete] === `extract_function` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/extract_function.rs#L29[extract_function.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/extract_function.rs#L28[extract_function.rs] Extracts selected statements into new function. @@ -840,6 +840,39 @@ impl Ctx { ``` +[discrete] +=== `generate_is_empty_from_len` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_is_empty_from_len.rs#L12[generate_is_empty_from_len.rs] + +Generates is_empty implementation from the len method. + +.Before +```rust +struct MyStruct { data: Vec } + +impl MyStruct { + p┃ub fn len(&self) -> usize { + self.data.len() + } +} +``` + +.After +```rust +struct MyStruct { data: Vec } + +impl MyStruct { + pub fn len(&self) -> usize { + self.data.len() + } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } +} +``` + + [discrete] === `generate_new` **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_new.rs#L11[generate_new.rs] @@ -1136,7 +1169,7 @@ fn handle(action: Action) { [discrete] === `move_bounds_to_where_clause` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_bounds.rs#L10[move_bounds.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_bounds.rs#L8[move_bounds.rs] Moves inline type bounds to a where clause. @@ -1242,7 +1275,7 @@ fn main() { [discrete] === `qualify_path` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/qualify_path.rs#L22[qualify_path.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/qualify_path.rs#L21[qualify_path.rs] If the name is unresolved, provides all possible qualified paths for it. diff --git a/generated_config.adoc b/generated_config.adoc index 042ba2d5..c2521289 100644 --- a/generated_config.adoc +++ b/generated_config.adoc @@ -276,7 +276,7 @@ Number of syntax trees rust-analyzer keeps in memory. Defaults to 128. -- Whether to show `can't find Cargo.toml` error message. -- -[[rust-analyzer.procMacro.enable]]rust-analyzer.procMacro.enable (default: `false`):: +[[rust-analyzer.procMacro.enable]]rust-analyzer.procMacro.enable (default: `true`):: + -- Enable support for procedural macros, implies `#rust-analyzer.cargo.runBuildScripts#`. diff --git a/generated_diagnostic.adoc b/generated_diagnostic.adoc index c44015dd..5780ba9e 100644 --- a/generated_diagnostic.adoc +++ b/generated_diagnostic.adoc @@ -115,7 +115,7 @@ This diagnostic is triggered if rust-analyzer is unable to discover imported mod === unresolved-macro-call **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L98[diagnostics.rs] -This diagnostic is triggered if rust-analyzer is unable to resolove path to a +This diagnostic is triggered if rust-analyzer is unable to resolve the path to a macro in a macro invocation. diff --git a/generated_features.adoc b/generated_features.adoc index 21ed3903..283eba95 100644 --- a/generated_features.adoc +++ b/generated_features.adoc @@ -1,6 +1,6 @@ //Generated file, do not edit by hand, see `xtask/src/codegen` === Annotations -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/annotations.rs#L17[annotations.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/annotations.rs#L18[annotations.rs] Provides user with annotations above items for looking up references or impl blocks and running/debugging binaries. @@ -91,7 +91,7 @@ This is a standard LSP feature and not a protocol extension. === File Structure -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/file_structure.rs#L18[file_structure.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/file_structure.rs#L25[file_structure.rs] Provides a tree of the symbols defined in the file. Can be used to @@ -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#L16[goto_definition.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_definition.rs#L19[goto_definition.rs] Navigates to the definition of an identifier. @@ -149,7 +149,7 @@ Navigates to the definition of an identifier. === Go to Implementation -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_implementation.rs#L7[goto_implementation.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_implementation.rs#L10[goto_implementation.rs] Navigates to the impl block of structs, enums or traits. Also implemented as a code lens. @@ -215,7 +215,7 @@ Join selected lines into one, smartly fixing up whitespace, trailing commas, and === Magic Completions -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_completion/src/lib.rs#L31[lib.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_completion/src/lib.rs#L34[lib.rs] In addition to usual reference completion, rust-analyzer provides some ✨magic✨ completions as well: @@ -334,7 +334,7 @@ Add the following to `settings.json`: === Parent Module -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/parent_module.rs#L11[parent_module.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/parent_module.rs#L12[parent_module.rs] Navigates to the parent module of the current module. @@ -346,7 +346,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#L115[runnables.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/runnables.rs#L131[runnables.rs] Provides a sneak peek of all tests where the current item is used. @@ -374,7 +374,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#L92[runnables.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/runnables.rs#L94[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 @@ -501,7 +501,7 @@ be parsed as a valid structural search and replace rule. === Workspace Symbol -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/symbol_index.rs#L142[symbol_index.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/symbol_index.rs#L148[symbol_index.rs] Uses fuzzy-search to find types, modules and functions by name across your project and dependencies. This is **the** most useful feature, which improves code diff --git a/manual.adoc b/manual.adoc index f4c37353..dba2197d 100644 --- a/manual.adoc +++ b/manual.adoc @@ -384,11 +384,9 @@ If the LSP binary is not available, GNOME Builder can install it when opening a === Eclipse IDE -Prerequisites: You have installed the <>. - Support for Rust development in the Eclipse IDE is provided by link:https://github.com/eclipse/corrosion[Eclipse Corrosion]. -While it currently uses RLS as default, you can successfully configure it so the IDE will use `rust-analyzer` instead. -To do so, with an Eclipse IDE where Corrosion is installed, just go to __Window > Preferences > Rust__ and edit the __Path to Rust Language Server__ entry to reference the path to `rust-analyzer`. +If available in PATH or in some standard location, `rust-analyzer` is detected and powers editing of Rust files without further configuration. +If `rust-analyzer` is not detected, Corrosion will prompt you for configuration of your Rust toolchain and language server with a link to the __Window > Preferences > Rust__ preference page; from here a button allows to download and configure `rust-analyzer`, but you can also reference another installation. You'll need to close and reopen all .rs and Cargo files, or to restart the IDE, for this change to take effect. == Configuration diff --git a/thisweek/_posts/2021-03-22-changelog-69.adoc b/thisweek/_posts/2021-03-22-changelog-69.adoc new file mode 100644 index 00000000..42835aa5 --- /dev/null +++ b/thisweek/_posts/2021-03-22-changelog-69.adoc @@ -0,0 +1,113 @@ += Changelog #69 +:sectanchors: +:page-layout: post + +Commit: commit:858ad554374a8b1ad67692558a0878391abfdd86[] + +Release: release:2021-03-22[] + +== Sponsors + +**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or +https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. + +== New Features + +* pr:8000[] add HIR formatter infra and use it for hover text: ++ +image::https://user-images.githubusercontent.com/308347/111968849-49d7b180-8b02-11eb-8f0d-4b7bc38d5247.png[] + +* pr:8032[] enable proc macros by default (use `rust-analyzer.procMacro.enable` to disable them). +* pr:7966[] add diagnostic for files missing from the module tree. +* pr:7975[] include regions in file structure: ++ +image::https://user-images.githubusercontent.com/308347/111967940-4bed4080-8b01-11eb-940a-fc8f81d5673b.gif[] + +* pr:8021[] enable reference searching for built-in types: ++ +image::https://user-images.githubusercontent.com/3757771/111132711-f69db600-8579-11eb-8c90-22fd6862d11f.png[] + +* pr:8020[] power up "Go to implementation": ++ +image::https://user-images.githubusercontent.com/3757771/111144403-52bb0700-8587-11eb-9205-7a2a5b8b75a3.png[] + +* pr:7992[], pr:8036[] improve completions and completion sorting: ++ +image::https://user-images.githubusercontent.com/22216761/111018680-0e551e80-836f-11eb-94b1-c88336ecbc6e.png[] ++ +image::https://user-images.githubusercontent.com/22216761/111189395-45941d00-8573-11eb-871b-09186b35cbb9.png[] + +* pr:8037[], pr:8040[] add "Generate `is_empty` method from `len` method" assist. +* pr:7900[] show function parameters in completion detail. +* pr:8060[] improve "Move bounds" assist. +* pr:8071[], pr:8086[] highlight intra-doc links in doc comments: ++ +image::https://user-images.githubusercontent.com/308347/111969661-27926380-8b03-11eb-8e78-70dc95e137fd.png[] + +* pr:8124[] add lifetime completion: ++ +image::https://user-images.githubusercontent.com/3757771/111886437-c9b02f80-89cd-11eb-9bee-340f1536b0de.gif[] + +* pr:8127[] add label completion: ++ +image::https://user-images.githubusercontent.com/3757771/111900839-07946e80-8a35-11eb-90f6-a47943e7501d.gif[] + +* pr:8131[] add smart case lookup into flyimport completion: ++ +image::https://user-images.githubusercontent.com/308347/111970038-8821a080-8b03-11eb-9bca-b4e06aac565b.png[] + ++ +image::https://user-images.githubusercontent.com/308347/111970065-8e178180-8b03-11eb-8a33-8aa245401e8a.png[] + +== Fixes + +* pr:8025[] fix resolution of incomplete fields. +* pr:8015[] make runnable detection more resilient to out-of-tree modules. +* pr:7970[] fix incorrect diagnostics for failing built in macros. +* pr:8044[] fix macro expansion for statements without semicolon. +* pr:8048[] fix missing unresolved macro diagnostic in function body. +* pr:8066[] handle `#[cfg]` on call arguments. +* pr:8068[] handle `#[cfg]` on function parameters. +* pr:8067[] check whether cursor is on and not between intra-doc links in `goto_definition`. +* pr:8073[] improve diagnostic when including nonexistent file. +* pr:8075[] fix `use crate as ;` imports. +* pr:8078[] support `#[cfg]` on all associated items. +* pr:8082[] properly handle inner recursive `macro_rules!`. +* pr:8088[] fix "Go to definition" and highlighting for function-like proc macros. +* pr:8089[] update info about Eclipse Corrosion. +* pr:8094[] fix infinite recursion when computing diagnostics for inner items. +* pr:8083[] track source file IDs in source mapping of `Attrs`. +* pr:8108[] fix handling of `#![cfg]` in outline module files. +* pr:8122[] make bare underscore token an `Ident` rather than `Punct` in proc-macro. +* pr:8123[] do not display unqualified associated item completions. +* pr:8128[] expand legacy-scoped macro during collection. +* pr:8133[] fix `salsa` panic. +* pr:8134[] (first contribution) fix module resolution in `include!`ed files. +* pr:8137[] fix box pattern inference panic. + + +== Internal Improvements + +* pr:7498[] switch to a mutable syntax tree implementation. +* pr:8023[] move `StructureNodeKind` from `ide_db` to `ide`. +* pr:8022[] fix some `clippy` performance warnings. +* pr:8026[] simplify source maps for fields. +* pr:8018[], pr:8038[] make `Ty` wrap `TyKind` in an `Arc`. +* pr:8008[] clean up `CompletionContext::expected_type`. +* pr:8030[] add `diesel` to the benchmark suite. +* pr:8029[] enable thread-local coverage mark support. +* pr:8035[] `unqualfied_path` completions aren't responsible for variant pattern completions. +* pr:8028[] prepare for returning parents in the "Locate parent module" command. +* pr:8039[] use `SmallVec` for `Substs`. +* pr:8046[] add `match` vs. `if let ... else` entry to the style guide. +* pr:8034[] implement `Crate::transitive_reverse_dependencies`. +* pr:8042[] (first contribution) add `rustc-perf` version to the metrics JSON. +* pr:8061[] structural editing API can automatically insert whitespace in simple cases. +* pr:8059[] support `cfg_attr` in doc-comment syntax highlighting. +* pr:8065[] handle block doc comments better. +* pr:8069[] support highlight injection in block doc comments. +* pr:8080[] change `ItemTree` API to accomodate creating an `ItemTree` per block expression. +* pr:8087[] make MacroDefId's `AstId` mandatory when possible. +* pr:8093[] record custom derive helpers in `DefMap`. +* pr:8097[] parse `extended_key_value_attributes`. +* pr:8112[] revamp `hir_def` attribute API. +* pr:8125[] don't use an untyped `String` for ActiveParam tracking.