From f27cda6865fa33670a2e364388ecc56285feae30 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Sep 2021 14:24:08 +0300 Subject: [PATCH 1/2] minor: more condensed tests --- crates/parser/src/grammar/expressions.rs | 18 ++-- .../ok/0070_stmt_bin_expr_ambiguity.rast | 90 +++++++++---------- .../inline/ok/0070_stmt_bin_expr_ambiguity.rs | 2 +- .../parser/inline/ok/0146_as_precedence.rast | 80 ++++++++--------- .../parser/inline/ok/0146_as_precedence.rs | 4 +- .../ok/0158_binop_resets_statementness.rast | 68 +++++++------- .../ok/0158_binop_resets_statementness.rs | 4 +- 7 files changed, 129 insertions(+), 137 deletions(-) diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 2bec8577f0ce..ba64f58e6dcf 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -243,12 +243,12 @@ fn current_op(p: &Parser) -> (u8, SyntaxKind) { fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option, 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 (Option Date: Sat, 25 Sep 2021 14:36:46 +0300 Subject: [PATCH 2/2] minore: improve consistency --- crates/syntax/src/tests/sourcegen_ast.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/syntax/src/tests/sourcegen_ast.rs b/crates/syntax/src/tests/sourcegen_ast.rs index 1a0377830be1..07213b08be27 100644 --- a/crates/syntax/src/tests/sourcegen_ast.rs +++ b/crates/syntax/src/tests/sourcegen_ast.rs @@ -19,22 +19,22 @@ use crate::tests::ast_src::{ #[test] fn sourcegen_ast() { - let grammar = rust_grammar(); - let ast = lower(&grammar); - + let syntax_kinds = generate_syntax_kinds(KINDS_SRC); let syntax_kinds_file = sourcegen::project_root().join("crates/parser/src/syntax_kind/generated.rs"); - let syntax_kinds = generate_syntax_kinds(KINDS_SRC); sourcegen::ensure_file_contents(syntax_kinds_file.as_path(), &syntax_kinds); + let grammar = rust_grammar(); + let ast = lower(&grammar); + + let ast_tokens = generate_tokens(&ast); let ast_tokens_file = sourcegen::project_root().join("crates/syntax/src/ast/generated/tokens.rs"); - let contents = generate_tokens(&ast); - sourcegen::ensure_file_contents(ast_tokens_file.as_path(), &contents); + sourcegen::ensure_file_contents(ast_tokens_file.as_path(), &ast_tokens); + let ast_nodes = generate_nodes(KINDS_SRC, &ast); let ast_nodes_file = sourcegen::project_root().join("crates/syntax/src/ast/generated/nodes.rs"); - let contents = generate_nodes(KINDS_SRC, &ast); - sourcegen::ensure_file_contents(ast_nodes_file.as_path(), &contents); + sourcegen::ensure_file_contents(ast_nodes_file.as_path(), &ast_nodes); } fn generate_tokens(grammar: &AstSrc) -> String {