mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 00:47:18 +00:00
Merge #5721
5721: Cleanup parser modifiers tests
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
441fbe3b0a
61 changed files with 618 additions and 669 deletions
|
@ -110,7 +110,7 @@ pub(crate) mod fragments {
|
|||
}
|
||||
|
||||
pub(crate) fn item(p: &mut Parser) {
|
||||
items::item_or_macro(p, true, items::ItemFlavor::Mod)
|
||||
items::item_or_macro(p, true)
|
||||
}
|
||||
|
||||
pub(crate) fn macro_items(p: &mut Parser) {
|
||||
|
|
|
@ -73,7 +73,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
|
|||
|
||||
// test block_items
|
||||
// fn a() { fn b() {} }
|
||||
let m = match items::maybe_item(p, m, items::ItemFlavor::Mod) {
|
||||
let m = match items::maybe_item(p, m) {
|
||||
Ok(()) => return,
|
||||
Err(m) => m,
|
||||
};
|
||||
|
|
|
@ -22,24 +22,19 @@ use super::*;
|
|||
pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
|
||||
attributes::inner_attributes(p);
|
||||
while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) {
|
||||
item_or_macro(p, stop_on_r_curly, ItemFlavor::Mod)
|
||||
item_or_macro(p, stop_on_r_curly)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) enum ItemFlavor {
|
||||
Mod,
|
||||
Trait,
|
||||
}
|
||||
|
||||
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
|
||||
];
|
||||
|
||||
pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) {
|
||||
pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
|
||||
let m = p.start();
|
||||
attributes::outer_attributes(p);
|
||||
let m = match maybe_item(p, m, flavor) {
|
||||
let m = match maybe_item(p, m) {
|
||||
Ok(()) => {
|
||||
if p.at(T![;]) {
|
||||
p.err_and_bump(
|
||||
|
@ -76,7 +71,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Result<(), Marker> {
|
||||
pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
||||
// test_err pub_expr
|
||||
// fn foo() { pub 92; }
|
||||
let has_visibility = opt_visibility(p);
|
||||
|
@ -114,38 +109,31 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
has_mods = true;
|
||||
}
|
||||
|
||||
if p.at(IDENT)
|
||||
&& p.at_contextual_kw("default")
|
||||
&& (match p.nth(1) {
|
||||
T![impl] => true,
|
||||
// test default_item
|
||||
// default impl T for Foo {}
|
||||
if p.at(IDENT) && p.at_contextual_kw("default") {
|
||||
match p.nth(1) {
|
||||
T![fn] | T![type] | T![const] | T![impl] => {
|
||||
p.bump_remap(T![default]);
|
||||
has_mods = true;
|
||||
}
|
||||
T![unsafe] => {
|
||||
// test default_unsafe_impl
|
||||
// default unsafe impl Foo {}
|
||||
|
||||
// test default_unsafe_fn
|
||||
// impl T for Foo {
|
||||
// test default_unsafe_item
|
||||
// default unsafe impl T for Foo {
|
||||
// default unsafe fn foo() {}
|
||||
// }
|
||||
if p.nth(2) == T![impl] || p.nth(2) == T![fn] {
|
||||
if matches!(p.nth(2), T![impl] | T![fn]) {
|
||||
p.bump_remap(T![default]);
|
||||
p.bump(T![unsafe]);
|
||||
has_mods = true;
|
||||
}
|
||||
false
|
||||
}
|
||||
T![fn] | T![type] | T![const] => {
|
||||
if let ItemFlavor::Mod = flavor {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
})
|
||||
{
|
||||
p.bump_remap(T![default]);
|
||||
has_mods = true;
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
// test existential_type
|
||||
// existential type Foo: Fn() -> usize;
|
||||
if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] {
|
||||
p.bump_remap(T![existential]);
|
||||
has_mods = true;
|
||||
|
@ -153,79 +141,31 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
|
||||
// items
|
||||
match p.current() {
|
||||
// test async_fn
|
||||
// async fn foo() {}
|
||||
|
||||
// test extern_fn
|
||||
// extern fn foo() {}
|
||||
|
||||
// test const_fn
|
||||
// const fn foo() {}
|
||||
|
||||
// test const_unsafe_fn
|
||||
// const unsafe fn foo() {}
|
||||
|
||||
// test unsafe_extern_fn
|
||||
// unsafe extern "C" fn foo() {}
|
||||
|
||||
// test unsafe_fn
|
||||
// unsafe fn foo() {}
|
||||
|
||||
// test combined_fns
|
||||
// async unsafe fn foo() {}
|
||||
// const unsafe fn bar() {}
|
||||
|
||||
// test_err wrong_order_fns
|
||||
// unsafe async fn foo() {}
|
||||
// unsafe const fn bar() {}
|
||||
// test fn
|
||||
// fn foo() {}
|
||||
T![fn] => {
|
||||
fn_def(p);
|
||||
m.complete(p, FN);
|
||||
}
|
||||
|
||||
// test unsafe_trait
|
||||
// unsafe trait T {}
|
||||
|
||||
// test auto_trait
|
||||
// auto trait T {}
|
||||
|
||||
// test unsafe_auto_trait
|
||||
// unsafe auto trait T {}
|
||||
// test trait
|
||||
// trait T {}
|
||||
T![trait] => {
|
||||
traits::trait_def(p);
|
||||
m.complete(p, TRAIT);
|
||||
}
|
||||
|
||||
// test unsafe_impl
|
||||
// unsafe impl Foo {}
|
||||
|
||||
// test default_impl
|
||||
// default impl Foo {}
|
||||
|
||||
// test_err default_fn_type
|
||||
// trait T {
|
||||
// default type T = Bar;
|
||||
// default fn foo() {}
|
||||
// }
|
||||
|
||||
// test default_fn_type
|
||||
// impl T for Foo {
|
||||
// default type T = Bar;
|
||||
// default fn foo() {}
|
||||
// }
|
||||
T![const] => {
|
||||
consts::const_def(p, m);
|
||||
}
|
||||
|
||||
// test unsafe_default_impl
|
||||
// unsafe default impl Foo {}
|
||||
// test impl
|
||||
// impl T for S {}
|
||||
T![impl] => {
|
||||
traits::impl_def(p);
|
||||
m.complete(p, IMPL);
|
||||
}
|
||||
|
||||
// test existential_type
|
||||
// existential type Foo: Fn() -> usize;
|
||||
T![type] => {
|
||||
type_def(p, m);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ pub(crate) fn trait_item_list(p: &mut Parser) {
|
|||
error_block(p, "expected an item");
|
||||
continue;
|
||||
}
|
||||
item_or_macro(p, true, ItemFlavor::Trait);
|
||||
item_or_macro(p, true);
|
||||
}
|
||||
p.expect(T!['}']);
|
||||
m.complete(p, ASSOC_ITEM_LIST);
|
||||
|
@ -104,7 +104,7 @@ pub(crate) fn impl_item_list(p: &mut Parser) {
|
|||
error_block(p, "expected an item");
|
||||
continue;
|
||||
}
|
||||
item_or_macro(p, true, ItemFlavor::Mod);
|
||||
item_or_macro(p, true);
|
||||
}
|
||||
p.expect(T!['}']);
|
||||
m.complete(p, ASSOC_ITEM_LIST);
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
SOURCE_FILE@0..39
|
||||
TRAIT@0..38
|
||||
TRAIT_KW@0..5 "trait"
|
||||
WHITESPACE@5..6 " "
|
||||
NAME@6..7
|
||||
IDENT@6..7 "T"
|
||||
WHITESPACE@7..8 " "
|
||||
ASSOC_ITEM_LIST@8..38
|
||||
L_CURLY@8..9 "{"
|
||||
WHITESPACE@9..12 "\n "
|
||||
MACRO_CALL@12..19
|
||||
PATH@12..19
|
||||
PATH_SEGMENT@12..19
|
||||
NAME_REF@12..19
|
||||
IDENT@12..19 "default"
|
||||
WHITESPACE@19..20 " "
|
||||
CONST@20..36
|
||||
CONST_KW@20..25 "const"
|
||||
WHITESPACE@25..26 " "
|
||||
NAME@26..27
|
||||
IDENT@26..27 "f"
|
||||
COLON@27..28 ":"
|
||||
WHITESPACE@28..29 " "
|
||||
PATH_TYPE@29..31
|
||||
PATH@29..31
|
||||
PATH_SEGMENT@29..31
|
||||
NAME_REF@29..31
|
||||
IDENT@29..31 "u8"
|
||||
WHITESPACE@31..32 " "
|
||||
EQ@32..33 "="
|
||||
WHITESPACE@33..34 " "
|
||||
LITERAL@34..35
|
||||
INT_NUMBER@34..35 "0"
|
||||
SEMICOLON@35..36 ";"
|
||||
WHITESPACE@36..37 "\n"
|
||||
R_CURLY@37..38 "}"
|
||||
WHITESPACE@38..39 "\n"
|
||||
error 19..19: expected BANG
|
||||
error 19..19: expected `{`, `[`, `(`
|
||||
error 19..19: expected SEMICOLON
|
|
@ -1,3 +0,0 @@
|
|||
trait T {
|
||||
default const f: u8 = 0;
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
SOURCE_FILE@0..62
|
||||
TRAIT@0..61
|
||||
TRAIT_KW@0..5 "trait"
|
||||
WHITESPACE@5..6 " "
|
||||
NAME@6..7
|
||||
IDENT@6..7 "T"
|
||||
WHITESPACE@7..8 " "
|
||||
ASSOC_ITEM_LIST@8..61
|
||||
L_CURLY@8..9 "{"
|
||||
WHITESPACE@9..14 "\n "
|
||||
MACRO_CALL@14..21
|
||||
PATH@14..21
|
||||
PATH_SEGMENT@14..21
|
||||
NAME_REF@14..21
|
||||
IDENT@14..21 "default"
|
||||
WHITESPACE@21..22 " "
|
||||
TYPE_ALIAS@22..35
|
||||
TYPE_KW@22..26 "type"
|
||||
WHITESPACE@26..27 " "
|
||||
NAME@27..28
|
||||
IDENT@27..28 "T"
|
||||
WHITESPACE@28..29 " "
|
||||
EQ@29..30 "="
|
||||
WHITESPACE@30..31 " "
|
||||
PATH_TYPE@31..34
|
||||
PATH@31..34
|
||||
PATH_SEGMENT@31..34
|
||||
NAME_REF@31..34
|
||||
IDENT@31..34 "Bar"
|
||||
SEMICOLON@34..35 ";"
|
||||
WHITESPACE@35..40 "\n "
|
||||
MACRO_CALL@40..47
|
||||
PATH@40..47
|
||||
PATH_SEGMENT@40..47
|
||||
NAME_REF@40..47
|
||||
IDENT@40..47 "default"
|
||||
WHITESPACE@47..48 " "
|
||||
FN@48..59
|
||||
FN_KW@48..50 "fn"
|
||||
WHITESPACE@50..51 " "
|
||||
NAME@51..54
|
||||
IDENT@51..54 "foo"
|
||||
PARAM_LIST@54..56
|
||||
L_PAREN@54..55 "("
|
||||
R_PAREN@55..56 ")"
|
||||
WHITESPACE@56..57 " "
|
||||
BLOCK_EXPR@57..59
|
||||
L_CURLY@57..58 "{"
|
||||
R_CURLY@58..59 "}"
|
||||
WHITESPACE@59..60 "\n"
|
||||
R_CURLY@60..61 "}"
|
||||
WHITESPACE@61..62 "\n"
|
||||
error 21..21: expected BANG
|
||||
error 21..21: expected `{`, `[`, `(`
|
||||
error 21..21: expected SEMICOLON
|
||||
error 47..47: expected BANG
|
||||
error 47..47: expected `{`, `[`, `(`
|
||||
error 47..47: expected SEMICOLON
|
|
@ -1,4 +0,0 @@
|
|||
trait T {
|
||||
default type T = Bar;
|
||||
default fn foo() {}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
SOURCE_FILE@0..18
|
||||
TRAIT@0..17
|
||||
UNSAFE_KW@0..6 "unsafe"
|
||||
WHITESPACE@6..7 " "
|
||||
TRAIT_KW@7..12 "trait"
|
||||
WHITESPACE@12..13 " "
|
||||
NAME@13..14
|
||||
IDENT@13..14 "T"
|
||||
WHITESPACE@14..15 " "
|
||||
ASSOC_ITEM_LIST@15..17
|
||||
L_CURLY@15..16 "{"
|
||||
R_CURLY@16..17 "}"
|
||||
WHITESPACE@17..18 "\n"
|
|
@ -1 +0,0 @@
|
|||
unsafe trait T {}
|
|
@ -1,21 +0,0 @@
|
|||
SOURCE_FILE@0..30
|
||||
FN@0..29
|
||||
UNSAFE_KW@0..6 "unsafe"
|
||||
WHITESPACE@6..7 " "
|
||||
ABI@7..17
|
||||
EXTERN_KW@7..13 "extern"
|
||||
WHITESPACE@13..14 " "
|
||||
STRING@14..17 "\"C\""
|
||||
WHITESPACE@17..18 " "
|
||||
FN_KW@18..20 "fn"
|
||||
WHITESPACE@20..21 " "
|
||||
NAME@21..24
|
||||
IDENT@21..24 "foo"
|
||||
PARAM_LIST@24..26
|
||||
L_PAREN@24..25 "("
|
||||
R_PAREN@25..26 ")"
|
||||
WHITESPACE@26..27 " "
|
||||
BLOCK_EXPR@27..29
|
||||
L_CURLY@27..28 "{"
|
||||
R_CURLY@28..29 "}"
|
||||
WHITESPACE@29..30 "\n"
|
|
@ -1 +0,0 @@
|
|||
unsafe extern "C" fn foo() {}
|
|
@ -1,18 +0,0 @@
|
|||
SOURCE_FILE@0..27
|
||||
IMPL@0..26
|
||||
UNSAFE_KW@0..6 "unsafe"
|
||||
WHITESPACE@6..7 " "
|
||||
DEFAULT_KW@7..14 "default"
|
||||
WHITESPACE@14..15 " "
|
||||
IMPL_KW@15..19 "impl"
|
||||
WHITESPACE@19..20 " "
|
||||
PATH_TYPE@20..23
|
||||
PATH@20..23
|
||||
PATH_SEGMENT@20..23
|
||||
NAME_REF@20..23
|
||||
IDENT@20..23 "Foo"
|
||||
WHITESPACE@23..24 " "
|
||||
ASSOC_ITEM_LIST@24..26
|
||||
L_CURLY@24..25 "{"
|
||||
R_CURLY@25..26 "}"
|
||||
WHITESPACE@26..27 "\n"
|
|
@ -1 +0,0 @@
|
|||
unsafe default impl Foo {}
|
|
@ -1,16 +0,0 @@
|
|||
SOURCE_FILE@0..18
|
||||
FN@0..17
|
||||
CONST_KW@0..5 "const"
|
||||
WHITESPACE@5..6 " "
|
||||
FN_KW@6..8 "fn"
|
||||
WHITESPACE@8..9 " "
|
||||
NAME@9..12
|
||||
IDENT@9..12 "foo"
|
||||
PARAM_LIST@12..14
|
||||
L_PAREN@12..13 "("
|
||||
R_PAREN@13..14 ")"
|
||||
WHITESPACE@14..15 " "
|
||||
BLOCK_EXPR@15..17
|
||||
L_CURLY@15..16 "{"
|
||||
R_CURLY@16..17 "}"
|
||||
WHITESPACE@17..18 "\n"
|
|
@ -1 +0,0 @@
|
|||
const fn foo() {}
|
|
@ -1,16 +0,0 @@
|
|||
SOURCE_FILE@0..19
|
||||
IMPL@0..18
|
||||
UNSAFE_KW@0..6 "unsafe"
|
||||
WHITESPACE@6..7 " "
|
||||
IMPL_KW@7..11 "impl"
|
||||
WHITESPACE@11..12 " "
|
||||
PATH_TYPE@12..15
|
||||
PATH@12..15
|
||||
PATH_SEGMENT@12..15
|
||||
NAME_REF@12..15
|
||||
IDENT@12..15 "Foo"
|
||||
WHITESPACE@15..16 " "
|
||||
ASSOC_ITEM_LIST@16..18
|
||||
L_CURLY@16..17 "{"
|
||||
R_CURLY@17..18 "}"
|
||||
WHITESPACE@18..19 "\n"
|
|
@ -1 +0,0 @@
|
|||
unsafe impl Foo {}
|
|
@ -1,17 +0,0 @@
|
|||
SOURCE_FILE@0..19
|
||||
FN@0..18
|
||||
ABI@0..6
|
||||
EXTERN_KW@0..6 "extern"
|
||||
WHITESPACE@6..7 " "
|
||||
FN_KW@7..9 "fn"
|
||||
WHITESPACE@9..10 " "
|
||||
NAME@10..13
|
||||
IDENT@10..13 "foo"
|
||||
PARAM_LIST@13..15
|
||||
L_PAREN@13..14 "("
|
||||
R_PAREN@14..15 ")"
|
||||
WHITESPACE@15..16 " "
|
||||
BLOCK_EXPR@16..18
|
||||
L_CURLY@16..17 "{"
|
||||
R_CURLY@17..18 "}"
|
||||
WHITESPACE@18..19 "\n"
|
|
@ -1 +0,0 @@
|
|||
extern fn foo() {}
|
|
@ -1,13 +0,0 @@
|
|||
SOURCE_FILE@0..16
|
||||
TRAIT@0..15
|
||||
AUTO_KW@0..4 "auto"
|
||||
WHITESPACE@4..5 " "
|
||||
TRAIT_KW@5..10 "trait"
|
||||
WHITESPACE@10..11 " "
|
||||
NAME@11..12
|
||||
IDENT@11..12 "T"
|
||||
WHITESPACE@12..13 " "
|
||||
ASSOC_ITEM_LIST@13..15
|
||||
L_CURLY@13..14 "{"
|
||||
R_CURLY@14..15 "}"
|
||||
WHITESPACE@15..16 "\n"
|
|
@ -1 +0,0 @@
|
|||
auto trait T {}
|
|
@ -1,15 +0,0 @@
|
|||
SOURCE_FILE@0..23
|
||||
TRAIT@0..22
|
||||
UNSAFE_KW@0..6 "unsafe"
|
||||
WHITESPACE@6..7 " "
|
||||
AUTO_KW@7..11 "auto"
|
||||
WHITESPACE@11..12 " "
|
||||
TRAIT_KW@12..17 "trait"
|
||||
WHITESPACE@17..18 " "
|
||||
NAME@18..19
|
||||
IDENT@18..19 "T"
|
||||
WHITESPACE@19..20 " "
|
||||
ASSOC_ITEM_LIST@20..22
|
||||
L_CURLY@20..21 "{"
|
||||
R_CURLY@21..22 "}"
|
||||
WHITESPACE@22..23 "\n"
|
|
@ -1 +0,0 @@
|
|||
unsafe auto trait T {}
|
|
@ -1,16 +0,0 @@
|
|||
SOURCE_FILE@0..20
|
||||
IMPL@0..19
|
||||
DEFAULT_KW@0..7 "default"
|
||||
WHITESPACE@7..8 " "
|
||||
IMPL_KW@8..12 "impl"
|
||||
WHITESPACE@12..13 " "
|
||||
PATH_TYPE@13..16
|
||||
PATH@13..16
|
||||
PATH_SEGMENT@13..16
|
||||
NAME_REF@13..16
|
||||
IDENT@13..16 "Foo"
|
||||
WHITESPACE@16..17 " "
|
||||
ASSOC_ITEM_LIST@17..19
|
||||
L_CURLY@17..18 "{"
|
||||
R_CURLY@18..19 "}"
|
||||
WHITESPACE@19..20 "\n"
|
|
@ -1 +0,0 @@
|
|||
default impl Foo {}
|
|
@ -1,18 +0,0 @@
|
|||
SOURCE_FILE@0..25
|
||||
FN@0..24
|
||||
CONST_KW@0..5 "const"
|
||||
WHITESPACE@5..6 " "
|
||||
UNSAFE_KW@6..12 "unsafe"
|
||||
WHITESPACE@12..13 " "
|
||||
FN_KW@13..15 "fn"
|
||||
WHITESPACE@15..16 " "
|
||||
NAME@16..19
|
||||
IDENT@16..19 "foo"
|
||||
PARAM_LIST@19..21
|
||||
L_PAREN@19..20 "("
|
||||
R_PAREN@20..21 ")"
|
||||
WHITESPACE@21..22 " "
|
||||
BLOCK_EXPR@22..24
|
||||
L_CURLY@22..23 "{"
|
||||
R_CURLY@23..24 "}"
|
||||
WHITESPACE@24..25 "\n"
|
|
@ -1 +0,0 @@
|
|||
const unsafe fn foo() {}
|
|
@ -1,16 +0,0 @@
|
|||
SOURCE_FILE@0..19
|
||||
FN@0..18
|
||||
UNSAFE_KW@0..6 "unsafe"
|
||||
WHITESPACE@6..7 " "
|
||||
FN_KW@7..9 "fn"
|
||||
WHITESPACE@9..10 " "
|
||||
NAME@10..13
|
||||
IDENT@10..13 "foo"
|
||||
PARAM_LIST@13..15
|
||||
L_PAREN@13..14 "("
|
||||
R_PAREN@14..15 ")"
|
||||
WHITESPACE@15..16 " "
|
||||
BLOCK_EXPR@16..18
|
||||
L_CURLY@16..17 "{"
|
||||
R_CURLY@17..18 "}"
|
||||
WHITESPACE@18..19 "\n"
|
|
@ -1 +0,0 @@
|
|||
unsafe fn foo() {}
|
|
@ -1,16 +0,0 @@
|
|||
SOURCE_FILE@0..18
|
||||
FN@0..17
|
||||
ASYNC_KW@0..5 "async"
|
||||
WHITESPACE@5..6 " "
|
||||
FN_KW@6..8 "fn"
|
||||
WHITESPACE@8..9 " "
|
||||
NAME@9..12
|
||||
IDENT@9..12 "foo"
|
||||
PARAM_LIST@12..14
|
||||
L_PAREN@12..13 "("
|
||||
R_PAREN@13..14 ")"
|
||||
WHITESPACE@14..15 " "
|
||||
BLOCK_EXPR@15..17
|
||||
L_CURLY@15..16 "{"
|
||||
R_CURLY@16..17 "}"
|
||||
WHITESPACE@17..18 "\n"
|
|
@ -1 +0,0 @@
|
|||
async fn foo() {}
|
|
@ -1,35 +0,0 @@
|
|||
SOURCE_FILE@0..50
|
||||
FN@0..24
|
||||
ASYNC_KW@0..5 "async"
|
||||
WHITESPACE@5..6 " "
|
||||
UNSAFE_KW@6..12 "unsafe"
|
||||
WHITESPACE@12..13 " "
|
||||
FN_KW@13..15 "fn"
|
||||
WHITESPACE@15..16 " "
|
||||
NAME@16..19
|
||||
IDENT@16..19 "foo"
|
||||
PARAM_LIST@19..21
|
||||
L_PAREN@19..20 "("
|
||||
R_PAREN@20..21 ")"
|
||||
WHITESPACE@21..22 " "
|
||||
BLOCK_EXPR@22..24
|
||||
L_CURLY@22..23 "{"
|
||||
R_CURLY@23..24 "}"
|
||||
WHITESPACE@24..25 "\n"
|
||||
FN@25..49
|
||||
CONST_KW@25..30 "const"
|
||||
WHITESPACE@30..31 " "
|
||||
UNSAFE_KW@31..37 "unsafe"
|
||||
WHITESPACE@37..38 " "
|
||||
FN_KW@38..40 "fn"
|
||||
WHITESPACE@40..41 " "
|
||||
NAME@41..44
|
||||
IDENT@41..44 "bar"
|
||||
PARAM_LIST@44..46
|
||||
L_PAREN@44..45 "("
|
||||
R_PAREN@45..46 ")"
|
||||
WHITESPACE@46..47 " "
|
||||
BLOCK_EXPR@47..49
|
||||
L_CURLY@47..48 "{"
|
||||
R_CURLY@48..49 "}"
|
||||
WHITESPACE@49..50 "\n"
|
|
@ -1,2 +0,0 @@
|
|||
async unsafe fn foo() {}
|
||||
const unsafe fn bar() {}
|
|
@ -1,55 +0,0 @@
|
|||
SOURCE_FILE@0..69
|
||||
IMPL@0..68
|
||||
IMPL_KW@0..4 "impl"
|
||||
WHITESPACE@4..5 " "
|
||||
PATH_TYPE@5..6
|
||||
PATH@5..6
|
||||
PATH_SEGMENT@5..6
|
||||
NAME_REF@5..6
|
||||
IDENT@5..6 "T"
|
||||
WHITESPACE@6..7 " "
|
||||
FOR_KW@7..10 "for"
|
||||
WHITESPACE@10..11 " "
|
||||
PATH_TYPE@11..14
|
||||
PATH@11..14
|
||||
PATH_SEGMENT@11..14
|
||||
NAME_REF@11..14
|
||||
IDENT@11..14 "Foo"
|
||||
WHITESPACE@14..15 " "
|
||||
ASSOC_ITEM_LIST@15..68
|
||||
L_CURLY@15..16 "{"
|
||||
WHITESPACE@16..21 "\n "
|
||||
TYPE_ALIAS@21..42
|
||||
DEFAULT_KW@21..28 "default"
|
||||
WHITESPACE@28..29 " "
|
||||
TYPE_KW@29..33 "type"
|
||||
WHITESPACE@33..34 " "
|
||||
NAME@34..35
|
||||
IDENT@34..35 "T"
|
||||
WHITESPACE@35..36 " "
|
||||
EQ@36..37 "="
|
||||
WHITESPACE@37..38 " "
|
||||
PATH_TYPE@38..41
|
||||
PATH@38..41
|
||||
PATH_SEGMENT@38..41
|
||||
NAME_REF@38..41
|
||||
IDENT@38..41 "Bar"
|
||||
SEMICOLON@41..42 ";"
|
||||
WHITESPACE@42..47 "\n "
|
||||
FN@47..66
|
||||
DEFAULT_KW@47..54 "default"
|
||||
WHITESPACE@54..55 " "
|
||||
FN_KW@55..57 "fn"
|
||||
WHITESPACE@57..58 " "
|
||||
NAME@58..61
|
||||
IDENT@58..61 "foo"
|
||||
PARAM_LIST@61..63
|
||||
L_PAREN@61..62 "("
|
||||
R_PAREN@62..63 ")"
|
||||
WHITESPACE@63..64 " "
|
||||
BLOCK_EXPR@64..66
|
||||
L_CURLY@64..65 "{"
|
||||
R_CURLY@65..66 "}"
|
||||
WHITESPACE@66..67 "\n"
|
||||
R_CURLY@67..68 "}"
|
||||
WHITESPACE@68..69 "\n"
|
|
@ -1,4 +0,0 @@
|
|||
impl T for Foo {
|
||||
default type T = Bar;
|
||||
default fn foo() {}
|
||||
}
|
14
crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast
Normal file
14
crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast
Normal file
|
@ -0,0 +1,14 @@
|
|||
SOURCE_FILE@0..12
|
||||
FN@0..11
|
||||
FN_KW@0..2 "fn"
|
||||
WHITESPACE@2..3 " "
|
||||
NAME@3..6
|
||||
IDENT@3..6 "foo"
|
||||
PARAM_LIST@6..8
|
||||
L_PAREN@6..7 "("
|
||||
R_PAREN@7..8 ")"
|
||||
WHITESPACE@8..9 " "
|
||||
BLOCK_EXPR@9..11
|
||||
L_CURLY@9..10 "{"
|
||||
R_CURLY@10..11 "}"
|
||||
WHITESPACE@11..12 "\n"
|
1
crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs
Normal file
1
crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs
Normal file
|
@ -0,0 +1 @@
|
|||
fn foo() {}
|
22
crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast
Normal file
22
crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast
Normal file
|
@ -0,0 +1,22 @@
|
|||
SOURCE_FILE@0..16
|
||||
IMPL@0..15
|
||||
IMPL_KW@0..4 "impl"
|
||||
WHITESPACE@4..5 " "
|
||||
PATH_TYPE@5..6
|
||||
PATH@5..6
|
||||
PATH_SEGMENT@5..6
|
||||
NAME_REF@5..6
|
||||
IDENT@5..6 "T"
|
||||
WHITESPACE@6..7 " "
|
||||
FOR_KW@7..10 "for"
|
||||
WHITESPACE@10..11 " "
|
||||
PATH_TYPE@11..12
|
||||
PATH@11..12
|
||||
PATH_SEGMENT@11..12
|
||||
NAME_REF@11..12
|
||||
IDENT@11..12 "S"
|
||||
WHITESPACE@12..13 " "
|
||||
ASSOC_ITEM_LIST@13..15
|
||||
L_CURLY@13..14 "{"
|
||||
R_CURLY@14..15 "}"
|
||||
WHITESPACE@15..16 "\n"
|
1
crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs
Normal file
1
crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs
Normal file
|
@ -0,0 +1 @@
|
|||
impl T for S {}
|
11
crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast
Normal file
11
crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast
Normal file
|
@ -0,0 +1,11 @@
|
|||
SOURCE_FILE@0..11
|
||||
TRAIT@0..10
|
||||
TRAIT_KW@0..5 "trait"
|
||||
WHITESPACE@5..6 " "
|
||||
NAME@6..7
|
||||
IDENT@6..7 "T"
|
||||
WHITESPACE@7..8 " "
|
||||
ASSOC_ITEM_LIST@8..10
|
||||
L_CURLY@8..9 "{"
|
||||
R_CURLY@9..10 "}"
|
||||
WHITESPACE@10..11 "\n"
|
|
@ -0,0 +1 @@
|
|||
trait T {}
|
|
@ -1,40 +0,0 @@
|
|||
SOURCE_FILE@0..50
|
||||
IMPL@0..49
|
||||
IMPL_KW@0..4 "impl"
|
||||
WHITESPACE@4..5 " "
|
||||
PATH_TYPE@5..6
|
||||
PATH@5..6
|
||||
PATH_SEGMENT@5..6
|
||||
NAME_REF@5..6
|
||||
IDENT@5..6 "T"
|
||||
WHITESPACE@6..7 " "
|
||||
FOR_KW@7..10 "for"
|
||||
WHITESPACE@10..11 " "
|
||||
PATH_TYPE@11..14
|
||||
PATH@11..14
|
||||
PATH_SEGMENT@11..14
|
||||
NAME_REF@11..14
|
||||
IDENT@11..14 "Foo"
|
||||
WHITESPACE@14..15 " "
|
||||
ASSOC_ITEM_LIST@15..49
|
||||
L_CURLY@15..16 "{"
|
||||
WHITESPACE@16..21 "\n "
|
||||
FN@21..47
|
||||
DEFAULT_KW@21..28 "default"
|
||||
WHITESPACE@28..29 " "
|
||||
UNSAFE_KW@29..35 "unsafe"
|
||||
WHITESPACE@35..36 " "
|
||||
FN_KW@36..38 "fn"
|
||||
WHITESPACE@38..39 " "
|
||||
NAME@39..42
|
||||
IDENT@39..42 "foo"
|
||||
PARAM_LIST@42..44
|
||||
L_PAREN@42..43 "("
|
||||
R_PAREN@43..44 ")"
|
||||
WHITESPACE@44..45 " "
|
||||
BLOCK_EXPR@45..47
|
||||
L_CURLY@45..46 "{"
|
||||
R_CURLY@46..47 "}"
|
||||
WHITESPACE@47..48 "\n"
|
||||
R_CURLY@48..49 "}"
|
||||
WHITESPACE@49..50 "\n"
|
|
@ -1,18 +0,0 @@
|
|||
SOURCE_FILE@0..27
|
||||
IMPL@0..26
|
||||
DEFAULT_KW@0..7 "default"
|
||||
WHITESPACE@7..8 " "
|
||||
UNSAFE_KW@8..14 "unsafe"
|
||||
WHITESPACE@14..15 " "
|
||||
IMPL_KW@15..19 "impl"
|
||||
WHITESPACE@19..20 " "
|
||||
PATH_TYPE@20..23
|
||||
PATH@20..23
|
||||
PATH_SEGMENT@20..23
|
||||
NAME_REF@20..23
|
||||
IDENT@20..23 "Foo"
|
||||
WHITESPACE@23..24 " "
|
||||
ASSOC_ITEM_LIST@24..26
|
||||
L_CURLY@24..25 "{"
|
||||
R_CURLY@25..26 "}"
|
||||
WHITESPACE@26..27 "\n"
|
|
@ -1 +0,0 @@
|
|||
default unsafe impl Foo {}
|
|
@ -0,0 +1,44 @@
|
|||
SOURCE_FILE@0..65
|
||||
IMPL@0..64
|
||||
DEFAULT_KW@0..7 "default"
|
||||
WHITESPACE@7..8 " "
|
||||
UNSAFE_KW@8..14 "unsafe"
|
||||
WHITESPACE@14..15 " "
|
||||
IMPL_KW@15..19 "impl"
|
||||
WHITESPACE@19..20 " "
|
||||
PATH_TYPE@20..21
|
||||
PATH@20..21
|
||||
PATH_SEGMENT@20..21
|
||||
NAME_REF@20..21
|
||||
IDENT@20..21 "T"
|
||||
WHITESPACE@21..22 " "
|
||||
FOR_KW@22..25 "for"
|
||||
WHITESPACE@25..26 " "
|
||||
PATH_TYPE@26..29
|
||||
PATH@26..29
|
||||
PATH_SEGMENT@26..29
|
||||
NAME_REF@26..29
|
||||
IDENT@26..29 "Foo"
|
||||
WHITESPACE@29..30 " "
|
||||
ASSOC_ITEM_LIST@30..64
|
||||
L_CURLY@30..31 "{"
|
||||
WHITESPACE@31..36 "\n "
|
||||
FN@36..62
|
||||
DEFAULT_KW@36..43 "default"
|
||||
WHITESPACE@43..44 " "
|
||||
UNSAFE_KW@44..50 "unsafe"
|
||||
WHITESPACE@50..51 " "
|
||||
FN_KW@51..53 "fn"
|
||||
WHITESPACE@53..54 " "
|
||||
NAME@54..57
|
||||
IDENT@54..57 "foo"
|
||||
PARAM_LIST@57..59
|
||||
L_PAREN@57..58 "("
|
||||
R_PAREN@58..59 ")"
|
||||
WHITESPACE@59..60 " "
|
||||
BLOCK_EXPR@60..62
|
||||
L_CURLY@60..61 "{"
|
||||
R_CURLY@61..62 "}"
|
||||
WHITESPACE@62..63 "\n"
|
||||
R_CURLY@63..64 "}"
|
||||
WHITESPACE@64..65 "\n"
|
|
@ -1,3 +1,3 @@
|
|||
impl T for Foo {
|
||||
default unsafe impl T for Foo {
|
||||
default unsafe fn foo() {}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
SOURCE_FILE@0..26
|
||||
IMPL@0..25
|
||||
DEFAULT_KW@0..7 "default"
|
||||
WHITESPACE@7..8 " "
|
||||
IMPL_KW@8..12 "impl"
|
||||
WHITESPACE@12..13 " "
|
||||
PATH_TYPE@13..14
|
||||
PATH@13..14
|
||||
PATH_SEGMENT@13..14
|
||||
NAME_REF@13..14
|
||||
IDENT@13..14 "T"
|
||||
WHITESPACE@14..15 " "
|
||||
FOR_KW@15..18 "for"
|
||||
WHITESPACE@18..19 " "
|
||||
PATH_TYPE@19..22
|
||||
PATH@19..22
|
||||
PATH_SEGMENT@19..22
|
||||
NAME_REF@19..22
|
||||
IDENT@19..22 "Foo"
|
||||
WHITESPACE@22..23 " "
|
||||
ASSOC_ITEM_LIST@23..25
|
||||
L_CURLY@23..24 "{"
|
||||
R_CURLY@24..25 "}"
|
||||
WHITESPACE@25..26 "\n"
|
|
@ -0,0 +1 @@
|
|||
default impl T for Foo {}
|
|
@ -1,56 +0,0 @@
|
|||
SOURCE_FILE@0..71
|
||||
FN@0..19
|
||||
ABI@0..6
|
||||
EXTERN_KW@0..6 "extern"
|
||||
WHITESPACE@6..7 " "
|
||||
FN_KW@7..9 "fn"
|
||||
WHITESPACE@9..10 " "
|
||||
NAME@10..13
|
||||
IDENT@10..13 "foo"
|
||||
PARAM_LIST@13..15
|
||||
L_PAREN@13..14 "("
|
||||
R_PAREN@14..15 ")"
|
||||
WHITESPACE@15..16 " "
|
||||
BLOCK_EXPR@16..19
|
||||
L_CURLY@16..17 "{"
|
||||
WHITESPACE@17..18 "\n"
|
||||
R_CURLY@18..19 "}"
|
||||
WHITESPACE@19..21 "\n\n"
|
||||
FN@21..44
|
||||
ABI@21..31
|
||||
EXTERN_KW@21..27 "extern"
|
||||
WHITESPACE@27..28 " "
|
||||
STRING@28..31 "\"C\""
|
||||
WHITESPACE@31..32 " "
|
||||
FN_KW@32..34 "fn"
|
||||
WHITESPACE@34..35 " "
|
||||
NAME@35..38
|
||||
IDENT@35..38 "bar"
|
||||
PARAM_LIST@38..40
|
||||
L_PAREN@38..39 "("
|
||||
R_PAREN@39..40 ")"
|
||||
WHITESPACE@40..41 " "
|
||||
BLOCK_EXPR@41..44
|
||||
L_CURLY@41..42 "{"
|
||||
WHITESPACE@42..43 "\n"
|
||||
R_CURLY@43..44 "}"
|
||||
WHITESPACE@44..46 "\n\n"
|
||||
FN@46..70
|
||||
ABI@46..57
|
||||
EXTERN_KW@46..52 "extern"
|
||||
WHITESPACE@52..53 " "
|
||||
RAW_STRING@53..57 "r\"D\""
|
||||
WHITESPACE@57..58 " "
|
||||
FN_KW@58..60 "fn"
|
||||
WHITESPACE@60..61 " "
|
||||
NAME@61..64
|
||||
IDENT@61..64 "baz"
|
||||
PARAM_LIST@64..66
|
||||
L_PAREN@64..65 "("
|
||||
R_PAREN@65..66 ")"
|
||||
WHITESPACE@66..67 " "
|
||||
BLOCK_EXPR@67..70
|
||||
L_CURLY@67..68 "{"
|
||||
WHITESPACE@68..69 "\n"
|
||||
R_CURLY@69..70 "}"
|
||||
WHITESPACE@70..71 "\n"
|
|
@ -1,8 +0,0 @@
|
|||
extern fn foo() {
|
||||
}
|
||||
|
||||
extern "C" fn bar() {
|
||||
}
|
||||
|
||||
extern r"D" fn baz() {
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
SOURCE_FILE@0..46
|
||||
IMPL@0..45
|
||||
IMPL_KW@0..4 "impl"
|
||||
WHITESPACE@4..5 " "
|
||||
PATH_TYPE@5..6
|
||||
PATH@5..6
|
||||
PATH_SEGMENT@5..6
|
||||
NAME_REF@5..6
|
||||
IDENT@5..6 "T"
|
||||
WHITESPACE@6..7 " "
|
||||
FOR_KW@7..10 "for"
|
||||
WHITESPACE@10..11 " "
|
||||
PATH_TYPE@11..14
|
||||
PATH@11..14
|
||||
PATH_SEGMENT@11..14
|
||||
NAME_REF@11..14
|
||||
IDENT@11..14 "Foo"
|
||||
WHITESPACE@14..15 " "
|
||||
ASSOC_ITEM_LIST@15..45
|
||||
L_CURLY@15..16 "{"
|
||||
WHITESPACE@16..19 "\n "
|
||||
CONST@19..43
|
||||
DEFAULT_KW@19..26 "default"
|
||||
WHITESPACE@26..27 " "
|
||||
CONST_KW@27..32 "const"
|
||||
WHITESPACE@32..33 " "
|
||||
NAME@33..34
|
||||
IDENT@33..34 "f"
|
||||
COLON@34..35 ":"
|
||||
WHITESPACE@35..36 " "
|
||||
PATH_TYPE@36..38
|
||||
PATH@36..38
|
||||
PATH_SEGMENT@36..38
|
||||
NAME_REF@36..38
|
||||
IDENT@36..38 "u8"
|
||||
WHITESPACE@38..39 " "
|
||||
EQ@39..40 "="
|
||||
WHITESPACE@40..41 " "
|
||||
LITERAL@41..42
|
||||
INT_NUMBER@41..42 "0"
|
||||
SEMICOLON@42..43 ";"
|
||||
WHITESPACE@43..44 "\n"
|
||||
R_CURLY@44..45 "}"
|
||||
WHITESPACE@45..46 "\n"
|
|
@ -1,3 +0,0 @@
|
|||
impl T for Foo {
|
||||
default const f: u8 = 0;
|
||||
}
|
218
crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast
Normal file
218
crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast
Normal file
|
@ -0,0 +1,218 @@
|
|||
SOURCE_FILE@0..294
|
||||
TRAIT@0..113
|
||||
TRAIT_KW@0..5 "trait"
|
||||
WHITESPACE@5..6 " "
|
||||
NAME@6..7
|
||||
IDENT@6..7 "T"
|
||||
WHITESPACE@7..8 " "
|
||||
ASSOC_ITEM_LIST@8..113
|
||||
L_CURLY@8..9 "{"
|
||||
WHITESPACE@9..12 "\n "
|
||||
TYPE_ALIAS@12..33
|
||||
DEFAULT_KW@12..19 "default"
|
||||
WHITESPACE@19..20 " "
|
||||
TYPE_KW@20..24 "type"
|
||||
WHITESPACE@24..25 " "
|
||||
NAME@25..26
|
||||
IDENT@25..26 "T"
|
||||
WHITESPACE@26..27 " "
|
||||
EQ@27..28 "="
|
||||
WHITESPACE@28..29 " "
|
||||
PATH_TYPE@29..32
|
||||
PATH@29..32
|
||||
PATH_SEGMENT@29..32
|
||||
NAME_REF@29..32
|
||||
IDENT@29..32 "Bar"
|
||||
SEMICOLON@32..33 ";"
|
||||
WHITESPACE@33..36 "\n "
|
||||
CONST@36..60
|
||||
DEFAULT_KW@36..43 "default"
|
||||
WHITESPACE@43..44 " "
|
||||
CONST_KW@44..49 "const"
|
||||
WHITESPACE@49..50 " "
|
||||
NAME@50..51
|
||||
IDENT@50..51 "f"
|
||||
COLON@51..52 ":"
|
||||
WHITESPACE@52..53 " "
|
||||
PATH_TYPE@53..55
|
||||
PATH@53..55
|
||||
PATH_SEGMENT@53..55
|
||||
NAME_REF@53..55
|
||||
IDENT@53..55 "u8"
|
||||
WHITESPACE@55..56 " "
|
||||
EQ@56..57 "="
|
||||
WHITESPACE@57..58 " "
|
||||
LITERAL@58..59
|
||||
INT_NUMBER@58..59 "0"
|
||||
SEMICOLON@59..60 ";"
|
||||
WHITESPACE@60..63 "\n "
|
||||
FN@63..82
|
||||
DEFAULT_KW@63..70 "default"
|
||||
WHITESPACE@70..71 " "
|
||||
FN_KW@71..73 "fn"
|
||||
WHITESPACE@73..74 " "
|
||||
NAME@74..77
|
||||
IDENT@74..77 "foo"
|
||||
PARAM_LIST@77..79
|
||||
L_PAREN@77..78 "("
|
||||
R_PAREN@78..79 ")"
|
||||
WHITESPACE@79..80 " "
|
||||
BLOCK_EXPR@80..82
|
||||
L_CURLY@80..81 "{"
|
||||
R_CURLY@81..82 "}"
|
||||
WHITESPACE@82..85 "\n "
|
||||
FN@85..111
|
||||
DEFAULT_KW@85..92 "default"
|
||||
WHITESPACE@92..93 " "
|
||||
UNSAFE_KW@93..99 "unsafe"
|
||||
WHITESPACE@99..100 " "
|
||||
FN_KW@100..102 "fn"
|
||||
WHITESPACE@102..103 " "
|
||||
NAME@103..106
|
||||
IDENT@103..106 "bar"
|
||||
PARAM_LIST@106..108
|
||||
L_PAREN@106..107 "("
|
||||
R_PAREN@107..108 ")"
|
||||
WHITESPACE@108..109 " "
|
||||
BLOCK_EXPR@109..111
|
||||
L_CURLY@109..110 "{"
|
||||
R_CURLY@110..111 "}"
|
||||
WHITESPACE@111..112 "\n"
|
||||
R_CURLY@112..113 "}"
|
||||
WHITESPACE@113..115 "\n\n"
|
||||
IMPL@115..235
|
||||
IMPL_KW@115..119 "impl"
|
||||
WHITESPACE@119..120 " "
|
||||
PATH_TYPE@120..121
|
||||
PATH@120..121
|
||||
PATH_SEGMENT@120..121
|
||||
NAME_REF@120..121
|
||||
IDENT@120..121 "T"
|
||||
WHITESPACE@121..122 " "
|
||||
FOR_KW@122..125 "for"
|
||||
WHITESPACE@125..126 " "
|
||||
PATH_TYPE@126..129
|
||||
PATH@126..129
|
||||
PATH_SEGMENT@126..129
|
||||
NAME_REF@126..129
|
||||
IDENT@126..129 "Foo"
|
||||
WHITESPACE@129..130 " "
|
||||
ASSOC_ITEM_LIST@130..235
|
||||
L_CURLY@130..131 "{"
|
||||
WHITESPACE@131..134 "\n "
|
||||
TYPE_ALIAS@134..155
|
||||
DEFAULT_KW@134..141 "default"
|
||||
WHITESPACE@141..142 " "
|
||||
TYPE_KW@142..146 "type"
|
||||
WHITESPACE@146..147 " "
|
||||
NAME@147..148
|
||||
IDENT@147..148 "T"
|
||||
WHITESPACE@148..149 " "
|
||||
EQ@149..150 "="
|
||||
WHITESPACE@150..151 " "
|
||||
PATH_TYPE@151..154
|
||||
PATH@151..154
|
||||
PATH_SEGMENT@151..154
|
||||
NAME_REF@151..154
|
||||
IDENT@151..154 "Bar"
|
||||
SEMICOLON@154..155 ";"
|
||||
WHITESPACE@155..158 "\n "
|
||||
CONST@158..182
|
||||
DEFAULT_KW@158..165 "default"
|
||||
WHITESPACE@165..166 " "
|
||||
CONST_KW@166..171 "const"
|
||||
WHITESPACE@171..172 " "
|
||||
NAME@172..173
|
||||
IDENT@172..173 "f"
|
||||
COLON@173..174 ":"
|
||||
WHITESPACE@174..175 " "
|
||||
PATH_TYPE@175..177
|
||||
PATH@175..177
|
||||
PATH_SEGMENT@175..177
|
||||
NAME_REF@175..177
|
||||
IDENT@175..177 "u8"
|
||||
WHITESPACE@177..178 " "
|
||||
EQ@178..179 "="
|
||||
WHITESPACE@179..180 " "
|
||||
LITERAL@180..181
|
||||
INT_NUMBER@180..181 "0"
|
||||
SEMICOLON@181..182 ";"
|
||||
WHITESPACE@182..185 "\n "
|
||||
FN@185..204
|
||||
DEFAULT_KW@185..192 "default"
|
||||
WHITESPACE@192..193 " "
|
||||
FN_KW@193..195 "fn"
|
||||
WHITESPACE@195..196 " "
|
||||
NAME@196..199
|
||||
IDENT@196..199 "foo"
|
||||
PARAM_LIST@199..201
|
||||
L_PAREN@199..200 "("
|
||||
R_PAREN@200..201 ")"
|
||||
WHITESPACE@201..202 " "
|
||||
BLOCK_EXPR@202..204
|
||||
L_CURLY@202..203 "{"
|
||||
R_CURLY@203..204 "}"
|
||||
WHITESPACE@204..207 "\n "
|
||||
FN@207..233
|
||||
DEFAULT_KW@207..214 "default"
|
||||
WHITESPACE@214..215 " "
|
||||
UNSAFE_KW@215..221 "unsafe"
|
||||
WHITESPACE@221..222 " "
|
||||
FN_KW@222..224 "fn"
|
||||
WHITESPACE@224..225 " "
|
||||
NAME@225..228
|
||||
IDENT@225..228 "bar"
|
||||
PARAM_LIST@228..230
|
||||
L_PAREN@228..229 "("
|
||||
R_PAREN@229..230 ")"
|
||||
WHITESPACE@230..231 " "
|
||||
BLOCK_EXPR@231..233
|
||||
L_CURLY@231..232 "{"
|
||||
R_CURLY@232..233 "}"
|
||||
WHITESPACE@233..234 "\n"
|
||||
R_CURLY@234..235 "}"
|
||||
WHITESPACE@235..237 "\n\n"
|
||||
IMPL@237..261
|
||||
DEFAULT_KW@237..244 "default"
|
||||
WHITESPACE@244..245 " "
|
||||
IMPL_KW@245..249 "impl"
|
||||
WHITESPACE@249..250 " "
|
||||
PATH_TYPE@250..251
|
||||
PATH@250..251
|
||||
PATH_SEGMENT@250..251
|
||||
NAME_REF@250..251
|
||||
IDENT@250..251 "T"
|
||||
WHITESPACE@251..252 " "
|
||||
FOR_KW@252..255 "for"
|
||||
WHITESPACE@255..256 " "
|
||||
TUPLE_TYPE@256..258
|
||||
L_PAREN@256..257 "("
|
||||
R_PAREN@257..258 ")"
|
||||
WHITESPACE@258..259 " "
|
||||
ASSOC_ITEM_LIST@259..261
|
||||
L_CURLY@259..260 "{"
|
||||
R_CURLY@260..261 "}"
|
||||
WHITESPACE@261..262 "\n"
|
||||
IMPL@262..293
|
||||
DEFAULT_KW@262..269 "default"
|
||||
WHITESPACE@269..270 " "
|
||||
UNSAFE_KW@270..276 "unsafe"
|
||||
WHITESPACE@276..277 " "
|
||||
IMPL_KW@277..281 "impl"
|
||||
WHITESPACE@281..282 " "
|
||||
PATH_TYPE@282..283
|
||||
PATH@282..283
|
||||
PATH_SEGMENT@282..283
|
||||
NAME_REF@282..283
|
||||
IDENT@282..283 "T"
|
||||
WHITESPACE@283..284 " "
|
||||
FOR_KW@284..287 "for"
|
||||
WHITESPACE@287..288 " "
|
||||
TUPLE_TYPE@288..290
|
||||
L_PAREN@288..289 "("
|
||||
R_PAREN@289..290 ")"
|
||||
WHITESPACE@290..291 " "
|
||||
ASSOC_ITEM_LIST@291..293
|
||||
L_CURLY@291..292 "{"
|
||||
R_CURLY@292..293 "}"
|
||||
WHITESPACE@293..294 "\n"
|
|
@ -0,0 +1,16 @@
|
|||
trait T {
|
||||
default type T = Bar;
|
||||
default const f: u8 = 0;
|
||||
default fn foo() {}
|
||||
default unsafe fn bar() {}
|
||||
}
|
||||
|
||||
impl T for Foo {
|
||||
default type T = Bar;
|
||||
default const f: u8 = 0;
|
||||
default fn foo() {}
|
||||
default unsafe fn bar() {}
|
||||
}
|
||||
|
||||
default impl T for () {}
|
||||
default unsafe impl T for () {}
|
218
crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast
Normal file
218
crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast
Normal file
|
@ -0,0 +1,218 @@
|
|||
SOURCE_FILE@0..304
|
||||
FN@0..17
|
||||
ASYNC_KW@0..5 "async"
|
||||
WHITESPACE@5..6 " "
|
||||
FN_KW@6..8 "fn"
|
||||
WHITESPACE@8..9 " "
|
||||
NAME@9..12
|
||||
IDENT@9..12 "foo"
|
||||
PARAM_LIST@12..14
|
||||
L_PAREN@12..13 "("
|
||||
R_PAREN@13..14 ")"
|
||||
WHITESPACE@14..15 " "
|
||||
BLOCK_EXPR@15..17
|
||||
L_CURLY@15..16 "{"
|
||||
R_CURLY@16..17 "}"
|
||||
WHITESPACE@17..18 "\n"
|
||||
FN@18..36
|
||||
ABI@18..24
|
||||
EXTERN_KW@18..24 "extern"
|
||||
WHITESPACE@24..25 " "
|
||||
FN_KW@25..27 "fn"
|
||||
WHITESPACE@27..28 " "
|
||||
NAME@28..31
|
||||
IDENT@28..31 "foo"
|
||||
PARAM_LIST@31..33
|
||||
L_PAREN@31..32 "("
|
||||
R_PAREN@32..33 ")"
|
||||
WHITESPACE@33..34 " "
|
||||
BLOCK_EXPR@34..36
|
||||
L_CURLY@34..35 "{"
|
||||
R_CURLY@35..36 "}"
|
||||
WHITESPACE@36..37 "\n"
|
||||
FN@37..54
|
||||
CONST_KW@37..42 "const"
|
||||
WHITESPACE@42..43 " "
|
||||
FN_KW@43..45 "fn"
|
||||
WHITESPACE@45..46 " "
|
||||
NAME@46..49
|
||||
IDENT@46..49 "foo"
|
||||
PARAM_LIST@49..51
|
||||
L_PAREN@49..50 "("
|
||||
R_PAREN@50..51 ")"
|
||||
WHITESPACE@51..52 " "
|
||||
BLOCK_EXPR@52..54
|
||||
L_CURLY@52..53 "{"
|
||||
R_CURLY@53..54 "}"
|
||||
WHITESPACE@54..55 "\n"
|
||||
FN@55..79
|
||||
CONST_KW@55..60 "const"
|
||||
WHITESPACE@60..61 " "
|
||||
UNSAFE_KW@61..67 "unsafe"
|
||||
WHITESPACE@67..68 " "
|
||||
FN_KW@68..70 "fn"
|
||||
WHITESPACE@70..71 " "
|
||||
NAME@71..74
|
||||
IDENT@71..74 "foo"
|
||||
PARAM_LIST@74..76
|
||||
L_PAREN@74..75 "("
|
||||
R_PAREN@75..76 ")"
|
||||
WHITESPACE@76..77 " "
|
||||
BLOCK_EXPR@77..79
|
||||
L_CURLY@77..78 "{"
|
||||
R_CURLY@78..79 "}"
|
||||
WHITESPACE@79..80 "\n"
|
||||
FN@80..109
|
||||
UNSAFE_KW@80..86 "unsafe"
|
||||
WHITESPACE@86..87 " "
|
||||
ABI@87..97
|
||||
EXTERN_KW@87..93 "extern"
|
||||
WHITESPACE@93..94 " "
|
||||
STRING@94..97 "\"C\""
|
||||
WHITESPACE@97..98 " "
|
||||
FN_KW@98..100 "fn"
|
||||
WHITESPACE@100..101 " "
|
||||
NAME@101..104
|
||||
IDENT@101..104 "foo"
|
||||
PARAM_LIST@104..106
|
||||
L_PAREN@104..105 "("
|
||||
R_PAREN@105..106 ")"
|
||||
WHITESPACE@106..107 " "
|
||||
BLOCK_EXPR@107..109
|
||||
L_CURLY@107..108 "{"
|
||||
R_CURLY@108..109 "}"
|
||||
WHITESPACE@109..110 "\n"
|
||||
FN@110..128
|
||||
UNSAFE_KW@110..116 "unsafe"
|
||||
WHITESPACE@116..117 " "
|
||||
FN_KW@117..119 "fn"
|
||||
WHITESPACE@119..120 " "
|
||||
NAME@120..123
|
||||
IDENT@120..123 "foo"
|
||||
PARAM_LIST@123..125
|
||||
L_PAREN@123..124 "("
|
||||
R_PAREN@124..125 ")"
|
||||
WHITESPACE@125..126 " "
|
||||
BLOCK_EXPR@126..128
|
||||
L_CURLY@126..127 "{"
|
||||
R_CURLY@127..128 "}"
|
||||
WHITESPACE@128..129 "\n"
|
||||
FN@129..153
|
||||
ASYNC_KW@129..134 "async"
|
||||
WHITESPACE@134..135 " "
|
||||
UNSAFE_KW@135..141 "unsafe"
|
||||
WHITESPACE@141..142 " "
|
||||
FN_KW@142..144 "fn"
|
||||
WHITESPACE@144..145 " "
|
||||
NAME@145..148
|
||||
IDENT@145..148 "foo"
|
||||
PARAM_LIST@148..150
|
||||
L_PAREN@148..149 "("
|
||||
R_PAREN@149..150 ")"
|
||||
WHITESPACE@150..151 " "
|
||||
BLOCK_EXPR@151..153
|
||||
L_CURLY@151..152 "{"
|
||||
R_CURLY@152..153 "}"
|
||||
WHITESPACE@153..154 "\n"
|
||||
FN@154..178
|
||||
CONST_KW@154..159 "const"
|
||||
WHITESPACE@159..160 " "
|
||||
UNSAFE_KW@160..166 "unsafe"
|
||||
WHITESPACE@166..167 " "
|
||||
FN_KW@167..169 "fn"
|
||||
WHITESPACE@169..170 " "
|
||||
NAME@170..173
|
||||
IDENT@170..173 "bar"
|
||||
PARAM_LIST@173..175
|
||||
L_PAREN@173..174 "("
|
||||
R_PAREN@174..175 ")"
|
||||
WHITESPACE@175..176 " "
|
||||
BLOCK_EXPR@176..178
|
||||
L_CURLY@176..177 "{"
|
||||
R_CURLY@177..178 "}"
|
||||
WHITESPACE@178..180 "\n\n"
|
||||
TRAIT@180..197
|
||||
UNSAFE_KW@180..186 "unsafe"
|
||||
WHITESPACE@186..187 " "
|
||||
TRAIT_KW@187..192 "trait"
|
||||
WHITESPACE@192..193 " "
|
||||
NAME@193..194
|
||||
IDENT@193..194 "T"
|
||||
WHITESPACE@194..195 " "
|
||||
ASSOC_ITEM_LIST@195..197
|
||||
L_CURLY@195..196 "{"
|
||||
R_CURLY@196..197 "}"
|
||||
WHITESPACE@197..198 "\n"
|
||||
TRAIT@198..213
|
||||
AUTO_KW@198..202 "auto"
|
||||
WHITESPACE@202..203 " "
|
||||
TRAIT_KW@203..208 "trait"
|
||||
WHITESPACE@208..209 " "
|
||||
NAME@209..210
|
||||
IDENT@209..210 "T"
|
||||
WHITESPACE@210..211 " "
|
||||
ASSOC_ITEM_LIST@211..213
|
||||
L_CURLY@211..212 "{"
|
||||
R_CURLY@212..213 "}"
|
||||
WHITESPACE@213..214 "\n"
|
||||
TRAIT@214..236
|
||||
UNSAFE_KW@214..220 "unsafe"
|
||||
WHITESPACE@220..221 " "
|
||||
AUTO_KW@221..225 "auto"
|
||||
WHITESPACE@225..226 " "
|
||||
TRAIT_KW@226..231 "trait"
|
||||
WHITESPACE@231..232 " "
|
||||
NAME@232..233
|
||||
IDENT@232..233 "T"
|
||||
WHITESPACE@233..234 " "
|
||||
ASSOC_ITEM_LIST@234..236
|
||||
L_CURLY@234..235 "{"
|
||||
R_CURLY@235..236 "}"
|
||||
WHITESPACE@236..238 "\n\n"
|
||||
IMPL@238..256
|
||||
UNSAFE_KW@238..244 "unsafe"
|
||||
WHITESPACE@244..245 " "
|
||||
IMPL_KW@245..249 "impl"
|
||||
WHITESPACE@249..250 " "
|
||||
PATH_TYPE@250..253
|
||||
PATH@250..253
|
||||
PATH_SEGMENT@250..253
|
||||
NAME_REF@250..253
|
||||
IDENT@250..253 "Foo"
|
||||
WHITESPACE@253..254 " "
|
||||
ASSOC_ITEM_LIST@254..256
|
||||
L_CURLY@254..255 "{"
|
||||
R_CURLY@255..256 "}"
|
||||
WHITESPACE@256..257 "\n"
|
||||
IMPL@257..276
|
||||
DEFAULT_KW@257..264 "default"
|
||||
WHITESPACE@264..265 " "
|
||||
IMPL_KW@265..269 "impl"
|
||||
WHITESPACE@269..270 " "
|
||||
PATH_TYPE@270..273
|
||||
PATH@270..273
|
||||
PATH_SEGMENT@270..273
|
||||
NAME_REF@270..273
|
||||
IDENT@270..273 "Foo"
|
||||
WHITESPACE@273..274 " "
|
||||
ASSOC_ITEM_LIST@274..276
|
||||
L_CURLY@274..275 "{"
|
||||
R_CURLY@275..276 "}"
|
||||
WHITESPACE@276..277 "\n"
|
||||
IMPL@277..303
|
||||
UNSAFE_KW@277..283 "unsafe"
|
||||
WHITESPACE@283..284 " "
|
||||
DEFAULT_KW@284..291 "default"
|
||||
WHITESPACE@291..292 " "
|
||||
IMPL_KW@292..296 "impl"
|
||||
WHITESPACE@296..297 " "
|
||||
PATH_TYPE@297..300
|
||||
PATH@297..300
|
||||
PATH_SEGMENT@297..300
|
||||
NAME_REF@297..300
|
||||
IDENT@297..300 "Foo"
|
||||
WHITESPACE@300..301 " "
|
||||
ASSOC_ITEM_LIST@301..303
|
||||
L_CURLY@301..302 "{"
|
||||
R_CURLY@302..303 "}"
|
||||
WHITESPACE@303..304 "\n"
|
16
crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs
Normal file
16
crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
async fn foo() {}
|
||||
extern fn foo() {}
|
||||
const fn foo() {}
|
||||
const unsafe fn foo() {}
|
||||
unsafe extern "C" fn foo() {}
|
||||
unsafe fn foo() {}
|
||||
async unsafe fn foo() {}
|
||||
const unsafe fn bar() {}
|
||||
|
||||
unsafe trait T {}
|
||||
auto trait T {}
|
||||
unsafe auto trait T {}
|
||||
|
||||
unsafe impl Foo {}
|
||||
default impl Foo {}
|
||||
unsafe default impl Foo {}
|
Loading…
Reference in a new issue