about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-19 09:29:48 +0000
committerbors <bors@rust-lang.org>2018-10-19 09:29:48 +0000
commit74ff7dcb1388e60a613cd6050bcd372a3cc4998b (patch)
tree4b035c9be0ee57066b2427b5d98794887b4f6e75 /src/test
parentdbab381da1a46a18e46a04a61156aec40c59a4f6 (diff)
parent0724efd9a1aac9cf4620795786fb8e896fbb17b3 (diff)
downloadrust-74ff7dcb1388e60a613cd6050bcd372a3cc4998b.tar.gz
rust-74ff7dcb1388e60a613cd6050bcd372a3cc4998b.zip
Auto merge of #55194 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

Successful merges:

 - #54300 (Updated RELEASES.md for 1.30.0)
 - #55013 ([NLL] Propagate bounds from generators)
 - #55071 (Fix ICE and report a human readable error)
 - #55144 (Cleanup resolve)
 - #55166 (Don't warn about parentheses on `match (return)`)
 - #55169 (Add a `copysign` function to f32 and f64)
 - #55178 (Stabilize slice::chunks_exact(), chunks_exact_mut(), rchunks(), rchunks_mut(), rchunks_exact(), rchunks_exact_mut())
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs5
-rw-r--r--src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr10
-rw-r--r--src/test/ui/consts/min_const_fn/cast_errors.rs14
-rw-r--r--src/test/ui/consts/min_const_fn/cast_errors.stderr32
-rw-r--r--src/test/ui/generator/generator-region-requirements.ast.stderr12
-rw-r--r--src/test/ui/generator/generator-region-requirements.nll.stderr12
-rw-r--r--src/test/ui/generator/generator-region-requirements.rs21
-rw-r--r--src/test/ui/lint/no-unused-parens-return-block.rs9
8 files changed, 115 insertions, 0 deletions
diff --git a/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs b/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs
new file mode 100644
index 00000000000..3e42cb8c1b0
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs
@@ -0,0 +1,5 @@
+const fn foo(a: i32) -> Vec<i32> {
+    vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr b/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr
new file mode 100644
index 00000000000..f6b704370b6
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr
@@ -0,0 +1,10 @@
+error: heap allocations are not allowed in const fn
+  --> $DIR/bad_const_fn_body_ice.rs:2:5
+   |
+LL |     vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn
+   |     ^^^^^^^^^^^^^
+   |
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/consts/min_const_fn/cast_errors.rs b/src/test/ui/consts/min_const_fn/cast_errors.rs
new file mode 100644
index 00000000000..8648cd35387
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/cast_errors.rs
@@ -0,0 +1,14 @@
+fn main() {}
+
+const fn unsize(x: &[u8; 3]) -> &[u8] { x }
+//~^ ERROR unsizing casts are not allowed in const fn
+const fn closure() -> fn() { || {} }
+//~^ ERROR function pointers in const fn are unstable
+const fn closure2() {
+    (|| {}) as fn();
+//~^ ERROR function pointers in const fn are unstable
+}
+const fn reify(f: fn()) -> unsafe fn() { f }
+//~^ ERROR function pointers in const fn are unstable
+const fn reify2() { main as unsafe fn(); }
+//~^ ERROR function pointers in const fn are unstable
diff --git a/src/test/ui/consts/min_const_fn/cast_errors.stderr b/src/test/ui/consts/min_const_fn/cast_errors.stderr
new file mode 100644
index 00000000000..ba980b7aacb
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/cast_errors.stderr
@@ -0,0 +1,32 @@
+error: unsizing casts are not allowed in const fn
+  --> $DIR/cast_errors.rs:3:41
+   |
+LL | const fn unsize(x: &[u8; 3]) -> &[u8] { x }
+   |                                         ^
+
+error: function pointers in const fn are unstable
+  --> $DIR/cast_errors.rs:5:23
+   |
+LL | const fn closure() -> fn() { || {} }
+   |                       ^^^^
+
+error: function pointers in const fn are unstable
+  --> $DIR/cast_errors.rs:8:5
+   |
+LL |     (|| {}) as fn();
+   |     ^^^^^^^^^^^^^^^
+
+error: function pointers in const fn are unstable
+  --> $DIR/cast_errors.rs:11:28
+   |
+LL | const fn reify(f: fn()) -> unsafe fn() { f }
+   |                            ^^^^^^^^^^^
+
+error: function pointers in const fn are unstable
+  --> $DIR/cast_errors.rs:13:21
+   |
+LL | const fn reify2() { main as unsafe fn(); }
+   |                     ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
+
diff --git a/src/test/ui/generator/generator-region-requirements.ast.stderr b/src/test/ui/generator/generator-region-requirements.ast.stderr
new file mode 100644
index 00000000000..6a423aea7ec
--- /dev/null
+++ b/src/test/ui/generator/generator-region-requirements.ast.stderr
@@ -0,0 +1,12 @@
+error[E0621]: explicit lifetime required in the type of `x`
+  --> $DIR/generator-region-requirements.rs:15:51
+   |
+LL | fn dangle(x: &mut i32) -> &'static mut i32 {
+   |              -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
+...
+LL |             GeneratorState::Complete(c) => return c,
+   |                                                   ^ lifetime `'static` required
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0621`.
diff --git a/src/test/ui/generator/generator-region-requirements.nll.stderr b/src/test/ui/generator/generator-region-requirements.nll.stderr
new file mode 100644
index 00000000000..5d1050dc352
--- /dev/null
+++ b/src/test/ui/generator/generator-region-requirements.nll.stderr
@@ -0,0 +1,12 @@
+error[E0621]: explicit lifetime required in the type of `x`
+  --> $DIR/generator-region-requirements.rs:11:9
+   |
+LL | fn dangle(x: &mut i32) -> &'static mut i32 {
+   |              -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
+...
+LL |         x
+   |         ^ lifetime `'static` required
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0621`.
diff --git a/src/test/ui/generator/generator-region-requirements.rs b/src/test/ui/generator/generator-region-requirements.rs
new file mode 100644
index 00000000000..59e7841309c
--- /dev/null
+++ b/src/test/ui/generator/generator-region-requirements.rs
@@ -0,0 +1,21 @@
+// revisions: ast nll
+// ignore-compare-mode-nll
+
+#![feature(generators, generator_trait)]
+#![cfg_attr(nll, feature(nll))]
+use std::ops::{Generator, GeneratorState};
+
+fn dangle(x: &mut i32) -> &'static mut i32 {
+    let mut g = || {
+        yield;
+        x
+    };
+    loop {
+        match unsafe { g.resume() } {
+            GeneratorState::Complete(c) => return c,
+            GeneratorState::Yielded(_) => (),
+        }
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/no-unused-parens-return-block.rs b/src/test/ui/lint/no-unused-parens-return-block.rs
new file mode 100644
index 00000000000..37dc519a204
--- /dev/null
+++ b/src/test/ui/lint/no-unused-parens-return-block.rs
@@ -0,0 +1,9 @@
+// run-pass
+
+#![deny(unused_parens)]
+#![allow(unreachable_code)]
+
+fn main() {
+    match (return) {} // ok
+    if (return) {} // ok
+}