mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
minor: more condensed tests
This commit is contained in:
parent
f692be853b
commit
f27cda6865
7 changed files with 129 additions and 137 deletions
|
@ -243,12 +243,12 @@ fn current_op(p: &Parser) -> (u8, SyntaxKind) {
|
|||
fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option<CompletedMarker>, BlockLike) {
|
||||
let mut lhs = match lhs(p, r) {
|
||||
Some((lhs, blocklike)) => {
|
||||
// test stmt_bin_expr_ambiguity
|
||||
// fn foo() {
|
||||
// let _ = {1} & 2;
|
||||
// {1} &2;
|
||||
// }
|
||||
if r.prefer_stmt && blocklike.is_block() {
|
||||
// test stmt_bin_expr_ambiguity
|
||||
// fn f() {
|
||||
// let _ = {1} & 2;
|
||||
// {1} &2;
|
||||
// }
|
||||
return (Some(lhs), BlockLike::Block);
|
||||
}
|
||||
lhs
|
||||
|
@ -263,9 +263,7 @@ fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option<CompletedMark
|
|||
break;
|
||||
}
|
||||
// test as_precedence
|
||||
// fn foo() {
|
||||
// let _ = &1 as *const i32;
|
||||
// }
|
||||
// fn f() { let _ = &1 as *const i32; }
|
||||
if p.at(T![as]) {
|
||||
lhs = cast_expr(p, lhs);
|
||||
continue;
|
||||
|
@ -274,9 +272,7 @@ fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option<CompletedMark
|
|||
p.bump(op);
|
||||
|
||||
// test binop_resets_statementness
|
||||
// fn foo() {
|
||||
// v = {1}&2;
|
||||
// }
|
||||
// fn f() { v = {1}&2; }
|
||||
r = Restrictions { prefer_stmt: false, ..r };
|
||||
|
||||
if is_range {
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
SOURCE_FILE@0..46
|
||||
FN@0..45
|
||||
SOURCE_FILE@0..44
|
||||
FN@0..43
|
||||
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..45
|
||||
L_CURLY@9..10 "{"
|
||||
WHITESPACE@10..15 "\n "
|
||||
LET_STMT@15..31
|
||||
LET_KW@15..18 "let"
|
||||
NAME@3..4
|
||||
IDENT@3..4 "f"
|
||||
PARAM_LIST@4..6
|
||||
L_PAREN@4..5 "("
|
||||
R_PAREN@5..6 ")"
|
||||
WHITESPACE@6..7 " "
|
||||
BLOCK_EXPR@7..43
|
||||
L_CURLY@7..8 "{"
|
||||
WHITESPACE@8..13 "\n "
|
||||
LET_STMT@13..29
|
||||
LET_KW@13..16 "let"
|
||||
WHITESPACE@16..17 " "
|
||||
WILDCARD_PAT@17..18
|
||||
UNDERSCORE@17..18 "_"
|
||||
WHITESPACE@18..19 " "
|
||||
WILDCARD_PAT@19..20
|
||||
UNDERSCORE@19..20 "_"
|
||||
EQ@19..20 "="
|
||||
WHITESPACE@20..21 " "
|
||||
EQ@21..22 "="
|
||||
WHITESPACE@22..23 " "
|
||||
BIN_EXPR@23..30
|
||||
BLOCK_EXPR@23..26
|
||||
L_CURLY@23..24 "{"
|
||||
LITERAL@24..25
|
||||
INT_NUMBER@24..25 "1"
|
||||
R_CURLY@25..26 "}"
|
||||
BIN_EXPR@21..28
|
||||
BLOCK_EXPR@21..24
|
||||
L_CURLY@21..22 "{"
|
||||
LITERAL@22..23
|
||||
INT_NUMBER@22..23 "1"
|
||||
R_CURLY@23..24 "}"
|
||||
WHITESPACE@24..25 " "
|
||||
AMP@25..26 "&"
|
||||
WHITESPACE@26..27 " "
|
||||
AMP@27..28 "&"
|
||||
WHITESPACE@28..29 " "
|
||||
LITERAL@29..30
|
||||
INT_NUMBER@29..30 "2"
|
||||
SEMICOLON@30..31 ";"
|
||||
WHITESPACE@31..36 "\n "
|
||||
EXPR_STMT@36..39
|
||||
BLOCK_EXPR@36..39
|
||||
L_CURLY@36..37 "{"
|
||||
LITERAL@37..38
|
||||
INT_NUMBER@37..38 "1"
|
||||
R_CURLY@38..39 "}"
|
||||
WHITESPACE@39..40 " "
|
||||
EXPR_STMT@40..43
|
||||
REF_EXPR@40..42
|
||||
AMP@40..41 "&"
|
||||
LITERAL@41..42
|
||||
INT_NUMBER@41..42 "2"
|
||||
SEMICOLON@42..43 ";"
|
||||
WHITESPACE@43..44 "\n"
|
||||
R_CURLY@44..45 "}"
|
||||
WHITESPACE@45..46 "\n"
|
||||
LITERAL@27..28
|
||||
INT_NUMBER@27..28 "2"
|
||||
SEMICOLON@28..29 ";"
|
||||
WHITESPACE@29..34 "\n "
|
||||
EXPR_STMT@34..37
|
||||
BLOCK_EXPR@34..37
|
||||
L_CURLY@34..35 "{"
|
||||
LITERAL@35..36
|
||||
INT_NUMBER@35..36 "1"
|
||||
R_CURLY@36..37 "}"
|
||||
WHITESPACE@37..38 " "
|
||||
EXPR_STMT@38..41
|
||||
REF_EXPR@38..40
|
||||
AMP@38..39 "&"
|
||||
LITERAL@39..40
|
||||
INT_NUMBER@39..40 "2"
|
||||
SEMICOLON@40..41 ";"
|
||||
WHITESPACE@41..42 "\n"
|
||||
R_CURLY@42..43 "}"
|
||||
WHITESPACE@43..44 "\n"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn foo() {
|
||||
fn f() {
|
||||
let _ = {1} & 2;
|
||||
{1} &2;
|
||||
}
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
SOURCE_FILE@0..43
|
||||
FN@0..42
|
||||
SOURCE_FILE@0..37
|
||||
FN@0..36
|
||||
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..42
|
||||
L_CURLY@9..10 "{"
|
||||
WHITESPACE@10..15 "\n "
|
||||
LET_STMT@15..40
|
||||
LET_KW@15..18 "let"
|
||||
WHITESPACE@18..19 " "
|
||||
WILDCARD_PAT@19..20
|
||||
UNDERSCORE@19..20 "_"
|
||||
WHITESPACE@20..21 " "
|
||||
EQ@21..22 "="
|
||||
WHITESPACE@22..23 " "
|
||||
CAST_EXPR@23..39
|
||||
REF_EXPR@23..25
|
||||
AMP@23..24 "&"
|
||||
LITERAL@24..25
|
||||
INT_NUMBER@24..25 "1"
|
||||
WHITESPACE@25..26 " "
|
||||
AS_KW@26..28 "as"
|
||||
WHITESPACE@28..29 " "
|
||||
PTR_TYPE@29..39
|
||||
STAR@29..30 "*"
|
||||
CONST_KW@30..35 "const"
|
||||
WHITESPACE@35..36 " "
|
||||
PATH_TYPE@36..39
|
||||
PATH@36..39
|
||||
PATH_SEGMENT@36..39
|
||||
NAME_REF@36..39
|
||||
IDENT@36..39 "i32"
|
||||
SEMICOLON@39..40 ";"
|
||||
WHITESPACE@40..41 "\n"
|
||||
R_CURLY@41..42 "}"
|
||||
WHITESPACE@42..43 "\n"
|
||||
NAME@3..4
|
||||
IDENT@3..4 "f"
|
||||
PARAM_LIST@4..6
|
||||
L_PAREN@4..5 "("
|
||||
R_PAREN@5..6 ")"
|
||||
WHITESPACE@6..7 " "
|
||||
BLOCK_EXPR@7..36
|
||||
L_CURLY@7..8 "{"
|
||||
WHITESPACE@8..9 " "
|
||||
LET_STMT@9..34
|
||||
LET_KW@9..12 "let"
|
||||
WHITESPACE@12..13 " "
|
||||
WILDCARD_PAT@13..14
|
||||
UNDERSCORE@13..14 "_"
|
||||
WHITESPACE@14..15 " "
|
||||
EQ@15..16 "="
|
||||
WHITESPACE@16..17 " "
|
||||
CAST_EXPR@17..33
|
||||
REF_EXPR@17..19
|
||||
AMP@17..18 "&"
|
||||
LITERAL@18..19
|
||||
INT_NUMBER@18..19 "1"
|
||||
WHITESPACE@19..20 " "
|
||||
AS_KW@20..22 "as"
|
||||
WHITESPACE@22..23 " "
|
||||
PTR_TYPE@23..33
|
||||
STAR@23..24 "*"
|
||||
CONST_KW@24..29 "const"
|
||||
WHITESPACE@29..30 " "
|
||||
PATH_TYPE@30..33
|
||||
PATH@30..33
|
||||
PATH_SEGMENT@30..33
|
||||
NAME_REF@30..33
|
||||
IDENT@30..33 "i32"
|
||||
SEMICOLON@33..34 ";"
|
||||
WHITESPACE@34..35 " "
|
||||
R_CURLY@35..36 "}"
|
||||
WHITESPACE@36..37 "\n"
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
fn foo() {
|
||||
let _ = &1 as *const i32;
|
||||
}
|
||||
fn f() { let _ = &1 as *const i32; }
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
SOURCE_FILE@0..28
|
||||
FN@0..27
|
||||
SOURCE_FILE@0..22
|
||||
FN@0..21
|
||||
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..27
|
||||
L_CURLY@9..10 "{"
|
||||
WHITESPACE@10..15 "\n "
|
||||
EXPR_STMT@15..25
|
||||
BIN_EXPR@15..24
|
||||
PATH_EXPR@15..16
|
||||
PATH@15..16
|
||||
PATH_SEGMENT@15..16
|
||||
NAME_REF@15..16
|
||||
IDENT@15..16 "v"
|
||||
WHITESPACE@16..17 " "
|
||||
EQ@17..18 "="
|
||||
WHITESPACE@18..19 " "
|
||||
BIN_EXPR@19..24
|
||||
BLOCK_EXPR@19..22
|
||||
L_CURLY@19..20 "{"
|
||||
LITERAL@20..21
|
||||
INT_NUMBER@20..21 "1"
|
||||
R_CURLY@21..22 "}"
|
||||
AMP@22..23 "&"
|
||||
LITERAL@23..24
|
||||
INT_NUMBER@23..24 "2"
|
||||
SEMICOLON@24..25 ";"
|
||||
WHITESPACE@25..26 "\n"
|
||||
R_CURLY@26..27 "}"
|
||||
WHITESPACE@27..28 "\n"
|
||||
NAME@3..4
|
||||
IDENT@3..4 "f"
|
||||
PARAM_LIST@4..6
|
||||
L_PAREN@4..5 "("
|
||||
R_PAREN@5..6 ")"
|
||||
WHITESPACE@6..7 " "
|
||||
BLOCK_EXPR@7..21
|
||||
L_CURLY@7..8 "{"
|
||||
WHITESPACE@8..9 " "
|
||||
EXPR_STMT@9..19
|
||||
BIN_EXPR@9..18
|
||||
PATH_EXPR@9..10
|
||||
PATH@9..10
|
||||
PATH_SEGMENT@9..10
|
||||
NAME_REF@9..10
|
||||
IDENT@9..10 "v"
|
||||
WHITESPACE@10..11 " "
|
||||
EQ@11..12 "="
|
||||
WHITESPACE@12..13 " "
|
||||
BIN_EXPR@13..18
|
||||
BLOCK_EXPR@13..16
|
||||
L_CURLY@13..14 "{"
|
||||
LITERAL@14..15
|
||||
INT_NUMBER@14..15 "1"
|
||||
R_CURLY@15..16 "}"
|
||||
AMP@16..17 "&"
|
||||
LITERAL@17..18
|
||||
INT_NUMBER@17..18 "2"
|
||||
SEMICOLON@18..19 ";"
|
||||
WHITESPACE@19..20 " "
|
||||
R_CURLY@20..21 "}"
|
||||
WHITESPACE@21..22 "\n"
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
fn foo() {
|
||||
v = {1}&2;
|
||||
}
|
||||
fn f() { v = {1}&2; }
|
||||
|
|
Loading…
Reference in a new issue