Skip to content

Changelog #79 #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions generated_assists.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ enum Action { Move { distance: u32 }, Stop }

fn handle(action: Action) {
match action {
┃Action::Move { distance } => {}
Action::Stop => {}
┃Action::Move { distance } => todo!(),
Action::Stop => todo!(),
}
}
```
Expand Down
19 changes: 13 additions & 6 deletions generated_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ This should be the reverse mapping of what is passed to `rustc` as `--remap-path
[[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`)::
+
--
List of warnings that should be displayed with info severity.
List of warnings that should be displayed with hint severity.

The warnings will be indicated by a blue squiggly underline in code
and a blue icon in the `Problems Panel`.
The warnings will be indicated by faded text or three dots in code
and will not show up in the `Problems Panel`.
--
[[rust-analyzer.diagnostics.warningsAsInfo]]rust-analyzer.diagnostics.warningsAsInfo (default: `[]`)::
+
--
List of warnings that should be displayed with hint severity.
List of warnings that should be displayed with info severity.

The warnings will be indicated by faded text or three dots in code
and will not show up in the `Problems Panel`.
The warnings will be indicated by a blue squiggly underline in code
and a blue icon in the `Problems Panel`.
--
[[rust-analyzer.files.watcher]]rust-analyzer.files.watcher (default: `"client"`)::
+
Expand Down Expand Up @@ -346,6 +346,13 @@ Additional arguments to `rustfmt`.
Advanced option, fully override the command rust-analyzer uses for
formatting.
--
[[rust-analyzer.rustfmt.enableRangeFormatting]]rust-analyzer.rustfmt.enableRangeFormatting (default: `false`)::
+
--
Enables the use of rustfmt's unstable range formatting command for the
`textDocument/rangeFormatting` request. The rustfmt option is unstable and only
available on a nightly build.
--
[[rust-analyzer.workspace.symbol.search.scope]]rust-analyzer.workspace.symbol.search.scope (default: `"workspace"`)::
+
--
Expand Down
40 changes: 16 additions & 24 deletions generated_diagnostic.adoc
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
//Generated file, do not edit by hand, see `xtask/src/codegen`
=== break-outside-of-loop
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L248[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L250[diagnostics.rs]

This diagnostic is triggered if the `break` keyword is used outside of a loop.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== inactive-code
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L127[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/diagnostics.rs#L129[diagnostics.rs]

This diagnostic is shown for code with inactive `#[cfg]` attributes.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== incorrect-ident-case
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L379[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L381[diagnostics.rs]

This diagnostic is triggered if an item name doesn't follow https://doc.rust-lang.org/1.0.0/style/style/naming/README.html[Rust naming convention].


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== macro-error
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L200[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/diagnostics.rs#L202[diagnostics.rs]

This diagnostic is shown for macro expansion errors.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== mismatched-arg-count
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L296[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L298[diagnostics.rs]

This diagnostic is triggered if a function is invoked with an incorrect amount of arguments.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== missing-match-arm
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L164[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L166[diagnostics.rs]

This diagnostic is triggered if `match` block is missing one or more match arms.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== missing-ok-or-some-in-tail-expr
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L189[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L191[diagnostics.rs]

This diagnostic is triggered if a block that should return `Result` returns a value not wrapped in `Ok`,
or if a block that should return `Option` returns a value not wrapped in `Some`.
Expand All @@ -65,7 +65,7 @@ fn foo() -> Result<u8, ()> {
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== missing-pat-fields
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L115[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L117[diagnostics.rs]

This diagnostic is triggered if pattern lacks some fields that exist in the corresponding structure.

Expand All @@ -85,7 +85,7 @@ if let A { a } = a {
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== missing-structure-fields
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L68[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L70[diagnostics.rs]

This diagnostic is triggered if record lacks some fields that exist in the corresponding structure.

Expand All @@ -101,23 +101,23 @@ let a = A { a: 10 };
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== missing-unsafe
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L272[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L274[diagnostics.rs]

This diagnostic is triggered if an operation marked as `unsafe` is used outside of an `unsafe` function or block.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== no-such-field
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L41[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L43[diagnostics.rs]

This diagnostic is triggered if created structure does not have field provided in record.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== replace-filter-map-next-with-find-map
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L420[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L422[diagnostics.rs]

This diagnostic is triggered when `.filter_map(..).next()` is used, rather than the more concise `.find_map(..)`.

Expand All @@ -134,23 +134,15 @@ crates rust-analyzer failed to discover. The file will not have IDE features ava
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== unresolved-extern-crate
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L43[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/diagnostics.rs#L48[diagnostics.rs]

This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== unresolved-import
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L67[diagnostics.rs]

This diagnostic is triggered if rust-analyzer is unable to discover imported module.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== unresolved-macro-call
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L98[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/diagnostics.rs#L100[diagnostics.rs]

This diagnostic is triggered if rust-analyzer is unable to resolve the path to a
macro in a macro invocation.
Expand All @@ -159,15 +151,15 @@ macro in a macro invocation.
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== unresolved-module
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L18[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/diagnostics.rs#L23[diagnostics.rs]

This diagnostic is triggered if rust-analyzer is unable to discover referred module.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== unresolved-proc-macro
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L160[diagnostics.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/diagnostics.rs#L162[diagnostics.rs]

This diagnostic is shown when a procedural macro can not be found. This usually means that
procedural macro support is simply disabled (and hence is only a weak hint instead of an error),
Expand Down
102 changes: 98 additions & 4 deletions generated_features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ image::https://user-images.githubusercontent.com/48062697/113020670-b7c34f00-917
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Folding
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/folding_ranges.rs#L30[folding_ranges.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/folding_ranges.rs#L31[folding_ranges.rs]

Defines folding regions for curly braced blocks, runs of consecutive import
statements, and `region` / `endregion` comment markers.
Expand Down Expand Up @@ -219,7 +219,7 @@ image::https://user-images.githubusercontent.com/48062697/113065566-02f85480-91b
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Go to Type Definition
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_type_definition.rs#L6[goto_type_definition.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_type_definition.rs#L7[goto_type_definition.rs]

Navigates to the type of an identifier.

Expand Down Expand Up @@ -518,13 +518,107 @@ image::https://user-images.githubusercontent.com/48062697/113065583-055aae80-91b
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/syntax_highlighting.rs#L42[syntax_highlighting.rs]

rust-analyzer highlights the code semantically.
For example, `bar` in `foo::Bar` might be colored differently depending on whether `Bar` is an enum or a trait.
rust-analyzer does not specify colors directly, instead it assigns tag (like `struct`) and a set of modifiers (like `declaration`) to each token.
For example, `Bar` in `foo::Bar` might be colored differently depending on whether `Bar` is an enum or a trait.
rust-analyzer does not specify colors directly, instead it assigns a tag (like `struct`) and a set of modifiers (like `declaration`) to each token.
It's up to the client to map those to specific colors.

The general rule is that a reference to an entity gets colored the same way as the entity itself.
We also give special modifier for `mut` and `&mut` local variables.


.Token Tags

Rust-analyzer currently emits the following token tags:

- For items:
+
[horizontal]
enum:: Emitted for enums.
function:: Emitted for free-standing functions.
macro:: Emitted for macros.
method:: Emitted for associated functions, also knowns as methods.
namespace:: Emitted for modules.
struct:: Emitted for structs.
trait:: Emitted for traits.
typeAlias:: Emitted for type aliases and `Self` in `impl`s.
union:: Emitted for unions.

- For literals:
+
[horizontal]
boolean:: Emitted for the boolean literals `true` and `false`.
character:: Emitted for character literals.
number:: Emitted for numeric literals.
string:: Emitted for string literals.
escapeSequence:: Emitted for escaped sequences inside strings like `\n`.
formatSpecifier:: Emitted for format specifiers `{:?}` in `format!`-like macros.

- For operators:
+
[horizontal]
operator:: Emitted for general operators.
arithmetic:: Emitted for the arithmetic operators `+`, `-`, `*`, `/`, `+=`, `-=`, `*=`, `/=`.
bitwise:: Emitted for the bitwise operators `|`, `&`, `!`, `^`, `|=`, `&=`, `^=`.
comparison:: Emitted for the comparison operators `>`, `<`, `==`, `>=`, `<=`, `!=`.
logical:: Emitted for the logical operators `||`, `&&`, `!`.

- For punctuation:
+
[horizontal]
punctuation:: Emitted for general punctuation.
angle:: Emitted for `<>` angle brackets.
brace:: Emitted for `{}` braces.
bracket:: Emitted for `[]` brackets.
parenthesis:: Emitted for `()` parentheses.
colon:: Emitted for the `:` token.
comma:: Emitted for the `,` token.
dot:: Emitted for the `.` token.
Semi:: Emitted for the `;` token.

//-

[horizontal]
attribute:: Emitted for attributes.
builtinType:: Emitted for builtin types like `u32`, `str` and `f32`.
comment:: Emitted for comments.
constParameter:: Emitted for const parameters.
enumMember:: Emitted for enum variants.
generic:: Emitted for generic tokens that have no mapping.
keyword:: Emitted for keywords.
label:: Emitted for labels.
lifetime:: Emitted for lifetimes.
parameter:: Emitted for non-self function parameters.
property:: Emitted for struct and union fields.
selfKeyword:: Emitted for the self function parameter and self path-specifier.
typeParameter:: Emitted for type parameters.
unresolvedReference:: Emitted for unresolved references, names that rust-analyzer can't find the definition of.
variable:: Emitted for locals, constants and statics.


.Token Modifiers

Token modifiers allow to style some elements in the source code more precisely.

Rust-analyzer currently emits the following token modifiers:

[horizontal]
async:: Emitted for async functions and the `async` and `await` keywords.
attribute:: Emitted for tokens inside attributes.
callable:: Emitted for locals whose types implements one of the `Fn*` traits.
constant:: Emitted for consts.
consuming:: Emitted for locals that are being consumed when use in a function call.
controlFlow:: Emitted for control-flow related tokens, this includes the `?` operator.
declaration:: Emitted for names of definitions, like `foo` in `fn foo() {}`.
documentation:: Emitted for documentation comments.
injected:: Emitted for doc-string injected highlighting like rust source blocks in documentation.
intraDocLink:: Emitted for intra doc links in doc-strings.
library:: Emitted for items that are defined outside of the current crate.
mutable:: Emitted for mutable locals and statics.
static:: Emitted for "static" functions, also known as functions that do not take a `self` param, as well as statics and consts.
trait:: Emitted for associated trait items.
unsafe:: Emitted for unsafe operations, like unsafe function calls, as well as the `unsafe` token.


image::https://user-images.githubusercontent.com/48062697/113164457-06cfb980-9239-11eb-819b-0f93e646acf8.png[]
image::https://user-images.githubusercontent.com/48062697/113187625-f7f50100-9250-11eb-825e-91c58f236071.png[]

Expand Down
10 changes: 5 additions & 5 deletions manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ $ cargo xtask install --server
== rust-analyzer Language Server Binary

Other editors generally require the `rust-analyzer` binary to be in `$PATH`.
You can download the pre-built binary from the https://github.com/rust-analyzer/rust-analyzer/releases[releases] page.
Typically, you then need to rename the binary for your platform, e.g. `rust-analyzer-mac` if you're on Mac OS, to `rust-analyzer` and make it executable in addition to moving it into a directory in your `$PATH`.
You can download pre-built binaries from the https://github.com/rust-analyzer/rust-analyzer/releases[releases] page.
You will need to uncompress and rename the binary for your platform, e.g. from `rust-analyzer-aarch64-apple-darwin.gz` on Mac OS to `rust-analyzer`, make it executable, then move it into a directory in your `$PATH`.

On Linux to install the `rust-analyzer` binary into `~/.local/bin`, this commands could be used
On Linux to install the `rust-analyzer` binary into `~/.local/bin`, these commands should work:

[source,bash]
----
$ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.local/bin/rust-analyzer
$ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer
$ chmod +x ~/.local/bin/rust-analyzer
----

Ensure `~/.local/bin` is listed in the `$PATH` variable.
Make sure that `~/.local/bin` is listed in the `$PATH` variable and use the appropriate URL if you're not on a `x86-64` system.

Alternatively, you can install it from source using the command below.
You'll need the latest stable version of the Rust toolchain.
Expand Down
Loading