aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yaml18
-rw-r--r--Cargo.lock20
-rw-r--r--crates/expect/src/lib.rs2
-rw-r--r--crates/flycheck/src/lib.rs10
-rw-r--r--crates/ra_assists/src/ast_transform.rs2
-rw-r--r--crates/ra_assists/src/handlers/add_custom_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/apply_demorgan.rs2
-rw-r--r--crates/ra_assists/src/handlers/generate_impl.rs5
-rw-r--r--crates/ra_assists/src/handlers/generate_new.rs9
-rw-r--r--crates/ra_assists/src/lib.rs25
-rw-r--r--crates/ra_assists/src/tests.rs2
-rw-r--r--crates/ra_hir/src/source_analyzer.rs7
-rw-r--r--crates/ra_hir_expand/src/hygiene.rs2
-rw-r--r--crates/ra_hir_expand/src/lib.rs3
-rw-r--r--crates/ra_ide/src/completion/complete_snippet.rs8
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs10
-rw-r--r--crates/ra_ide/src/completion/presentation.rs31
-rw-r--r--crates/ra_ide/src/syntax_highlighting/injection.rs5
-rw-r--r--crates/ra_mbe/src/mbe_expander/matcher.rs2
-rw-r--r--crates/ra_parser/src/grammar.rs2
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs3
-rw-r--r--crates/ra_parser/src/grammar/items.rs112
-rw-r--r--crates/ra_parser/src/grammar/items/traits.rs4
-rw-r--r--crates/ra_parser/src/parser.rs16
-rw-r--r--crates/ra_proc_macro/src/process.rs2
-rw-r--r--crates/ra_prof/src/memory_usage.rs2
-rw-r--r--crates/ra_syntax/src/ast/traits.rs5
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_default_const.rast40
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_default_const.rs3
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast (renamed from crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast)0
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs (renamed from crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs)0
-rw-r--r--crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast (renamed from crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast)0
-rw-r--r--crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs (renamed from crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs)0
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast58
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast13
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast21
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast17
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast13
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast15
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast35
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast55
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast22
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast11
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast40
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast44
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs (renamed from crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs)2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast24
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast56
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0066_default_const.rast44
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0066_default_const.rs3
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast218
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs16
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast218
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs16
-rw-r--r--crates/ra_text_edit/src/lib.rs13
-rw-r--r--crates/ra_tt/src/lib.rs2
-rw-r--r--crates/rust-analyzer/src/global_state.rs2
-rw-r--r--crates/rust-analyzer/src/handlers.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs15
-rw-r--r--crates/rust-analyzer/src/to_proto.rs8
-rw-r--r--crates/stdx/src/lib.rs65
-rw-r--r--docs/dev/README.md6
-rw-r--r--docs/dev/syntax.md2
-rw-r--r--editors/code/src/client.ts10
-rw-r--r--xtask/tests/tidy.rs15
95 files changed, 781 insertions, 839 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 2acd44012..f977c88be 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -88,11 +88,14 @@ jobs:
88 if: matrix.os == 'windows-latest' 88 if: matrix.os == 'windows-latest'
89 run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe 89 run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe
90 90
91 # Weird target to catch non-portable code 91 # Weird targets to catch non-portable code
92 rust-power: 92 rust-cross:
93 name: Rust Power 93 name: Rust Cross
94 runs-on: ubuntu-latest 94 runs-on: ubuntu-latest
95 95
96 env:
97 targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
98
96 steps: 99 steps:
97 - name: Checkout repository 100 - name: Checkout repository
98 uses: actions/checkout@v2 101 uses: actions/checkout@v2
@@ -103,7 +106,9 @@ jobs:
103 toolchain: stable 106 toolchain: stable
104 profile: minimal 107 profile: minimal
105 override: true 108 override: true
106 target: 'powerpc-unknown-linux-gnu' 109
110 - name: Install Rust targets
111 run: rustup target add ${{ env.targets }}
107 112
108 - name: Cache cargo directories 113 - name: Cache cargo directories
109 uses: actions/cache@v2 114 uses: actions/cache@v2
@@ -114,7 +119,10 @@ jobs:
114 key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} 119 key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
115 120
116 - name: Check 121 - name: Check
117 run: cargo check --target=powerpc-unknown-linux-gnu --all-targets 122 run: |
123 for target in ${{ env.targets }}; do
124 cargo check --target=$target --all-targets
125 done
118 126
119 typescript: 127 typescript:
120 name: TypeScript 128 name: TypeScript
diff --git a/Cargo.lock b/Cargo.lock
index dc49fc4bd..265889162 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -418,9 +418,9 @@ dependencies = [
418 418
419[[package]] 419[[package]]
420name = "hashbrown" 420name = "hashbrown"
421version = "0.8.1" 421version = "0.8.2"
422source = "registry+https://github.com/rust-lang/crates.io-index" 422source = "registry+https://github.com/rust-lang/crates.io-index"
423checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" 423checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
424dependencies = [ 424dependencies = [
425 "autocfg", 425 "autocfg",
426] 426]
@@ -465,9 +465,9 @@ dependencies = [
465 465
466[[package]] 466[[package]]
467name = "indexmap" 467name = "indexmap"
468version = "1.5.0" 468version = "1.5.1"
469source = "registry+https://github.com/rust-lang/crates.io-index" 469source = "registry+https://github.com/rust-lang/crates.io-index"
470checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" 470checksum = "86b45e59b16c76b11bf9738fd5d38879d3bd28ad292d7b313608becb17ae2df9"
471dependencies = [ 471dependencies = [
472 "autocfg", 472 "autocfg",
473 "hashbrown", 473 "hashbrown",
@@ -852,9 +852,9 @@ dependencies = [
852 852
853[[package]] 853[[package]]
854name = "perf-event-open-sys" 854name = "perf-event-open-sys"
855version = "0.3.1" 855version = "0.3.2"
856source = "registry+https://github.com/rust-lang/crates.io-index" 856source = "registry+https://github.com/rust-lang/crates.io-index"
857checksum = "95db63e37862bc1b842135d2234ef9418f222cc660c6752f45e7cf9ddfb97f96" 857checksum = "83e7183862f36d10263d0a1ccaef50fef734ade948bf026afd1bd97355c78273"
858dependencies = [ 858dependencies = [
859 "libc", 859 "libc",
860] 860]
@@ -871,9 +871,9 @@ dependencies = [
871 871
872[[package]] 872[[package]]
873name = "pico-args" 873name = "pico-args"
874version = "0.3.3" 874version = "0.3.4"
875source = "registry+https://github.com/rust-lang/crates.io-index" 875source = "registry+https://github.com/rust-lang/crates.io-index"
876checksum = "1b1eee8b1f4966c8343d7ca0f5a8452cd35d5610a2e0efbe2a68cae44bef2046" 876checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1"
877 877
878[[package]] 878[[package]]
879name = "plain" 879name = "plain"
@@ -1694,9 +1694,9 @@ dependencies = [
1694 1694
1695[[package]] 1695[[package]]
1696name = "tracing-tree" 1696name = "tracing-tree"
1697version = "0.1.4" 1697version = "0.1.5"
1698source = "registry+https://github.com/rust-lang/crates.io-index" 1698source = "registry+https://github.com/rust-lang/crates.io-index"
1699checksum = "37ee7f0f53ed2093971a698db799ef56a2dfd89b32e3aeb5165f0e637a02be04" 1699checksum = "e1a3dc4774db3a6b2d66a4f8d8de670e874ec3ed55615860c994927419b32c5f"
1700dependencies = [ 1700dependencies = [
1701 "ansi_term", 1701 "ansi_term",
1702 "atty", 1702 "atty",
diff --git a/crates/expect/src/lib.rs b/crates/expect/src/lib.rs
index 21a458d47..bd83895f7 100644
--- a/crates/expect/src/lib.rs
+++ b/crates/expect/src/lib.rs
@@ -74,7 +74,7 @@ impl fmt::Display for Position {
74impl Expect { 74impl Expect {
75 pub fn assert_eq(&self, actual: &str) { 75 pub fn assert_eq(&self, actual: &str) {
76 let trimmed = self.trimmed(); 76 let trimmed = self.trimmed();
77 if &trimmed == actual { 77 if trimmed == actual {
78 return; 78 return;
79 } 79 }
80 Runtime::fail_expect(self, &trimmed, actual); 80 Runtime::fail_expect(self, &trimmed, actual);
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index 7c38f5ef9..31e14246d 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -1,4 +1,4 @@
1//! cargo_check provides the functionality needed to run `cargo check` or 1//! Flycheck provides the functionality needed to run `cargo check` or
2//! another compatible command (f.x. clippy) in a background thread and provide 2//! another compatible command (f.x. clippy) in a background thread and provide
3//! LSP diagnostics based on the output of the command. 3//! LSP diagnostics based on the output of the command.
4 4
@@ -147,6 +147,12 @@ impl FlycheckActor {
147 // avoid busy-waiting. 147 // avoid busy-waiting.
148 let cargo_handle = self.cargo_handle.take().unwrap(); 148 let cargo_handle = self.cargo_handle.take().unwrap();
149 let res = cargo_handle.join(); 149 let res = cargo_handle.join();
150 if res.is_err() {
151 log::error!(
152 "Flycheck failed to run the following command: {:?}",
153 self.check_command()
154 )
155 }
150 self.send(Message::Progress(Progress::DidFinish(res))); 156 self.send(Message::Progress(Progress::DidFinish(res)));
151 } 157 }
152 Event::CheckEvent(Some(message)) => match message { 158 Event::CheckEvent(Some(message)) => match message {
@@ -253,7 +259,7 @@ impl CargoHandle {
253 return Err(io::Error::new( 259 return Err(io::Error::new(
254 io::ErrorKind::Other, 260 io::ErrorKind::Other,
255 format!( 261 format!(
256 "Cargo watcher failed,the command produced no valid metadata (exit code: {:?})", 262 "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})",
257 exit_status 263 exit_status
258 ), 264 ),
259 )); 265 ));
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index 15ec75c95..07c978378 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -51,7 +51,7 @@ impl<'a> SubstituteTypeParams<'a> {
51 // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky 51 // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky
52 .skip(1) 52 .skip(1)
53 // The actual list of trait type parameters may be longer than the one 53 // The actual list of trait type parameters may be longer than the one
54 // used in the `impl` block due to trailing default type parametrs. 54 // used in the `impl` block due to trailing default type parameters.
55 // For that case we extend the `substs` with an empty iterator so we 55 // For that case we extend the `substs` with an empty iterator so we
56 // can still hit those trailing values and check if they actually have 56 // can still hit those trailing values and check if they actually have
57 // a default type. If they do, go for that type from `hir` to `ast` so 57 // a default type. If they do, go for that type from `hir` to `ast` so
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs
index b67438b6b..ebdf00e67 100644
--- a/crates/ra_assists/src/handlers/add_custom_impl.rs
+++ b/crates/ra_assists/src/handlers/add_custom_impl.rs
@@ -1,10 +1,10 @@
1use itertools::Itertools;
1use ra_syntax::{ 2use ra_syntax::{
2 ast::{self, AstNode}, 3 ast::{self, AstNode},
3 Direction, SmolStr, 4 Direction, SmolStr,
4 SyntaxKind::{IDENT, WHITESPACE}, 5 SyntaxKind::{IDENT, WHITESPACE},
5 TextRange, TextSize, 6 TextRange, TextSize,
6}; 7};
7use stdx::SepBy;
8 8
9use crate::{ 9use crate::{
10 assist_context::{AssistContext, Assists}, 10 assist_context::{AssistContext, Assists},
@@ -61,9 +61,9 @@ pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<
61 .filter(|t| t != trait_token.text()) 61 .filter(|t| t != trait_token.text())
62 .collect::<Vec<SmolStr>>(); 62 .collect::<Vec<SmolStr>>();
63 let has_more_derives = !new_attr_input.is_empty(); 63 let has_more_derives = !new_attr_input.is_empty();
64 let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string();
65 64
66 if has_more_derives { 65 if has_more_derives {
66 let new_attr_input = format!("({})", new_attr_input.iter().format(", "));
67 builder.replace(input.syntax().text_range(), new_attr_input); 67 builder.replace(input.syntax().text_range(), new_attr_input);
68 } else { 68 } else {
69 let attr_range = attr.syntax().text_range(); 69 let attr_range = attr.syntax().text_range();
diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/ra_assists/src/handlers/apply_demorgan.rs
index de701f8b8..3ac4aed7d 100644
--- a/crates/ra_assists/src/handlers/apply_demorgan.rs
+++ b/crates/ra_assists/src/handlers/apply_demorgan.rs
@@ -4,7 +4,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin
4 4
5// Assist: apply_demorgan 5// Assist: apply_demorgan
6// 6//
7// Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). 7// Apply https://en.wikipedia.org/wiki/De_Morgan%27s_laws[De Morgan's law].
8// This transforms expressions of the form `!l || !r` into `!(l && r)`. 8// This transforms expressions of the form `!l || !r` into `!(l && r)`.
9// This also works with `&&`. This assist can only be applied with the cursor 9// This also works with `&&`. This assist can only be applied with the cursor
10// on either `||` or `&&`, with both operands being a negation of some kind. 10// on either `||` or `&&`, with both operands being a negation of some kind.
diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs
index d9b87c9c0..7162dc184 100644
--- a/crates/ra_assists/src/handlers/generate_impl.rs
+++ b/crates/ra_assists/src/handlers/generate_impl.rs
@@ -1,5 +1,6 @@
1use itertools::Itertools;
1use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; 2use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
2use stdx::{format_to, SepBy}; 3use stdx::format_to;
3 4
4use crate::{AssistContext, AssistId, AssistKind, Assists}; 5use crate::{AssistContext, AssistId, AssistKind, Assists};
5 6
@@ -50,7 +51,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()
50 .filter_map(|it| it.name()) 51 .filter_map(|it| it.name())
51 .map(|it| it.text().clone()); 52 .map(|it| it.text().clone());
52 53
53 let generic_params = lifetime_params.chain(type_params).sep_by(", "); 54 let generic_params = lifetime_params.chain(type_params).format(", ");
54 format_to!(buf, "<{}>", generic_params) 55 format_to!(buf, "<{}>", generic_params)
55 } 56 }
56 match ctx.config.snippet_cap { 57 match ctx.config.snippet_cap {
diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs
index b84aa24b6..32dfed274 100644
--- a/crates/ra_assists/src/handlers/generate_new.rs
+++ b/crates/ra_assists/src/handlers/generate_new.rs
@@ -1,9 +1,10 @@
1use hir::Adt; 1use hir::Adt;
2use itertools::Itertools;
2use ra_syntax::{ 3use ra_syntax::{
3 ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner}, 4 ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner},
4 T, 5 T,
5}; 6};
6use stdx::{format_to, SepBy}; 7use stdx::format_to;
7 8
8use crate::{AssistContext, AssistId, AssistKind, Assists}; 9use crate::{AssistContext, AssistId, AssistKind, Assists};
9 10
@@ -52,8 +53,8 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
52 let params = field_list 53 let params = field_list
53 .fields() 54 .fields()
54 .filter_map(|f| Some(format!("{}: {}", f.name()?.syntax(), f.ty()?.syntax()))) 55 .filter_map(|f| Some(format!("{}: {}", f.name()?.syntax(), f.ty()?.syntax())))
55 .sep_by(", "); 56 .format(", ");
56 let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", "); 57 let fields = field_list.fields().filter_map(|f| f.name()).format(", ");
57 58
58 format_to!(buf, " {}fn new({}) -> Self {{ Self {{ {} }} }}", vis, params, fields); 59 format_to!(buf, " {}fn new({}) -> Self {{ Self {{ {} }} }}", vis, params, fields);
59 60
@@ -102,7 +103,7 @@ fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String {
102 .map(|it| it.text().clone()); 103 .map(|it| it.text().clone());
103 let type_params = 104 let type_params =
104 type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); 105 type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone());
105 format_to!(buf, "<{}>", lifetime_params.chain(type_params).sep_by(", ")) 106 format_to!(buf, "<{}>", lifetime_params.chain(type_params).format(", "))
106 } 107 }
107 108
108 format_to!(buf, " {{\n{}\n}}\n", code); 109 format_to!(buf, " {{\n{}\n}}\n", code);
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 507646cc8..890996a68 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -66,13 +66,13 @@ pub struct GroupLabel(pub String);
66 66
67#[derive(Debug, Clone)] 67#[derive(Debug, Clone)]
68pub struct Assist { 68pub struct Assist {
69 pub id: AssistId, 69 id: AssistId,
70 /// Short description of the assist, as shown in the UI. 70 /// Short description of the assist, as shown in the UI.
71 pub label: String, 71 label: String,
72 pub group: Option<GroupLabel>, 72 group: Option<GroupLabel>,
73 /// Target ranges are used to sort assists: the smaller the target range, 73 /// Target ranges are used to sort assists: the smaller the target range,
74 /// the more specific assist is, and so it should be sorted first. 74 /// the more specific assist is, and so it should be sorted first.
75 pub target: TextRange, 75 target: TextRange,
76} 76}
77 77
78#[derive(Debug, Clone)] 78#[derive(Debug, Clone)]
@@ -120,10 +120,25 @@ impl Assist {
120 group: Option<GroupLabel>, 120 group: Option<GroupLabel>,
121 target: TextRange, 121 target: TextRange,
122 ) -> Assist { 122 ) -> Assist {
123 // FIXME: make fields private, so that this invariant can't be broken
124 assert!(label.starts_with(|c: char| c.is_uppercase())); 123 assert!(label.starts_with(|c: char| c.is_uppercase()));
125 Assist { id, label, group, target } 124 Assist { id, label, group, target }
126 } 125 }
126
127 pub fn id(&self) -> AssistId {
128 self.id
129 }
130
131 pub fn label(&self) -> String {
132 self.label.clone()
133 }
134
135 pub fn group(&self) -> Option<GroupLabel> {
136 self.group.clone()
137 }
138
139 pub fn target(&self) -> TextRange {
140 self.target
141 }
127} 142}
128 143
129mod handlers { 144mod handlers {
diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs
index 18fcb9049..e73836422 100644
--- a/crates/ra_assists/src/tests.rs
+++ b/crates/ra_assists/src/tests.rs
@@ -20,7 +20,7 @@ pub(crate) fn check_assist(assist: Handler, ra_fixture_before: &str, ra_fixture_
20 20
21// FIXME: instead of having a separate function here, maybe use 21// FIXME: instead of having a separate function here, maybe use
22// `extract_ranges` and mark the target as `<target> </target>` in the 22// `extract_ranges` and mark the target as `<target> </target>` in the
23// fixuture? 23// fixture?
24pub(crate) fn check_assist_target(assist: Handler, ra_fixture: &str, target: &str) { 24pub(crate) fn check_assist_target(assist: Handler, ra_fixture: &str, target: &str) {
25 check(assist, ra_fixture, ExpectedResult::Target(target)); 25 check(assist, ra_fixture, ExpectedResult::Target(target));
26} 26}
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs
index d0cb62ef0..d3d62debf 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/ra_hir/src/source_analyzer.rs
@@ -265,8 +265,7 @@ impl SourceAnalyzer {
265 } 265 }
266 266
267 // This must be a normal source file rather than macro file. 267 // This must be a normal source file rather than macro file.
268 let hir_path = 268 let hir_path = Path::from_src(path.clone(), &Hygiene::new(db.upcast(), self.file_id))?;
269 crate::Path::from_src(path.clone(), &Hygiene::new(db.upcast(), self.file_id))?;
270 269
271 // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we 270 // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we
272 // trying to resolve foo::bar. 271 // trying to resolve foo::bar.
@@ -451,7 +450,7 @@ fn adjust(
451pub(crate) fn resolve_hir_path( 450pub(crate) fn resolve_hir_path(
452 db: &dyn HirDatabase, 451 db: &dyn HirDatabase,
453 resolver: &Resolver, 452 resolver: &Resolver,
454 path: &crate::Path, 453 path: &Path,
455) -> Option<PathResolution> { 454) -> Option<PathResolution> {
456 let types = 455 let types =
457 resolver.resolve_path_in_type_ns_fully(db.upcast(), path.mod_path()).map(|ty| match ty { 456 resolver.resolve_path_in_type_ns_fully(db.upcast(), path.mod_path()).map(|ty| match ty {
@@ -512,7 +511,7 @@ pub(crate) fn resolve_hir_path(
512pub(crate) fn resolve_hir_path_qualifier( 511pub(crate) fn resolve_hir_path_qualifier(
513 db: &dyn HirDatabase, 512 db: &dyn HirDatabase,
514 resolver: &Resolver, 513 resolver: &Resolver,
515 path: &crate::Path, 514 path: &Path,
516) -> Option<PathResolution> { 515) -> Option<PathResolution> {
517 let items = resolver 516 let items = resolver
518 .resolve_module_path_in_items(db.upcast(), path.mod_path()) 517 .resolve_module_path_in_items(db.upcast(), path.mod_path())
diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs
index 6b482a60c..aefe47bd3 100644
--- a/crates/ra_hir_expand/src/hygiene.rs
+++ b/crates/ra_hir_expand/src/hygiene.rs
@@ -17,7 +17,7 @@ pub struct Hygiene {
17 // This is what `$crate` expands to 17 // This is what `$crate` expands to
18 def_crate: Option<CrateId>, 18 def_crate: Option<CrateId>,
19 19
20 // Indiciate this is a local inner macro 20 // Indicate this is a local inner macro
21 local_inner: bool, 21 local_inner: bool,
22} 22}
23 23
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 2e8d63691..8bb735fc6 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -44,7 +44,8 @@ mod test_db;
44/// containing the call plus the offset of the macro call in the file. Note that 44/// containing the call plus the offset of the macro call in the file. Note that
45/// this is a recursive definition! However, the size_of of `HirFileId` is 45/// this is a recursive definition! However, the size_of of `HirFileId` is
46/// finite (because everything bottoms out at the real `FileId`) and small 46/// finite (because everything bottoms out at the real `FileId`) and small
47/// (`MacroCallId` uses the location interner). 47/// (`MacroCallId` uses the location interning. You can check details here:
48/// https://en.wikipedia.org/wiki/String_interning).
48#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 49#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
49pub struct HirFileId(HirFileIdRepr); 50pub struct HirFileId(HirFileIdRepr);
50 51
diff --git a/crates/ra_ide/src/completion/complete_snippet.rs b/crates/ra_ide/src/completion/complete_snippet.rs
index 28d8f7876..4368e4eec 100644
--- a/crates/ra_ide/src/completion/complete_snippet.rs
+++ b/crates/ra_ide/src/completion/complete_snippet.rs
@@ -36,7 +36,7 @@ pub(super) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionConte
36 snippet( 36 snippet(
37 ctx, 37 ctx,
38 cap, 38 cap,
39 "Test module", 39 "tmod (Test module)",
40 "\ 40 "\
41#[cfg(test)] 41#[cfg(test)]
42mod tests { 42mod tests {
@@ -54,7 +54,7 @@ mod tests {
54 snippet( 54 snippet(
55 ctx, 55 ctx,
56 cap, 56 cap,
57 "Test function", 57 "tfn (Test function)",
58 "\ 58 "\
59#[test] 59#[test]
60fn ${1:feature}() { 60fn ${1:feature}() {
@@ -106,10 +106,10 @@ mod tests {
106} 106}
107"#, 107"#,
108 expect![[r#" 108 expect![[r#"
109 sn Test function
110 sn Test module
111 sn macro_rules 109 sn macro_rules
112 sn pub(crate) 110 sn pub(crate)
111 sn tfn (Test function)
112 sn tmod (Test module)
113 "#]], 113 "#]],
114 ) 114 )
115 } 115 }
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 6b03b30bb..4aa761148 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -27,7 +27,7 @@ pub(crate) struct CompletionContext<'a> {
27 pub(super) scope: SemanticsScope<'a>, 27 pub(super) scope: SemanticsScope<'a>,
28 pub(super) db: &'a RootDatabase, 28 pub(super) db: &'a RootDatabase,
29 pub(super) config: &'a CompletionConfig, 29 pub(super) config: &'a CompletionConfig,
30 pub(super) offset: TextSize, 30 pub(super) position: FilePosition,
31 /// The token before the cursor, in the original file. 31 /// The token before the cursor, in the original file.
32 pub(super) original_token: SyntaxToken, 32 pub(super) original_token: SyntaxToken,
33 /// The token before the cursor, in the macro-expanded file. 33 /// The token before the cursor, in the macro-expanded file.
@@ -117,7 +117,7 @@ impl<'a> CompletionContext<'a> {
117 config, 117 config,
118 original_token, 118 original_token,
119 token, 119 token,
120 offset: position.offset, 120 position,
121 krate, 121 krate,
122 expected_type: None, 122 expected_type: None,
123 name_ref_syntax: None, 123 name_ref_syntax: None,
@@ -209,7 +209,7 @@ impl<'a> CompletionContext<'a> {
209 mark::hit!(completes_if_prefix_is_keyword); 209 mark::hit!(completes_if_prefix_is_keyword);
210 self.original_token.text_range() 210 self.original_token.text_range()
211 } else { 211 } else {
212 TextRange::empty(self.offset) 212 TextRange::empty(self.position.offset)
213 } 213 }
214 } 214 }
215 215
@@ -379,8 +379,8 @@ impl<'a> CompletionContext<'a> {
379 self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); 379 self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some();
380 self.has_type_args = segment.generic_arg_list().is_some(); 380 self.has_type_args = segment.generic_arg_list().is_some();
381 381
382 #[allow(deprecated)] 382 let hygiene = hir::Hygiene::new(self.db, self.position.file_id.into());
383 if let Some(path) = hir::Path::from_ast(path.clone()) { 383 if let Some(path) = hir::Path::from_src(path.clone(), &hygiene) {
384 if let Some(path_prefix) = path.qualifier() { 384 if let Some(path_prefix) = path.qualifier() {
385 self.path_prefix = Some(path_prefix); 385 self.path_prefix = Some(path_prefix);
386 return; 386 return;
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index 9a94ff476..59f1b1424 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -2,8 +2,8 @@
2//! It also handles scoring (sorting) completions. 2//! It also handles scoring (sorting) completions.
3 3
4use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; 4use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type};
5use itertools::Itertools;
5use ra_syntax::ast::NameOwner; 6use ra_syntax::ast::NameOwner;
6use stdx::SepBy;
7use test_utils::mark; 7use test_utils::mark;
8 8
9use crate::{ 9use crate::{
@@ -289,16 +289,16 @@ impl Completions {
289 .map(|field| (field.name(ctx.db), field.signature_ty(ctx.db))); 289 .map(|field| (field.name(ctx.db), field.signature_ty(ctx.db)));
290 let variant_kind = variant.kind(ctx.db); 290 let variant_kind = variant.kind(ctx.db);
291 let detail = match variant_kind { 291 let detail = match variant_kind {
292 StructKind::Tuple | StructKind::Unit => detail_types 292 StructKind::Tuple | StructKind::Unit => format!(
293 .map(|(_, t)| t.display(ctx.db).to_string()) 293 "({})",
294 .sep_by(", ") 294 detail_types.map(|(_, t)| t.display(ctx.db).to_string()).format(", ")
295 .surround_with("(", ")") 295 ),
296 .to_string(), 296 StructKind::Record => format!(
297 StructKind::Record => detail_types 297 "{{ {} }}",
298 .map(|(n, t)| format!("{}: {}", n, t.display(ctx.db).to_string())) 298 detail_types
299 .sep_by(", ") 299 .map(|(n, t)| format!("{}: {}", n, t.display(ctx.db).to_string()))
300 .surround_with("{ ", " }") 300 .format(", ")
301 .to_string(), 301 ),
302 }; 302 };
303 let mut res = CompletionItem::new( 303 let mut res = CompletionItem::new(
304 CompletionKind::Reference, 304 CompletionKind::Reference,
@@ -412,11 +412,10 @@ impl Builder {
412 self = self.trigger_call_info(); 412 self = self.trigger_call_info();
413 let snippet = match (ctx.config.add_call_argument_snippets, params) { 413 let snippet = match (ctx.config.add_call_argument_snippets, params) {
414 (true, Params::Named(params)) => { 414 (true, Params::Named(params)) => {
415 let function_params_snippet = params 415 let function_params_snippet =
416 .iter() 416 params.iter().enumerate().format_with(", ", |(index, param_name), f| {
417 .enumerate() 417 f(&format_args!("${{{}:{}}}", index + 1, param_name))
418 .map(|(index, param_name)| format!("${{{}:{}}}", index + 1, param_name)) 418 });
419 .sep_by(", ");
420 format!("{}({})$0", name, function_params_snippet) 419 format!("{}({})$0", name, function_params_snippet)
421 } 420 }
422 _ => { 421 _ => {
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs
index 8665b480f..6046643ef 100644
--- a/crates/ra_ide/src/syntax_highlighting/injection.rs
+++ b/crates/ra_ide/src/syntax_highlighting/injection.rs
@@ -4,8 +4,8 @@ use std::{collections::BTreeMap, convert::TryFrom};
4 4
5use ast::{HasQuotes, HasStringValue}; 5use ast::{HasQuotes, HasStringValue};
6use hir::Semantics; 6use hir::Semantics;
7use itertools::Itertools;
7use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; 8use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize};
8use stdx::SepBy;
9 9
10use crate::{ 10use crate::{
11 call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, 11 call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag,
@@ -129,8 +129,7 @@ pub(super) fn extract_doc_comments(
129 129
130 line[pos..].to_owned() 130 line[pos..].to_owned()
131 }) 131 })
132 .sep_by("\n") 132 .join("\n");
133 .to_string();
134 133
135 if doctest.is_empty() { 134 if doctest.is_empty() {
136 return None; 135 return None;
diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs
index f9e515b81..933a3a3b5 100644
--- a/crates/ra_mbe/src/mbe_expander/matcher.rs
+++ b/crates/ra_mbe/src/mbe_expander/matcher.rs
@@ -276,7 +276,7 @@ impl<'a> TtIter<'a> {
276 Ok(tt::Subtree { 276 Ok(tt::Subtree {
277 delimiter: None, 277 delimiter: None,
278 token_trees: vec![ 278 token_trees: vec![
279 tt::Leaf::Punct(punct.clone()).into(), 279 tt::Leaf::Punct(*punct).into(),
280 tt::Leaf::Ident(ident.clone()).into(), 280 tt::Leaf::Ident(ident.clone()).into(),
281 ], 281 ],
282 } 282 }
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index c2e1d701e..88468bc97 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -110,7 +110,7 @@ pub(crate) mod fragments {
110 } 110 }
111 111
112 pub(crate) fn item(p: &mut Parser) { 112 pub(crate) fn item(p: &mut Parser) {
113 items::item_or_macro(p, true, items::ItemFlavor::Mod) 113 items::item_or_macro(p, true)
114 } 114 }
115 115
116 pub(crate) fn macro_items(p: &mut Parser) { 116 pub(crate) fn macro_items(p: &mut Parser) {
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index e1c25a838..3291e3f14 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -73,7 +73,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
73 73
74 // test block_items 74 // test block_items
75 // fn a() { fn b() {} } 75 // fn a() { fn b() {} }
76 let m = match items::maybe_item(p, m, items::ItemFlavor::Mod) { 76 let m = match items::maybe_item(p, m) {
77 Ok(()) => return, 77 Ok(()) => return,
78 Err(m) => m, 78 Err(m) => m,
79 }; 79 };
@@ -509,7 +509,6 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
509// x.1i32; 509// x.1i32;
510// x.0x01; 510// x.0x01;
511// } 511// }
512#[allow(clippy::if_same_then_else)]
513fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { 512fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
514 assert!(p.at(T![.])); 513 assert!(p.at(T![.]));
515 let m = lhs.precede(p); 514 let m = lhs.precede(p);
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index cca524cea..d091b0fbb 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -22,24 +22,19 @@ use super::*;
22pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { 22pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
23 attributes::inner_attributes(p); 23 attributes::inner_attributes(p);
24 while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) { 24 while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) {
25 item_or_macro(p, stop_on_r_curly, ItemFlavor::Mod) 25 item_or_macro(p, stop_on_r_curly)
26 } 26 }
27} 27}
28 28
29pub(super) enum ItemFlavor {
30 Mod,
31 Trait,
32}
33
34pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ 29pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![
35 FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, 30 FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW,
36 CRATE_KW, USE_KW, MACRO_KW 31 CRATE_KW, USE_KW, MACRO_KW
37]; 32];
38 33
39pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { 34pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
40 let m = p.start(); 35 let m = p.start();
41 attributes::outer_attributes(p); 36 attributes::outer_attributes(p);
42 let m = match maybe_item(p, m, flavor) { 37 let m = match maybe_item(p, m) {
43 Ok(()) => { 38 Ok(()) => {
44 if p.at(T![;]) { 39 if p.at(T![;]) {
45 p.err_and_bump( 40 p.err_and_bump(
@@ -76,7 +71,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF
76 } 71 }
77} 72}
78 73
79pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Result<(), Marker> { 74pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
80 // test_err pub_expr 75 // test_err pub_expr
81 // fn foo() { pub 92; } 76 // fn foo() { pub 92; }
82 let has_visibility = opt_visibility(p); 77 let has_visibility = opt_visibility(p);
@@ -114,38 +109,31 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
114 has_mods = true; 109 has_mods = true;
115 } 110 }
116 111
117 if p.at(IDENT) 112 // test default_item
118 && p.at_contextual_kw("default") 113 // default impl T for Foo {}
119 && (match p.nth(1) { 114 if p.at(IDENT) && p.at_contextual_kw("default") {
120 T![impl] => true, 115 match p.nth(1) {
116 T![fn] | T![type] | T![const] | T![impl] => {
117 p.bump_remap(T![default]);
118 has_mods = true;
119 }
121 T![unsafe] => { 120 T![unsafe] => {
122 // test default_unsafe_impl 121 // test default_unsafe_item
123 // default unsafe impl Foo {} 122 // default unsafe impl T for Foo {
124
125 // test default_unsafe_fn
126 // impl T for Foo {
127 // default unsafe fn foo() {} 123 // default unsafe fn foo() {}
128 // } 124 // }
129 if p.nth(2) == T![impl] || p.nth(2) == T![fn] { 125 if matches!(p.nth(2), T![impl] | T![fn]) {
130 p.bump_remap(T![default]); 126 p.bump_remap(T![default]);
131 p.bump(T![unsafe]); 127 p.bump(T![unsafe]);
132 has_mods = true; 128 has_mods = true;
133 } 129 }
134 false
135 } 130 }
136 T![fn] | T![type] | T![const] => { 131 _ => (),
137 if let ItemFlavor::Mod = flavor { 132 }
138 true
139 } else {
140 false
141 }
142 }
143 _ => false,
144 })
145 {
146 p.bump_remap(T![default]);
147 has_mods = true;
148 } 133 }
134
135 // test existential_type
136 // existential type Foo: Fn() -> usize;
149 if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] { 137 if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] {
150 p.bump_remap(T![existential]); 138 p.bump_remap(T![existential]);
151 has_mods = true; 139 has_mods = true;
@@ -153,79 +141,31 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
153 141
154 // items 142 // items
155 match p.current() { 143 match p.current() {
156 // test async_fn 144 // test fn
157 // async fn foo() {} 145 // fn foo() {}
158
159 // test extern_fn
160 // extern fn foo() {}
161
162 // test const_fn
163 // const fn foo() {}
164
165 // test const_unsafe_fn
166 // const unsafe fn foo() {}
167
168 // test unsafe_extern_fn
169 // unsafe extern "C" fn foo() {}
170
171 // test unsafe_fn
172 // unsafe fn foo() {}
173
174 // test combined_fns
175 // async unsafe fn foo() {}
176 // const unsafe fn bar() {}
177
178 // test_err wrong_order_fns
179 // unsafe async fn foo() {}
180 // unsafe const fn bar() {}
181 T![fn] => { 146 T![fn] => {
182 fn_def(p); 147 fn_def(p);
183 m.complete(p, FN); 148 m.complete(p, FN);
184 } 149 }
185 150
186 // test unsafe_trait 151 // test trait
187 // unsafe trait T {} 152 // trait T {}
188
189 // test auto_trait
190 // auto trait T {}
191
192 // test unsafe_auto_trait
193 // unsafe auto trait T {}
194 T![trait] => { 153 T![trait] => {
195 traits::trait_def(p); 154 traits::trait_def(p);
196 m.complete(p, TRAIT); 155 m.complete(p, TRAIT);
197 } 156 }
198 157
199 // test unsafe_impl
200 // unsafe impl Foo {}
201
202 // test default_impl
203 // default impl Foo {}
204
205 // test_err default_fn_type
206 // trait T {
207 // default type T = Bar;
208 // default fn foo() {}
209 // }
210
211 // test default_fn_type
212 // impl T for Foo {
213 // default type T = Bar;
214 // default fn foo() {}
215 // }
216 T![const] => { 158 T![const] => {
217 consts::const_def(p, m); 159 consts::const_def(p, m);
218 } 160 }
219 161
220 // test unsafe_default_impl 162 // test impl
221 // unsafe default impl Foo {} 163 // impl T for S {}
222 T![impl] => { 164 T![impl] => {
223 traits::impl_def(p); 165 traits::impl_def(p);
224 m.complete(p, IMPL); 166 m.complete(p, IMPL);
225 } 167 }
226 168
227 // test existential_type
228 // existential type Foo: Fn() -> usize;
229 T![type] => { 169 T![type] => {
230 type_def(p, m); 170 type_def(p, m);
231 } 171 }
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs
index ef9c8ff5b..751ce65f2 100644
--- a/crates/ra_parser/src/grammar/items/traits.rs
+++ b/crates/ra_parser/src/grammar/items/traits.rs
@@ -47,7 +47,7 @@ pub(crate) fn trait_item_list(p: &mut Parser) {
47 error_block(p, "expected an item"); 47 error_block(p, "expected an item");
48 continue; 48 continue;
49 } 49 }
50 item_or_macro(p, true, ItemFlavor::Trait); 50 item_or_macro(p, true);
51 } 51 }
52 p.expect(T!['}']); 52 p.expect(T!['}']);
53 m.complete(p, ASSOC_ITEM_LIST); 53 m.complete(p, ASSOC_ITEM_LIST);
@@ -104,7 +104,7 @@ pub(crate) fn impl_item_list(p: &mut Parser) {
104 error_block(p, "expected an item"); 104 error_block(p, "expected an item");
105 continue; 105 continue;
106 } 106 }
107 item_or_macro(p, true, ItemFlavor::Mod); 107 item_or_macro(p, true);
108 } 108 }
109 p.expect(T!['}']); 109 p.expect(T!['}']);
110 m.complete(p, ASSOC_ITEM_LIST); 110 m.complete(p, ASSOC_ITEM_LIST);
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs
index d797f2cc9..d2487acc3 100644
--- a/crates/ra_parser/src/parser.rs
+++ b/crates/ra_parser/src/parser.rs
@@ -269,8 +269,8 @@ impl Marker {
269 pub(crate) fn complete(mut self, p: &mut Parser, kind: SyntaxKind) -> CompletedMarker { 269 pub(crate) fn complete(mut self, p: &mut Parser, kind: SyntaxKind) -> CompletedMarker {
270 self.bomb.defuse(); 270 self.bomb.defuse();
271 let idx = self.pos as usize; 271 let idx = self.pos as usize;
272 match p.events[idx] { 272 match &mut p.events[idx] {
273 Event::Start { kind: ref mut slot, .. } => { 273 Event::Start { kind: slot, .. } => {
274 *slot = kind; 274 *slot = kind;
275 } 275 }
276 _ => unreachable!(), 276 _ => unreachable!(),
@@ -320,8 +320,8 @@ impl CompletedMarker {
320 pub(crate) fn precede(self, p: &mut Parser) -> Marker { 320 pub(crate) fn precede(self, p: &mut Parser) -> Marker {
321 let new_pos = p.start(); 321 let new_pos = p.start();
322 let idx = self.start_pos as usize; 322 let idx = self.start_pos as usize;
323 match p.events[idx] { 323 match &mut p.events[idx] {
324 Event::Start { ref mut forward_parent, .. } => { 324 Event::Start { forward_parent, .. } => {
325 *forward_parent = Some(new_pos.pos - self.start_pos); 325 *forward_parent = Some(new_pos.pos - self.start_pos);
326 } 326 }
327 _ => unreachable!(), 327 _ => unreachable!(),
@@ -333,12 +333,12 @@ impl CompletedMarker {
333 pub(crate) fn undo_completion(self, p: &mut Parser) -> Marker { 333 pub(crate) fn undo_completion(self, p: &mut Parser) -> Marker {
334 let start_idx = self.start_pos as usize; 334 let start_idx = self.start_pos as usize;
335 let finish_idx = self.finish_pos as usize; 335 let finish_idx = self.finish_pos as usize;
336 match p.events[start_idx] { 336 match &mut p.events[start_idx] {
337 Event::Start { ref mut kind, forward_parent: None } => *kind = TOMBSTONE, 337 Event::Start { kind, forward_parent: None } => *kind = TOMBSTONE,
338 _ => unreachable!(), 338 _ => unreachable!(),
339 } 339 }
340 match p.events[finish_idx] { 340 match &mut p.events[finish_idx] {
341 ref mut slot @ Event::Finish => *slot = Event::tombstone(), 341 slot @ Event::Finish => *slot = Event::tombstone(),
342 _ => unreachable!(), 342 _ => unreachable!(),
343 } 343 }
344 Marker::new(self.start_pos) 344 Marker::new(self.start_pos)
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs
index 5bcdacb48..37dd3f496 100644
--- a/crates/ra_proc_macro/src/process.rs
+++ b/crates/ra_proc_macro/src/process.rs
@@ -90,7 +90,7 @@ impl ProcMacroProcessSrv {
90 } 90 }
91 Some(it) => it, 91 Some(it) => it,
92 }; 92 };
93 sender.send(Task { req: req.into(), result_tx }).unwrap(); 93 sender.send(Task { req, result_tx }).unwrap();
94 let res = result_rx 94 let res = result_rx
95 .recv() 95 .recv()
96 .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; 96 .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?;
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs
index c2ecbd33c..83390212a 100644
--- a/crates/ra_prof/src/memory_usage.rs
+++ b/crates/ra_prof/src/memory_usage.rs
@@ -24,7 +24,7 @@ impl std::ops::Sub for MemoryUsage {
24impl MemoryUsage { 24impl MemoryUsage {
25 pub fn current() -> MemoryUsage { 25 pub fn current() -> MemoryUsage {
26 cfg_if! { 26 cfg_if! {
27 if #[cfg(target_os = "linux")] { 27 if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
28 // Note: This is incredibly slow. 28 // Note: This is incredibly slow.
29 let alloc = unsafe { libc::mallinfo() }.uordblks as isize; 29 let alloc = unsafe { libc::mallinfo() }.uordblks as isize;
30 MemoryUsage { allocated: Bytes(alloc) } 30 MemoryUsage { allocated: Bytes(alloc) }
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 3a56b1674..0bdc22d95 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -1,7 +1,7 @@
1//! Various traits that are implemented by ast nodes. 1//! Various traits that are implemented by ast nodes.
2//! 2//!
3//! The implementations are usually trivial, and live in generated.rs 3//! The implementations are usually trivial, and live in generated.rs
4use stdx::SepBy; 4use itertools::Itertools;
5 5
6use crate::{ 6use crate::{
7 ast::{self, support, AstChildren, AstNode, AstToken}, 7 ast::{self, support, AstChildren, AstNode, AstToken},
@@ -119,8 +119,7 @@ impl CommentIter {
119 // of a line in markdown. 119 // of a line in markdown.
120 line[pos..end].to_owned() 120 line[pos..end].to_owned()
121 }) 121 })
122 .sep_by("\n") 122 .join("\n");
123 .to_string();
124 123
125 if has_comments { 124 if has_comments {
126 Some(docs) 125 Some(docs)
diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
deleted file mode 100644
index 51ad2a846..000000000
--- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
+++ /dev/null
@@ -1,40 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "trait"
4 [email protected] " "
5 [email protected]
6 [email protected] "T"
7 [email protected] " "
8 [email protected]
9 [email protected] "{"
10 [email protected] "\n "
11 [email protected]
12 [email protected]
13 [email protected]
14 [email protected]
15 [email protected] "default"
16 [email protected] " "
17 [email protected]
18 [email protected] "const"
19 [email protected] " "
20 [email protected]
21 [email protected] "f"
22 [email protected] ":"
23 [email protected] " "
24 [email protected]
25 [email protected]
26 [email protected]
27 [email protected]
28 [email protected] "u8"
29 [email protected] " "
30 [email protected] "="
31 [email protected] " "
32 [email protected]
33 [email protected] "0"
34 [email protected] ";"
35 [email protected] "\n"
36 [email protected] "}"
37 [email protected] "\n"
38error 19..19: expected BANG
39error 19..19: expected `{`, `[`, `(`
40error 19..19: expected SEMICOLON
diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rs b/crates/ra_syntax/test_data/parser/err/0043_default_const.rs
deleted file mode 100644
index 80f15474a..000000000
--- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rs
+++ /dev/null
@@ -1,3 +0,0 @@
1trait T {
2 default const f: u8 = 0;
3}
diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast b/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast
index df29017e7..df29017e7 100644
--- a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast
+++ b/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast
diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs b/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs
index 8fa324c1a..8fa324c1a 100644
--- a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs
+++ b/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast b/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast
index a6e6552a9..a6e6552a9 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
+++ b/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs b/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs
index 731e58013..731e58013 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs
+++ b/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
deleted file mode 100644
index acd72094b..000000000
--- a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
+++ /dev/null
@@ -1,58 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "trait"
4 [email protected] " "
5 [email protected]
6 [email protected] "T"
7 [email protected] " "
8 [email protected]
9 [email protected] "{"
10 [email protected] "\n "
11 [email protected]
12 [email protected]
13 [email protected]
14 [email protected]
15 [email protected] "default"
16 [email protected] " "
17 [email protected]
18 [email protected] "type"
19 [email protected] " "
20 [email protected]
21 [email protected] "T"
22 [email protected] " "
23 [email protected] "="
24 [email protected] " "
25 [email protected]
26 [email protected]
27 [email protected]
28 [email protected]
29 [email protected] "Bar"
30 [email protected] ";"
31 [email protected] "\n "
32 [email protected]
33 [email protected]
34 [email protected]
35 [email protected]
36 [email protected] "default"
37 [email protected] " "
38 [email protected]
39 [email protected] "fn"
40 [email protected] " "
41 [email protected]
42 [email protected] "foo"
43 [email protected]
44 [email protected] "("
45 [email protected] ")"
46 [email protected] " "
47 [email protected]
48 [email protected] "{"
49 [email protected] "}"
50 [email protected] "\n"
51 [email protected] "}"
52 [email protected] "\n"
53error 21..21: expected BANG
54error 21..21: expected `{`, `[`, `(`
55error 21..21: expected SEMICOLON
56error 47..47: expected BANG
57error 47..47: expected `{`, `[`, `(`
58error 47..47: expected SEMICOLON
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs
deleted file mode 100644
index 15ba8f4a8..000000000
--- a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs
+++ /dev/null
@@ -1,4 +0,0 @@
1trait T {
2 default type T = Bar;
3 default fn foo() {}
4}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
deleted file mode 100644
index 625ab4c2d..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
+++ /dev/null
@@ -1,13 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "unsafe"
4 [email protected] " "
5 [email protected] "trait"
6 [email protected] " "
7 [email protected]
8 [email protected] "T"
9 [email protected] " "
10 [email protected]
11 [email protected] "{"
12 [email protected] "}"
13 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs
deleted file mode 100644
index 04e021550..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs
+++ /dev/null
@@ -1 +0,0 @@
1unsafe trait T {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast
deleted file mode 100644
index 293b1d64c..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast
+++ /dev/null
@@ -1,21 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "unsafe"
4 [email protected] " "
5 [email protected]
6 [email protected] "extern"
7 [email protected] " "
8 [email protected] "\"C\""
9 [email protected] " "
10 [email protected] "fn"
11 [email protected] " "
12 [email protected]
13 [email protected] "foo"
14 [email protected]
15 [email protected] "("
16 [email protected] ")"
17 [email protected] " "
18 [email protected]
19 [email protected] "{"
20 [email protected] "}"
21 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs
deleted file mode 100644
index 1295c2cd2..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs
+++ /dev/null
@@ -1 +0,0 @@
1unsafe extern "C" fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast
deleted file mode 100644
index d6dfa83b7..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast
+++ /dev/null
@@ -1,18 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "unsafe"
4 [email protected] " "
5 [email protected] "default"
6 [email protected] " "
7 [email protected] "impl"
8 [email protected] " "
9 [email protected]
10 [email protected]
11 [email protected]
12 [email protected]
13 [email protected] "Foo"
14 [email protected] " "
15 [email protected]
16 [email protected] "{"
17 [email protected] "}"
18 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs
deleted file mode 100644
index 9cd6c57bd..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs
+++ /dev/null
@@ -1 +0,0 @@
1unsafe default impl Foo {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast
deleted file mode 100644
index 97548a5ee..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast
+++ /dev/null
@@ -1,16 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "const"
4 [email protected] " "
5 [email protected] "fn"
6 [email protected] " "
7 [email protected]
8 [email protected] "foo"
9 [email protected]
10 [email protected] "("
11 [email protected] ")"
12 [email protected] " "
13 [email protected]
14 [email protected] "{"
15 [email protected] "}"
16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs
deleted file mode 100644
index 8c84d9cd7..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs
+++ /dev/null
@@ -1 +0,0 @@
1const fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast
deleted file mode 100644
index 43c09affe..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast
+++ /dev/null
@@ -1,16 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "unsafe"
4 [email protected] " "
5 [email protected] "impl"
6 [email protected] " "
7 [email protected]
8 [email protected]
9 [email protected]
10 [email protected]
11 [email protected] "Foo"
12 [email protected] " "
13 [email protected]
14 [email protected] "{"
15 [email protected] "}"
16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs
deleted file mode 100644
index 41055f41d..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs
+++ /dev/null
@@ -1 +0,0 @@
1unsafe impl Foo {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast
deleted file mode 100644
index 405b6a259..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast
+++ /dev/null
@@ -1,17 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected] "extern"
5 [email protected] " "
6 [email protected] "fn"
7 [email protected] " "
8 [email protected]
9 [email protected] "foo"
10 [email protected]
11 [email protected] "("
12 [email protected] ")"
13 [email protected] " "
14 [email protected]
15 [email protected] "{"
16 [email protected] "}"
17 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs
deleted file mode 100644
index 394a049f0..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs
+++ /dev/null
@@ -1 +0,0 @@
1extern fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
deleted file mode 100644
index 0cac9ac43..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
+++ /dev/null
@@ -1,13 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "auto"
4 [email protected] " "
5 [email protected] "trait"
6 [email protected] " "
7 [email protected]
8 [email protected] "T"
9 [email protected] " "
10 [email protected]
11 [email protected] "{"
12 [email protected] "}"
13 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs
deleted file mode 100644
index 72adf6035..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs
+++ /dev/null
@@ -1 +0,0 @@
1auto trait T {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
deleted file mode 100644
index 0ef11c682..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
+++ /dev/null
@@ -1,15 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "unsafe"
4 [email protected] " "
5 [email protected] "auto"
6 [email protected] " "
7 [email protected] "trait"
8 [email protected] " "
9 [email protected]
10 [email protected] "T"
11 [email protected] " "
12 [email protected]
13 [email protected] "{"
14 [email protected] "}"
15 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs
deleted file mode 100644
index 03d29f324..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs
+++ /dev/null
@@ -1 +0,0 @@
1unsafe auto trait T {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast
deleted file mode 100644
index 0a1b21d6e..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast
+++ /dev/null
@@ -1,16 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "default"
4 [email protected] " "
5 [email protected] "impl"
6 [email protected] " "
7 [email protected]
8 [email protected]
9 [email protected]
10 [email protected]
11 [email protected] "Foo"
12 [email protected] " "
13 [email protected]
14 [email protected] "{"
15 [email protected] "}"
16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs
deleted file mode 100644
index ef6aa84a2..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs
+++ /dev/null
@@ -1 +0,0 @@
1default impl Foo {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast
deleted file mode 100644
index 32a77ba49..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast
+++ /dev/null
@@ -1,18 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "const"
4 [email protected] " "
5 [email protected] "unsafe"
6 [email protected] " "
7 [email protected] "fn"
8 [email protected] " "
9 [email protected]
10 [email protected] "foo"
11 [email protected]
12 [email protected] "("
13 [email protected] ")"
14 [email protected] " "
15 [email protected]
16 [email protected] "{"
17 [email protected] "}"
18 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs
deleted file mode 100644
index 31a1e435f..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs
+++ /dev/null
@@ -1 +0,0 @@
1const unsafe fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast
deleted file mode 100644
index 73c94e5d4..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast
+++ /dev/null
@@ -1,16 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "unsafe"
4 [email protected] " "
5 [email protected] "fn"
6 [email protected] " "
7 [email protected]
8 [email protected] "foo"
9 [email protected]
10 [email protected] "("
11 [email protected] ")"
12 [email protected] " "
13 [email protected]
14 [email protected] "{"
15 [email protected] "}"
16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs
deleted file mode 100644
index 33cfc4cd7..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs
+++ /dev/null
@@ -1 +0,0 @@
1unsafe fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast
deleted file mode 100644
index a7df188bd..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast
+++ /dev/null
@@ -1,16 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "async"
4 [email protected] " "
5 [email protected] "fn"
6 [email protected] " "
7 [email protected]
8 [email protected] "foo"
9 [email protected]
10 [email protected] "("
11 [email protected] ")"
12 [email protected] " "
13 [email protected]
14 [email protected] "{"
15 [email protected] "}"
16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs
deleted file mode 100644
index f4adcb62b..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs
+++ /dev/null
@@ -1 +0,0 @@
1async fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast
deleted file mode 100644
index 98a20f36d..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast
+++ /dev/null
@@ -1,35 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "async"
4 [email protected] " "
5 [email protected] "unsafe"
6 [email protected] " "
7 [email protected] "fn"
8 [email protected] " "
9 [email protected]
10 [email protected] "foo"
11 [email protected]
12 [email protected] "("
13 [email protected] ")"
14 [email protected] " "
15 [email protected]
16 [email protected] "{"
17 [email protected] "}"
18 [email protected] "\n"
19 [email protected]
20 [email protected] "const"
21 [email protected] " "
22 [email protected] "unsafe"
23 [email protected] " "
24 [email protected] "fn"
25 [email protected] " "
26 [email protected]
27 [email protected] "bar"
28 [email protected]
29 [email protected] "("
30 [email protected] ")"
31 [email protected] " "
32 [email protected]
33 [email protected] "{"
34 [email protected] "}"
35 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs
deleted file mode 100644
index 126287145..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs
+++ /dev/null
@@ -1,2 +0,0 @@
1async unsafe fn foo() {}
2const unsafe fn bar() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast
deleted file mode 100644
index b8d26a53a..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast
+++ /dev/null
@@ -1,55 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "impl"
4 [email protected] " "
5 [email protected]
6 [email protected]
7 [email protected]
8 [email protected]
9 [email protected] "T"
10 [email protected] " "
11 [email protected] "for"
12 [email protected] " "
13 [email protected]
14 [email protected]
15 [email protected]
16 [email protected]
17 [email protected] "Foo"
18 [email protected] " "
19 [email protected]
20 [email protected] "{"
21 [email protected] "\n "
22 [email protected]
23 [email protected] "default"
24 [email protected] " "
25 [email protected] "type"
26 [email protected] " "
27 [email protected]
28 [email protected] "T"
29 [email protected] " "
30 [email protected] "="
31 [email protected] " "
32 [email protected]
33 [email protected]
34 [email protected]
35 [email protected]
36 [email protected] "Bar"
37 [email protected] ";"
38 [email protected] "\n "
39 [email protected]
40 [email protected] "default"
41 [email protected] " "
42 [email protected] "fn"
43 [email protected] " "
44 [email protected]
45 [email protected] "foo"
46 [email protected]
47 [email protected] "("
48 [email protected] ")"
49 [email protected] " "
50 [email protected]
51 [email protected] "{"
52 [email protected] "}"
53 [email protected] "\n"
54 [email protected] "}"
55 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs
deleted file mode 100644
index 8f5d61113..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs
+++ /dev/null
@@ -1,4 +0,0 @@
1impl T for Foo {
2 default type T = Bar;
3 default fn foo() {}
4}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast
new file mode 100644
index 000000000..23c4269b3
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast
@@ -0,0 +1,14 @@
1[email protected]
2 [email protected]
3 [email protected] "fn"
4 [email protected] " "
5 [email protected]
6 [email protected] "foo"
7 [email protected]
8 [email protected] "("
9 [email protected] ")"
10 [email protected] " "
11 [email protected]
12 [email protected] "{"
13 [email protected] "}"
14 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs
new file mode 100644
index 000000000..8f3b7ef11
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs
@@ -0,0 +1 @@
fn foo() {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast
new file mode 100644
index 000000000..7968cf9ff
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast
@@ -0,0 +1,22 @@
1[email protected]
2 [email protected]
3 [email protected] "impl"
4 [email protected] " "
5 [email protected]
6 [email protected]
7 [email protected]
8 [email protected]
9 [email protected] "T"
10 [email protected] " "
11 [email protected] "for"
12 [email protected] " "
13 [email protected]
14 [email protected]
15 [email protected]
16 [email protected]
17 [email protected] "S"
18 [email protected] " "
19 [email protected]
20 [email protected] "{"
21 [email protected] "}"
22 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs
new file mode 100644
index 000000000..a1a550d8a
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs
@@ -0,0 +1 @@
impl T for S {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast
new file mode 100644
index 000000000..9881e5048
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast
@@ -0,0 +1,11 @@
1[email protected]
2 [email protected]
3 [email protected] "trait"
4 [email protected] " "
5 [email protected]
6 [email protected] "T"
7 [email protected] " "
8 [email protected]
9 [email protected] "{"
10 [email protected] "}"
11 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs
new file mode 100644
index 000000000..8d183dbb5
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs
@@ -0,0 +1 @@
trait T {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
deleted file mode 100644
index 1269621dc..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
+++ /dev/null
@@ -1,40 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "impl"
4 [email protected] " "
5 [email protected]
6 [email protected]
7 [email protected]
8 [email protected]
9 [email protected] "T"
10 [email protected] " "
11 [email protected] "for"
12 [email protected] " "
13 [email protected]
14 [email protected]
15 [email protected]
16 [email protected]
17 [email protected] "Foo"
18 [email protected] " "
19 [email protected]
20 [email protected] "{"
21 [email protected] "\n "
22 [email protected]
23 [email protected] "default"
24 [email protected] " "
25 [email protected] "unsafe"
26 [email protected] " "
27 [email protected] "fn"
28 [email protected] " "
29 [email protected]
30 [email protected] "foo"
31 [email protected]
32 [email protected] "("
33 [email protected] ")"
34 [email protected] " "
35 [email protected]
36 [email protected] "{"
37 [email protected] "}"
38 [email protected] "\n"
39 [email protected] "}"
40 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast
deleted file mode 100644
index 6bfe925af..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast
+++ /dev/null
@@ -1,18 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "default"
4 [email protected] " "
5 [email protected] "unsafe"
6 [email protected] " "
7 [email protected] "impl"
8 [email protected] " "
9 [email protected]
10 [email protected]
11 [email protected]
12 [email protected]
13 [email protected] "Foo"
14 [email protected] " "
15 [email protected]
16 [email protected] "{"
17 [email protected] "}"
18 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs
deleted file mode 100644
index ba0998ff4..000000000
--- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs
+++ /dev/null
@@ -1 +0,0 @@
1default unsafe impl Foo {}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast
new file mode 100644
index 000000000..f2e201460
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast
@@ -0,0 +1,44 @@
1[email protected]
2 [email protected]
3 [email protected] "default"
4 [email protected] " "
5 [email protected] "unsafe"
6 [email protected] " "
7 [email protected] "impl"
8 [email protected] " "
9 [email protected]
10 [email protected]
11 [email protected]
12 [email protected]
13 [email protected] "T"
14 [email protected] " "
15 [email protected] "for"
16 [email protected] " "
17 [email protected]
18 [email protected]
19 [email protected]
20 [email protected]
21 [email protected] "Foo"
22 [email protected] " "
23 [email protected]
24 [email protected] "{"
25 [email protected] "\n "
26 [email protected]
27 [email protected] "default"
28 [email protected] " "
29 [email protected] "unsafe"
30 [email protected] " "
31 [email protected] "fn"
32 [email protected] " "
33 [email protected]
34 [email protected] "foo"
35 [email protected]
36 [email protected] "("
37 [email protected] ")"
38 [email protected] " "
39 [email protected]
40 [email protected] "{"
41 [email protected] "}"
42 [email protected] "\n"
43 [email protected] "}"
44 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs
index 12926cd8a..96340f84a 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs
@@ -1,3 +1,3 @@
1impl T for Foo { 1default unsafe impl T for Foo {
2 default unsafe fn foo() {} 2 default unsafe fn foo() {}
3} 3}
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast
new file mode 100644
index 000000000..9282772f3
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast
@@ -0,0 +1,24 @@
1[email protected]
2 [email protected]
3 [email protected] "default"
4 [email protected] " "
5 [email protected] "impl"
6 [email protected] " "
7 [email protected]
8 [email protected]
9 [email protected]
10 [email protected]
11 [email protected] "T"
12 [email protected] " "
13 [email protected] "for"
14 [email protected] " "
15 [email protected]
16 [email protected]
17 [email protected]
18 [email protected]
19 [email protected] "Foo"
20 [email protected] " "
21 [email protected]
22 [email protected] "{"
23 [email protected] "}"
24 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs
new file mode 100644
index 000000000..a6836cbd5
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs
@@ -0,0 +1 @@
default impl T for Foo {}
diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast
deleted file mode 100644
index 5524efaaf..000000000
--- a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast
+++ /dev/null
@@ -1,56 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected] "extern"
5 [email protected] " "
6 [email protected] "fn"
7 [email protected] " "
8 [email protected]
9 [email protected] "foo"
10 [email protected]
11 [email protected] "("
12 [email protected] ")"
13 [email protected] " "
14 [email protected]
15 [email protected] "{"
16 [email protected] "\n"
17 [email protected] "}"
18 [email protected] "\n\n"
19 [email protected]
20 [email protected]
21 [email protected] "extern"
22 [email protected] " "
23 [email protected] "\"C\""
24 [email protected] " "
25 [email protected] "fn"
26 [email protected] " "
27 [email protected]
28 [email protected] "bar"
29 [email protected]
30 [email protected] "("
31 [email protected] ")"
32 [email protected] " "
33 [email protected]
34 [email protected] "{"
35 [email protected] "\n"
36 [email protected] "}"
37 [email protected] "\n\n"
38 [email protected]
39 [email protected]
40 [email protected] "extern"
41 [email protected] " "
42 [email protected] "r\"D\""
43 [email protected] " "
44 [email protected] "fn"
45 [email protected] " "
46 [email protected]
47 [email protected] "baz"
48 [email protected]
49 [email protected] "("
50 [email protected] ")"
51 [email protected] " "
52 [email protected]
53 [email protected] "{"
54 [email protected] "\n"
55 [email protected] "}"
56 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs
deleted file mode 100644
index e929eef74..000000000
--- a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs
+++ /dev/null
@@ -1,8 +0,0 @@
1extern fn foo() {
2}
3
4extern "C" fn bar() {
5}
6
7extern r"D" fn baz() {
8}
diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast
deleted file mode 100644
index 6246a31a6..000000000
--- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast
+++ /dev/null
@@ -1,44 +0,0 @@
1[email protected]
2 [email protected]
3 [email protected] "impl"
4 [email protected] " "
5 [email protected]
6 [email protected]
7 [email protected]
8 [email protected]
9 [email protected] "T"
10 [email protected] " "
11 [email protected] "for"
12 [email protected] " "
13 [email protected]
14 [email protected]
15 [email protected]
16 [email protected]
17 [email protected] "Foo"
18 [email protected] " "
19 [email protected]
20 [email protected] "{"
21 [email protected] "\n "
22 [email protected]
23 [email protected] "default"
24 [email protected] " "
25 [email protected] "const"
26 [email protected] " "
27 [email protected]
28 [email protected] "f"
29 [email protected] ":"
30 [email protected] " "
31 [email protected]
32 [email protected]
33 [email protected]
34 [email protected]
35 [email protected] "u8"
36 [email protected] " "
37 [email protected] "="
38 [email protected] " "
39 [email protected]
40 [email protected] "0"
41 [email protected] ";"
42 [email protected] "\n"
43 [email protected] "}"
44 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rs b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rs
deleted file mode 100644
index dfb3b92dc..000000000
--- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rs
+++ /dev/null
@@ -1,3 +0,0 @@
1impl T for Foo {
2 default const f: u8 = 0;
3}
diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast
new file mode 100644
index 000000000..e9b57ec3b
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast
@@ -0,0 +1,218 @@
1[email protected]
2 [email protected]
3 [email protected] "trait"
4 [email protected] " "
5 [email protected]
6 [email protected] "T"
7 [email protected] " "
8 [email protected]
9 [email protected] "{"
10 [email protected] "\n "
11 [email protected]
12 [email protected] "default"
13 [email protected] " "
14 [email protected] "type"
15 [email protected] " "
16 [email protected]
17 [email protected] "T"
18 [email protected] " "
19 [email protected] "="
20 [email protected] " "
21 [email protected]
22 [email protected]
23 [email protected]
24 [email protected]
25 [email protected] "Bar"
26 [email protected] ";"
27 [email protected] "\n "
28 [email protected]
29 [email protected] "default"
30 [email protected] " "
31 [email protected] "const"
32 [email protected] " "
33 [email protected]
34 [email protected] "f"
35 [email protected] ":"
36 [email protected] " "
37 [email protected]
38 [email protected]
39 [email protected]
40 [email protected]
41 [email protected] "u8"
42 [email protected] " "
43 [email protected] "="
44 [email protected] " "
45 [email protected]
46 [email protected] "0"
47 [email protected] ";"
48 [email protected] "\n "
49 [email protected]
50 [email protected] "default"
51 [email protected] " "
52 [email protected] "fn"
53 [email protected] " "
54 [email protected]
55 [email protected] "foo"
56 [email protected]
57 [email protected] "("
58 [email protected] ")"
59 [email protected] " "
60 [email protected]
61 [email protected] "{"
62 [email protected] "}"
63 [email protected] "\n "
64 [email protected]
65 [email protected] "default"
66 [email protected] " "
67 [email protected] "unsafe"
68 [email protected] " "
69 [email protected] "fn"
70 [email protected] " "
71 [email protected]
72 [email protected] "bar"
73 [email protected]
74 [email protected] "("
75 [email protected] ")"
76 [email protected] " "
77 [email protected]
78 [email protected] "{"
79 [email protected] "}"
80 [email protected] "\n"
81 [email protected] "}"
82 [email protected] "\n\n"
83 [email protected]
84 [email protected] "impl"
85 [email protected] " "
86 [email protected]
87 [email protected]
88 [email protected]
89 [email protected]
90 [email protected] "T"
91 [email protected] " "
92 [email protected] "for"
93 [email protected] " "
94 [email protected]
95 [email protected]
96 [email protected]
97 [email protected]
98 [email protected] "Foo"
99 [email protected] " "
100 [email protected]
101 [email protected] "{"
102 [email protected] "\n "
103 [email protected]
104 [email protected] "default"
105 [email protected] " "
106 [email protected] "type"
107 [email protected] " "
108 [email protected]
109 [email protected] "T"
110 [email protected] " "
111 [email protected] "="
112 [email protected] " "
113 [email protected]
114 [email protected]
115 [email protected]
116 [email protected]
117 [email protected] "Bar"
118 [email protected] ";"
119 [email protected] "\n "
120 [email protected]
121 [email protected] "default"
122 [email protected] " "
123 [email protected] "const"
124 [email protected] " "
125 [email protected]
126 [email protected] "f"
127 [email protected] ":"
128 [email protected] " "
129 [email protected]
130 [email protected]
131 [email protected]
132 [email protected]
133 [email protected] "u8"
134 [email protected] " "
135 [email protected] "="
136 [email protected] " "
137 [email protected]
138 [email protected] "0"
139 [email protected] ";"
140 [email protected] "\n "
141 [email protected]
142 [email protected] "default"
143 [email protected] " "
144 [email protected] "fn"
145 [email protected] " "
146 [email protected]
147 [email protected] "foo"
148 [email protected]
149 [email protected] "("
150 [email protected] ")"
151 [email protected] " "
152 [email protected]
153 [email protected] "{"
154 [email protected] "}"
155 [email protected] "\n "
156 [email protected]
157 [email protected] "default"
158 [email protected] " "
159 [email protected] "unsafe"
160 [email protected] " "
161 [email protected] "fn"
162 [email protected] " "
163 [email protected]
164 [email protected] "bar"
165 [email protected]
166 [email protected] "("
167 [email protected] ")"
168 [email protected] " "
169 [email protected]
170 [email protected] "{"
171 [email protected] "}"
172 [email protected] "\n"
173 [email protected] "}"
174 [email protected] "\n\n"
175 [email protected]
176 [email protected] "default"
177 [email protected] " "
178 [email protected] "impl"
179 [email protected] " "
180 [email protected]
181 [email protected]
182 [email protected]
183 [email protected]
184 [email protected] "T"
185 [email protected] " "
186 [email protected] "for"
187 [email protected] " "
188 [email protected]
189 [email protected] "("
190 [email protected] ")"
191 [email protected] " "
192 [email protected]
193 [email protected] "{"
194 [email protected] "}"
195 [email protected] "\n"
196 [email protected]
197 [email protected] "default"
198 [email protected] " "
199 [email protected] "unsafe"
200 [email protected] " "
201 [email protected] "impl"
202 [email protected] " "
203 [email protected]
204 [email protected]
205 [email protected]
206 [email protected]
207 [email protected] "T"
208 [email protected] " "
209 [email protected] "for"
210 [email protected] " "
211 [email protected]
212 [email protected] "("
213 [email protected] ")"
214 [email protected] " "
215 [email protected]
216 [email protected] "{"
217 [email protected] "}"
218 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs
new file mode 100644
index 000000000..e443e3495
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs
@@ -0,0 +1,16 @@
1trait T {
2 default type T = Bar;
3 default const f: u8 = 0;
4 default fn foo() {}
5 default unsafe fn bar() {}
6}
7
8impl T for Foo {
9 default type T = Bar;
10 default const f: u8 = 0;
11 default fn foo() {}
12 default unsafe fn bar() {}
13}
14
15default impl T for () {}
16default unsafe impl T for () {}
diff --git a/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast
new file mode 100644
index 000000000..50a6d8ee9
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast
@@ -0,0 +1,218 @@
1[email protected]
2 [email protected]
3 [email protected] "async"
4 [email protected] " "
5 [email protected] "fn"
6 [email protected] " "
7 [email protected]
8 [email protected] "foo"
9 [email protected]
10 [email protected] "("
11 [email protected] ")"
12 [email protected] " "
13 [email protected]
14 [email protected] "{"
15 [email protected] "}"
16 [email protected] "\n"
17 [email protected]
18 [email protected]
19 [email protected] "extern"
20 [email protected] " "
21 [email protected] "fn"
22 [email protected] " "
23 [email protected]
24 [email protected] "foo"
25 [email protected]
26 [email protected] "("
27 [email protected] ")"
28 [email protected] " "
29 [email protected]
30 [email protected] "{"
31 [email protected] "}"
32 [email protected] "\n"
33 [email protected]
34 [email protected] "const"
35 [email protected] " "
36 [email protected] "fn"
37 [email protected] " "
38 [email protected]
39 [email protected] "foo"
40 [email protected]
41 [email protected] "("
42 [email protected] ")"
43 [email protected] " "
44 [email protected]
45 [email protected] "{"
46 [email protected] "}"
47 [email protected] "\n"
48 [email protected]
49 [email protected] "const"
50 [email protected] " "
51 [email protected] "unsafe"
52 [email protected] " "
53 [email protected] "fn"
54 [email protected] " "
55 [email protected]
56 [email protected] "foo"
57 [email protected]
58 [email protected] "("
59 [email protected] ")"
60 [email protected] " "
61 [email protected]
62 [email protected] "{"
63 [email protected] "}"
64 [email protected] "\n"
65 [email protected]
66 [email protected] "unsafe"
67 [email protected] " "
68 [email protected]
69 [email protected] "extern"
70 [email protected] " "
71 [email protected] "\"C\""
72 [email protected] " "
73 [email protected] "fn"
74 [email protected] " "
75 [email protected]
76 [email protected] "foo"
77 [email protected]
78 [email protected] "("
79 [email protected] ")"
80 [email protected] " "
81 [email protected]
82 [email protected] "{"
83 [email protected] "}"
84 [email protected] "\n"
85 [email protected]
86 [email protected] "unsafe"
87 [email protected] " "
88 [email protected] "fn"
89 [email protected] " "
90 [email protected]
91 [email protected] "foo"
92 [email protected]
93 [email protected] "("
94 [email protected] ")"
95 [email protected] " "
96 [email protected]
97 [email protected] "{"
98 [email protected] "}"
99 [email protected] "\n"
100 [email protected]
101 [email protected] "async"
102 [email protected] " "
103 [email protected] "unsafe"
104 [email protected] " "
105 [email protected] "fn"
106 [email protected] " "
107 [email protected]
108 [email protected] "foo"
109 [email protected]
110 [email protected] "("
111 [email protected] ")"
112 [email protected] " "
113 [email protected]
114 [email protected] "{"
115 [email protected] "}"
116 [email protected] "\n"
117 [email protected]
118 [email protected] "const"
119 [email protected] " "
120 [email protected] "unsafe"
121 [email protected] " "
122 [email protected] "fn"
123 [email protected] " "
124 [email protected]
125 [email protected] "bar"
126 [email protected]
127 [email protected] "("
128 [email protected] ")"
129 [email protected] " "
130 [email protected]
131 [email protected] "{"
132 [email protected] "}"
133 [email protected] "\n\n"
134 [email protected]
135 [email protected] "unsafe"
136 [email protected] " "
137 [email protected] "trait"
138 [email protected] " "
139 [email protected]
140 [email protected] "T"
141 [email protected] " "
142 [email protected]
143 [email protected] "{"
144 [email protected] "}"
145 [email protected] "\n"
146 [email protected]
147 [email protected] "auto"
148 [email protected] " "
149 [email protected] "trait"
150 [email protected] " "
151 [email protected]
152 [email protected] "T"
153 [email protected] " "
154 [email protected]
155 [email protected] "{"
156 [email protected] "}"
157 [email protected] "\n"
158 [email protected]
159 [email protected] "unsafe"
160 [email protected] " "
161 [email protected] "auto"
162 [email protected] " "
163 [email protected] "trait"
164 [email protected] " "
165 [email protected]
166 [email protected] "T"
167 [email protected] " "
168 [email protected]
169 [email protected] "{"
170 [email protected] "}"
171 [email protected] "\n\n"
172 [email protected]
173 [email protected] "unsafe"
174 [email protected] " "
175 [email protected] "impl"
176 [email protected] " "
177 [email protected]
178 [email protected]
179 [email protected]
180 [email protected]
181 [email protected] "Foo"
182 [email protected] " "
183 [email protected]
184 [email protected] "{"
185 [email protected] "}"
186 [email protected] "\n"
187 [email protected]
188 [email protected] "default"
189 [email protected] " "
190 [email protected] "impl"
191 [email protected] " "
192 [email protected]
193 [email protected]
194 [email protected]
195 [email protected]
196 [email protected] "Foo"
197 [email protected] " "
198 [email protected]
199 [email protected] "{"
200 [email protected] "}"
201 [email protected] "\n"
202 [email protected]
203 [email protected] "unsafe"
204 [email protected] " "
205 [email protected] "default"
206 [email protected] " "
207 [email protected] "impl"
208 [email protected] " "
209 [email protected]
210 [email protected]
211 [email protected]
212 [email protected]
213 [email protected] "Foo"
214 [email protected] " "
215 [email protected]
216 [email protected] "{"
217 [email protected] "}"
218 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs
new file mode 100644
index 000000000..8d697c04b
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs
@@ -0,0 +1,16 @@
1async fn foo() {}
2extern fn foo() {}
3const fn foo() {}
4const unsafe fn foo() {}
5unsafe extern "C" fn foo() {}
6unsafe fn foo() {}
7async unsafe fn foo() {}
8const unsafe fn bar() {}
9
10unsafe trait T {}
11auto trait T {}
12unsafe auto trait T {}
13
14unsafe impl Foo {}
15default impl Foo {}
16unsafe default impl Foo {}
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs
index 25554f583..d68791cf1 100644
--- a/crates/ra_text_edit/src/lib.rs
+++ b/crates/ra_text_edit/src/lib.rs
@@ -76,10 +76,6 @@ impl TextEdit {
76 self.indels.iter() 76 self.indels.iter()
77 } 77 }
78 78
79 pub fn into_iter(self) -> vec::IntoIter<Indel> {
80 self.indels.into_iter()
81 }
82
83 pub fn apply(&self, text: &mut String) { 79 pub fn apply(&self, text: &mut String) {
84 match self.len() { 80 match self.len() {
85 0 => return, 81 0 => return,
@@ -141,6 +137,15 @@ impl TextEdit {
141 } 137 }
142} 138}
143 139
140impl IntoIterator for TextEdit {
141 type Item = Indel;
142 type IntoIter = vec::IntoIter<Self::Item>;
143
144 fn into_iter(self) -> Self::IntoIter {
145 self.indels.into_iter()
146 }
147}
148
144impl TextEditBuilder { 149impl TextEditBuilder {
145 pub fn replace(&mut self, range: TextRange, replace_with: String) { 150 pub fn replace(&mut self, range: TextRange, replace_with: String) {
146 self.indels.push(Indel::replace(range, replace_with)) 151 self.indels.push(Indel::replace(range, replace_with))
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs
index 8faf1cc67..20c3f5eab 100644
--- a/crates/ra_tt/src/lib.rs
+++ b/crates/ra_tt/src/lib.rs
@@ -107,7 +107,7 @@ fn print_debug_subtree(f: &mut fmt::Formatter<'_>, subtree: &Subtree, level: usi
107 for (idx, child) in subtree.token_trees.iter().enumerate() { 107 for (idx, child) in subtree.token_trees.iter().enumerate() {
108 print_debug_token(f, child, level + 1)?; 108 print_debug_token(f, child, level + 1)?;
109 if idx != subtree.token_trees.len() - 1 { 109 if idx != subtree.token_trees.len() - 1 {
110 writeln!(f, "")?; 110 writeln!(f)?;
111 } 111 }
112 } 112 }
113 } 113 }
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index 0e592ac1b..658a50d15 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -73,6 +73,7 @@ pub(crate) struct GlobalState {
73 pub(crate) mem_docs: FxHashMap<VfsPath, DocumentData>, 73 pub(crate) mem_docs: FxHashMap<VfsPath, DocumentData>,
74 pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>, 74 pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
75 pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, 75 pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
76 pub(crate) shutdown_requested: bool,
76 pub(crate) status: Status, 77 pub(crate) status: Status,
77 pub(crate) source_root_config: SourceRootConfig, 78 pub(crate) source_root_config: SourceRootConfig,
78 pub(crate) proc_macro_client: ProcMacroClient, 79 pub(crate) proc_macro_client: ProcMacroClient,
@@ -124,6 +125,7 @@ impl GlobalState {
124 mem_docs: FxHashMap::default(), 125 mem_docs: FxHashMap::default(),
125 semantic_tokens_cache: Arc::new(Default::default()), 126 semantic_tokens_cache: Arc::new(Default::default()),
126 vfs: Arc::new(RwLock::new((vfs::Vfs::default(), FxHashMap::default()))), 127 vfs: Arc::new(RwLock::new((vfs::Vfs::default(), FxHashMap::default()))),
128 shutdown_requested: false,
127 status: Status::default(), 129 status: Status::default(),
128 source_root_config: SourceRootConfig::default(), 130 source_root_config: SourceRootConfig::default(),
129 proc_macro_client: ProcMacroClient::dummy(), 131 proc_macro_client: ProcMacroClient::dummy(),
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 895af1dd7..c2afcf192 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -864,7 +864,7 @@ pub(crate) fn handle_resolve_code_action(
864 let (id_string, index) = split_once(&params.id, ':').unwrap(); 864 let (id_string, index) = split_once(&params.id, ':').unwrap();
865 let index = index.parse::<usize>().unwrap(); 865 let index = index.parse::<usize>().unwrap();
866 let assist = &assists[index]; 866 let assist = &assists[index];
867 assert!(assist.assist.id.0 == id_string); 867 assert!(assist.assist.id().0 == id_string);
868 Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit) 868 Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit)
869} 869}
870 870
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 0ac6434dd..e6cf46df2 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -337,6 +337,16 @@ impl GlobalState {
337 fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { 337 fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> {
338 self.register_request(&req, request_received); 338 self.register_request(&req, request_received);
339 339
340 if self.shutdown_requested {
341 self.respond(Response::new_err(
342 req.id,
343 lsp_server::ErrorCode::InvalidRequest as i32,
344 "Shutdown already requested.".to_owned(),
345 ));
346
347 return Ok(());
348 }
349
340 if self.status == Status::Loading && req.method != "shutdown" { 350 if self.status == Status::Loading && req.method != "shutdown" {
341 self.respond(lsp_server::Response::new_err( 351 self.respond(lsp_server::Response::new_err(
342 req.id, 352 req.id,
@@ -351,7 +361,10 @@ impl GlobalState {
351 .on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.fetch_workspaces()))? 361 .on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.fetch_workspaces()))?
352 .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))? 362 .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
353 .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))? 363 .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
354 .on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))? 364 .on_sync::<lsp_types::request::Shutdown>(|s, ()| {
365 s.shutdown_requested = true;
366 Ok(())
367 })?
355 .on_sync::<lsp_types::request::SelectionRangeRequest>(|s, p| { 368 .on_sync::<lsp_types::request::SelectionRangeRequest>(|s, p| {
356 handlers::handle_selection_range(s.snapshot(), p) 369 handlers::handle_selection_range(s.snapshot(), p)
357 })? 370 })?
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 27460db78..62fda8a1f 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -704,10 +704,10 @@ pub(crate) fn unresolved_code_action(
704 index: usize, 704 index: usize,
705) -> Result<lsp_ext::CodeAction> { 705) -> Result<lsp_ext::CodeAction> {
706 let res = lsp_ext::CodeAction { 706 let res = lsp_ext::CodeAction {
707 title: assist.label, 707 title: assist.label(),
708 id: Some(format!("{}:{}", assist.id.0.to_owned(), index.to_string())), 708 id: Some(format!("{}:{}", assist.id().0.to_owned(), index.to_string())),
709 group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), 709 group: assist.group().filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0),
710 kind: Some(code_action_kind(assist.id.1)), 710 kind: Some(code_action_kind(assist.id().1)),
711 edit: None, 711 edit: None,
712 is_preferred: None, 712 is_preferred: None,
713 }; 713 };
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index b65875c96..3c5027fe5 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -1,5 +1,5 @@
1//! Missing batteries for standard libraries. 1//! Missing batteries for standard libraries.
2use std::{cell::Cell, fmt, time::Instant}; 2use std::time::Instant;
3 3
4mod macros; 4mod macros;
5 5
@@ -8,69 +8,6 @@ pub fn is_ci() -> bool {
8 option_env!("CI").is_some() 8 option_env!("CI").is_some()
9} 9}
10 10
11pub trait SepBy: Sized {
12 /// Returns an `impl fmt::Display`, which joins elements via a separator.
13 fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self>;
14}
15
16impl<I> SepBy for I
17where
18 I: Iterator,
19 I::Item: fmt::Display,
20{
21 fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self> {
22 SepByBuilder::new(sep, self)
23 }
24}
25
26pub struct SepByBuilder<'a, I> {
27 sep: &'a str,
28 prefix: &'a str,
29 suffix: &'a str,
30 iter: Cell<Option<I>>,
31}
32
33impl<'a, I> SepByBuilder<'a, I> {
34 fn new(sep: &'a str, iter: I) -> SepByBuilder<'a, I> {
35 SepByBuilder { sep, prefix: "", suffix: "", iter: Cell::new(Some(iter)) }
36 }
37
38 pub fn prefix(mut self, prefix: &'a str) -> Self {
39 self.prefix = prefix;
40 self
41 }
42
43 pub fn suffix(mut self, suffix: &'a str) -> Self {
44 self.suffix = suffix;
45 self
46 }
47
48 /// Set both suffix and prefix.
49 pub fn surround_with(self, prefix: &'a str, suffix: &'a str) -> Self {
50 self.prefix(prefix).suffix(suffix)
51 }
52}
53
54impl<I> fmt::Display for SepByBuilder<'_, I>
55where
56 I: Iterator,
57 I::Item: fmt::Display,
58{
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60 f.write_str(self.prefix)?;
61 let mut first = true;
62 for item in self.iter.take().unwrap() {
63 if !first {
64 f.write_str(self.sep)?;
65 }
66 first = false;
67 fmt::Display::fmt(&item, f)?;
68 }
69 f.write_str(self.suffix)?;
70 Ok(())
71 }
72}
73
74#[must_use] 11#[must_use]
75pub fn timeit(label: &'static str) -> impl Drop { 12pub fn timeit(label: &'static str) -> impl Drop {
76 struct Guard { 13 struct Guard {
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 67813a9c0..51cf716b3 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -256,9 +256,9 @@ Release steps:
256 * checkout the `release` branch 256 * checkout the `release` branch
257 * reset it to `upstream/nightly` 257 * reset it to `upstream/nightly`
258 * push it to `upstream`. This triggers GitHub Actions which: 258 * push it to `upstream`. This triggers GitHub Actions which:
259 ** runs `cargo xtask dist` to package binaries and VS Code extension 259 * runs `cargo xtask dist` to package binaries and VS Code extension
260 ** makes a GitHub release 260 * makes a GitHub release
261 ** pushes VS Code extension to the marketplace 261 * pushes VS Code extension to the marketplace
262 * create new changelog in `rust-analyzer.github.io` 262 * create new changelog in `rust-analyzer.github.io`
263 * create `rust-analyzer.github.io/git.log` file with the log of merge commits since last release 263 * create `rust-analyzer.github.io/git.log` file with the log of merge commits since last release
2642. While the release is in progress, fill-in the changelog using `git.log` 2642. While the release is in progress, fill-in the changelog using `git.log`
diff --git a/docs/dev/syntax.md b/docs/dev/syntax.md
index d4bc4b07c..f1bcdc4af 100644
--- a/docs/dev/syntax.md
+++ b/docs/dev/syntax.md
@@ -74,7 +74,7 @@ Points of note:
74* The original text can be recovered by concatenating the texts of all tokens in order. 74* The original text can be recovered by concatenating the texts of all tokens in order.
75* Accessing a child of particular type (for example, parameter list of a function) generally involves linerary traversing the children, looking for a specific `kind`. 75* Accessing a child of particular type (for example, parameter list of a function) generally involves linerary traversing the children, looking for a specific `kind`.
76* Modifying the tree is roughly `O(depth)`. 76* Modifying the tree is roughly `O(depth)`.
77 We don't make special efforts to guarantree that the depth is not liner, but, in practice, syntax trees are branchy and shallow. 77 We don't make special efforts to guarantee that the depth is not linear, but, in practice, syntax trees are branchy and shallow.
78* If mandatory (grammar wise) node is missing from the input, it's just missing from the tree. 78* If mandatory (grammar wise) node is missing from the input, it's just missing from the tree.
79* If an extra erroneous input is present, it is wrapped into a node with `ERROR` kind, and treated just like any other node. 79* If an extra erroneous input is present, it is wrapped into a node with `ERROR` kind, and treated just like any other node.
80* Parser errors are not a part of syntax tree. 80* Parser errors are not a part of syntax tree.
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 18948cb3c..f5db55b8c 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -4,7 +4,7 @@ import * as ra from '../src/lsp_ext';
4import * as Is from 'vscode-languageclient/lib/utils/is'; 4import * as Is from 'vscode-languageclient/lib/utils/is';
5 5
6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; 6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
7import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; 7import { SemanticTokensFeature } from 'vscode-languageclient/lib/semanticTokens.proposed';
8import { assert } from './util'; 8import { assert } from './util';
9 9
10function renderCommand(cmd: ra.CommandLink) { 10function renderCommand(cmd: ra.CommandLink) {
@@ -44,12 +44,6 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient
44 diagnosticCollectionName: "rustc", 44 diagnosticCollectionName: "rustc",
45 traceOutputChannel, 45 traceOutputChannel,
46 middleware: { 46 middleware: {
47 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576
48 async provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature) {
49 const res = await next(document, token);
50 if (res === undefined) throw new Error('busy');
51 return res;
52 },
53 async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { 47 async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) {
54 return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( 48 return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then(
55 (result) => { 49 (result) => {
@@ -135,7 +129,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient
135 ); 129 );
136 } 130 }
137 131
138 } as any 132 }
139 }; 133 };
140 134
141 const client = new lc.LanguageClient( 135 const client = new lc.LanguageClient(
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index d65a2acbc..4ff72865e 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -44,11 +44,26 @@ fn rust_files_are_tidy() {
44 let text = fs2::read_to_string(&path).unwrap(); 44 let text = fs2::read_to_string(&path).unwrap();
45 check_todo(&path, &text); 45 check_todo(&path, &text);
46 check_trailing_ws(&path, &text); 46 check_trailing_ws(&path, &text);
47 deny_clippy(&path, &text);
47 tidy_docs.visit(&path, &text); 48 tidy_docs.visit(&path, &text);
48 } 49 }
49 tidy_docs.finish(); 50 tidy_docs.finish();
50} 51}
51 52
53fn deny_clippy(path: &PathBuf, text: &String) {
54 if text.contains("[\u{61}llow(clippy") {
55 panic!(
56 "\n\nallowing lints is forbidden: {}.
57rust-analyzer intentionally doesn't check clippy on CI.
58You can allow lint globally via `xtask clippy`.
59See https://github.com/rust-lang/rust-clippy/issues/5537 for discussion.
60
61",
62 path.display()
63 )
64 }
65}
66
52#[test] 67#[test]
53fn check_licenses() { 68fn check_licenses() {
54 let expected = " 69 let expected = "