Skip to content

Commit 2779261

Browse files
committed
trailing-comma
1 parent 6fbb60c commit 2779261

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed
Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
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+
110
//@ run-pass
211

3-
fn f<T,>(_: T,) {}
12+
fn f<T>(_: T) {}
413

5-
struct Foo<T,>(#[allow(dead_code)] T);
14+
struct Foo<T>(#[allow(dead_code)] T);
615

716
struct Bar;
817

918
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) {}
1322
}
1423

1524
enum Baz {
16-
Qux(#[allow(dead_code)] isize,),
25+
Qux(#[allow(dead_code)] isize),
1726
}
1827

19-
#[allow(unused,)]
28+
#[allow(unused)]
2029
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];
2635

27-
let x: Foo<isize,> = Foo::<isize,>(1);
36+
let x: Foo<isize> = Foo::<isize>(1);
2837

29-
Bar::f(0,);
30-
Bar.g(0,);
38+
Bar::f(0);
39+
Bar.g(0);
3140
Bar.h();
3241

33-
let x = Baz::Qux(1,);
42+
let x = Baz::Qux(1);
3443
}

0 commit comments

Comments
 (0)