diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-13 17:50:50 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-13 17:50:50 +0100 |
commit | 3d6fd620e80050d68e6da55aabad2ca780ba2323 (patch) | |
tree | 1ee2aaf3f2b3ae4901ddd03985b5d217d1521612 | |
parent | 018a6cac072767dfd630c22e6d9ce134b7bb09af (diff) | |
parent | ef462ed6af7ae8e0d30894baefe6ba1ff49aab8f (diff) |
Merge #5751
5751: Better recovery in `use foo::;`
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | crates/ide/src/completion/completion_context.rs | 18 | ||||
-rw-r--r-- | crates/parser/src/grammar/items.rs | 16 | ||||
-rw-r--r-- | crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast | 8 |
3 files changed, 29 insertions, 13 deletions
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 047ecd9d7..09440334d 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs | |||
@@ -9,15 +9,21 @@ use syntax::{ | |||
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
10 | SyntaxNode, SyntaxToken, TextRange, TextSize, | 10 | SyntaxNode, SyntaxToken, TextRange, TextSize, |
11 | }; | 11 | }; |
12 | use test_utils::mark; | ||
12 | use text_edit::Indel; | 13 | use text_edit::Indel; |
13 | 14 | ||
14 | use super::patterns::{ | 15 | use crate::{ |
15 | has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, | 16 | call_info::ActiveParameter, |
16 | has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling, | 17 | completion::{ |
17 | has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev, | 18 | patterns::{ |
19 | has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, | ||
20 | has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling, | ||
21 | has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev, | ||
22 | }, | ||
23 | CompletionConfig, | ||
24 | }, | ||
25 | FilePosition, | ||
18 | }; | 26 | }; |
19 | use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition}; | ||
20 | use test_utils::mark; | ||
21 | 27 | ||
22 | /// `CompletionContext` is created early during completion to figure out, where | 28 | /// `CompletionContext` is created early during completion to figure out, where |
23 | /// exactly is the cursor, syntax-wise. | 29 | /// exactly is the cursor, syntax-wise. |
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index b2f7cc21f..8fd8f3b80 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs | |||
@@ -27,8 +27,20 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { | |||
27 | } | 27 | } |
28 | 28 | ||
29 | pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ | 29 | pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ |
30 | FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, | 30 | FN_KW, |
31 | CRATE_KW, USE_KW, MACRO_KW | 31 | STRUCT_KW, |
32 | ENUM_KW, | ||
33 | IMPL_KW, | ||
34 | TRAIT_KW, | ||
35 | CONST_KW, | ||
36 | STATIC_KW, | ||
37 | LET_KW, | ||
38 | MOD_KW, | ||
39 | PUB_KW, | ||
40 | CRATE_KW, | ||
41 | USE_KW, | ||
42 | MACRO_KW, | ||
43 | T![;], | ||
32 | ]; | 44 | ]; |
33 | 45 | ||
34 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { | 46 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { |
diff --git a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast index 2f59d0606..e872526d9 100644 --- a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast +++ b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast | |||
@@ -2,14 +2,12 @@ [email protected] | |||
2 | [email protected] | 2 | [email protected] |
3 | [email protected] "use" | 3 | [email protected] "use" |
4 | [email protected] " " | 4 | [email protected] " " |
5 | [email protected]2 | 5 | [email protected]1 |
6 | [email protected]2 | 6 | [email protected]1 |
7 | [email protected] | 7 | [email protected] |
8 | [email protected] | 8 | [email protected] |
9 | [email protected] "crate" | 9 | [email protected] "crate" |
10 | [email protected] "::" | 10 | [email protected] "::" |
11 | [email protected] | 11 | [email protected] ";" |
12 | [email protected] ";" | ||
13 | [email protected] "\n" | 12 | [email protected] "\n" |
14 | error 11..11: expected identifier | 13 | error 11..11: expected identifier |
15 | error 12..12: expected SEMICOLON | ||