Skip to content

Commit 27ffc37

Browse files
committed
Add long explanation for E0757
1 parent cf932aa commit 27ffc37

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ E0753: include_str!("./error_codes/E0753.md"),
449449
E0754: include_str!("./error_codes/E0754.md"),
450450
E0755: include_str!("./error_codes/E0755.md"),
451451
E0756: include_str!("./error_codes/E0756.md"),
452+
E0757: include_str!("./error_codes/E0757.md"),
452453
E0758: include_str!("./error_codes/E0758.md"),
453454
E0759: include_str!("./error_codes/E0759.md"),
454455
E0760: include_str!("./error_codes/E0760.md"),
@@ -638,6 +639,5 @@ E0783: include_str!("./error_codes/E0783.md"),
638639
// E0723, unstable feature in `const` context
639640
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
640641
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
641-
E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]`
642642
E0772, // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`.
643643
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
A function was given both the `ffi_const` and `ffi_pure` attributes.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0757
6+
#![feature(ffi_const, ffi_pure)]
7+
8+
extern "C" {
9+
#[ffi_const]
10+
#[ffi_pure] // error: `#[ffi_const]` function cannot be `#[ffi_pure]`
11+
pub fn square(num: i32) -> i32;
12+
}
13+
```
14+
15+
As `const` has a stricter set of requirements than `pure`, remove the `ffi_pure`
16+
attribute:
17+
18+
```
19+
#![feature(ffi_const)]
20+
21+
extern "C" {
22+
#[ffi_const]
23+
pub fn square(num: i32) -> i32;
24+
}
25+
```

src/test/ui/ffi_const2.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | #[ffi_pure]
66

77
error: aborting due to previous error
88

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

0 commit comments

Comments
 (0)