]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0757.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0757.md
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 `ffi_const` provides stronger guarantees than `ffi_pure`, remove the
16 `ffi_pure` attribute:
17
18 ```
19 #![feature(ffi_const)]
20
21 extern "C" {
22     #[ffi_const]
23     pub fn square(num: i32) -> i32;
24 }
25 ```
26
27 You can get more information about `const` and `pure` in the [GCC documentation
28 on Common Function Attributes]. The unstable Rust Book has more information
29 about [`ffi_const`] and [`ffi_pure`].
30
31 [GCC documentation on Common Function Attributes]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
32 [`ffi_const`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-const.html
33 [`ffi_pure`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-pure.html