diff options
-rw-r--r-- | crates/ide/src/diagnostics/unlinked_file.rs | 2 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/generate_impl.rs | 17 | ||||
-rw-r--r-- | crates/ide_assists/src/utils.rs | 9 | ||||
-rw-r--r-- | crates/ide_db/src/call_info/tests.rs | 3 | ||||
-rw-r--r-- | crates/ide_db/src/helpers/insert_use.rs | 3 | ||||
-rw-r--r-- | crates/ide_db/src/label.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/search.rs | 3 | ||||
-rw-r--r-- | crates/ide_db/src/source_change.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/traits.rs | 3 | ||||
-rw-r--r-- | crates/ide_db/src/traits/tests.rs | 3 | ||||
-rw-r--r-- | crates/ide_db/src/ty_filter.rs | 6 | ||||
-rw-r--r-- | docs/user/manual.adoc | 9 |
12 files changed, 46 insertions, 16 deletions
diff --git a/crates/ide/src/diagnostics/unlinked_file.rs b/crates/ide/src/diagnostics/unlinked_file.rs index 019b0b440..e174fb767 100644 --- a/crates/ide/src/diagnostics/unlinked_file.rs +++ b/crates/ide/src/diagnostics/unlinked_file.rs | |||
@@ -63,7 +63,7 @@ impl DiagnosticWithFix for UnlinkedFile { | |||
63 | // - `$dir.rs` in the parent folder, where `$dir` is the directory containing `self.file_id` | 63 | // - `$dir.rs` in the parent folder, where `$dir` is the directory containing `self.file_id` |
64 | let parent = our_path.parent()?; | 64 | let parent = our_path.parent()?; |
65 | let mut paths = | 65 | let mut paths = |
66 | vec![parent.join("mod.rs")?, parent.join("main.rs")?, parent.join("lib.rs")?]; | 66 | vec![parent.join("mod.rs")?, parent.join("lib.rs")?, parent.join("main.rs")?]; |
67 | 67 | ||
68 | // `submod/bla.rs` -> `submod.rs` | 68 | // `submod/bla.rs` -> `submod.rs` |
69 | if let Some(newmod) = (|| { | 69 | if let Some(newmod) = (|| { |
diff --git a/crates/ide_assists/src/handlers/generate_impl.rs b/crates/ide_assists/src/handlers/generate_impl.rs index a8e3c4fc2..fd2e250bc 100644 --- a/crates/ide_assists/src/handlers/generate_impl.rs +++ b/crates/ide_assists/src/handlers/generate_impl.rs | |||
@@ -72,6 +72,17 @@ mod tests { | |||
72 | check_assist( | 72 | check_assist( |
73 | generate_impl, | 73 | generate_impl, |
74 | r#" | 74 | r#" |
75 | struct MyOwnArray<T, const S: usize> {}$0"#, | ||
76 | r#" | ||
77 | struct MyOwnArray<T, const S: usize> {} | ||
78 | |||
79 | impl<T, const S: usize> MyOwnArray<T, S> { | ||
80 | $0 | ||
81 | }"#, | ||
82 | ); | ||
83 | check_assist( | ||
84 | generate_impl, | ||
85 | r#" | ||
75 | #[cfg(feature = "foo")] | 86 | #[cfg(feature = "foo")] |
76 | struct Foo<'a, T: Foo<'a>> {$0}"#, | 87 | struct Foo<'a, T: Foo<'a>> {$0}"#, |
77 | r#" | 88 | r#" |
@@ -114,11 +125,11 @@ mod tests { | |||
114 | check_assist( | 125 | check_assist( |
115 | generate_impl, | 126 | generate_impl, |
116 | r#" | 127 | r#" |
117 | struct Defaulted<'a, 'b: 'a, T: Debug + Clone + 'a + 'b = String> {}$0"#, | 128 | struct Defaulted<'a, 'b: 'a, T: Debug + Clone + 'a + 'b = String, const S: usize> {}$0"#, |
118 | r#" | 129 | r#" |
119 | struct Defaulted<'a, 'b: 'a, T: Debug + Clone + 'a + 'b = String> {} | 130 | struct Defaulted<'a, 'b: 'a, T: Debug + Clone + 'a + 'b = String, const S: usize> {} |
120 | 131 | ||
121 | impl<'a, 'b: 'a, T: Debug + Clone + 'a + 'b> Defaulted<'a, 'b, T> { | 132 | impl<'a, 'b: 'a, T: Debug + Clone + 'a + 'b, const S: usize> Defaulted<'a, 'b, T, S> { |
122 | $0 | 133 | $0 |
123 | }"#, | 134 | }"#, |
124 | ); | 135 | ); |
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs index 9de9e4dbd..5f630ec75 100644 --- a/crates/ide_assists/src/utils.rs +++ b/crates/ide_assists/src/utils.rs | |||
@@ -434,7 +434,8 @@ fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str | |||
434 | } | 434 | } |
435 | buf | 435 | buf |
436 | }); | 436 | }); |
437 | let generics = lifetimes.chain(type_params).format(", "); | 437 | let const_params = generic_params.const_params().map(|t| t.syntax().to_string()); |
438 | let generics = lifetimes.chain(type_params).chain(const_params).format(", "); | ||
438 | format_to!(buf, "<{}>", generics); | 439 | format_to!(buf, "<{}>", generics); |
439 | } | 440 | } |
440 | buf.push(' '); | 441 | buf.push(' '); |
@@ -452,7 +453,11 @@ fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str | |||
452 | .type_params() | 453 | .type_params() |
453 | .filter_map(|it| it.name()) | 454 | .filter_map(|it| it.name()) |
454 | .map(|it| SmolStr::from(it.text())); | 455 | .map(|it| SmolStr::from(it.text())); |
455 | format_to!(buf, "<{}>", lifetime_params.chain(type_params).format(", ")) | 456 | let const_params = generic_params |
457 | .const_params() | ||
458 | .filter_map(|it| it.name()) | ||
459 | .map(|it| SmolStr::from(it.text())); | ||
460 | format_to!(buf, "<{}>", lifetime_params.chain(type_params).chain(const_params).format(", ")) | ||
456 | } | 461 | } |
457 | 462 | ||
458 | match adt.where_clause() { | 463 | match adt.where_clause() { |
diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs index 75ab3eb6e..281a081a3 100644 --- a/crates/ide_db/src/call_info/tests.rs +++ b/crates/ide_db/src/call_info/tests.rs | |||
@@ -1,8 +1,9 @@ | |||
1 | use crate::RootDatabase; | ||
2 | use base_db::{fixture::ChangeFixture, FilePosition}; | 1 | use base_db::{fixture::ChangeFixture, FilePosition}; |
3 | use expect_test::{expect, Expect}; | 2 | use expect_test::{expect, Expect}; |
4 | use test_utils::RangeOrOffset; | 3 | use test_utils::RangeOrOffset; |
5 | 4 | ||
5 | use crate::RootDatabase; | ||
6 | |||
6 | /// Creates analysis from a multi-file fixture, returns positions marked with $0. | 7 | /// Creates analysis from a multi-file fixture, returns positions marked with $0. |
7 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { | 8 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { |
8 | let change_fixture = ChangeFixture::parse(ra_fixture); | 9 | let change_fixture = ChangeFixture::parse(ra_fixture); |
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index e681ced80..be3a22725 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | //! Handle syntactic aspects of inserting a new `use`. | 1 | //! Handle syntactic aspects of inserting a new `use`. |
2 | use std::{cmp::Ordering, iter::successors}; | 2 | use std::{cmp::Ordering, iter::successors}; |
3 | 3 | ||
4 | use crate::RootDatabase; | ||
5 | use hir::Semantics; | 4 | use hir::Semantics; |
6 | use itertools::{EitherOrBoth, Itertools}; | 5 | use itertools::{EitherOrBoth, Itertools}; |
7 | use syntax::{ | 6 | use syntax::{ |
@@ -14,6 +13,8 @@ use syntax::{ | |||
14 | AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken, | 13 | AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken, |
15 | }; | 14 | }; |
16 | 15 | ||
16 | use crate::RootDatabase; | ||
17 | |||
17 | pub use hir::PrefixKind; | 18 | pub use hir::PrefixKind; |
18 | 19 | ||
19 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | 20 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
diff --git a/crates/ide_db/src/label.rs b/crates/ide_db/src/label.rs index c0e89e72f..1f1e715c9 100644 --- a/crates/ide_db/src/label.rs +++ b/crates/ide_db/src/label.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! See `Label` | 1 | //! See [`Label`] |
2 | use std::fmt; | 2 | use std::fmt; |
3 | 3 | ||
4 | /// A type to specify UI label, like an entry in the list of assists. Enforces | 4 | /// A type to specify UI label, like an entry in the list of assists. Enforces |
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 3634b2b26..b55e3851e 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs | |||
@@ -12,9 +12,8 @@ use once_cell::unsync::Lazy; | |||
12 | use rustc_hash::FxHashMap; | 12 | use rustc_hash::FxHashMap; |
13 | use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; | 13 | use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; |
14 | 14 | ||
15 | use crate::defs::NameClass; | ||
16 | use crate::{ | 15 | use crate::{ |
17 | defs::{Definition, NameRefClass}, | 16 | defs::{Definition, NameClass, NameRefClass}, |
18 | RootDatabase, | 17 | RootDatabase, |
19 | }; | 18 | }; |
20 | 19 | ||
diff --git a/crates/ide_db/src/source_change.rs b/crates/ide_db/src/source_change.rs index b36455d49..846530f78 100644 --- a/crates/ide_db/src/source_change.rs +++ b/crates/ide_db/src/source_change.rs | |||
@@ -37,6 +37,8 @@ impl SourceChange { | |||
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | /// Inserts a [`TextEdit`] for the given [`FileId`]. This properly handles merging existing | ||
41 | /// edits for a file if some already exist. | ||
40 | pub fn insert_source_edit(&mut self, file_id: FileId, edit: TextEdit) { | 42 | pub fn insert_source_edit(&mut self, file_id: FileId, edit: TextEdit) { |
41 | match self.source_file_edits.entry(file_id) { | 43 | match self.source_file_edits.entry(file_id) { |
42 | Entry::Occupied(mut entry) => { | 44 | Entry::Occupied(mut entry) => { |
diff --git a/crates/ide_db/src/traits.rs b/crates/ide_db/src/traits.rs index 78a43f587..66ae81c73 100644 --- a/crates/ide_db/src/traits.rs +++ b/crates/ide_db/src/traits.rs | |||
@@ -61,7 +61,7 @@ pub fn get_missing_assoc_items( | |||
61 | resolve_target_trait(sema, impl_def).map_or(vec![], |target_trait| { | 61 | resolve_target_trait(sema, impl_def).map_or(vec![], |target_trait| { |
62 | target_trait | 62 | target_trait |
63 | .items(sema.db) | 63 | .items(sema.db) |
64 | .iter() | 64 | .into_iter() |
65 | .filter(|i| match i { | 65 | .filter(|i| match i { |
66 | hir::AssocItem::Function(f) => { | 66 | hir::AssocItem::Function(f) => { |
67 | !impl_fns_consts.contains(&f.name(sema.db).to_string()) | 67 | !impl_fns_consts.contains(&f.name(sema.db).to_string()) |
@@ -72,7 +72,6 @@ pub fn get_missing_assoc_items( | |||
72 | .map(|n| !impl_fns_consts.contains(&n.to_string())) | 72 | .map(|n| !impl_fns_consts.contains(&n.to_string())) |
73 | .unwrap_or_default(), | 73 | .unwrap_or_default(), |
74 | }) | 74 | }) |
75 | .cloned() | ||
76 | .collect() | 75 | .collect() |
77 | }) | 76 | }) |
78 | } | 77 | } |
diff --git a/crates/ide_db/src/traits/tests.rs b/crates/ide_db/src/traits/tests.rs index 84bb25505..2a5482024 100644 --- a/crates/ide_db/src/traits/tests.rs +++ b/crates/ide_db/src/traits/tests.rs | |||
@@ -1,10 +1,11 @@ | |||
1 | use crate::RootDatabase; | ||
2 | use base_db::{fixture::ChangeFixture, FilePosition}; | 1 | use base_db::{fixture::ChangeFixture, FilePosition}; |
3 | use expect_test::{expect, Expect}; | 2 | use expect_test::{expect, Expect}; |
4 | use hir::Semantics; | 3 | use hir::Semantics; |
5 | use syntax::ast::{self, AstNode}; | 4 | use syntax::ast::{self, AstNode}; |
6 | use test_utils::RangeOrOffset; | 5 | use test_utils::RangeOrOffset; |
7 | 6 | ||
7 | use crate::RootDatabase; | ||
8 | |||
8 | /// Creates analysis from a multi-file fixture, returns positions marked with $0. | 9 | /// Creates analysis from a multi-file fixture, returns positions marked with $0. |
9 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { | 10 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { |
10 | let change_fixture = ChangeFixture::parse(ra_fixture); | 11 | let change_fixture = ChangeFixture::parse(ra_fixture); |
diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs index f8406851b..988ecd060 100644 --- a/crates/ide_db/src/ty_filter.rs +++ b/crates/ide_db/src/ty_filter.rs | |||
@@ -2,11 +2,13 @@ | |||
2 | //! Use case for structures in this module is, for example, situation when you need to process | 2 | //! Use case for structures in this module is, for example, situation when you need to process |
3 | //! only certain `Enum`s. | 3 | //! only certain `Enum`s. |
4 | 4 | ||
5 | use crate::RootDatabase; | ||
6 | use hir::{Adt, Semantics, Type}; | ||
7 | use std::iter; | 5 | use std::iter; |
6 | |||
7 | use hir::{Adt, Semantics, Type}; | ||
8 | use syntax::ast::{self, make}; | 8 | use syntax::ast::{self, make}; |
9 | 9 | ||
10 | use crate::RootDatabase; | ||
11 | |||
10 | /// Enum types that implement `std::ops::Try` trait. | 12 | /// Enum types that implement `std::ops::Try` trait. |
11 | #[derive(Clone, Copy)] | 13 | #[derive(Clone, Copy)] |
12 | pub enum TryEnum { | 14 | pub enum TryEnum { |
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index 36a86e78f..b1beeb883 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc | |||
@@ -178,6 +178,15 @@ $ cargo xtask install --server | |||
178 | If your editor can't find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn't see the same `$PATH` as the shell, see https://github.com/rust-analyzer/rust-analyzer/issues/1811[this issue]. | 178 | If your editor can't find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn't see the same `$PATH` as the shell, see https://github.com/rust-analyzer/rust-analyzer/issues/1811[this issue]. |
179 | On Unix, running the editor from a shell or changing the `.desktop` file to set the environment should help. | 179 | On Unix, running the editor from a shell or changing the `.desktop` file to set the environment should help. |
180 | 180 | ||
181 | ==== `rustup` | ||
182 | |||
183 | `rust-analyzer` is available in `rustup`, but only in the nightly toolchain: | ||
184 | |||
185 | [source,bash] | ||
186 | --- | ||
187 | $ rustup +nightly component add rust-analyzer-preview | ||
188 | --- | ||
189 | |||
181 | ==== Arch Linux | 190 | ==== Arch Linux |
182 | 191 | ||
183 | The `rust-analyzer` binary can be installed from the repos or AUR (Arch User Repository): | 192 | The `rust-analyzer` binary can be installed from the repos or AUR (Arch User Repository): |