Skip to content

Add long error explanation for E0724 #73163

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
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_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -615,7 +616,6 @@ E0760: include_str!("./error_codes/E0760.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
Expand Down
24 changes: 24 additions & 0 deletions src/librustc_error_codes/error_codes/E0724.md
Original file line number Diff line number Diff line change
@@ -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();
}
```
1 change: 1 addition & 0 deletions src/test/ui/ffi_returns_twice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | #[ffi_returns_twice]

error: aborting due to previous error

For more information about this error, try `rustc --explain E0724`.