about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-21 15:06:20 +0000
committerbors <bors@rust-lang.org>2020-09-21 15:06:20 +0000
commit4eff9b0b29a8898c839d46f3c66526710afed68a (patch)
tree293b62ed5a035e287e40e111ccf1d32bf18de682 /compiler/rustc_error_codes/src
parente0bf356f9e5f6a8cca1eb656e900ffba79340fa1 (diff)
parent6417eb0cff24da1a6e026891c0714ef8f4f773bd (diff)
downloadrust-4eff9b0b29a8898c839d46f3c66526710afed68a.tar.gz
rust-4eff9b0b29a8898c839d46f3c66526710afed68a.zip
Auto merge of #77013 - RalfJung:rollup-84ut0xq, r=RalfJung
Rollup of 10 pull requests

Successful merges:

 - #76439 (Add error explanation for E0755)
 - #76521 (Fix segfault if pthread_getattr_np fails)
 - #76835 (make replace_prefix only take &str as arguments )
 - #76967 (Revert adding Atomic::from_mut.)
 - #76977 (Add a regression test for copy propagation miscompilation)
 - #76981 (liballoc bench use imported path Bencher)
 - #76983 (BTreeMap: extra testing & fixed comments)
 - #76996 (Fix typo in rustc_lexer docs)
 - #77009 (Dogfood total_cmp in the test crate)
 - #77012 (update Miri for another bugfix)

Failed merges:

 - #76489 (Add explanation for E0756)

r? `@ghost`
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes.rs2
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0755.md28
2 files changed, 29 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs
index b0be1bf7e72..23a7b08016e 100644
--- a/compiler/rustc_error_codes/src/error_codes.rs
+++ b/compiler/rustc_error_codes/src/error_codes.rs
@@ -440,6 +440,7 @@ E0751: include_str!("./error_codes/E0751.md"),
 E0752: include_str!("./error_codes/E0752.md"),
 E0753: include_str!("./error_codes/E0753.md"),
 E0754: include_str!("./error_codes/E0754.md"),
+E0755: include_str!("./error_codes/E0755.md"),
 E0758: include_str!("./error_codes/E0758.md"),
 E0759: include_str!("./error_codes/E0759.md"),
 E0760: include_str!("./error_codes/E0760.md"),
@@ -632,7 +633,6 @@ E0774: include_str!("./error_codes/E0774.md"),
     E0722, // Malformed `#[optimize]` attribute
     E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
 //  E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
-    E0755, // `#[ffi_pure]` is only allowed on foreign functions
     E0756, // `#[ffi_const]` is only allowed on foreign functions
     E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]`
     E0772, // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0755.md b/compiler/rustc_error_codes/src/error_codes/E0755.md
new file mode 100644
index 00000000000..88b7f484969
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0755.md
@@ -0,0 +1,28 @@
+The `ffi_pure` attribute was used on a non-foreign function.
+
+Erroneous code example:
+
+```compile_fail,E0755
+#![feature(ffi_pure)]
+
+#[ffi_pure] // error!
+pub fn foo() {}
+# fn main() {}
+```
+
+The `ffi_pure` attribute can only be used on foreign functions which do not have
+side effects or infinite loops:
+
+```
+#![feature(ffi_pure)]
+
+extern "C" {
+    #[ffi_pure] // ok!
+    pub fn strlen(s: *const i8) -> isize;
+}
+# fn main() {}
+```
+
+You can find more information about it in the [unstable Rust Book].
+
+[unstable Rust Book]: https://doc.rust-lang.org/unstable-book/language-features/ffi-pure.html