Skip to content

Commit c1613c0

Browse files
committed
not use capture_cfg
1 parent 903cf7e commit c1613c0

File tree

4 files changed

+24
-38
lines changed

4 files changed

+24
-38
lines changed

compiler/rustc_parse/src/parser/item.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -2496,15 +2496,11 @@ impl<'a> Parser<'a> {
24962496
p.recover_diff_marker();
24972497
let starts_with_paren = p.check_noexpect(&token::OpenDelim(Delimiter::Parenthesis));
24982498
let param = p.parse_param_general(req_name, first_param).or_else(|mut e| {
2499-
if p.capture_cfg {
2500-
e.cancel();
2501-
} else {
2502-
e.emit();
2503-
}
2499+
e.emit();
25042500
let lo = p.prev_token.span;
25052501
// Skip every token until next possible arg or end.
25062502
p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(Delimiter::Parenthesis)]);
2507-
if p.capture_cfg && starts_with_paren {
2503+
if starts_with_paren {
25082504
p.eat_noexpect(&token::CloseDelim(Delimiter::Parenthesis));
25092505
}
25102506
// Create a placeholder argument for proper arg count (issue #34264).

tests/ui/parser/inverted-parameters.stderr

+16-25
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,25 @@ error: expected one of `:` or `|`, found `(`
2828
LL | fn pattern((i32, i32) (a, b)) {}
2929
| ^ expected one of `:` or `|`
3030

31-
error: expected one of `:`, `@`, or `|`, found `)`
32-
--> $DIR/inverted-parameters.rs:21:12
31+
error: expected parameter name, found `{`
32+
--> $DIR/inverted-parameters.rs:18:31
3333
|
34-
LL | fn fizz(i32) {}
35-
| ^ expected one of `:`, `@`, or `|`
36-
|
37-
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
38-
help: if this is a `self` type, give it a parameter name
39-
|
40-
LL | fn fizz(self: i32) {}
41-
| +++++
42-
help: if this is a parameter name, give it a type
43-
|
44-
LL | fn fizz(i32: TypeName) {}
45-
| ++++++++++
46-
help: if this is a type, explicitly ignore the parameter name
34+
LL | fn pattern((i32, i32) (a, b)) {}
35+
| ^ expected parameter name
36+
37+
error: expected one of `)` or `,`, found `{`
38+
--> $DIR/inverted-parameters.rs:18:31
4739
|
48-
LL | fn fizz(_: i32) {}
49-
| ++
40+
LL | fn pattern((i32, i32) (a, b)) {}
41+
| -^ expected one of `)` or `,`
42+
| |
43+
| help: missing `,`
5044

51-
error: expected one of `:`, `@`, or `|`, found `S`
52-
--> $DIR/inverted-parameters.rs:27:23
45+
error: expected one of `)`, `,`, `->`, `where`, or `{`, found `<eof>`
46+
--> $DIR/inverted-parameters.rs:32:12
5347
|
54-
LL | fn missing_colon(quux S) {}
55-
| -----^
56-
| | |
57-
| | expected one of `:`, `@`, or `|`
58-
| help: declare the type after the parameter binding: `<identifier>: <type>`
48+
LL | fn main() {}
49+
| ^ expected one of `)`, `,`, `->`, `where`, or `{`
5950

60-
error: aborting due to 6 previous errors
51+
error: aborting due to 7 previous errors
6152

tests/ui/parser/issue-116781.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
struct Foo {
33
#[cfg(all())]
44
field: fn(($),), //~ ERROR expected pattern, found `$`
5-
//~^ ERROR expected identifier, found `)`
5+
//~^ ERROR expected pattern, found `$`
66
}
77

88
fn main() {}

tests/ui/parser/issue-116781.stderr

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ error: expected pattern, found `$`
44
LL | field: fn(($),),
55
| ^ expected pattern
66

7-
error: expected identifier, found `)`
8-
--> $DIR/issue-116781.rs:4:19
7+
error: expected pattern, found `$`
8+
--> $DIR/issue-116781.rs:4:16
99
|
10-
LL | struct Foo {
11-
| --- while parsing this struct
12-
LL | #[cfg(all())]
1310
LL | field: fn(($),),
14-
| ^ expected identifier
11+
| ^ expected pattern
12+
|
13+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1514

1615
error: aborting due to 2 previous errors
1716

0 commit comments

Comments
 (0)