diff --git a/generated_assists.adoc b/generated_assists.adoc index 02279af9..13843d4f 100644 --- a/generated_assists.adoc +++ b/generated_assists.adoc @@ -329,6 +329,51 @@ fn main() { ``` +[discrete] +=== `convert_tuple_struct_to_named_struct` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs#L9[convert_tuple_struct_to_named_struct.rs] + +Converts tuple struct to struct with named fields. + +.Before +```rust +struct Point┃(f32, f32); + +impl Point { + pub fn new(x: f32, y: f32) -> Self { + Point(x, y) + } + + pub fn x(&self) -> f32 { + self.0 + } + + pub fn y(&self) -> f32 { + self.1 + } +} +``` + +.After +```rust +struct Point { field1: f32, field2: f32 } + +impl Point { + pub fn new(x: f32, y: f32) -> Self { + Point { field1: x, field2: y } + } + + pub fn x(&self) -> f32 { + self.field1 + } + + pub fn y(&self) -> f32 { + self.field2 + } +} +``` + + [discrete] === `expand_glob_import` **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/expand_glob_import.rs#L18[expand_glob_import.rs] @@ -457,7 +502,7 @@ fn main() { [discrete] === `fill_match_arms` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/fill_match_arms.rs#L14[fill_match_arms.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/fill_match_arms.rs#L15[fill_match_arms.rs] Adds missing clauses to a `match` expression. @@ -1058,7 +1103,7 @@ fn main() { [discrete] === `inline_local_variable` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_local_variable.rs#L13[inline_local_variable.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_local_variable.rs#L15[inline_local_variable.rs] Inlines local variable. @@ -1080,7 +1125,7 @@ fn main() { [discrete] === `introduce_named_lifetime` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/introduce_named_lifetime.rs#L12[introduce_named_lifetime.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/introduce_named_lifetime.rs#L13[introduce_named_lifetime.rs] Change an anonymous lifetime to a named lifetime. @@ -1489,7 +1534,7 @@ const test: Foo = Foo {foo: 1, bar: 0} [discrete] === `reorder_impl` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/reorder_impl.rs#L14[reorder_impl.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/reorder_impl.rs#L13[reorder_impl.rs] Reorder the methods of an `impl Trait`. The methods will be ordered in the same order as in the trait definition. @@ -1529,7 +1574,7 @@ impl Foo for Bar { [discrete] === `replace_derive_with_manual_impl` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs#L20[replace_derive_with_manual_impl.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs#L19[replace_derive_with_manual_impl.rs] Converts a `derive` impl into a manual one. diff --git a/generated_config.adoc b/generated_config.adoc index e0ee35b4..e28423e9 100644 --- a/generated_config.adoc +++ b/generated_config.adoc @@ -147,6 +147,12 @@ have more false positives than usual. -- List of rust-analyzer diagnostics to disable. -- +[[rust-analyzer.diagnostics.remapPrefix]]rust-analyzer.diagnostics.remapPrefix (default: `{}`):: ++ +-- +Map of prefixes to be substituted when parsing diagnostic file paths. +This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`. +-- [[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`):: + -- diff --git a/generated_features.adoc b/generated_features.adoc index 66e0967e..c00f0038 100644 --- a/generated_features.adoc +++ b/generated_features.adoc @@ -68,7 +68,7 @@ image::https://user-images.githubusercontent.com/48062697/113020673-b85be580-917 === Expand Macro Recursively -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/expand_macro.rs#L19[expand_macro.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/expand_macro.rs#L17[expand_macro.rs] Shows the full macro expansion of the macro at current cursor. @@ -418,7 +418,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#L64[rename.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/references/rename.rs#L75[rename.rs] Renames the item below the cursor and all of its references diff --git a/manual.adoc b/manual.adoc index b86e9177..54195adb 100644 --- a/manual.adoc +++ b/manual.adoc @@ -429,24 +429,32 @@ However, if you use some other build system, you'll have to describe the structu [source,TypeScript] ---- interface JsonProject { - /// Path to the directory with *source code* of sysroot crates. + /// Path to the directory with *source code* of + /// sysroot crates. + /// + /// It should point to the directory where std, + /// core, and friends can be found: /// - /// It should point to the directory where std, core, and friends can be found: /// https://github.com/rust-lang/rust/tree/master/library. /// - /// If provided, rust-analyzer automatically adds dependencies on sysroot - /// crates. Conversely, if you omit this path, you can specify sysroot - /// dependencies yourself and, for example, have several different "sysroots" in - /// one graph of crates. + /// If provided, rust-analyzer automatically adds + /// dependencies on sysroot crates. Conversely, + /// if you omit this path, you can specify sysroot + /// dependencies yourself and, for example, have + /// several different "sysroots" in one graph of + /// crates. sysroot_src?: string; - /// The set of crates comprising the current project. - /// Must include all transitive dependencies as well as sysroot crate (libstd, libcore and such). + /// The set of crates comprising the current + /// project. Must include all transitive + /// dependencies as well as sysroot crate (libstd, + /// libcore and such). crates: Crate[]; } interface Crate { - /// Optional crate name used for display purposes, without affecting semantics. - /// See the `deps` key for semantically-significant crate names. + /// Optional crate name used for display purposes, + /// without affecting semantics. See the `deps` + /// key for semantically-significant crate names. display_name?: string; /// Path to the root module of the crate. root_module: string; @@ -454,45 +462,59 @@ interface Crate { edition: "2015" | "2018" | "2021"; /// Dependencies deps: Dep[]; - /// Should this crate be treated as a member of current "workspace". + /// Should this crate be treated as a member of + /// current "workspace". /// - /// By default, inferred from the `root_module` (members are the crates which reside - /// inside the directory opened in the editor). + /// By default, inferred from the `root_module` + /// (members are the crates which reside inside + /// the directory opened in the editor). /// - /// Set this to `false` for things like standard library and 3rd party crates to - /// enable performance optimizations (rust-analyzer assumes that non-member crates - /// don't change). + /// Set this to `false` for things like standard + /// library and 3rd party crates to enable + /// performance optimizations (rust-analyzer + /// assumes that non-member crates don't change). is_workspace_member?: boolean; - /// Optionally specify the (super)set of `.rs` files comprising this crate. + /// Optionally specify the (super)set of `.rs` + /// files comprising this crate. /// - /// By default, rust-analyzer assumes that only files under `root_module.parent` can belong to a crate. - /// `include_dirs` are included recursively, unless a subdirectory is in `exclude_dirs`. + /// By default, rust-analyzer assumes that only + /// files under `root_module.parent` can belong + /// to a crate. `include_dirs` are included + /// recursively, unless a subdirectory is in + /// `exclude_dirs`. /// /// Different crates can share the same `source`. /// - /// If two crates share an `.rs` file in common, they *must* have the same `source`. - /// rust-analyzer assumes that files from one source can't refer to files in another source. + /// If two crates share an `.rs` file in common, + /// they *must* have the same `source`. + /// rust-analyzer assumes that files from one + /// source can't refer to files in another source. source?: { 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. /// - /// Used when running `rustc --print cfg` to get target-specific cfgs. + /// Used when running `rustc --print cfg` + /// to get target-specific cfgs. target?: string; - /// Environment variables, used for the `env!` macro + /// Environment variables, used for + /// the `env!` macro env: : { [key: string]: string; }, - /// For proc-macro crates, path to compiles proc-macro (.so file). + /// For proc-macro crates, path to compiled + /// proc-macro (.so file). proc_macro_dylib_path?: string; } interface Dep { /// Index of a crate in the `crates` array. crate: number, - /// Name as should appear in the (implicit) `extern crate name` declaration. + /// Name as should appear in the (implicit) + /// `extern crate name` declaration. name: string, } ---- diff --git a/thisweek/_posts/2021-04-26-changelog-74.adoc b/thisweek/_posts/2021-04-26-changelog-74.adoc new file mode 100644 index 00000000..ecb77eab --- /dev/null +++ b/thisweek/_posts/2021-04-26-changelog-74.adoc @@ -0,0 +1,61 @@ += Changelog #74 +:sectanchors: +:page-layout: post + +Commit: commit:617535393bb5ccc7adf0bac8a3b9a9c306454e79[] + +Release: release:2021-04-26[] + +== Sponsors + +**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or +https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. + +== New Features + +* pr:8467[] (first contribution) add "generate `Deref` impl" assist: ++ +image::https://user-images.githubusercontent.com/5489149/115183917-9971b480-a091-11eb-98b0-d847543cde01.gif[] ++ +This feature was included in the last week's changelog by mistake. +* pr:8317[] add "Convert tuple to named struct" assist: ++ +image::https://user-images.githubusercontent.com/308347/116033884-ebef3a00-a66a-11eb-8e34-f95afe788a30.gif[] +* pr:8462[] expand macros in type positions. +* pr:8621[] make sure nightly regressions don't break users. +* pr:8570[] parse `rustc` error messages in flycheck for non-Cargo build systems. +* pr:8595[] add support for remapping diagnostic paths. + + +== Fixes + +* pr:8611[] (first contribution) add support for boolean values to "Fill match arms". +* pr:8658[] (first contribution) check more carefully for cases when a rename can't be done. +* pr:8582[] (first contribution) fix typo in `comparison` semantic token type. +* pr:8600[] fix project loading hang. +* pr:8606[] fix "Registering progress handler" error. +* pr:8639[] fix `configuration.property` startup error in VS Code. +* pr:8643[] change version string to contain hash, build date and channel. +* pr:8524[] fix "Extract function" with partial block selection. +* pr:8540[] prevent renaming items that are not part of the workspace (LSP extension). +* pr:8565[] "Fill match arms" assist: add remaining arms for enum tuples. +* pr:8577[] support crates/module roots in `external_docs`. +* pr:8578[] fix inner attributes false positives in docs. +* pr:8587[] fix some `find_path` bugs around inner items (fixes auto-imports with macro calls). +* pr:8601[] trigger "Inline variable" assist on variable usages. +* pr:8609[] parse outer attributes for `RecordPatField`. +* pr:8620[] avoid unnecessary braces in "Extract function". +* pr:8602[] fix panic in "Replace derive with manual implementation". + +== Internal Improvements + +* pr:8502[] document review requesting etiquette. +* pr:8527[] rewrite "Introduce named lifetime" assist to use mutable syntax trees. +* pr:8579[] fix "Server status" capability name in docs. +* pr:8580[] remove confusion around `serverStatusNotification`. +* pr:8584[] fix slightly broken test. +* pr:8586[] replace `SyntaxRewriter` usage with `ted` in `eager::eager_macro_recur`. +* pr:8588[] add guidelines for release notes PR descriptions. +* pr:8605[] automatically categorize the changelog entries. +* pr:8591[] remove `SyntaxRewriter` usage in `insert_use` in favor of mutable syntax trees. +* pr:8638[] remove `SyntaxRewriter::from_fn`. +* pr:8647[] split out `merge_imports` module from `helpers::insert_use`.