Skip to content

Commit 594685b

Browse files
committed
token::LArrow can begin arguments
`<-` may indicate the start of a negative const argument.
1 parent 7ac0200 commit 594685b

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,8 @@ impl<'a> Parser<'a> {
23192319
let ident = self.parse_path_segment_ident()?;
23202320

23212321
let is_args_start = |token: &token::Token| match *token {
2322-
token::Lt | token::BinOp(token::Shl) | token::OpenDelim(token::Paren) => true,
2322+
token::Lt | token::BinOp(token::Shl) | token::OpenDelim(token::Paren)
2323+
| token::LArrow => true,
23232324
_ => false,
23242325
};
23252326
let check_args_start = |this: &mut Self| {

src/test/ui/const-generics/const-expression-parameter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn i32_identity<const X: i32>() -> i32 {
66
}
77

88
fn foo_a() {
9-
i32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
9+
i32_identity::<-1>(); // ok
1010
}
1111

1212
fn foo_b() {
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error: expected identifier, found `<-`
2-
--> $DIR/const-expression-parameter.rs:9:19
3-
|
4-
LL | i32_identity::<-1>();
5-
| ^^ expected identifier
6-
71
error: expected one of `,` or `>`, found `+`
82
--> $DIR/const-expression-parameter.rs:13:22
93
|
@@ -16,5 +10,5 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
1610
LL | #![feature(const_generics)]
1711
| ^^^^^^^^^^^^^^
1812

19-
error: aborting due to 2 previous errors
13+
error: aborting due to previous error
2014

0 commit comments

Comments
 (0)