mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Parse unsafe extern block
This commit is contained in:
parent
cadf0e9fb6
commit
8a11da40a7
3 changed files with 25 additions and 3 deletions
|
@ -112,7 +112,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
has_mods = true;
|
||||
}
|
||||
|
||||
if p.at(T![extern]) {
|
||||
if p.at(T![extern]) && p.nth(1) != T!['{'] && (p.nth(1) != STRING || p.nth(2) != T!['{']) {
|
||||
has_mods = true;
|
||||
abi(p);
|
||||
}
|
||||
|
@ -181,6 +181,14 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
T![type] => {
|
||||
type_alias(p, m);
|
||||
}
|
||||
|
||||
// unsafe extern "C" {}
|
||||
T![extern] => {
|
||||
abi(p);
|
||||
extern_item_list(p);
|
||||
m.complete(p, EXTERN_BLOCK);
|
||||
}
|
||||
|
||||
_ => {
|
||||
if !has_visibility && !has_mods {
|
||||
return Err(m);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SOURCE_FILE@0..304
|
||||
SOURCE_FILE@0..328
|
||||
FN@0..17
|
||||
ASYNC_KW@0..5 "async"
|
||||
WHITESPACE@5..6 " "
|
||||
|
@ -215,4 +215,16 @@ SOURCE_FILE@0..304
|
|||
ASSOC_ITEM_LIST@301..303
|
||||
L_CURLY@301..302 "{"
|
||||
R_CURLY@302..303 "}"
|
||||
WHITESPACE@303..304 "\n"
|
||||
WHITESPACE@303..305 "\n\n"
|
||||
EXTERN_BLOCK@305..327
|
||||
UNSAFE_KW@305..311 "unsafe"
|
||||
WHITESPACE@311..312 " "
|
||||
ABI@312..324
|
||||
EXTERN_KW@312..318 "extern"
|
||||
WHITESPACE@318..319 " "
|
||||
STRING@319..324 "\"C++\""
|
||||
WHITESPACE@324..325 " "
|
||||
EXTERN_ITEM_LIST@325..327
|
||||
L_CURLY@325..326 "{"
|
||||
R_CURLY@326..327 "}"
|
||||
WHITESPACE@327..328 "\n"
|
||||
|
|
|
@ -14,3 +14,5 @@ unsafe auto trait T {}
|
|||
unsafe impl Foo {}
|
||||
default impl Foo {}
|
||||
unsafe default impl Foo {}
|
||||
|
||||
unsafe extern "C++" {}
|
||||
|
|
Loading…
Reference in a new issue