Unnamed repository; edit this file 'description' to name the repository.
Merge #10345
10345: minore: improve consistency r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
8 files changed, 137 insertions, 145 deletions
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 2bec8577f0..ba64f58e6d 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<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 { diff --git a/crates/syntax/src/tests/sourcegen_ast.rs b/crates/syntax/src/tests/sourcegen_ast.rs index 1a0377830b..07213b08be 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 { diff --git a/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast b/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast index 36c9cd5bb2..509c54c2ac 100644 --- a/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast +++ b/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast @@ -1,50 +1,50 @@ [email protected] "fn" - [email protected] "foo" - [email protected] "(" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "\n " - [email protected] "let" + [email protected] "f" + [email protected] "(" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] "\n " + [email protected] "let" + [email protected] " " + [email protected] "_" - [email protected] "_" + [email protected] "=" - [email protected] "=" - [email protected] " " - [email protected] "{" - [email protected] "1" - [email protected] "}" + [email protected] "{" + [email protected] "1" + [email protected] "}" + [email protected] " " + [email protected] "&" - [email protected] "&" - [email protected] " " - [email protected] "2" - [email protected] ";" - [email protected] "\n " - [email protected] "{" - [email protected] "1" - [email protected] "}" - [email protected] " " - [email protected] "&" - [email protected] "2" - [email protected] ";" - [email protected] "\n" - [email protected] "}" - [email protected] "\n" + [email protected] "2" + [email protected] ";" + [email protected] "\n " + [email protected] "{" + [email protected] "1" + [email protected] "}" + [email protected] " " + [email protected] "&" + [email protected] "2" + [email protected] ";" + [email protected] "\n" + [email protected] "}" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs b/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs index 37b8437426..7e8bd87bf1 100644 --- a/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs +++ b/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs @@ -1,4 +1,4 @@ -fn foo() { +fn f() { let _ = {1} & 2; {1} &2; } diff --git a/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rast b/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rast index a36cc8dab3..c9cfb97ef3 100644 --- a/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rast +++ b/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rast @@ -1,42 +1,42 @@ [email protected] "fn" - [email protected] "foo" - [email protected] "(" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "\n " - [email protected] "let" - [email protected] " " - [email protected] "_" - [email protected] " " - [email protected] "=" - [email protected] " " - [email protected] "&" - [email protected] "1" - [email protected] " " - [email protected] "as" - [email protected] " " - [email protected] "*" - [email protected] "const" - [email protected] " " - [email protected] "i32" - [email protected] ";" - [email protected] "\n" - [email protected] "}" - [email protected] "\n" + [email protected] "f" + [email protected] "(" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] " " + [email protected] "let" + [email protected] " " + [email protected] "_" + [email protected] " " + [email protected] "=" + [email protected] " " + [email protected] "&" + [email protected] "1" + [email protected] " " + [email protected] "as" + [email protected] " " + [email protected] "*" + [email protected] "const" + [email protected] " " + [email protected] "i32" + [email protected] ";" + [email protected] " " + [email protected] "}" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rs b/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rs index a06dec1faf..70559c5ef5 100644 --- a/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rs +++ b/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rs @@ -1,3 +1 @@ -fn foo() { - let _ = &1 as *const i32; -} +fn f() { let _ = &1 as *const i32; } diff --git a/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast b/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast index 8ae24b9c10..7473f4836e 100644 --- a/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast +++ b/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast @@ -1,36 +1,36 @@ [email protected] "fn" - [email protected] "foo" - [email protected] "(" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "\n " - [email protected] "v" - [email protected] " " - [email protected] "=" - [email protected] " " - [email protected] "{" - [email protected] "1" - [email protected] "}" - [email protected] "&" - [email protected] "2" - [email protected] ";" - [email protected] "\n" - [email protected] "}" - [email protected] "\n" + [email protected] "f" + [email protected] "(" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] " " + [email protected] "v" + [email protected] " " + [email protected] "=" + [email protected] " " + [email protected] "{" + [email protected] "1" + [email protected] "}" + [email protected] "&" + [email protected] "2" + [email protected] ";" + [email protected] " " + [email protected] "}" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs b/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs index 05acc30f12..e325e46676 100644 --- a/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs +++ b/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs @@ -1,3 +1 @@ -fn foo() { - v = {1}&2; -} +fn f() { v = {1}&2; } |