Add long explanation for E0757

This commit is contained in:
Chris Midgley
2021-07-21 13:22:57 +01:00
parent cf932aa584
commit 27ffc3725a
3 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
A function was given both the `ffi_const` and `ffi_pure` attributes.
Erroneous code example:
```compile_fail,E0757
#![feature(ffi_const, ffi_pure)]
extern "C" {
#[ffi_const]
#[ffi_pure] // error: `#[ffi_const]` function cannot be `#[ffi_pure]`
pub fn square(num: i32) -> i32;
}
```
As `const` has a stricter set of requirements than `pure`, remove the `ffi_pure`
attribute:
```
#![feature(ffi_const)]
extern "C" {
#[ffi_const]
pub fn square(num: i32) -> i32;
}
```