diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-22 14:54:13 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-22 14:54:13 +0100 |
commit | d56e52402eedbd738b5161cd1e5a8c152cb65e21 (patch) | |
tree | c88222888e201b2173cd4a15673bd879cb88dd95 /crates | |
parent | 542337eca49986d785db2318bfe9c70809d4a229 (diff) | |
parent | 188b0f96f98feaa0771f941343887c46113c8ced (diff) |
Merge #8922
8922: Add more docs r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir/src/db.rs | 7 | ||||
-rw-r--r-- | crates/hir/src/diagnostics.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 2 | ||||
-rwxr-xr-x | crates/ide/src/folding_ranges.rs | 6 | ||||
-rw-r--r-- | crates/ide_assists/src/assist_context.rs | 2 | ||||
-rw-r--r-- | crates/ide_assists/src/path_transform.rs | 3 | ||||
-rw-r--r-- | crates/profile/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/profile/src/memory_usage.rs | 6 | ||||
-rw-r--r-- | crates/profile/src/stop_watch.rs | 4 | ||||
-rw-r--r-- | crates/project_model/src/cargo_workspace.rs | 7 | ||||
-rw-r--r-- | crates/project_model/src/lib.rs | 17 | ||||
-rw-r--r-- | crates/project_model/src/project_json.rs | 7 | ||||
-rw-r--r-- | crates/syntax/fuzz/fuzz_targets/parser.rs | 2 | ||||
-rw-r--r-- | crates/syntax/fuzz/fuzz_targets/reparse.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/algo.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/fuzz.rs | 4 | ||||
-rw-r--r-- | crates/syntax/src/parsing/text_tree_sink.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/ptr.rs | 11 | ||||
-rw-r--r-- | crates/tt/src/buffer.rs | 7 |
19 files changed, 71 insertions, 28 deletions
diff --git a/crates/hir/src/db.rs b/crates/hir/src/db.rs index ffc8155b9..19898f683 100644 --- a/crates/hir/src/db.rs +++ b/crates/hir/src/db.rs | |||
@@ -1,5 +1,8 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Re-exports various subcrates databases so that the calling code can depend |
2 | 2 | //! only on `hir`. This breaks abstraction boundary a bit, it would be cool if | |
3 | //! we didn't do that. | ||
4 | //! | ||
5 | //! But we need this for at least LRU caching at the query level. | ||
3 | pub use hir_def::db::*; | 6 | pub use hir_def::db::*; |
4 | pub use hir_expand::db::{ | 7 | pub use hir_expand::db::{ |
5 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, HygieneFrameQuery, InternMacroQuery, | 8 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, HygieneFrameQuery, InternMacroQuery, |
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index b1ebba516..414c3f35e 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -1,4 +1,8 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Re-export diagnostics such that clients of `hir` don't have to depend on |
2 | //! low-level crates. | ||
3 | //! | ||
4 | //! This probably isn't the best way to do this -- ideally, diagnistics should | ||
5 | //! be expressed in terms of hir types themselves. | ||
2 | pub use hir_def::diagnostics::{ | 6 | pub use hir_def::diagnostics::{ |
3 | InactiveCode, UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro, | 7 | InactiveCode, UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro, |
4 | }; | 8 | }; |
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 2079c22a3..b75ec411c 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! See [`NavigationTarget`]. |
2 | 2 | ||
3 | use std::fmt; | 3 | use std::fmt; |
4 | 4 | ||
diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs index a03988778..b893c1c54 100755 --- a/crates/ide/src/folding_ranges.rs +++ b/crates/ide/src/folding_ranges.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use rustc_hash::FxHashSet; | 1 | use rustc_hash::FxHashSet; |
4 | 2 | ||
5 | use syntax::{ | 3 | use syntax::{ |
@@ -29,6 +27,10 @@ pub struct Fold { | |||
29 | pub kind: FoldKind, | 27 | pub kind: FoldKind, |
30 | } | 28 | } |
31 | 29 | ||
30 | // Feature: Folding | ||
31 | // | ||
32 | // Defines folding regions for curly braced blocks, runs of consecutive import | ||
33 | // statements, and `region` / `endregion` comment markers. | ||
32 | pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> { | 34 | pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> { |
33 | let mut res = vec![]; | 35 | let mut res = vec![]; |
34 | let mut visited_comments = FxHashSet::default(); | 36 | let mut visited_comments = FxHashSet::default(); |
diff --git a/crates/ide_assists/src/assist_context.rs b/crates/ide_assists/src/assist_context.rs index 20754a02a..8fc40f9bd 100644 --- a/crates/ide_assists/src/assist_context.rs +++ b/crates/ide_assists/src/assist_context.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! See `AssistContext` | 1 | //! See [`AssistContext`]. |
2 | 2 | ||
3 | use std::mem; | 3 | use std::mem; |
4 | 4 | ||
diff --git a/crates/ide_assists/src/path_transform.rs b/crates/ide_assists/src/path_transform.rs index 6ec318c4c..48a7fa06a 100644 --- a/crates/ide_assists/src/path_transform.rs +++ b/crates/ide_assists/src/path_transform.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! See `PathTransform` | 1 | //! See [`PathTransform`]. |
2 | |||
2 | use hir::{HirDisplay, SemanticsScope}; | 3 | use hir::{HirDisplay, SemanticsScope}; |
3 | use ide_db::helpers::mod_path_to_ast; | 4 | use ide_db::helpers::mod_path_to_ast; |
4 | use rustc_hash::FxHashMap; | 5 | use rustc_hash::FxHashMap; |
diff --git a/crates/profile/src/lib.rs b/crates/profile/src/lib.rs index a31fb8f43..7cd01a7df 100644 --- a/crates/profile/src/lib.rs +++ b/crates/profile/src/lib.rs | |||
@@ -124,5 +124,5 @@ impl Drop for CpuSpan { | |||
124 | } | 124 | } |
125 | 125 | ||
126 | pub fn memory_usage() -> MemoryUsage { | 126 | pub fn memory_usage() -> MemoryUsage { |
127 | MemoryUsage::current() | 127 | MemoryUsage::now() |
128 | } | 128 | } |
diff --git a/crates/profile/src/memory_usage.rs b/crates/profile/src/memory_usage.rs index cb4e54447..2917ded60 100644 --- a/crates/profile/src/memory_usage.rs +++ b/crates/profile/src/memory_usage.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Like [`std::time::Instant`], but for memory. |
2 | //! | ||
3 | //! Measures the total size of all currently allocated objects. | ||
2 | use std::fmt; | 4 | use std::fmt; |
3 | 5 | ||
4 | use cfg_if::cfg_if; | 6 | use cfg_if::cfg_if; |
@@ -22,7 +24,7 @@ impl std::ops::Sub for MemoryUsage { | |||
22 | } | 24 | } |
23 | 25 | ||
24 | impl MemoryUsage { | 26 | impl MemoryUsage { |
25 | pub fn current() -> MemoryUsage { | 27 | pub fn now() -> MemoryUsage { |
26 | cfg_if! { | 28 | cfg_if! { |
27 | if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { | 29 | if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { |
28 | jemalloc_ctl::epoch::advance().unwrap(); | 30 | jemalloc_ctl::epoch::advance().unwrap(); |
diff --git a/crates/profile/src/stop_watch.rs b/crates/profile/src/stop_watch.rs index cb6915d45..112d03a9c 100644 --- a/crates/profile/src/stop_watch.rs +++ b/crates/profile/src/stop_watch.rs | |||
@@ -44,7 +44,7 @@ impl StopWatch { | |||
44 | } | 44 | } |
45 | pub fn memory(mut self, yes: bool) -> StopWatch { | 45 | pub fn memory(mut self, yes: bool) -> StopWatch { |
46 | if yes { | 46 | if yes { |
47 | self.memory = Some(MemoryUsage::current()); | 47 | self.memory = Some(MemoryUsage::now()); |
48 | } | 48 | } |
49 | self | 49 | self |
50 | } | 50 | } |
@@ -58,7 +58,7 @@ impl StopWatch { | |||
58 | #[cfg(not(target_os = "linux"))] | 58 | #[cfg(not(target_os = "linux"))] |
59 | let instructions = None; | 59 | let instructions = None; |
60 | 60 | ||
61 | let memory = self.memory.map(|it| MemoryUsage::current() - it); | 61 | let memory = self.memory.map(|it| MemoryUsage::now() - it); |
62 | StopWatchSpan { time, instructions, memory } | 62 | StopWatchSpan { time, instructions, memory } |
63 | } | 63 | } |
64 | } | 64 | } |
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index 4a4996cf4..ad705c752 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! See [`CargoWorkspace`]. |
2 | 2 | ||
3 | use std::path::PathBuf; | 3 | use std::path::PathBuf; |
4 | use std::{convert::TryInto, ops, process::Command, sync::Arc}; | 4 | use std::{convert::TryInto, ops, process::Command, sync::Arc}; |
@@ -12,10 +12,9 @@ use rustc_hash::FxHashMap; | |||
12 | use serde::Deserialize; | 12 | use serde::Deserialize; |
13 | use serde_json::from_value; | 13 | use serde_json::from_value; |
14 | 14 | ||
15 | use crate::build_data::BuildDataConfig; | 15 | use crate::{build_data::BuildDataConfig, utf8_stdout}; |
16 | use crate::utf8_stdout; | ||
17 | 16 | ||
18 | /// `CargoWorkspace` represents the logical structure of, well, a Cargo | 17 | /// [`CargoWorkspace`] represents the logical structure of, well, a Cargo |
19 | /// workspace. It pretty closely mirrors `cargo metadata` output. | 18 | /// workspace. It pretty closely mirrors `cargo metadata` output. |
20 | /// | 19 | /// |
21 | /// Note that internally, rust analyzer uses a different structure: | 20 | /// Note that internally, rust analyzer uses a different structure: |
diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index a5b35ed95..8c6cf94c2 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs | |||
@@ -1,4 +1,19 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! In rust-analyzer, we maintain a strict separation between pure abstract |
2 | //! semantic project model and a concrete model of a particular build system. | ||
3 | //! | ||
4 | //! Pure model is represented by the [`base_db::CrateGraph`] from another crate. | ||
5 | //! | ||
6 | //! In this crate, we are conserned with "real world" project models. | ||
7 | //! | ||
8 | //! Specifically, here we have a representation for a Cargo project | ||
9 | //! ([`CargoWorkspace`]) and for manually specified layout ([`ProjectJson`]). | ||
10 | //! | ||
11 | //! Roughly, the things we do here are: | ||
12 | //! | ||
13 | //! * Project discovery (where's the relevant Cargo.toml for the current dir). | ||
14 | //! * Custom build steps (`build.rs` code generation and compilation of | ||
15 | //! procedural macros). | ||
16 | //! * Lowering of concrete model to a [`base_db::CrateGraph`] | ||
2 | 17 | ||
3 | mod cargo_workspace; | 18 | mod cargo_workspace; |
4 | mod cfg_flag; | 19 | mod cfg_flag; |
diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index 41a2ac03e..e8f1aca61 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs | |||
@@ -1,4 +1,9 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! `rust-project.json` file format. |
2 | //! | ||
3 | //! This format is spiritually a serialization of [`base_db::CrateGraph`]. The | ||
4 | //! idea here is that people who do not use Cargo, can instead teach their build | ||
5 | //! system to generate `rust-project.json` which can be ingested by | ||
6 | //! rust-analyzer. | ||
2 | 7 | ||
3 | use std::path::PathBuf; | 8 | use std::path::PathBuf; |
4 | 9 | ||
diff --git a/crates/syntax/fuzz/fuzz_targets/parser.rs b/crates/syntax/fuzz/fuzz_targets/parser.rs index 386768343..f80e13002 100644 --- a/crates/syntax/fuzz/fuzz_targets/parser.rs +++ b/crates/syntax/fuzz/fuzz_targets/parser.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Fuzzing for from-scratch parsing. |
2 | 2 | ||
3 | #![no_main] | 3 | #![no_main] |
4 | use libfuzzer_sys::fuzz_target; | 4 | use libfuzzer_sys::fuzz_target; |
diff --git a/crates/syntax/fuzz/fuzz_targets/reparse.rs b/crates/syntax/fuzz/fuzz_targets/reparse.rs index 5ac99fdaf..f865ce8d6 100644 --- a/crates/syntax/fuzz/fuzz_targets/reparse.rs +++ b/crates/syntax/fuzz/fuzz_targets/reparse.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Fuzzing for incremental parsing. |
2 | 2 | ||
3 | #![no_main] | 3 | #![no_main] |
4 | use libfuzzer_sys::fuzz_target; | 4 | use libfuzzer_sys::fuzz_target; |
diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 241713c48..8d7a77b50 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Collection of assorted algorithms for syntax trees. |
2 | 2 | ||
3 | use std::{hash::BuildHasherDefault, ops::RangeInclusive}; | 3 | use std::{hash::BuildHasherDefault, ops::RangeInclusive}; |
4 | 4 | ||
diff --git a/crates/syntax/src/fuzz.rs b/crates/syntax/src/fuzz.rs index aa84239d2..256999fe0 100644 --- a/crates/syntax/src/fuzz.rs +++ b/crates/syntax/src/fuzz.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Some infrastructure for fuzzy testing. |
2 | //! | ||
3 | //! We don't normally run fuzzying, so this is hopelessly bitrotten :( | ||
2 | 4 | ||
3 | use std::{ | 5 | use std::{ |
4 | convert::TryInto, | 6 | convert::TryInto, |
diff --git a/crates/syntax/src/parsing/text_tree_sink.rs b/crates/syntax/src/parsing/text_tree_sink.rs index d63ec080b..25bfd41a1 100644 --- a/crates/syntax/src/parsing/text_tree_sink.rs +++ b/crates/syntax/src/parsing/text_tree_sink.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! See [`TextTreeSink`]. |
2 | 2 | ||
3 | use std::mem; | 3 | use std::mem; |
4 | 4 | ||
diff --git a/crates/syntax/src/ptr.rs b/crates/syntax/src/ptr.rs index d3fb7a5d9..195d2251b 100644 --- a/crates/syntax/src/ptr.rs +++ b/crates/syntax/src/ptr.rs | |||
@@ -1,4 +1,13 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! In rust-analyzer, syntax trees are transient objects. |
2 | //! | ||
3 | //! That means that we create trees when we need them, and tear them down to | ||
4 | //! save memory. In this architecture, hanging on to a particular syntax node | ||
5 | //! for a long time is ill-advisable, as that keeps the whole tree resident. | ||
6 | //! | ||
7 | //! Instead, we provide a [`SyntaxNodePtr`] type, which stores information about | ||
8 | //! *location* of a particular syntax node in a tree. Its a small type which can | ||
9 | //! be cheaply stored, and which can be resolved to a real [`SyntaxNode`] when | ||
10 | //! necessary. | ||
2 | 11 | ||
3 | use std::{ | 12 | use std::{ |
4 | hash::{Hash, Hasher}, | 13 | hash::{Hash, Hasher}, |
diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs index 3606c887d..e0021039a 100644 --- a/crates/tt/src/buffer.rs +++ b/crates/tt/src/buffer.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Stateful iteration over token trees. |
2 | 2 | //! | |
3 | //! We use this as the source of tokens for parser. | ||
3 | use crate::{Leaf, Subtree, TokenTree}; | 4 | use crate::{Leaf, Subtree, TokenTree}; |
4 | 5 | ||
5 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] | 6 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] |
@@ -104,7 +105,7 @@ impl<'t> TokenBuffer<'t> { | |||
104 | 105 | ||
105 | /// Creates a cursor referencing the first token in the buffer and able to | 106 | /// Creates a cursor referencing the first token in the buffer and able to |
106 | /// traverse until the end of the buffer. | 107 | /// traverse until the end of the buffer. |
107 | pub fn begin(&self) -> Cursor { | 108 | pub fn begin(&self) -> Cursor<'_> { |
108 | Cursor::create(self, EntryPtr(EntryId(0), 0)) | 109 | Cursor::create(self, EntryPtr(EntryId(0), 0)) |
109 | } | 110 | } |
110 | 111 | ||