]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0756.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0756.md
1 The `ffi_const` attribute was used on something other than a foreign function
2 declaration.
3
4 Erroneous code example:
5
6 ```compile_fail,E0756
7 #![feature(ffi_const)]
8
9 #[ffi_const] // error!
10 pub fn foo() {}
11 # fn main() {}
12 ```
13
14 The `ffi_const` attribute can only be used on foreign function declarations
15 which have no side effects except for their return value:
16
17 ```
18 #![feature(ffi_const)]
19
20 extern "C" {
21     #[ffi_const] // ok!
22     pub fn strlen(s: *const i8) -> i32;
23 }
24 # fn main() {}
25 ```
26
27 You can get more information about it in the [unstable Rust Book].
28
29 [unstable Rust Book]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-const.html