When writing something like the expression `|_: ...| {}`, we now detect the `...` during parsing explicitly instead of relying on the detection in `parse_ty_common` so that we don't talk about "nested `...` are not supported".
```
error: unexpected `...`
--> $DIR/no-closure.rs:6:35
|
LL | const F: extern "C" fn(...) = |_: ...| {};
| ^^^
|
= note: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
```
21 lines
646 B
Rust
21 lines
646 B
Rust
#![feature(c_variadic)]
|
|
#![crate_type = "lib"]
|
|
|
|
// Check that `...` in closures is rejected.
|
|
|
|
const F: extern "C" fn(...) = |_: ...| {};
|
|
//~^ ERROR: unexpected `...`
|
|
//~| NOTE: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
|
|
|
|
fn foo() {
|
|
let f = |...| {};
|
|
//~^ ERROR: unexpected `...`
|
|
//~| NOTE: not a valid pattern
|
|
//~| NOTE: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
|
|
|
|
let f = |_: ...| {};
|
|
//~^ ERROR: unexpected `...`
|
|
//~| NOTE: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
|
|
f(1i64)
|
|
}
|