File tree 3 files changed +31
-1
lines changed
compiler/rustc_error_codes/src
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -441,6 +441,7 @@ E0752: include_str!("./error_codes/E0752.md"),
441
441
E0753 : include_str!( "./error_codes/E0753.md" ) ,
442
442
E0754 : include_str!( "./error_codes/E0754.md" ) ,
443
443
E0755 : include_str!( "./error_codes/E0755.md" ) ,
444
+ E0756 : include_str!( "./error_codes/E0756.md" ) ,
444
445
E0758 : include_str!( "./error_codes/E0758.md" ) ,
445
446
E0759 : include_str!( "./error_codes/E0759.md" ) ,
446
447
E0760 : include_str!( "./error_codes/E0760.md" ) ,
@@ -633,7 +634,6 @@ E0774: include_str!("./error_codes/E0774.md"),
633
634
E0722 , // Malformed `#[optimize]` attribute
634
635
E0726 , // non-explicit (not `'_`) elided lifetime in unsupported position
635
636
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
636
- E0756 , // `#[ffi_const]` is only allowed on foreign functions
637
637
E0757 , // `#[ffi_const]` functions cannot be `#[ffi_pure]`
638
638
E0772 , // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`.
639
639
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ LL | #[ffi_const]
6
6
7
7
error: aborting due to previous error
8
8
9
+ For more information about this error, try `rustc --explain E0756`.
You can’t perform that action at this time.
0 commit comments