Skip to content

Commit 3d6fd62

Browse files
bors[bot]matklad
andauthored
Merge #5751
5751: Better recovery in `use foo::;` r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 018a6ca + ef462ed commit 3d6fd62

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

crates/ide/src/completion/completion_context.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ use syntax::{
99
SyntaxKind::*,
1010
SyntaxNode, SyntaxToken, TextRange, TextSize,
1111
};
12+
use test_utils::mark;
1213
use text_edit::Indel;
1314

14-
use super::patterns::{
15-
has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent,
16-
has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling,
17-
has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev,
15+
use crate::{
16+
call_info::ActiveParameter,
17+
completion::{
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,
1826
};
19-
use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition};
20-
use test_utils::mark;
2127

2228
/// `CompletionContext` is created early during completion to figure out, where
2329
/// exactly is the cursor, syntax-wise.

crates/parser/src/grammar/items.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,20 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
2727
}
2828

2929
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,
31-
CRATE_KW, USE_KW, MACRO_KW
30+
FN_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![;],
3244
];
3345

3446
pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {

crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ [email protected]
22
33
44
5-
USE_TREE@4..12
6-
PATH@4..12
5+
USE_TREE@4..11
6+
PATH@4..11
77
88
99
1010
11-
12-
11+
1312
1413
error 11..11: expected identifier
15-
error 12..12: expected SEMICOLON

0 commit comments

Comments
 (0)