mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
commit
5e5313a7c7
9 changed files with 54 additions and 0 deletions
|
@ -25,6 +25,8 @@ fn item(p: &mut Parser) {
|
||||||
use_item::use_item(p);
|
use_item::use_item(p);
|
||||||
USE_ITEM
|
USE_ITEM
|
||||||
}
|
}
|
||||||
|
// test extern_crate
|
||||||
|
// extern crate foo;
|
||||||
EXTERN_KW if la == CRATE_KW => {
|
EXTERN_KW if la == CRATE_KW => {
|
||||||
extern_crate_item(p);
|
extern_crate_item(p);
|
||||||
EXTERN_CRATE_ITEM
|
EXTERN_CRATE_ITEM
|
||||||
|
@ -32,14 +34,20 @@ fn item(p: &mut Parser) {
|
||||||
EXTERN_KW => {
|
EXTERN_KW => {
|
||||||
abi(p);
|
abi(p);
|
||||||
match p.current() {
|
match p.current() {
|
||||||
|
// test extern_fn
|
||||||
|
// extern fn foo() {}
|
||||||
FN_KW => {
|
FN_KW => {
|
||||||
fn_item(p);
|
fn_item(p);
|
||||||
FN_ITEM
|
FN_ITEM
|
||||||
}
|
}
|
||||||
|
// test extern_block
|
||||||
|
// extern {}
|
||||||
L_CURLY => {
|
L_CURLY => {
|
||||||
extern_block(p);
|
extern_block(p);
|
||||||
EXTERN_BLOCK
|
EXTERN_BLOCK
|
||||||
}
|
}
|
||||||
|
// test extern_struct
|
||||||
|
// extern struct Foo;
|
||||||
_ => {
|
_ => {
|
||||||
item.abandon(p);
|
item.abandon(p);
|
||||||
p.error().message("expected `fn` or `{`").emit();
|
p.error().message("expected `fn` or `{`").emit();
|
||||||
|
|
1
tests/data/parser/inline/0003_extern_block.rs
Normal file
1
tests/data/parser/inline/0003_extern_block.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
extern {}
|
8
tests/data/parser/inline/0003_extern_block.txt
Normal file
8
tests/data/parser/inline/0003_extern_block.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
FILE@[0; 10)
|
||||||
|
EXTERN_BLOCK@[0; 10)
|
||||||
|
ABI@[0; 7)
|
||||||
|
EXTERN_KW@[0; 6)
|
||||||
|
WHITESPACE@[6; 7)
|
||||||
|
L_CURLY@[7; 8)
|
||||||
|
R_CURLY@[8; 9)
|
||||||
|
WHITESPACE@[9; 10)
|
1
tests/data/parser/inline/0004_extern_fn.rs
Normal file
1
tests/data/parser/inline/0004_extern_fn.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
extern fn foo() {}
|
14
tests/data/parser/inline/0004_extern_fn.txt
Normal file
14
tests/data/parser/inline/0004_extern_fn.txt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
FILE@[0; 19)
|
||||||
|
FN_ITEM@[0; 19)
|
||||||
|
ABI@[0; 7)
|
||||||
|
EXTERN_KW@[0; 6)
|
||||||
|
WHITESPACE@[6; 7)
|
||||||
|
FN_KW@[7; 9)
|
||||||
|
WHITESPACE@[9; 10)
|
||||||
|
IDENT@[10; 13) "foo"
|
||||||
|
L_PAREN@[13; 14)
|
||||||
|
R_PAREN@[14; 15)
|
||||||
|
WHITESPACE@[15; 16)
|
||||||
|
L_CURLY@[16; 17)
|
||||||
|
R_CURLY@[17; 18)
|
||||||
|
WHITESPACE@[18; 19)
|
1
tests/data/parser/inline/0005_extern_crate.rs
Normal file
1
tests/data/parser/inline/0005_extern_crate.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
extern crate foo;
|
9
tests/data/parser/inline/0005_extern_crate.txt
Normal file
9
tests/data/parser/inline/0005_extern_crate.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
FILE@[0; 18)
|
||||||
|
EXTERN_CRATE_ITEM@[0; 18)
|
||||||
|
EXTERN_KW@[0; 6)
|
||||||
|
WHITESPACE@[6; 7)
|
||||||
|
CRATE_KW@[7; 12)
|
||||||
|
WHITESPACE@[12; 13)
|
||||||
|
IDENT@[13; 16) "foo"
|
||||||
|
SEMI@[16; 17)
|
||||||
|
WHITESPACE@[17; 18)
|
1
tests/data/parser/inline/0006_extern_struct.rs
Normal file
1
tests/data/parser/inline/0006_extern_struct.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
extern struct Foo;
|
11
tests/data/parser/inline/0006_extern_struct.txt
Normal file
11
tests/data/parser/inline/0006_extern_struct.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FILE@[0; 19)
|
||||||
|
ABI@[0; 7)
|
||||||
|
EXTERN_KW@[0; 6)
|
||||||
|
WHITESPACE@[6; 7)
|
||||||
|
err: `expected `fn` or `{``
|
||||||
|
STRUCT_ITEM@[7; 19)
|
||||||
|
STRUCT_KW@[7; 13)
|
||||||
|
WHITESPACE@[13; 14)
|
||||||
|
IDENT@[14; 17) "Foo"
|
||||||
|
SEMI@[17; 18)
|
||||||
|
WHITESPACE@[18; 19)
|
Loading…
Reference in a new issue