aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/dev/style.md38
-rw-r--r--docs/user/generated_config.adoc9
-rw-r--r--docs/user/manual.adoc1
3 files changed, 44 insertions, 4 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md
index d24a5952e..96dd684b3 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -636,6 +636,10 @@ use crate::{}
636 636
637// Finally, parent and child modules, but prefer `use crate::`. 637// Finally, parent and child modules, but prefer `use crate::`.
638use super::{} 638use super::{}
639
640// Re-exports are treated as item definitions rather than imports, so they go
641// after imports and modules. Use them sparingly.
642pub use crate::x::Z;
639``` 643```
640 644
641**Rationale:** consistency. 645**Rationale:** consistency.
@@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports.
694Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. 698Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`.
695**Rationale:** consistency, this is the style which works in all cases. 699**Rationale:** consistency, this is the style which works in all cases.
696 700
701By default, avoid re-exports.
702**Rationale:** for non-library code, re-exports introduce two ways to use something and allow for inconsistency.
703
697## Order of Items 704## Order of Items
698 705
699Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. 706Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.
@@ -784,13 +791,14 @@ Many names in rust-analyzer conflict with keywords.
784We use mangled names instead of `r#ident` syntax: 791We use mangled names instead of `r#ident` syntax:
785 792
786``` 793```
787struct -> strukt
788crate -> krate 794crate -> krate
789impl -> imp
790trait -> trait_
791fn -> func
792enum -> enum_ 795enum -> enum_
796fn -> func
797impl -> imp
793mod -> module 798mod -> module
799struct -> strukt
800trait -> trait_
801type -> ty
794``` 802```
795 803
796**Rationale:** consistency. 804**Rationale:** consistency.
@@ -944,6 +952,28 @@ match p.current() {
944 952
945## Documentation 953## Documentation
946 954
955Style inline code comments as proper sentences.
956Start with a capital letter, end with a dot.
957
958```rust
959// GOOD
960
961// Only simple single segment paths are allowed.
962MergeBehavior::Last => {
963 tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1)
964}
965
966// BAD
967
968// only simple single segment paths are allowed
969MergeBehavior::Last => {
970 tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1)
971}
972```
973
974**Rationale:** writing a sentence (or maybe even a paragraph) rather just "a comment" creates a more appropriate frame of mind.
975It tricks you into writing down more of the context you keep in your head while coding.
976
947For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. 977For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.
948If the line is too long, you want to split the sentence in two :-) 978If the line is too long, you want to split the sentence in two :-)
949 979
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index f70558200..feba43ff1 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -179,6 +179,15 @@ Controls file watching implementation.
179-- 179--
180These directories will be ignored by rust-analyzer. 180These directories will be ignored by rust-analyzer.
181-- 181--
182[[rust-analyzer.highlighting.strings]]rust-analyzer.highlighting.strings (default: `true`)::
183+
184--
185Use semantic tokens for strings.
186
187In some editors (e.g. vscode) semantic tokens override other highlighting grammars.
188By disabling semantic tokens for strings, other grammars can be used to highlight
189their contents.
190--
182[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`):: 191[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`)::
183+ 192+
184-- 193--
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc
index 797af3f75..f96c09a79 100644
--- a/docs/user/manual.adoc
+++ b/docs/user/manual.adoc
@@ -589,6 +589,7 @@ Here is a **non-exhaustive** list of ways to make rust-analyzer execute arbitrar
589 589
590* proc macros and build scripts are executed by default 590* proc macros and build scripts are executed by default
591* `.cargo/config` can override `rustc` with an arbitrary executable 591* `.cargo/config` can override `rustc` with an arbitrary executable
592* `rust-toolchain.toml` can override `rustc` with an arbitrary executable
592* 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. 593* 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.
593* rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety. 594* rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety.
594 595