Merge #5751
5751: Better recovery in `use foo::;`
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
3d6fd620e8
3 changed files with 29 additions and 13 deletions
|
|
@ -9,15 +9,21 @@ use syntax::{
|
|||
SyntaxKind::*,
|
||||
SyntaxNode, SyntaxToken, TextRange, TextSize,
|
||||
};
|
||||
use test_utils::mark;
|
||||
use text_edit::Indel;
|
||||
|
||||
use super::patterns::{
|
||||
has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent,
|
||||
has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling,
|
||||
has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev,
|
||||
use crate::{
|
||||
call_info::ActiveParameter,
|
||||
completion::{
|
||||
patterns::{
|
||||
has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent,
|
||||
has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling,
|
||||
has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev,
|
||||
},
|
||||
CompletionConfig,
|
||||
},
|
||||
FilePosition,
|
||||
};
|
||||
use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition};
|
||||
use test_utils::mark;
|
||||
|
||||
/// `CompletionContext` is created early during completion to figure out, where
|
||||
/// exactly is the cursor, syntax-wise.
|
||||
|
|
|
|||
|
|
@ -27,8 +27,20 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
|
|||
}
|
||||
|
||||
pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![
|
||||
FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW,
|
||||
CRATE_KW, USE_KW, MACRO_KW
|
||||
FN_KW,
|
||||
STRUCT_KW,
|
||||
ENUM_KW,
|
||||
IMPL_KW,
|
||||
TRAIT_KW,
|
||||
CONST_KW,
|
||||
STATIC_KW,
|
||||
LET_KW,
|
||||
MOD_KW,
|
||||
PUB_KW,
|
||||
CRATE_KW,
|
||||
USE_KW,
|
||||
MACRO_KW,
|
||||
T![;],
|
||||
];
|
||||
|
||||
pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
|
||||
|
|
|
|||
|
|
@ -2,14 +2,12 @@ SOURCE_FILE@0..13
|
|||
USE@0..12
|
||||
USE_KW@0..3 "use"
|
||||
WHITESPACE@3..4 " "
|
||||
USE_TREE@4..12
|
||||
PATH@4..12
|
||||
USE_TREE@4..11
|
||||
PATH@4..11
|
||||
PATH@4..9
|
||||
PATH_SEGMENT@4..9
|
||||
CRATE_KW@4..9 "crate"
|
||||
COLON2@9..11 "::"
|
||||
ERROR@11..12
|
||||
SEMICOLON@11..12 ";"
|
||||
SEMICOLON@11..12 ";"
|
||||
WHITESPACE@12..13 "\n"
|
||||
error 11..11: expected identifier
|
||||
error 12..12: expected SEMICOLON
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue