File tree 3 files changed +30
-1
lines changed
compiler/rustc_error_codes/src
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -440,6 +440,7 @@ E0751: include_str!("./error_codes/E0751.md"),
440
440
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
+ E0755 : include_str!( "./error_codes/E0755.md" ) ,
443
444
E0758 : include_str!( "./error_codes/E0758.md" ) ,
444
445
E0759 : include_str!( "./error_codes/E0759.md" ) ,
445
446
E0760 : include_str!( "./error_codes/E0760.md" ) ,
@@ -631,7 +632,6 @@ E0773: include_str!("./error_codes/E0773.md"),
631
632
E0722 , // Malformed `#[optimize]` attribute
632
633
E0726 , // non-explicit (not `'_`) elided lifetime in unsupported position
633
634
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
634
- E0755 , // `#[ffi_pure]` is only allowed on foreign functions
635
635
E0756 , // `#[ffi_const]` is only allowed on foreign functions
636
636
E0757 , // `#[ffi_const]` functions cannot be `#[ffi_pure]`
637
637
E0772 , // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`.
Original file line number Diff line number Diff line change
1
+ The ` ffi_pure ` attribute was used on a non-foreign function.
2
+
3
+ Erroneous code example:
4
+
5
+ ``` compile_fail,E0755
6
+ #![feature(ffi_pure)]
7
+
8
+ #[ffi_pure] // error!
9
+ pub fn foo() {}
10
+ # fn main() {}
11
+ ```
12
+
13
+ The ` ffi_pure ` attribute can only be used on foreign functions which do not have
14
+ side effects or infinite loops:
15
+
16
+ ```
17
+ #![feature(ffi_pure)]
18
+
19
+ extern "C" {
20
+ #[ffi_pure] // ok!
21
+ pub fn strlen(s: *const i8) -> isize;
22
+ }
23
+ # fn main() {}
24
+ ```
25
+
26
+ You can find more information about it in the [ unstable Rust Book] .
27
+
28
+ [ unstable Rust Book ] : https://doc.rust-lang.org/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 E0755`.
You can’t perform that action at this time.
0 commit comments