File tree 3 files changed +35
-1
lines changed
compiler/rustc_error_codes/src
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,7 @@ E0753: include_str!("./error_codes/E0753.md"),
450
450
E0754 : include_str!( "./error_codes/E0754.md" ) ,
451
451
E0755 : include_str!( "./error_codes/E0755.md" ) ,
452
452
E0756 : include_str!( "./error_codes/E0756.md" ) ,
453
+ E0757 : include_str!( "./error_codes/E0757.md" ) ,
453
454
E0758 : include_str!( "./error_codes/E0758.md" ) ,
454
455
E0759 : include_str!( "./error_codes/E0759.md" ) ,
455
456
E0760 : include_str!( "./error_codes/E0760.md" ) ,
@@ -638,6 +639,5 @@ E0783: include_str!("./error_codes/E0783.md"),
638
639
// E0723, unstable feature in `const` context
639
640
E0726 , // non-explicit (not `'_`) elided lifetime in unsupported position
640
641
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
641
- E0757 , // `#[ffi_const]` functions cannot be `#[ffi_pure]`
642
642
E0772 , // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`.
643
643
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ LL | #[ffi_pure]
6
6
7
7
error: aborting due to previous error
8
8
9
+ For more information about this error, try `rustc --explain E0757`.
You can’t perform that action at this time.
0 commit comments