diff options
Diffstat (limited to 'crates')
89 files changed, 737 insertions, 812 deletions
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 { | |||
74 | impl Expect { | 74 | impl 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 @@ | |||
1 | use itertools::Itertools; | ||
1 | use ra_syntax::{ | 2 | use 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 | }; |
7 | use stdx::SepBy; | ||
8 | 8 | ||
9 | use crate::{ | 9 | use 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 @@ | |||
1 | use itertools::Itertools; | ||
1 | use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; | 2 | use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; |
2 | use stdx::{format_to, SepBy}; | 3 | use stdx::format_to; |
3 | 4 | ||
4 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 5 | use 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 @@ | |||
1 | use hir::Adt; | 1 | use hir::Adt; |
2 | use itertools::Itertools; | ||
2 | use ra_syntax::{ | 3 | use ra_syntax::{ |
3 | ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner}, | 4 | ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner}, |
4 | T, | 5 | T, |
5 | }; | 6 | }; |
6 | use stdx::{format_to, SepBy}; | 7 | use stdx::format_to; |
7 | 8 | ||
8 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 9 | use 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)] |
68 | pub struct Assist { | 68 | pub 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 | ||
129 | mod handlers { | 144 | mod 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? |
24 | pub(crate) fn check_assist_target(assist: Handler, ra_fixture: &str, target: &str) { | 24 | pub(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( | |||
451 | pub(crate) fn resolve_hir_path( | 450 | pub(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( | |||
512 | pub(crate) fn resolve_hir_path_qualifier( | 511 | pub(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)] |
49 | pub struct HirFileId(HirFileIdRepr); | 50 | pub 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)] |
42 | mod tests { | 42 | mod 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] |
60 | fn ${1:feature}() { | 60 | fn ${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 | ||
4 | use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; | 4 | use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; |
5 | use itertools::Itertools; | ||
5 | use ra_syntax::ast::NameOwner; | 6 | use ra_syntax::ast::NameOwner; |
6 | use stdx::SepBy; | ||
7 | use test_utils::mark; | 7 | use test_utils::mark; |
8 | 8 | ||
9 | use crate::{ | 9 | use 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 | ||
5 | use ast::{HasQuotes, HasStringValue}; | 5 | use ast::{HasQuotes, HasStringValue}; |
6 | use hir::Semantics; | 6 | use hir::Semantics; |
7 | use itertools::Itertools; | ||
7 | use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; | 8 | use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; |
8 | use stdx::SepBy; | ||
9 | 9 | ||
10 | use crate::{ | 10 | use 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)] | ||
513 | fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 512 | fn 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::*; | |||
22 | pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { | 22 | pub(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 | ||
29 | pub(super) enum ItemFlavor { | ||
30 | Mod, | ||
31 | Trait, | ||
32 | } | ||
33 | |||
34 | pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ | 29 | pub(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 | ||
39 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { | 34 | pub(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 | ||
79 | pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Result<(), Marker> { | 74 | pub(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 { | |||
24 | impl MemoryUsage { | 24 | impl 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 |
4 | use stdx::SepBy; | 4 | use itertools::Itertools; |
5 | 5 | ||
6 | use crate::{ | 6 | use 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 | SOURCE_FILE@0..39 | ||
2 | TRAIT@0..38 | ||
3 | TRAIT_KW@0..5 "trait" | ||
4 | WHITESPACE@5..6 " " | ||
5 | NAME@6..7 | ||
6 | IDENT@6..7 "T" | ||
7 | WHITESPACE@7..8 " " | ||
8 | ASSOC_ITEM_LIST@8..38 | ||
9 | L_CURLY@8..9 "{" | ||
10 | WHITESPACE@9..12 "\n " | ||
11 | MACRO_CALL@12..19 | ||
12 | PATH@12..19 | ||
13 | PATH_SEGMENT@12..19 | ||
14 | NAME_REF@12..19 | ||
15 | IDENT@12..19 "default" | ||
16 | WHITESPACE@19..20 " " | ||
17 | CONST@20..36 | ||
18 | CONST_KW@20..25 "const" | ||
19 | WHITESPACE@25..26 " " | ||
20 | NAME@26..27 | ||
21 | IDENT@26..27 "f" | ||
22 | COLON@27..28 ":" | ||
23 | WHITESPACE@28..29 " " | ||
24 | PATH_TYPE@29..31 | ||
25 | PATH@29..31 | ||
26 | PATH_SEGMENT@29..31 | ||
27 | NAME_REF@29..31 | ||
28 | IDENT@29..31 "u8" | ||
29 | WHITESPACE@31..32 " " | ||
30 | EQ@32..33 "=" | ||
31 | WHITESPACE@33..34 " " | ||
32 | LITERAL@34..35 | ||
33 | INT_NUMBER@34..35 "0" | ||
34 | SEMICOLON@35..36 ";" | ||
35 | WHITESPACE@36..37 "\n" | ||
36 | R_CURLY@37..38 "}" | ||
37 | WHITESPACE@38..39 "\n" | ||
38 | error 19..19: expected BANG | ||
39 | error 19..19: expected `{`, `[`, `(` | ||
40 | error 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 @@ | |||
1 | trait 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 | SOURCE_FILE@0..62 | ||
2 | TRAIT@0..61 | ||
3 | TRAIT_KW@0..5 "trait" | ||
4 | WHITESPACE@5..6 " " | ||
5 | NAME@6..7 | ||
6 | IDENT@6..7 "T" | ||
7 | WHITESPACE@7..8 " " | ||
8 | ASSOC_ITEM_LIST@8..61 | ||
9 | L_CURLY@8..9 "{" | ||
10 | WHITESPACE@9..14 "\n " | ||
11 | MACRO_CALL@14..21 | ||
12 | PATH@14..21 | ||
13 | PATH_SEGMENT@14..21 | ||
14 | NAME_REF@14..21 | ||
15 | IDENT@14..21 "default" | ||
16 | WHITESPACE@21..22 " " | ||
17 | TYPE_ALIAS@22..35 | ||
18 | TYPE_KW@22..26 "type" | ||
19 | WHITESPACE@26..27 " " | ||
20 | NAME@27..28 | ||
21 | IDENT@27..28 "T" | ||
22 | WHITESPACE@28..29 " " | ||
23 | EQ@29..30 "=" | ||
24 | WHITESPACE@30..31 " " | ||
25 | PATH_TYPE@31..34 | ||
26 | PATH@31..34 | ||
27 | PATH_SEGMENT@31..34 | ||
28 | NAME_REF@31..34 | ||
29 | IDENT@31..34 "Bar" | ||
30 | SEMICOLON@34..35 ";" | ||
31 | WHITESPACE@35..40 "\n " | ||
32 | MACRO_CALL@40..47 | ||
33 | PATH@40..47 | ||
34 | PATH_SEGMENT@40..47 | ||
35 | NAME_REF@40..47 | ||
36 | IDENT@40..47 "default" | ||
37 | WHITESPACE@47..48 " " | ||
38 | FN@48..59 | ||
39 | FN_KW@48..50 "fn" | ||
40 | WHITESPACE@50..51 " " | ||
41 | NAME@51..54 | ||
42 | IDENT@51..54 "foo" | ||
43 | PARAM_LIST@54..56 | ||
44 | L_PAREN@54..55 "(" | ||
45 | R_PAREN@55..56 ")" | ||
46 | WHITESPACE@56..57 " " | ||
47 | BLOCK_EXPR@57..59 | ||
48 | L_CURLY@57..58 "{" | ||
49 | R_CURLY@58..59 "}" | ||
50 | WHITESPACE@59..60 "\n" | ||
51 | R_CURLY@60..61 "}" | ||
52 | WHITESPACE@61..62 "\n" | ||
53 | error 21..21: expected BANG | ||
54 | error 21..21: expected `{`, `[`, `(` | ||
55 | error 21..21: expected SEMICOLON | ||
56 | error 47..47: expected BANG | ||
57 | error 47..47: expected `{`, `[`, `(` | ||
58 | error 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 @@ | |||
1 | trait 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 | SOURCE_FILE@0..18 | ||
2 | TRAIT@0..17 | ||
3 | UNSAFE_KW@0..6 "unsafe" | ||
4 | WHITESPACE@6..7 " " | ||
5 | TRAIT_KW@7..12 "trait" | ||
6 | WHITESPACE@12..13 " " | ||
7 | NAME@13..14 | ||
8 | IDENT@13..14 "T" | ||
9 | WHITESPACE@14..15 " " | ||
10 | ASSOC_ITEM_LIST@15..17 | ||
11 | L_CURLY@15..16 "{" | ||
12 | R_CURLY@16..17 "}" | ||
13 | WHITESPACE@17..18 "\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 @@ | |||
1 | unsafe 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 | SOURCE_FILE@0..30 | ||
2 | FN@0..29 | ||
3 | UNSAFE_KW@0..6 "unsafe" | ||
4 | WHITESPACE@6..7 " " | ||
5 | ABI@7..17 | ||
6 | EXTERN_KW@7..13 "extern" | ||
7 | WHITESPACE@13..14 " " | ||
8 | STRING@14..17 "\"C\"" | ||
9 | WHITESPACE@17..18 " " | ||
10 | FN_KW@18..20 "fn" | ||
11 | WHITESPACE@20..21 " " | ||
12 | NAME@21..24 | ||
13 | IDENT@21..24 "foo" | ||
14 | PARAM_LIST@24..26 | ||
15 | L_PAREN@24..25 "(" | ||
16 | R_PAREN@25..26 ")" | ||
17 | WHITESPACE@26..27 " " | ||
18 | BLOCK_EXPR@27..29 | ||
19 | L_CURLY@27..28 "{" | ||
20 | R_CURLY@28..29 "}" | ||
21 | WHITESPACE@29..30 "\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 @@ | |||
1 | unsafe 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 | SOURCE_FILE@0..27 | ||
2 | IMPL@0..26 | ||
3 | UNSAFE_KW@0..6 "unsafe" | ||
4 | WHITESPACE@6..7 " " | ||
5 | DEFAULT_KW@7..14 "default" | ||
6 | WHITESPACE@14..15 " " | ||
7 | IMPL_KW@15..19 "impl" | ||
8 | WHITESPACE@19..20 " " | ||
9 | PATH_TYPE@20..23 | ||
10 | PATH@20..23 | ||
11 | PATH_SEGMENT@20..23 | ||
12 | NAME_REF@20..23 | ||
13 | IDENT@20..23 "Foo" | ||
14 | WHITESPACE@23..24 " " | ||
15 | ASSOC_ITEM_LIST@24..26 | ||
16 | L_CURLY@24..25 "{" | ||
17 | R_CURLY@25..26 "}" | ||
18 | WHITESPACE@26..27 "\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 @@ | |||
1 | unsafe 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 | SOURCE_FILE@0..18 | ||
2 | FN@0..17 | ||
3 | CONST_KW@0..5 "const" | ||
4 | WHITESPACE@5..6 " " | ||
5 | FN_KW@6..8 "fn" | ||
6 | WHITESPACE@8..9 " " | ||
7 | NAME@9..12 | ||
8 | IDENT@9..12 "foo" | ||
9 | PARAM_LIST@12..14 | ||
10 | L_PAREN@12..13 "(" | ||
11 | R_PAREN@13..14 ")" | ||
12 | WHITESPACE@14..15 " " | ||
13 | BLOCK_EXPR@15..17 | ||
14 | L_CURLY@15..16 "{" | ||
15 | R_CURLY@16..17 "}" | ||
16 | WHITESPACE@17..18 "\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 @@ | |||
1 | const 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 | SOURCE_FILE@0..19 | ||
2 | IMPL@0..18 | ||
3 | UNSAFE_KW@0..6 "unsafe" | ||
4 | WHITESPACE@6..7 " " | ||
5 | IMPL_KW@7..11 "impl" | ||
6 | WHITESPACE@11..12 " " | ||
7 | PATH_TYPE@12..15 | ||
8 | PATH@12..15 | ||
9 | PATH_SEGMENT@12..15 | ||
10 | NAME_REF@12..15 | ||
11 | IDENT@12..15 "Foo" | ||
12 | WHITESPACE@15..16 " " | ||
13 | ASSOC_ITEM_LIST@16..18 | ||
14 | L_CURLY@16..17 "{" | ||
15 | R_CURLY@17..18 "}" | ||
16 | WHITESPACE@18..19 "\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 @@ | |||
1 | unsafe 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 | SOURCE_FILE@0..19 | ||
2 | FN@0..18 | ||
3 | ABI@0..6 | ||
4 | EXTERN_KW@0..6 "extern" | ||
5 | WHITESPACE@6..7 " " | ||
6 | FN_KW@7..9 "fn" | ||
7 | WHITESPACE@9..10 " " | ||
8 | NAME@10..13 | ||
9 | IDENT@10..13 "foo" | ||
10 | PARAM_LIST@13..15 | ||
11 | L_PAREN@13..14 "(" | ||
12 | R_PAREN@14..15 ")" | ||
13 | WHITESPACE@15..16 " " | ||
14 | BLOCK_EXPR@16..18 | ||
15 | L_CURLY@16..17 "{" | ||
16 | R_CURLY@17..18 "}" | ||
17 | WHITESPACE@18..19 "\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 @@ | |||
1 | extern 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 | SOURCE_FILE@0..16 | ||
2 | TRAIT@0..15 | ||
3 | AUTO_KW@0..4 "auto" | ||
4 | WHITESPACE@4..5 " " | ||
5 | TRAIT_KW@5..10 "trait" | ||
6 | WHITESPACE@10..11 " " | ||
7 | NAME@11..12 | ||
8 | IDENT@11..12 "T" | ||
9 | WHITESPACE@12..13 " " | ||
10 | ASSOC_ITEM_LIST@13..15 | ||
11 | L_CURLY@13..14 "{" | ||
12 | R_CURLY@14..15 "}" | ||
13 | WHITESPACE@15..16 "\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 @@ | |||
1 | auto 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 | SOURCE_FILE@0..23 | ||
2 | TRAIT@0..22 | ||
3 | UNSAFE_KW@0..6 "unsafe" | ||
4 | WHITESPACE@6..7 " " | ||
5 | AUTO_KW@7..11 "auto" | ||
6 | WHITESPACE@11..12 " " | ||
7 | TRAIT_KW@12..17 "trait" | ||
8 | WHITESPACE@17..18 " " | ||
9 | NAME@18..19 | ||
10 | IDENT@18..19 "T" | ||
11 | WHITESPACE@19..20 " " | ||
12 | ASSOC_ITEM_LIST@20..22 | ||
13 | L_CURLY@20..21 "{" | ||
14 | R_CURLY@21..22 "}" | ||
15 | WHITESPACE@22..23 "\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 @@ | |||
1 | unsafe 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 | SOURCE_FILE@0..20 | ||
2 | IMPL@0..19 | ||
3 | DEFAULT_KW@0..7 "default" | ||
4 | WHITESPACE@7..8 " " | ||
5 | IMPL_KW@8..12 "impl" | ||
6 | WHITESPACE@12..13 " " | ||
7 | PATH_TYPE@13..16 | ||
8 | PATH@13..16 | ||
9 | PATH_SEGMENT@13..16 | ||
10 | NAME_REF@13..16 | ||
11 | IDENT@13..16 "Foo" | ||
12 | WHITESPACE@16..17 " " | ||
13 | ASSOC_ITEM_LIST@17..19 | ||
14 | L_CURLY@17..18 "{" | ||
15 | R_CURLY@18..19 "}" | ||
16 | WHITESPACE@19..20 "\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 @@ | |||
1 | default 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 | SOURCE_FILE@0..25 | ||
2 | FN@0..24 | ||
3 | CONST_KW@0..5 "const" | ||
4 | WHITESPACE@5..6 " " | ||
5 | UNSAFE_KW@6..12 "unsafe" | ||
6 | WHITESPACE@12..13 " " | ||
7 | FN_KW@13..15 "fn" | ||
8 | WHITESPACE@15..16 " " | ||
9 | NAME@16..19 | ||
10 | IDENT@16..19 "foo" | ||
11 | PARAM_LIST@19..21 | ||
12 | L_PAREN@19..20 "(" | ||
13 | R_PAREN@20..21 ")" | ||
14 | WHITESPACE@21..22 " " | ||
15 | BLOCK_EXPR@22..24 | ||
16 | L_CURLY@22..23 "{" | ||
17 | R_CURLY@23..24 "}" | ||
18 | WHITESPACE@24..25 "\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 @@ | |||
1 | const 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 | SOURCE_FILE@0..19 | ||
2 | FN@0..18 | ||
3 | UNSAFE_KW@0..6 "unsafe" | ||
4 | WHITESPACE@6..7 " " | ||
5 | FN_KW@7..9 "fn" | ||
6 | WHITESPACE@9..10 " " | ||
7 | NAME@10..13 | ||
8 | IDENT@10..13 "foo" | ||
9 | PARAM_LIST@13..15 | ||
10 | L_PAREN@13..14 "(" | ||
11 | R_PAREN@14..15 ")" | ||
12 | WHITESPACE@15..16 " " | ||
13 | BLOCK_EXPR@16..18 | ||
14 | L_CURLY@16..17 "{" | ||
15 | R_CURLY@17..18 "}" | ||
16 | WHITESPACE@18..19 "\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 @@ | |||
1 | unsafe 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 | SOURCE_FILE@0..18 | ||
2 | FN@0..17 | ||
3 | ASYNC_KW@0..5 "async" | ||
4 | WHITESPACE@5..6 " " | ||
5 | FN_KW@6..8 "fn" | ||
6 | WHITESPACE@8..9 " " | ||
7 | NAME@9..12 | ||
8 | IDENT@9..12 "foo" | ||
9 | PARAM_LIST@12..14 | ||
10 | L_PAREN@12..13 "(" | ||
11 | R_PAREN@13..14 ")" | ||
12 | WHITESPACE@14..15 " " | ||
13 | BLOCK_EXPR@15..17 | ||
14 | L_CURLY@15..16 "{" | ||
15 | R_CURLY@16..17 "}" | ||
16 | WHITESPACE@17..18 "\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 @@ | |||
1 | async 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 | SOURCE_FILE@0..50 | ||
2 | FN@0..24 | ||
3 | ASYNC_KW@0..5 "async" | ||
4 | WHITESPACE@5..6 " " | ||
5 | UNSAFE_KW@6..12 "unsafe" | ||
6 | WHITESPACE@12..13 " " | ||
7 | FN_KW@13..15 "fn" | ||
8 | WHITESPACE@15..16 " " | ||
9 | NAME@16..19 | ||
10 | IDENT@16..19 "foo" | ||
11 | PARAM_LIST@19..21 | ||
12 | L_PAREN@19..20 "(" | ||
13 | R_PAREN@20..21 ")" | ||
14 | WHITESPACE@21..22 " " | ||
15 | BLOCK_EXPR@22..24 | ||
16 | L_CURLY@22..23 "{" | ||
17 | R_CURLY@23..24 "}" | ||
18 | WHITESPACE@24..25 "\n" | ||
19 | FN@25..49 | ||
20 | CONST_KW@25..30 "const" | ||
21 | WHITESPACE@30..31 " " | ||
22 | UNSAFE_KW@31..37 "unsafe" | ||
23 | WHITESPACE@37..38 " " | ||
24 | FN_KW@38..40 "fn" | ||
25 | WHITESPACE@40..41 " " | ||
26 | NAME@41..44 | ||
27 | IDENT@41..44 "bar" | ||
28 | PARAM_LIST@44..46 | ||
29 | L_PAREN@44..45 "(" | ||
30 | R_PAREN@45..46 ")" | ||
31 | WHITESPACE@46..47 " " | ||
32 | BLOCK_EXPR@47..49 | ||
33 | L_CURLY@47..48 "{" | ||
34 | R_CURLY@48..49 "}" | ||
35 | WHITESPACE@49..50 "\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 @@ | |||
1 | async unsafe fn foo() {} | ||
2 | const 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 | SOURCE_FILE@0..69 | ||
2 | IMPL@0..68 | ||
3 | IMPL_KW@0..4 "impl" | ||
4 | WHITESPACE@4..5 " " | ||
5 | PATH_TYPE@5..6 | ||
6 | PATH@5..6 | ||
7 | PATH_SEGMENT@5..6 | ||
8 | NAME_REF@5..6 | ||
9 | IDENT@5..6 "T" | ||
10 | WHITESPACE@6..7 " " | ||
11 | FOR_KW@7..10 "for" | ||
12 | WHITESPACE@10..11 " " | ||
13 | PATH_TYPE@11..14 | ||
14 | PATH@11..14 | ||
15 | PATH_SEGMENT@11..14 | ||
16 | NAME_REF@11..14 | ||
17 | IDENT@11..14 "Foo" | ||
18 | WHITESPACE@14..15 " " | ||
19 | ASSOC_ITEM_LIST@15..68 | ||
20 | L_CURLY@15..16 "{" | ||
21 | WHITESPACE@16..21 "\n " | ||
22 | TYPE_ALIAS@21..42 | ||
23 | DEFAULT_KW@21..28 "default" | ||
24 | WHITESPACE@28..29 " " | ||
25 | TYPE_KW@29..33 "type" | ||
26 | WHITESPACE@33..34 " " | ||
27 | NAME@34..35 | ||
28 | IDENT@34..35 "T" | ||
29 | WHITESPACE@35..36 " " | ||
30 | EQ@36..37 "=" | ||
31 | WHITESPACE@37..38 " " | ||
32 | PATH_TYPE@38..41 | ||
33 | PATH@38..41 | ||
34 | PATH_SEGMENT@38..41 | ||
35 | NAME_REF@38..41 | ||
36 | IDENT@38..41 "Bar" | ||
37 | SEMICOLON@41..42 ";" | ||
38 | WHITESPACE@42..47 "\n " | ||
39 | FN@47..66 | ||
40 | DEFAULT_KW@47..54 "default" | ||
41 | WHITESPACE@54..55 " " | ||
42 | FN_KW@55..57 "fn" | ||
43 | WHITESPACE@57..58 " " | ||
44 | NAME@58..61 | ||
45 | IDENT@58..61 "foo" | ||
46 | PARAM_LIST@61..63 | ||
47 | L_PAREN@61..62 "(" | ||
48 | R_PAREN@62..63 ")" | ||
49 | WHITESPACE@63..64 " " | ||
50 | BLOCK_EXPR@64..66 | ||
51 | L_CURLY@64..65 "{" | ||
52 | R_CURLY@65..66 "}" | ||
53 | WHITESPACE@66..67 "\n" | ||
54 | R_CURLY@67..68 "}" | ||
55 | WHITESPACE@68..69 "\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 @@ | |||
1 | impl 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 | SOURCE_FILE@0..12 | ||
2 | FN@0..11 | ||
3 | FN_KW@0..2 "fn" | ||
4 | WHITESPACE@2..3 " " | ||
5 | NAME@3..6 | ||
6 | IDENT@3..6 "foo" | ||
7 | PARAM_LIST@6..8 | ||
8 | L_PAREN@6..7 "(" | ||
9 | R_PAREN@7..8 ")" | ||
10 | WHITESPACE@8..9 " " | ||
11 | BLOCK_EXPR@9..11 | ||
12 | L_CURLY@9..10 "{" | ||
13 | R_CURLY@10..11 "}" | ||
14 | WHITESPACE@11..12 "\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 | SOURCE_FILE@0..16 | ||
2 | IMPL@0..15 | ||
3 | IMPL_KW@0..4 "impl" | ||
4 | WHITESPACE@4..5 " " | ||
5 | PATH_TYPE@5..6 | ||
6 | PATH@5..6 | ||
7 | PATH_SEGMENT@5..6 | ||
8 | NAME_REF@5..6 | ||
9 | IDENT@5..6 "T" | ||
10 | WHITESPACE@6..7 " " | ||
11 | FOR_KW@7..10 "for" | ||
12 | WHITESPACE@10..11 " " | ||
13 | PATH_TYPE@11..12 | ||
14 | PATH@11..12 | ||
15 | PATH_SEGMENT@11..12 | ||
16 | NAME_REF@11..12 | ||
17 | IDENT@11..12 "S" | ||
18 | WHITESPACE@12..13 " " | ||
19 | ASSOC_ITEM_LIST@13..15 | ||
20 | L_CURLY@13..14 "{" | ||
21 | R_CURLY@14..15 "}" | ||
22 | WHITESPACE@15..16 "\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 | SOURCE_FILE@0..11 | ||
2 | TRAIT@0..10 | ||
3 | TRAIT_KW@0..5 "trait" | ||
4 | WHITESPACE@5..6 " " | ||
5 | NAME@6..7 | ||
6 | IDENT@6..7 "T" | ||
7 | WHITESPACE@7..8 " " | ||
8 | ASSOC_ITEM_LIST@8..10 | ||
9 | L_CURLY@8..9 "{" | ||
10 | R_CURLY@9..10 "}" | ||
11 | WHITESPACE@10..11 "\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 | SOURCE_FILE@0..50 | ||
2 | IMPL@0..49 | ||
3 | IMPL_KW@0..4 "impl" | ||
4 | WHITESPACE@4..5 " " | ||
5 | PATH_TYPE@5..6 | ||
6 | PATH@5..6 | ||
7 | PATH_SEGMENT@5..6 | ||
8 | NAME_REF@5..6 | ||
9 | IDENT@5..6 "T" | ||
10 | WHITESPACE@6..7 " " | ||
11 | FOR_KW@7..10 "for" | ||
12 | WHITESPACE@10..11 " " | ||
13 | PATH_TYPE@11..14 | ||
14 | PATH@11..14 | ||
15 | PATH_SEGMENT@11..14 | ||
16 | NAME_REF@11..14 | ||
17 | IDENT@11..14 "Foo" | ||
18 | WHITESPACE@14..15 " " | ||
19 | ASSOC_ITEM_LIST@15..49 | ||
20 | L_CURLY@15..16 "{" | ||
21 | WHITESPACE@16..21 "\n " | ||
22 | FN@21..47 | ||
23 | DEFAULT_KW@21..28 "default" | ||
24 | WHITESPACE@28..29 " " | ||
25 | UNSAFE_KW@29..35 "unsafe" | ||
26 | WHITESPACE@35..36 " " | ||
27 | FN_KW@36..38 "fn" | ||
28 | WHITESPACE@38..39 " " | ||
29 | NAME@39..42 | ||
30 | IDENT@39..42 "foo" | ||
31 | PARAM_LIST@42..44 | ||
32 | L_PAREN@42..43 "(" | ||
33 | R_PAREN@43..44 ")" | ||
34 | WHITESPACE@44..45 " " | ||
35 | BLOCK_EXPR@45..47 | ||
36 | L_CURLY@45..46 "{" | ||
37 | R_CURLY@46..47 "}" | ||
38 | WHITESPACE@47..48 "\n" | ||
39 | R_CURLY@48..49 "}" | ||
40 | WHITESPACE@49..50 "\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 | SOURCE_FILE@0..27 | ||
2 | IMPL@0..26 | ||
3 | DEFAULT_KW@0..7 "default" | ||
4 | WHITESPACE@7..8 " " | ||
5 | UNSAFE_KW@8..14 "unsafe" | ||
6 | WHITESPACE@14..15 " " | ||
7 | IMPL_KW@15..19 "impl" | ||
8 | WHITESPACE@19..20 " " | ||
9 | PATH_TYPE@20..23 | ||
10 | PATH@20..23 | ||
11 | PATH_SEGMENT@20..23 | ||
12 | NAME_REF@20..23 | ||
13 | IDENT@20..23 "Foo" | ||
14 | WHITESPACE@23..24 " " | ||
15 | ASSOC_ITEM_LIST@24..26 | ||
16 | L_CURLY@24..25 "{" | ||
17 | R_CURLY@25..26 "}" | ||
18 | WHITESPACE@26..27 "\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 @@ | |||
1 | default 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 | SOURCE_FILE@0..65 | ||
2 | IMPL@0..64 | ||
3 | DEFAULT_KW@0..7 "default" | ||
4 | WHITESPACE@7..8 " " | ||
5 | UNSAFE_KW@8..14 "unsafe" | ||
6 | WHITESPACE@14..15 " " | ||
7 | IMPL_KW@15..19 "impl" | ||
8 | WHITESPACE@19..20 " " | ||
9 | PATH_TYPE@20..21 | ||
10 | PATH@20..21 | ||
11 | PATH_SEGMENT@20..21 | ||
12 | NAME_REF@20..21 | ||
13 | IDENT@20..21 "T" | ||
14 | WHITESPACE@21..22 " " | ||
15 | FOR_KW@22..25 "for" | ||
16 | WHITESPACE@25..26 " " | ||
17 | PATH_TYPE@26..29 | ||
18 | PATH@26..29 | ||
19 | PATH_SEGMENT@26..29 | ||
20 | NAME_REF@26..29 | ||
21 | IDENT@26..29 "Foo" | ||
22 | WHITESPACE@29..30 " " | ||
23 | ASSOC_ITEM_LIST@30..64 | ||
24 | L_CURLY@30..31 "{" | ||
25 | WHITESPACE@31..36 "\n " | ||
26 | FN@36..62 | ||
27 | DEFAULT_KW@36..43 "default" | ||
28 | WHITESPACE@43..44 " " | ||
29 | UNSAFE_KW@44..50 "unsafe" | ||
30 | WHITESPACE@50..51 " " | ||
31 | FN_KW@51..53 "fn" | ||
32 | WHITESPACE@53..54 " " | ||
33 | NAME@54..57 | ||
34 | IDENT@54..57 "foo" | ||
35 | PARAM_LIST@57..59 | ||
36 | L_PAREN@57..58 "(" | ||
37 | R_PAREN@58..59 ")" | ||
38 | WHITESPACE@59..60 " " | ||
39 | BLOCK_EXPR@60..62 | ||
40 | L_CURLY@60..61 "{" | ||
41 | R_CURLY@61..62 "}" | ||
42 | WHITESPACE@62..63 "\n" | ||
43 | R_CURLY@63..64 "}" | ||
44 | WHITESPACE@64..65 "\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 @@ | |||
1 | impl T for Foo { | 1 | default 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 | SOURCE_FILE@0..26 | ||
2 | IMPL@0..25 | ||
3 | DEFAULT_KW@0..7 "default" | ||
4 | WHITESPACE@7..8 " " | ||
5 | IMPL_KW@8..12 "impl" | ||
6 | WHITESPACE@12..13 " " | ||
7 | PATH_TYPE@13..14 | ||
8 | PATH@13..14 | ||
9 | PATH_SEGMENT@13..14 | ||
10 | NAME_REF@13..14 | ||
11 | IDENT@13..14 "T" | ||
12 | WHITESPACE@14..15 " " | ||
13 | FOR_KW@15..18 "for" | ||
14 | WHITESPACE@18..19 " " | ||
15 | PATH_TYPE@19..22 | ||
16 | PATH@19..22 | ||
17 | PATH_SEGMENT@19..22 | ||
18 | NAME_REF@19..22 | ||
19 | IDENT@19..22 "Foo" | ||
20 | WHITESPACE@22..23 " " | ||
21 | ASSOC_ITEM_LIST@23..25 | ||
22 | L_CURLY@23..24 "{" | ||
23 | R_CURLY@24..25 "}" | ||
24 | WHITESPACE@25..26 "\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 | SOURCE_FILE@0..71 | ||
2 | FN@0..19 | ||
3 | ABI@0..6 | ||
4 | EXTERN_KW@0..6 "extern" | ||
5 | WHITESPACE@6..7 " " | ||
6 | FN_KW@7..9 "fn" | ||
7 | WHITESPACE@9..10 " " | ||
8 | NAME@10..13 | ||
9 | IDENT@10..13 "foo" | ||
10 | PARAM_LIST@13..15 | ||
11 | L_PAREN@13..14 "(" | ||
12 | R_PAREN@14..15 ")" | ||
13 | WHITESPACE@15..16 " " | ||
14 | BLOCK_EXPR@16..19 | ||
15 | L_CURLY@16..17 "{" | ||
16 | WHITESPACE@17..18 "\n" | ||
17 | R_CURLY@18..19 "}" | ||
18 | WHITESPACE@19..21 "\n\n" | ||
19 | FN@21..44 | ||
20 | ABI@21..31 | ||
21 | EXTERN_KW@21..27 "extern" | ||
22 | WHITESPACE@27..28 " " | ||
23 | STRING@28..31 "\"C\"" | ||
24 | WHITESPACE@31..32 " " | ||
25 | FN_KW@32..34 "fn" | ||
26 | WHITESPACE@34..35 " " | ||
27 | NAME@35..38 | ||
28 | IDENT@35..38 "bar" | ||
29 | PARAM_LIST@38..40 | ||
30 | L_PAREN@38..39 "(" | ||
31 | R_PAREN@39..40 ")" | ||
32 | WHITESPACE@40..41 " " | ||
33 | BLOCK_EXPR@41..44 | ||
34 | L_CURLY@41..42 "{" | ||
35 | WHITESPACE@42..43 "\n" | ||
36 | R_CURLY@43..44 "}" | ||
37 | WHITESPACE@44..46 "\n\n" | ||
38 | FN@46..70 | ||
39 | ABI@46..57 | ||
40 | EXTERN_KW@46..52 "extern" | ||
41 | WHITESPACE@52..53 " " | ||
42 | RAW_STRING@53..57 "r\"D\"" | ||
43 | WHITESPACE@57..58 " " | ||
44 | FN_KW@58..60 "fn" | ||
45 | WHITESPACE@60..61 " " | ||
46 | NAME@61..64 | ||
47 | IDENT@61..64 "baz" | ||
48 | PARAM_LIST@64..66 | ||
49 | L_PAREN@64..65 "(" | ||
50 | R_PAREN@65..66 ")" | ||
51 | WHITESPACE@66..67 " " | ||
52 | BLOCK_EXPR@67..70 | ||
53 | L_CURLY@67..68 "{" | ||
54 | WHITESPACE@68..69 "\n" | ||
55 | R_CURLY@69..70 "}" | ||
56 | WHITESPACE@70..71 "\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 @@ | |||
1 | extern fn foo() { | ||
2 | } | ||
3 | |||
4 | extern "C" fn bar() { | ||
5 | } | ||
6 | |||
7 | extern 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 | SOURCE_FILE@0..46 | ||
2 | IMPL@0..45 | ||
3 | IMPL_KW@0..4 "impl" | ||
4 | WHITESPACE@4..5 " " | ||
5 | PATH_TYPE@5..6 | ||
6 | PATH@5..6 | ||
7 | PATH_SEGMENT@5..6 | ||
8 | NAME_REF@5..6 | ||
9 | IDENT@5..6 "T" | ||
10 | WHITESPACE@6..7 " " | ||
11 | FOR_KW@7..10 "for" | ||
12 | WHITESPACE@10..11 " " | ||
13 | PATH_TYPE@11..14 | ||
14 | PATH@11..14 | ||
15 | PATH_SEGMENT@11..14 | ||
16 | NAME_REF@11..14 | ||
17 | IDENT@11..14 "Foo" | ||
18 | WHITESPACE@14..15 " " | ||
19 | ASSOC_ITEM_LIST@15..45 | ||
20 | L_CURLY@15..16 "{" | ||
21 | WHITESPACE@16..19 "\n " | ||
22 | CONST@19..43 | ||
23 | DEFAULT_KW@19..26 "default" | ||
24 | WHITESPACE@26..27 " " | ||
25 | CONST_KW@27..32 "const" | ||
26 | WHITESPACE@32..33 " " | ||
27 | NAME@33..34 | ||
28 | IDENT@33..34 "f" | ||
29 | COLON@34..35 ":" | ||
30 | WHITESPACE@35..36 " " | ||
31 | PATH_TYPE@36..38 | ||
32 | PATH@36..38 | ||
33 | PATH_SEGMENT@36..38 | ||
34 | NAME_REF@36..38 | ||
35 | IDENT@36..38 "u8" | ||
36 | WHITESPACE@38..39 " " | ||
37 | EQ@39..40 "=" | ||
38 | WHITESPACE@40..41 " " | ||
39 | LITERAL@41..42 | ||
40 | INT_NUMBER@41..42 "0" | ||
41 | SEMICOLON@42..43 ";" | ||
42 | WHITESPACE@43..44 "\n" | ||
43 | R_CURLY@44..45 "}" | ||
44 | WHITESPACE@45..46 "\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 @@ | |||
1 | impl 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 | SOURCE_FILE@0..294 | ||
2 | TRAIT@0..113 | ||
3 | TRAIT_KW@0..5 "trait" | ||
4 | WHITESPACE@5..6 " " | ||
5 | NAME@6..7 | ||
6 | IDENT@6..7 "T" | ||
7 | WHITESPACE@7..8 " " | ||
8 | ASSOC_ITEM_LIST@8..113 | ||
9 | L_CURLY@8..9 "{" | ||
10 | WHITESPACE@9..12 "\n " | ||
11 | TYPE_ALIAS@12..33 | ||
12 | DEFAULT_KW@12..19 "default" | ||
13 | WHITESPACE@19..20 " " | ||
14 | TYPE_KW@20..24 "type" | ||
15 | WHITESPACE@24..25 " " | ||
16 | NAME@25..26 | ||
17 | IDENT@25..26 "T" | ||
18 | WHITESPACE@26..27 " " | ||
19 | EQ@27..28 "=" | ||
20 | WHITESPACE@28..29 " " | ||
21 | PATH_TYPE@29..32 | ||
22 | PATH@29..32 | ||
23 | PATH_SEGMENT@29..32 | ||
24 | NAME_REF@29..32 | ||
25 | IDENT@29..32 "Bar" | ||
26 | SEMICOLON@32..33 ";" | ||
27 | WHITESPACE@33..36 "\n " | ||
28 | CONST@36..60 | ||
29 | DEFAULT_KW@36..43 "default" | ||
30 | WHITESPACE@43..44 " " | ||
31 | CONST_KW@44..49 "const" | ||
32 | WHITESPACE@49..50 " " | ||
33 | NAME@50..51 | ||
34 | IDENT@50..51 "f" | ||
35 | COLON@51..52 ":" | ||
36 | WHITESPACE@52..53 " " | ||
37 | PATH_TYPE@53..55 | ||
38 | PATH@53..55 | ||
39 | PATH_SEGMENT@53..55 | ||
40 | NAME_REF@53..55 | ||
41 | IDENT@53..55 "u8" | ||
42 | WHITESPACE@55..56 " " | ||
43 | EQ@56..57 "=" | ||
44 | WHITESPACE@57..58 " " | ||
45 | LITERAL@58..59 | ||
46 | INT_NUMBER@58..59 "0" | ||
47 | SEMICOLON@59..60 ";" | ||
48 | WHITESPACE@60..63 "\n " | ||
49 | FN@63..82 | ||
50 | DEFAULT_KW@63..70 "default" | ||
51 | WHITESPACE@70..71 " " | ||
52 | FN_KW@71..73 "fn" | ||
53 | WHITESPACE@73..74 " " | ||
54 | NAME@74..77 | ||
55 | IDENT@74..77 "foo" | ||
56 | PARAM_LIST@77..79 | ||
57 | L_PAREN@77..78 "(" | ||
58 | R_PAREN@78..79 ")" | ||
59 | WHITESPACE@79..80 " " | ||
60 | BLOCK_EXPR@80..82 | ||
61 | L_CURLY@80..81 "{" | ||
62 | R_CURLY@81..82 "}" | ||
63 | WHITESPACE@82..85 "\n " | ||
64 | FN@85..111 | ||
65 | DEFAULT_KW@85..92 "default" | ||
66 | WHITESPACE@92..93 " " | ||
67 | UNSAFE_KW@93..99 "unsafe" | ||
68 | WHITESPACE@99..100 " " | ||
69 | FN_KW@100..102 "fn" | ||
70 | WHITESPACE@102..103 " " | ||
71 | NAME@103..106 | ||
72 | IDENT@103..106 "bar" | ||
73 | PARAM_LIST@106..108 | ||
74 | L_PAREN@106..107 "(" | ||
75 | R_PAREN@107..108 ")" | ||
76 | WHITESPACE@108..109 " " | ||
77 | BLOCK_EXPR@109..111 | ||
78 | L_CURLY@109..110 "{" | ||
79 | R_CURLY@110..111 "}" | ||
80 | WHITESPACE@111..112 "\n" | ||
81 | R_CURLY@112..113 "}" | ||
82 | WHITESPACE@113..115 "\n\n" | ||
83 | IMPL@115..235 | ||
84 | IMPL_KW@115..119 "impl" | ||
85 | WHITESPACE@119..120 " " | ||
86 | PATH_TYPE@120..121 | ||
87 | PATH@120..121 | ||
88 | PATH_SEGMENT@120..121 | ||
89 | NAME_REF@120..121 | ||
90 | IDENT@120..121 "T" | ||
91 | WHITESPACE@121..122 " " | ||
92 | FOR_KW@122..125 "for" | ||
93 | WHITESPACE@125..126 " " | ||
94 | PATH_TYPE@126..129 | ||
95 | PATH@126..129 | ||
96 | PATH_SEGMENT@126..129 | ||
97 | NAME_REF@126..129 | ||
98 | IDENT@126..129 "Foo" | ||
99 | WHITESPACE@129..130 " " | ||
100 | ASSOC_ITEM_LIST@130..235 | ||
101 | L_CURLY@130..131 "{" | ||
102 | WHITESPACE@131..134 "\n " | ||
103 | TYPE_ALIAS@134..155 | ||
104 | DEFAULT_KW@134..141 "default" | ||
105 | WHITESPACE@141..142 " " | ||
106 | TYPE_KW@142..146 "type" | ||
107 | WHITESPACE@146..147 " " | ||
108 | NAME@147..148 | ||
109 | IDENT@147..148 "T" | ||
110 | WHITESPACE@148..149 " " | ||
111 | EQ@149..150 "=" | ||
112 | WHITESPACE@150..151 " " | ||
113 | PATH_TYPE@151..154 | ||
114 | PATH@151..154 | ||
115 | PATH_SEGMENT@151..154 | ||
116 | NAME_REF@151..154 | ||
117 | IDENT@151..154 "Bar" | ||
118 | SEMICOLON@154..155 ";" | ||
119 | WHITESPACE@155..158 "\n " | ||
120 | CONST@158..182 | ||
121 | DEFAULT_KW@158..165 "default" | ||
122 | WHITESPACE@165..166 " " | ||
123 | CONST_KW@166..171 "const" | ||
124 | WHITESPACE@171..172 " " | ||
125 | NAME@172..173 | ||
126 | IDENT@172..173 "f" | ||
127 | COLON@173..174 ":" | ||
128 | WHITESPACE@174..175 " " | ||
129 | PATH_TYPE@175..177 | ||
130 | PATH@175..177 | ||
131 | PATH_SEGMENT@175..177 | ||
132 | NAME_REF@175..177 | ||
133 | IDENT@175..177 "u8" | ||
134 | WHITESPACE@177..178 " " | ||
135 | EQ@178..179 "=" | ||
136 | WHITESPACE@179..180 " " | ||
137 | LITERAL@180..181 | ||
138 | INT_NUMBER@180..181 "0" | ||
139 | SEMICOLON@181..182 ";" | ||
140 | WHITESPACE@182..185 "\n " | ||
141 | FN@185..204 | ||
142 | DEFAULT_KW@185..192 "default" | ||
143 | WHITESPACE@192..193 " " | ||
144 | FN_KW@193..195 "fn" | ||
145 | WHITESPACE@195..196 " " | ||
146 | NAME@196..199 | ||
147 | IDENT@196..199 "foo" | ||
148 | PARAM_LIST@199..201 | ||
149 | L_PAREN@199..200 "(" | ||
150 | R_PAREN@200..201 ")" | ||
151 | WHITESPACE@201..202 " " | ||
152 | BLOCK_EXPR@202..204 | ||
153 | L_CURLY@202..203 "{" | ||
154 | R_CURLY@203..204 "}" | ||
155 | WHITESPACE@204..207 "\n " | ||
156 | FN@207..233 | ||
157 | DEFAULT_KW@207..214 "default" | ||
158 | WHITESPACE@214..215 " " | ||
159 | UNSAFE_KW@215..221 "unsafe" | ||
160 | WHITESPACE@221..222 " " | ||
161 | FN_KW@222..224 "fn" | ||
162 | WHITESPACE@224..225 " " | ||
163 | NAME@225..228 | ||
164 | IDENT@225..228 "bar" | ||
165 | PARAM_LIST@228..230 | ||
166 | L_PAREN@228..229 "(" | ||
167 | R_PAREN@229..230 ")" | ||
168 | WHITESPACE@230..231 " " | ||
169 | BLOCK_EXPR@231..233 | ||
170 | L_CURLY@231..232 "{" | ||
171 | R_CURLY@232..233 "}" | ||
172 | WHITESPACE@233..234 "\n" | ||
173 | R_CURLY@234..235 "}" | ||
174 | WHITESPACE@235..237 "\n\n" | ||
175 | IMPL@237..261 | ||
176 | DEFAULT_KW@237..244 "default" | ||
177 | WHITESPACE@244..245 " " | ||
178 | IMPL_KW@245..249 "impl" | ||
179 | WHITESPACE@249..250 " " | ||
180 | PATH_TYPE@250..251 | ||
181 | PATH@250..251 | ||
182 | PATH_SEGMENT@250..251 | ||
183 | NAME_REF@250..251 | ||
184 | IDENT@250..251 "T" | ||
185 | WHITESPACE@251..252 " " | ||
186 | FOR_KW@252..255 "for" | ||
187 | WHITESPACE@255..256 " " | ||
188 | TUPLE_TYPE@256..258 | ||
189 | L_PAREN@256..257 "(" | ||
190 | R_PAREN@257..258 ")" | ||
191 | WHITESPACE@258..259 " " | ||
192 | ASSOC_ITEM_LIST@259..261 | ||
193 | L_CURLY@259..260 "{" | ||
194 | R_CURLY@260..261 "}" | ||
195 | WHITESPACE@261..262 "\n" | ||
196 | IMPL@262..293 | ||
197 | DEFAULT_KW@262..269 "default" | ||
198 | WHITESPACE@269..270 " " | ||
199 | UNSAFE_KW@270..276 "unsafe" | ||
200 | WHITESPACE@276..277 " " | ||
201 | IMPL_KW@277..281 "impl" | ||
202 | WHITESPACE@281..282 " " | ||
203 | PATH_TYPE@282..283 | ||
204 | PATH@282..283 | ||
205 | PATH_SEGMENT@282..283 | ||
206 | NAME_REF@282..283 | ||
207 | IDENT@282..283 "T" | ||
208 | WHITESPACE@283..284 " " | ||
209 | FOR_KW@284..287 "for" | ||
210 | WHITESPACE@287..288 " " | ||
211 | TUPLE_TYPE@288..290 | ||
212 | L_PAREN@288..289 "(" | ||
213 | R_PAREN@289..290 ")" | ||
214 | WHITESPACE@290..291 " " | ||
215 | ASSOC_ITEM_LIST@291..293 | ||
216 | L_CURLY@291..292 "{" | ||
217 | R_CURLY@292..293 "}" | ||
218 | WHITESPACE@293..294 "\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 @@ | |||
1 | trait T { | ||
2 | default type T = Bar; | ||
3 | default const f: u8 = 0; | ||
4 | default fn foo() {} | ||
5 | default unsafe fn bar() {} | ||
6 | } | ||
7 | |||
8 | impl 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 | |||
15 | default impl T for () {} | ||
16 | default 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 | SOURCE_FILE@0..304 | ||
2 | FN@0..17 | ||
3 | ASYNC_KW@0..5 "async" | ||
4 | WHITESPACE@5..6 " " | ||
5 | FN_KW@6..8 "fn" | ||
6 | WHITESPACE@8..9 " " | ||
7 | NAME@9..12 | ||
8 | IDENT@9..12 "foo" | ||
9 | PARAM_LIST@12..14 | ||
10 | L_PAREN@12..13 "(" | ||
11 | R_PAREN@13..14 ")" | ||
12 | WHITESPACE@14..15 " " | ||
13 | BLOCK_EXPR@15..17 | ||
14 | L_CURLY@15..16 "{" | ||
15 | R_CURLY@16..17 "}" | ||
16 | WHITESPACE@17..18 "\n" | ||
17 | FN@18..36 | ||
18 | ABI@18..24 | ||
19 | EXTERN_KW@18..24 "extern" | ||
20 | WHITESPACE@24..25 " " | ||
21 | FN_KW@25..27 "fn" | ||
22 | WHITESPACE@27..28 " " | ||
23 | NAME@28..31 | ||
24 | IDENT@28..31 "foo" | ||
25 | PARAM_LIST@31..33 | ||
26 | L_PAREN@31..32 "(" | ||
27 | R_PAREN@32..33 ")" | ||
28 | WHITESPACE@33..34 " " | ||
29 | BLOCK_EXPR@34..36 | ||
30 | L_CURLY@34..35 "{" | ||
31 | R_CURLY@35..36 "}" | ||
32 | WHITESPACE@36..37 "\n" | ||
33 | FN@37..54 | ||
34 | CONST_KW@37..42 "const" | ||
35 | WHITESPACE@42..43 " " | ||
36 | FN_KW@43..45 "fn" | ||
37 | WHITESPACE@45..46 " " | ||
38 | NAME@46..49 | ||
39 | IDENT@46..49 "foo" | ||
40 | PARAM_LIST@49..51 | ||
41 | L_PAREN@49..50 "(" | ||
42 | R_PAREN@50..51 ")" | ||
43 | WHITESPACE@51..52 " " | ||
44 | BLOCK_EXPR@52..54 | ||
45 | L_CURLY@52..53 "{" | ||
46 | R_CURLY@53..54 "}" | ||
47 | WHITESPACE@54..55 "\n" | ||
48 | FN@55..79 | ||
49 | CONST_KW@55..60 "const" | ||
50 | WHITESPACE@60..61 " " | ||
51 | UNSAFE_KW@61..67 "unsafe" | ||
52 | WHITESPACE@67..68 " " | ||
53 | FN_KW@68..70 "fn" | ||
54 | WHITESPACE@70..71 " " | ||
55 | NAME@71..74 | ||
56 | IDENT@71..74 "foo" | ||
57 | PARAM_LIST@74..76 | ||
58 | L_PAREN@74..75 "(" | ||
59 | R_PAREN@75..76 ")" | ||
60 | WHITESPACE@76..77 " " | ||
61 | BLOCK_EXPR@77..79 | ||
62 | L_CURLY@77..78 "{" | ||
63 | R_CURLY@78..79 "}" | ||
64 | WHITESPACE@79..80 "\n" | ||
65 | FN@80..109 | ||
66 | UNSAFE_KW@80..86 "unsafe" | ||
67 | WHITESPACE@86..87 " " | ||
68 | ABI@87..97 | ||
69 | EXTERN_KW@87..93 "extern" | ||
70 | WHITESPACE@93..94 " " | ||
71 | STRING@94..97 "\"C\"" | ||
72 | WHITESPACE@97..98 " " | ||
73 | FN_KW@98..100 "fn" | ||
74 | WHITESPACE@100..101 " " | ||
75 | NAME@101..104 | ||
76 | IDENT@101..104 "foo" | ||
77 | PARAM_LIST@104..106 | ||
78 | L_PAREN@104..105 "(" | ||
79 | R_PAREN@105..106 ")" | ||
80 | WHITESPACE@106..107 " " | ||
81 | BLOCK_EXPR@107..109 | ||
82 | L_CURLY@107..108 "{" | ||
83 | R_CURLY@108..109 "}" | ||
84 | WHITESPACE@109..110 "\n" | ||
85 | FN@110..128 | ||
86 | UNSAFE_KW@110..116 "unsafe" | ||
87 | WHITESPACE@116..117 " " | ||
88 | FN_KW@117..119 "fn" | ||
89 | WHITESPACE@119..120 " " | ||
90 | NAME@120..123 | ||
91 | IDENT@120..123 "foo" | ||
92 | PARAM_LIST@123..125 | ||
93 | L_PAREN@123..124 "(" | ||
94 | R_PAREN@124..125 ")" | ||
95 | WHITESPACE@125..126 " " | ||
96 | BLOCK_EXPR@126..128 | ||
97 | L_CURLY@126..127 "{" | ||
98 | R_CURLY@127..128 "}" | ||
99 | WHITESPACE@128..129 "\n" | ||
100 | FN@129..153 | ||
101 | ASYNC_KW@129..134 "async" | ||
102 | WHITESPACE@134..135 " " | ||
103 | UNSAFE_KW@135..141 "unsafe" | ||
104 | WHITESPACE@141..142 " " | ||
105 | FN_KW@142..144 "fn" | ||
106 | WHITESPACE@144..145 " " | ||
107 | NAME@145..148 | ||
108 | IDENT@145..148 "foo" | ||
109 | PARAM_LIST@148..150 | ||
110 | L_PAREN@148..149 "(" | ||
111 | R_PAREN@149..150 ")" | ||
112 | WHITESPACE@150..151 " " | ||
113 | BLOCK_EXPR@151..153 | ||
114 | L_CURLY@151..152 "{" | ||
115 | R_CURLY@152..153 "}" | ||
116 | WHITESPACE@153..154 "\n" | ||
117 | FN@154..178 | ||
118 | CONST_KW@154..159 "const" | ||
119 | WHITESPACE@159..160 " " | ||
120 | UNSAFE_KW@160..166 "unsafe" | ||
121 | WHITESPACE@166..167 " " | ||
122 | FN_KW@167..169 "fn" | ||
123 | WHITESPACE@169..170 " " | ||
124 | NAME@170..173 | ||
125 | IDENT@170..173 "bar" | ||
126 | PARAM_LIST@173..175 | ||
127 | L_PAREN@173..174 "(" | ||
128 | R_PAREN@174..175 ")" | ||
129 | WHITESPACE@175..176 " " | ||
130 | BLOCK_EXPR@176..178 | ||
131 | L_CURLY@176..177 "{" | ||
132 | R_CURLY@177..178 "}" | ||
133 | WHITESPACE@178..180 "\n\n" | ||
134 | TRAIT@180..197 | ||
135 | UNSAFE_KW@180..186 "unsafe" | ||
136 | WHITESPACE@186..187 " " | ||
137 | TRAIT_KW@187..192 "trait" | ||
138 | WHITESPACE@192..193 " " | ||
139 | NAME@193..194 | ||
140 | IDENT@193..194 "T" | ||
141 | WHITESPACE@194..195 " " | ||
142 | ASSOC_ITEM_LIST@195..197 | ||
143 | L_CURLY@195..196 "{" | ||
144 | R_CURLY@196..197 "}" | ||
145 | WHITESPACE@197..198 "\n" | ||
146 | TRAIT@198..213 | ||
147 | AUTO_KW@198..202 "auto" | ||
148 | WHITESPACE@202..203 " " | ||
149 | TRAIT_KW@203..208 "trait" | ||
150 | WHITESPACE@208..209 " " | ||
151 | NAME@209..210 | ||
152 | IDENT@209..210 "T" | ||
153 | WHITESPACE@210..211 " " | ||
154 | ASSOC_ITEM_LIST@211..213 | ||
155 | L_CURLY@211..212 "{" | ||
156 | R_CURLY@212..213 "}" | ||
157 | WHITESPACE@213..214 "\n" | ||
158 | TRAIT@214..236 | ||
159 | UNSAFE_KW@214..220 "unsafe" | ||
160 | WHITESPACE@220..221 " " | ||
161 | AUTO_KW@221..225 "auto" | ||
162 | WHITESPACE@225..226 " " | ||
163 | TRAIT_KW@226..231 "trait" | ||
164 | WHITESPACE@231..232 " " | ||
165 | NAME@232..233 | ||
166 | IDENT@232..233 "T" | ||
167 | WHITESPACE@233..234 " " | ||
168 | ASSOC_ITEM_LIST@234..236 | ||
169 | L_CURLY@234..235 "{" | ||
170 | R_CURLY@235..236 "}" | ||
171 | WHITESPACE@236..238 "\n\n" | ||
172 | IMPL@238..256 | ||
173 | UNSAFE_KW@238..244 "unsafe" | ||
174 | WHITESPACE@244..245 " " | ||
175 | IMPL_KW@245..249 "impl" | ||
176 | WHITESPACE@249..250 " " | ||
177 | PATH_TYPE@250..253 | ||
178 | PATH@250..253 | ||
179 | PATH_SEGMENT@250..253 | ||
180 | NAME_REF@250..253 | ||
181 | IDENT@250..253 "Foo" | ||
182 | WHITESPACE@253..254 " " | ||
183 | ASSOC_ITEM_LIST@254..256 | ||
184 | L_CURLY@254..255 "{" | ||
185 | R_CURLY@255..256 "}" | ||
186 | WHITESPACE@256..257 "\n" | ||
187 | IMPL@257..276 | ||
188 | DEFAULT_KW@257..264 "default" | ||
189 | WHITESPACE@264..265 " " | ||
190 | IMPL_KW@265..269 "impl" | ||
191 | WHITESPACE@269..270 " " | ||
192 | PATH_TYPE@270..273 | ||
193 | PATH@270..273 | ||
194 | PATH_SEGMENT@270..273 | ||
195 | NAME_REF@270..273 | ||
196 | IDENT@270..273 "Foo" | ||
197 | WHITESPACE@273..274 " " | ||
198 | ASSOC_ITEM_LIST@274..276 | ||
199 | L_CURLY@274..275 "{" | ||
200 | R_CURLY@275..276 "}" | ||
201 | WHITESPACE@276..277 "\n" | ||
202 | IMPL@277..303 | ||
203 | UNSAFE_KW@277..283 "unsafe" | ||
204 | WHITESPACE@283..284 " " | ||
205 | DEFAULT_KW@284..291 "default" | ||
206 | WHITESPACE@291..292 " " | ||
207 | IMPL_KW@292..296 "impl" | ||
208 | WHITESPACE@296..297 " " | ||
209 | PATH_TYPE@297..300 | ||
210 | PATH@297..300 | ||
211 | PATH_SEGMENT@297..300 | ||
212 | NAME_REF@297..300 | ||
213 | IDENT@297..300 "Foo" | ||
214 | WHITESPACE@300..301 " " | ||
215 | ASSOC_ITEM_LIST@301..303 | ||
216 | L_CURLY@301..302 "{" | ||
217 | R_CURLY@302..303 "}" | ||
218 | WHITESPACE@303..304 "\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 @@ | |||
1 | async fn foo() {} | ||
2 | extern fn foo() {} | ||
3 | const fn foo() {} | ||
4 | const unsafe fn foo() {} | ||
5 | unsafe extern "C" fn foo() {} | ||
6 | unsafe fn foo() {} | ||
7 | async unsafe fn foo() {} | ||
8 | const unsafe fn bar() {} | ||
9 | |||
10 | unsafe trait T {} | ||
11 | auto trait T {} | ||
12 | unsafe auto trait T {} | ||
13 | |||
14 | unsafe impl Foo {} | ||
15 | default impl Foo {} | ||
16 | unsafe 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 | ||
140 | impl 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 | |||
144 | impl TextEditBuilder { | 149 | impl 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(¶ms.id, ':').unwrap(); | 864 | let (id_string, index) = split_once(¶ms.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. |
2 | use std::{cell::Cell, fmt, time::Instant}; | 2 | use std::time::Instant; |
3 | 3 | ||
4 | mod macros; | 4 | mod 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 | ||
11 | pub 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 | |||
16 | impl<I> SepBy for I | ||
17 | where | ||
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 | |||
26 | pub struct SepByBuilder<'a, I> { | ||
27 | sep: &'a str, | ||
28 | prefix: &'a str, | ||
29 | suffix: &'a str, | ||
30 | iter: Cell<Option<I>>, | ||
31 | } | ||
32 | |||
33 | impl<'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 | |||
54 | impl<I> fmt::Display for SepByBuilder<'_, I> | ||
55 | where | ||
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] |
75 | pub fn timeit(label: &'static str) -> impl Drop { | 12 | pub fn timeit(label: &'static str) -> impl Drop { |
76 | struct Guard { | 13 | struct Guard { |