about summary refs log tree commit diff
path: root/src/test/ui/const-eval
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-07-02 19:59:39 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-08-07 14:41:33 +0200
commitfee07534bbe192befadb03b1626c2bbf3d6e5cfb (patch)
tree91eff421355539c24c88e68708e1a71117e8aaa7 /src/test/ui/const-eval
parent3ef863bfdfb9173a0ad55d24e20202948dda6bbe (diff)
Add feature gate checks
Diffstat (limited to 'src/test/ui/const-eval')
-rw-r--r--src/test/ui/const-eval/feature-gate-const_fn_union.rs22
-rw-r--r--src/test/ui/const-eval/feature-gate-const_fn_union.stderr11
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/const-eval/feature-gate-const_fn_union.rs b/src/test/ui/const-eval/feature-gate-const_fn_union.rs
new file mode 100644
index 00000000000..113046b0689
--- /dev/null
+++ b/src/test/ui/const-eval/feature-gate-const_fn_union.rs
@@ -0,0 +1,22 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_fn)]
+
+fn main() {}
+
+union Foo {
+    u: u32,
+    i: i32,
+}
+
+const unsafe fn foo(u: u32) -> i32 {
+    Foo { u }.i //~ ERROR unions in const fn are unstable
+}
diff --git a/src/test/ui/const-eval/feature-gate-const_fn_union.stderr b/src/test/ui/const-eval/feature-gate-const_fn_union.stderr
new file mode 100644
index 00000000000..1e28f14165f
--- /dev/null
+++ b/src/test/ui/const-eval/feature-gate-const_fn_union.stderr
@@ -0,0 +1,11 @@
+error[E0658]: unions in const fn are unstable (see issue #51909)
+  --> $DIR/feature-gate-const_fn_union.rs:21:5
+   |
+LL |     Foo { u }.i //~ ERROR unions in const fn are unstable
+   |     ^^^^^^^^^^^
+   |
+   = help: add #![feature(const_fn_union)] to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.