about summary refs log tree commit diff
path: root/src/tools/rustfmt/tests/source
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-01-10 03:55:21 -0500
committerGitHub <noreply@github.com>2025-01-10 03:55:21 -0500
commit0dcbda8225fda5373d958d128d4d722fcc9cb2d0 (patch)
treee62ed4a4ddcfb23c8866b8a82dccc8222aea042c /src/tools/rustfmt/tests/source
parenta6d38a1fb72b211c067347491c550ce2f5f9cb7d (diff)
parentbe92ac3567e4a808cc08cd909efa5663fff2f8ea (diff)
downloadrust-0dcbda8225fda5373d958d128d4d722fcc9cb2d0.tar.gz
rust-0dcbda8225fda5373d958d128d4d722fcc9cb2d0.zip
Rollup merge of #135251 - oli-obk:push-lmpyvvyrtplk, r=ytmimi
Only treat plain literal patterns as short

See https://github.com/rust-lang/rust/pull/134228#discussion_r1905848384 and https://github.com/rust-lang/rust/pull/134228#discussion_r1905916702 for context. We never wanted to treat const blocks and paths as short, only plain literals.

I don't know how to write a test for this, it.s not clear to me how the short pattern check actually affects the formatting
Diffstat (limited to 'src/tools/rustfmt/tests/source')
-rw-r--r--src/tools/rustfmt/tests/source/pattern.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/source/pattern.rs b/src/tools/rustfmt/tests/source/pattern.rs
index f06d03cadf2..ed6ad690fa9 100644
--- a/src/tools/rustfmt/tests/source/pattern.rs
+++ b/src/tools/rustfmt/tests/source/pattern.rs
@@ -88,3 +88,13 @@ fn issue3728() {
         | c;
     foo((1,));
 }
+
+fn literals() {
+    match 42 {
+        const { 1 + 2 } | 4
+        | 6 => {}
+        10 | 11 | 12
+        | 13 | 14 => {}
+        _ => {}
+    }
+}
\ No newline at end of file