about summary refs log tree commit diff
path: root/tests/ui/parser/syntactic-trailing-commas.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-13 15:32:13 +0000
committerbors <bors@rust-lang.org>2025-07-13 15:32:13 +0000
commit56835d7ac14da9f966e1ff39fd9ffd2e29b764d1 (patch)
tree74bf7603a760a610352e6f0fa88668b71cb6d8a2 /tests/ui/parser/syntactic-trailing-commas.rs
parent7e310f4b9a3f166d833ed09cf1d1ff96ab84b72c (diff)
parent3ff549f6d33ac15df8307025ee068cada8b1e021 (diff)
downloadrust-56835d7ac14da9f966e1ff39fd9ffd2e29b764d1.tar.gz
rust-56835d7ac14da9f966e1ff39fd9ffd2e29b764d1.zip
Auto merge of #143888 - matthiaskrgr:rollup-fv9x7kf, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#143301 (`tests/ui`: A New Order [26/N])
 - rust-lang/rust#143519 (Check assoc consts and tys later like assoc fns)
 - rust-lang/rust#143554 (slice: Mark `rotate_left`, `rotate_right` unstably const)
 - rust-lang/rust#143634 (interpret/allocation: expose init + write_wildcards on a range)
 - rust-lang/rust#143685 (Resolve: merge `source_bindings` and `target_bindings` into `bindings`)
 - rust-lang/rust#143734 (Refactor resolve resolution bindings)
 - rust-lang/rust#143774 (constify `From` and `Into`)
 - rust-lang/rust#143785 (Add --compile-time-deps argument for x check)
 - rust-lang/rust#143786 (Fix fallback for CI_JOB_NAME)
 - rust-lang/rust#143825 (clippy: fix test filtering when TESTNAME is empty)
 - rust-lang/rust#143826 (Fix command trace)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/ui/parser/syntactic-trailing-commas.rs')
-rw-r--r--tests/ui/parser/syntactic-trailing-commas.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/parser/syntactic-trailing-commas.rs b/tests/ui/parser/syntactic-trailing-commas.rs
new file mode 100644
index 00000000000..ba688dffb3c
--- /dev/null
+++ b/tests/ui/parser/syntactic-trailing-commas.rs
@@ -0,0 +1,42 @@
+//! Checks trailing commas are accepted in various places:
+//! - Generic parameters in function and struct definitions.
+//! - Function and method arguments.
+//! - Tuple and array literal expressions.
+//! - Tuple and array destructuring patterns, including those with `..`.
+//! - Enum variant declarations.
+//! - Attributes.
+
+//@ run-pass
+
+fn f<T,>(_: T,) {}
+
+struct Foo<T,>(#[allow(dead_code)] T);
+
+struct Bar;
+
+impl Bar {
+    fn f(_: isize,) {}
+    fn g(self, _: isize,) {}
+    fn h(self,) {}
+}
+
+enum Baz {
+    Qux(#[allow(dead_code)] isize,),
+}
+
+#[allow(unused,)]
+pub fn main() {
+    f::<isize,>(0,);
+    let (_, _,) = (1, 1,);
+    let [_, _,] = [1, 1,];
+    let [_, _, .., _,] = [1, 1, 1, 1,];
+    let [_, _, _, ..,] = [1, 1, 1, 1,];
+
+    let x: Foo<isize,> = Foo::<isize,>(1);
+
+    Bar::f(0,);
+    Bar.g(0,);
+    Bar.h();
+
+    let x = Baz::Qux(1,);
+}