diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-10-31 10:39:38 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-10-31 10:39:38 +0100 |
| commit | 5dfb167bf33162f03e11e42f74c8d2befefbb04d (patch) | |
| tree | ae8795826c6c7804d3648887a5df9d031fddd0af | |
| parent | 0b7e28a1610924a27471ffdb59a2885709b3b415 (diff) | |
| download | rust-5dfb167bf33162f03e11e42f74c8d2befefbb04d.tar.gz rust-5dfb167bf33162f03e11e42f74c8d2befefbb04d.zip | |
Create new error E0743
| -rw-r--r-- | src/libsyntax/error_codes.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/ty.rs | 7 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/libsyntax/error_codes.rs b/src/libsyntax/error_codes.rs index 17ea4767520..941df5ea570 100644 --- a/src/libsyntax/error_codes.rs +++ b/src/libsyntax/error_codes.rs @@ -487,7 +487,6 @@ Erroneous code example: // `test_2018_feature` is // included in the Rust 2018 edition ``` - "##, E0725: r##" @@ -505,6 +504,20 @@ Delete the offending feature attribute, or add it to the list of allowed features in the `-Z allow_features` flag. "##, +E0743: r##" +C-variadic has been used on a non-foreign function. + +Erroneous code example: + +```compile_fail,E0743 +fn foo2(x: u8, ...) {} // error! +``` + +Only foreign functions can use C-variadic (`...`). It is used to give an +undefined number of parameters to a given function (like `printf` in C). The +equivalent in Rust would be to use macros directly. +"##, + ; E0539, // incorrect meta item diff --git a/src/libsyntax/parse/parser/ty.rs b/src/libsyntax/parse/parser/ty.rs index 86c94b680b2..e8f718a2483 100644 --- a/src/libsyntax/parse/parser/ty.rs +++ b/src/libsyntax/parse/parser/ty.rs @@ -197,8 +197,11 @@ impl<'a> Parser<'a> { self.eat(&token::DotDotDot); TyKind::CVarArgs } else { - return Err(self.fatal( - "only foreign functions are allowed to be C-variadic" + return Err(struct_span_fatal!( + self.sess.span_diagnostic, + self.token.span, + E0743, + "only foreign functions are allowed to be C-variadic", )); } } else { |
