|
| 1 | +//! This test verifies that the Rust compiler correctly handles trailing commas |
| 2 | +//! in a wide variety of syntactic contexts. This includes: |
| 3 | +//! - Generic parameters in function and struct definitions. |
| 4 | +//! - Function and method arguments. |
| 5 | +//! - Tuple and array literal expressions. |
| 6 | +//! - Tuple and array destructuring patterns, including those with `..`. |
| 7 | +//! - Enum variant declarations. |
| 8 | +//! - Attributes. |
| 9 | +
|
1 | 10 | //@ run-pass
|
2 | 11 |
|
3 |
| -fn f<T,>(_: T,) {} |
| 12 | +fn f<T>(_: T) {} |
4 | 13 |
|
5 |
| -struct Foo<T,>(#[allow(dead_code)] T); |
| 14 | +struct Foo<T>(#[allow(dead_code)] T); |
6 | 15 |
|
7 | 16 | struct Bar;
|
8 | 17 |
|
9 | 18 | impl Bar {
|
10 |
| - fn f(_: isize,) {} |
11 |
| - fn g(self, _: isize,) {} |
12 |
| - fn h(self,) {} |
| 19 | + fn f(_: isize) {} |
| 20 | + fn g(self, _: isize) {} |
| 21 | + fn h(self) {} |
13 | 22 | }
|
14 | 23 |
|
15 | 24 | enum Baz {
|
16 |
| - Qux(#[allow(dead_code)] isize,), |
| 25 | + Qux(#[allow(dead_code)] isize), |
17 | 26 | }
|
18 | 27 |
|
19 |
| -#[allow(unused,)] |
| 28 | +#[allow(unused)] |
20 | 29 | pub fn main() {
|
21 |
| - f::<isize,>(0,); |
22 |
| - let (_, _,) = (1, 1,); |
23 |
| - let [_, _,] = [1, 1,]; |
24 |
| - let [_, _, .., _,] = [1, 1, 1, 1,]; |
25 |
| - let [_, _, _, ..,] = [1, 1, 1, 1,]; |
| 30 | + f::<isize>(0); |
| 31 | + let (_, _) = (1, 1); |
| 32 | + let [_, _] = [1, 1]; |
| 33 | + let [_, _, .., _] = [1, 1, 1, 1]; |
| 34 | + let [_, _, _, ..] = [1, 1, 1, 1]; |
26 | 35 |
|
27 |
| - let x: Foo<isize,> = Foo::<isize,>(1); |
| 36 | + let x: Foo<isize> = Foo::<isize>(1); |
28 | 37 |
|
29 |
| - Bar::f(0,); |
30 |
| - Bar.g(0,); |
| 38 | + Bar::f(0); |
| 39 | + Bar.g(0); |
31 | 40 | Bar.h();
|
32 | 41 |
|
33 |
| - let x = Baz::Qux(1,); |
| 42 | + let x = Baz::Qux(1); |
34 | 43 | }
|
0 commit comments