Skip to content

Commit 5dfb167

Browse files
Create new error E0743
1 parent 0b7e28a commit 5dfb167

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/libsyntax/error_codes.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ Erroneous code example:
487487
// `test_2018_feature` is
488488
// included in the Rust 2018 edition
489489
```
490-
491490
"##,
492491

493492
E0725: r##"
@@ -505,6 +504,20 @@ Delete the offending feature attribute, or add it to the list of allowed
505504
features in the `-Z allow_features` flag.
506505
"##,
507506

507+
E0743: r##"
508+
C-variadic has been used on a non-foreign function.
509+
510+
Erroneous code example:
511+
512+
```compile_fail,E0743
513+
fn foo2(x: u8, ...) {} // error!
514+
```
515+
516+
Only foreign functions can use C-variadic (`...`). It is used to give an
517+
undefined number of parameters to a given function (like `printf` in C). The
518+
equivalent in Rust would be to use macros directly.
519+
"##,
520+
508521
;
509522

510523
E0539, // incorrect meta item

src/libsyntax/parse/parser/ty.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,11 @@ impl<'a> Parser<'a> {
197197
self.eat(&token::DotDotDot);
198198
TyKind::CVarArgs
199199
} else {
200-
return Err(self.fatal(
201-
"only foreign functions are allowed to be C-variadic"
200+
return Err(struct_span_fatal!(
201+
self.sess.span_diagnostic,
202+
self.token.span,
203+
E0743,
204+
"only foreign functions are allowed to be C-variadic",
202205
));
203206
}
204207
} else {

0 commit comments

Comments
 (0)