about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-10-20 14:07:46 +0000
committerbors <bors@rust-lang.org>2019-10-20 14:07:46 +0000
commit89e645ace853d86e8c0002247482eac9073c90fd (patch)
tree7b52eb4ca8e821ef521a8ae45a82746f7e85edc8 /src/test
parent857a55b8f0a692cb2304ab7c062d9cc74122e516 (diff)
parentba42fc27fd8cd089fc101c9724c2c4326ada9a4b (diff)
downloadrust-89e645ace853d86e8c0002247482eac9073c90fd.tar.gz
rust-89e645ace853d86e8c0002247482eac9073c90fd.zip
Auto merge of #65622 - Centril:rollup-l8orba7, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #64996 (Inline `ptr::null(_mut)` even in debug builds)
 - #65551 (Avoid realloc in `CString::new`)
 - #65593 (add test for calling non-const fn)
 - #65595 (move `parse_cfgspecs` to `rustc_interface`)
 - #65600 (Remove unneeded `ref` from docs)
 - #65602 (Fix plural mistake in emitter.rs)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/miri_unleashed/non_const_fn.rs13
-rw-r--r--src/test/ui/consts/miri_unleashed/non_const_fn.stderr29
-rw-r--r--src/test/ui/issues/issue-17546.stderr4
3 files changed, 44 insertions, 2 deletions
diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.rs b/src/test/ui/consts/miri_unleashed/non_const_fn.rs
new file mode 100644
index 00000000000..e1ac4306575
--- /dev/null
+++ b/src/test/ui/consts/miri_unleashed/non_const_fn.rs
@@ -0,0 +1,13 @@
+// compile-flags: -Zunleash-the-miri-inside-of-you
+#![warn(const_err)]
+
+// A test demonstrating that we prevent calling non-const fn during CTFE.
+
+fn foo() {}
+
+const C: () = foo(); //~ WARN: skipping const checks
+//~^ WARN any use of this value will cause an error
+
+fn main() {
+    println!("{:?}", C); //~ ERROR: evaluation of constant expression failed
+}
diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr
new file mode 100644
index 00000000000..7a574b34304
--- /dev/null
+++ b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr
@@ -0,0 +1,29 @@
+warning: skipping const checks
+  --> $DIR/non_const_fn.rs:8:15
+   |
+LL | const C: () = foo();
+   |               ^^^^^
+
+warning: any use of this value will cause an error
+  --> $DIR/non_const_fn.rs:8:15
+   |
+LL | const C: () = foo();
+   | --------------^^^^^-
+   |               |
+   |               calling non-const function `foo`
+   |
+note: lint level defined here
+  --> $DIR/non_const_fn.rs:2:9
+   |
+LL | #![warn(const_err)]
+   |         ^^^^^^^^^
+
+error[E0080]: evaluation of constant expression failed
+  --> $DIR/non_const_fn.rs:12:22
+   |
+LL |     println!("{:?}", C);
+   |                      ^ referenced constant has errors
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/issues/issue-17546.stderr b/src/test/ui/issues/issue-17546.stderr
index 4a0fb186e49..291086d4f69 100644
--- a/src/test/ui/issues/issue-17546.stderr
+++ b/src/test/ui/issues/issue-17546.stderr
@@ -27,7 +27,7 @@ LL |     use std::prelude::v1::Result;
    |
 LL |     use std::result::Result;
    |
-     and 1 other candidates
+     and 1 other candidate
 
 error[E0573]: expected type, found variant `Result`
   --> $DIR/issue-17546.rs:28:13
@@ -44,7 +44,7 @@ LL | use std::prelude::v1::Result;
    |
 LL | use std::result::Result;
    |
-     and 1 other candidates
+     and 1 other candidate
 
 error[E0573]: expected type, found variant `NoResult`
   --> $DIR/issue-17546.rs:33:15