Skip to content

Commit 68b4c03

Browse files
author
Ayush Kumar Mishra
committed
Add long error explanation for E0724
Minor refactoring Minor refactoring Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood <[email protected]> Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood <[email protected]> Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood <[email protected]> Minor refactoring
1 parent ccac43b commit 68b4c03

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ E0718: include_str!("./error_codes/E0718.md"),
409409
E0719: include_str!("./error_codes/E0719.md"),
410410
E0720: include_str!("./error_codes/E0720.md"),
411411
E0723: include_str!("./error_codes/E0723.md"),
412+
E0724: include_str!("./error_codes/E0724.md"),
412413
E0725: include_str!("./error_codes/E0725.md"),
413414
E0727: include_str!("./error_codes/E0727.md"),
414415
E0728: include_str!("./error_codes/E0728.md"),
@@ -615,7 +616,6 @@ E0760: include_str!("./error_codes/E0760.md"),
615616
E0717, // rustc_promotable without stability attribute
616617
// E0721, // `await` keyword
617618
E0722, // Malformed `#[optimize]` attribute
618-
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
619619
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
620620
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
621621
E0755, // `#[ffi_pure]` is only allowed on foreign functions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
`#[ffi_returns_twice]` was used on non-foreign function.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0724
6+
#![feature(ffi_returns_twice)]
7+
#![crate_type = "lib"]
8+
9+
#[ffi_returns_twice] // error!
10+
pub fn foo() {}
11+
```
12+
13+
`#[ffi_returns_twice]` can only be used on foreign function declarations.
14+
For example, we might correct the previous example by declaring
15+
the function inside of an `extern` block.
16+
17+
```
18+
#![feature(ffi_returns_twice)]
19+
20+
extern {
21+
#[ffi_returns_twice] // ok!
22+
pub fn foo();
23+
}
24+
```

src/test/ui/ffi_returns_twice.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | #[ffi_returns_twice]
66

77
error: aborting due to previous error
88

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

0 commit comments

Comments
 (0)