Rollup merge of #73163 - ayushmishra2005:61137-add-long-error-code-e0724, r=davidtwco

Add long error explanation for E0724

Add long explanation for the E0724 error code
Part of #61137
This commit is contained in:
Dylan DPC 2020-06-12 00:05:29 +02:00 committed by GitHub
commit 6baf867882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -409,6 +409,7 @@ E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"),
E0723: include_str!("./error_codes/E0723.md"),
E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"),
E0728: include_str!("./error_codes/E0728.md"),
@ -617,7 +618,6 @@ E0762: include_str!("./error_codes/E0762.md"),
E0717, // rustc_promotable without stability attribute
// E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
E0755, // `#[ffi_pure]` is only allowed on foreign functions

View File

@ -0,0 +1,24 @@
`#[ffi_returns_twice]` was used on non-foreign function.
Erroneous code example:
```compile_fail,E0724
#![feature(ffi_returns_twice)]
#![crate_type = "lib"]
#[ffi_returns_twice] // error!
pub fn foo() {}
```
`#[ffi_returns_twice]` can only be used on foreign function declarations.
For example, we might correct the previous example by declaring
the function inside of an `extern` block.
```
#![feature(ffi_returns_twice)]
extern {
#[ffi_returns_twice] // ok!
pub fn foo();
}
```

View File

@ -6,3 +6,4 @@ LL | #[ffi_returns_twice]
error: aborting due to previous error
For more information about this error, try `rustc --explain E0724`.