Skip to content

Unify variadic errors #26503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
ast::TyBareFn(ref bf) => {
if bf.decl.variadic && bf.abi != abi::C {
span_err!(tcx.sess, ast_ty.span, E0222,
span_err!(tcx.sess, ast_ty.span, E0045,
"variadic function must have C calling convention");
}
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
Expand Down
26 changes: 24 additions & 2 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,28 @@ fn main() {
```
"##,

E0045: r##"
Rust only supports variadic parameters for interoperability with C code in its
FFI. As such, variadic parameters can only be used with functions which are
using the C ABI. Examples of erroneous code:

```
extern "rust-call" { fn foo(x: u8, ...); }
// or
fn foo(x: u8, ...) {}
```

To fix such code, put them in an extern "C" block:

```
extern "C" fn foo (x: u8, ...);
// or:
extern "C" {
fn foo (x: u8, ...);
}
```
"##,

E0046: r##"
When trying to make some type implement a trait `Foo`, you must, at minimum,
provide implementations for all of `Foo`'s required methods (meaning the
Expand Down Expand Up @@ -1467,7 +1489,6 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust

register_diagnostics! {
E0044, // foreign items may not have type parameters
E0045, // variadic function must have C calling convention
E0068,
E0071,
E0074,
Expand Down Expand Up @@ -1535,7 +1556,8 @@ register_diagnostics! {
E0219, // associated type defined in higher-ranked supertrait
E0220, // associated type not found for type parameter
E0221, // ambiguous associated type in bounds
E0222, // variadic function must have C calling convention
//E0222, // Error code E0045 (variadic function must have C calling
// convention) duplicate
E0223, // ambiguous associated type
E0224, // at least one non-builtin train is required for an object type
E0225, // only the builtin traits can be used as closure or object bounds
Expand Down