Skip to content

Commit d54ab41

Browse files
committed
Auto merge of #26503 - GuillaumeGomez:patch-4, r=Manishearth
r? @Manishearth
2 parents 3223c88 + 3ff1222 commit d54ab41

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
15511551
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
15521552
ast::TyBareFn(ref bf) => {
15531553
if bf.decl.variadic && bf.abi != abi::C {
1554-
span_err!(tcx.sess, ast_ty.span, E0222,
1554+
span_err!(tcx.sess, ast_ty.span, E0045,
15551555
"variadic function must have C calling convention");
15561556
}
15571557
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);

src/librustc_typeck/diagnostics.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,28 @@ fn main() {
380380
```
381381
"##,
382382

383+
E0045: r##"
384+
Rust only supports variadic parameters for interoperability with C code in its
385+
FFI. As such, variadic parameters can only be used with functions which are
386+
using the C ABI. Examples of erroneous code:
387+
388+
```
389+
extern "rust-call" { fn foo(x: u8, ...); }
390+
// or
391+
fn foo(x: u8, ...) {}
392+
```
393+
394+
To fix such code, put them in an extern "C" block:
395+
396+
```
397+
extern "C" fn foo (x: u8, ...);
398+
// or:
399+
extern "C" {
400+
fn foo (x: u8, ...);
401+
}
402+
```
403+
"##,
404+
383405
E0046: r##"
384406
When trying to make some type implement a trait `Foo`, you must, at minimum,
385407
provide implementations for all of `Foo`'s required methods (meaning the
@@ -1467,7 +1489,6 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust
14671489

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

0 commit comments

Comments
 (0)