From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../target/configs/combine_control_expr/false.rs | 134 +++++++++++++++++++++ .../target/configs/combine_control_expr/true.rs | 122 +++++++++++++++++++ 2 files changed, 256 insertions(+) create mode 100644 src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs create mode 100644 src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs (limited to 'src/tools/rustfmt/tests/target/configs/combine_control_expr') diff --git a/src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs b/src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs new file mode 100644 index 000000000..5ada9b1dd --- /dev/null +++ b/src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs @@ -0,0 +1,134 @@ +// rustfmt-indent_style: Block +// rustfmt-combine_control_expr: false + +// Combining openings and closings. See rust-lang/fmt-rfcs#61. + +fn main() { + // Call + foo(bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Mac + foo(foo!( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // MethodCall + foo(x.foo::( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Block + foo!({ + foo(); + bar(); + }); + + // Closure + foo(|x| { + let y = x + 1; + y + }); + + // Match + foo(match opt { + Some(x) => x, + None => y, + }); + + // Struct + foo(Bar { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + }); + + // If + foo!( + if x { + foo(); + } else { + bar(); + } + ); + + // IfLet + foo!( + if let Some(..) = x { + foo(); + } else { + bar(); + } + ); + + // While + foo!( + while x { + foo(); + bar(); + } + ); + + // WhileLet + foo!( + while let Some(..) = x { + foo(); + bar(); + } + ); + + // ForLoop + foo!( + for x in y { + foo(); + bar(); + } + ); + + // Loop + foo!( + loop { + foo(); + bar(); + } + ); + + // Tuple + foo(( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // AddrOf + foo(&bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Box + foo(box Bar { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + }); + + // Unary + foo(!bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Try + foo(bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )?); + + // Cast + foo(Bar { + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, + } as i64); +} diff --git a/src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs b/src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs new file mode 100644 index 000000000..52acd2649 --- /dev/null +++ b/src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs @@ -0,0 +1,122 @@ +// rustfmt-indent_style: Block +// rustfmt-combine_control_expr: true + +// Combining openings and closings. See rust-lang/fmt-rfcs#61. + +fn main() { + // Call + foo(bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Mac + foo(foo!( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // MethodCall + foo(x.foo::( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Block + foo!({ + foo(); + bar(); + }); + + // Closure + foo(|x| { + let y = x + 1; + y + }); + + // Match + foo(match opt { + Some(x) => x, + None => y, + }); + + // Struct + foo(Bar { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + }); + + // If + foo!(if x { + foo(); + } else { + bar(); + }); + + // IfLet + foo!(if let Some(..) = x { + foo(); + } else { + bar(); + }); + + // While + foo!(while x { + foo(); + bar(); + }); + + // WhileLet + foo!(while let Some(..) = x { + foo(); + bar(); + }); + + // ForLoop + foo!(for x in y { + foo(); + bar(); + }); + + // Loop + foo!(loop { + foo(); + bar(); + }); + + // Tuple + foo(( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // AddrOf + foo(&bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Box + foo(box Bar { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + }); + + // Unary + foo(!bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )); + + // Try + foo(bar( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + )?); + + // Cast + foo(Bar { + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, + } as i64); +} -- cgit v1.2.3