about summary refs log tree commit diff
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
parent3ef863bfdfb9173a0ad55d24e20202948dda6bbe (diff)
downloadrust-fee07534bbe192befadb03b1626c2bbf3d6e5cfb.tar.gz
rust-fee07534bbe192befadb03b1626c2bbf3d6e5cfb.zip
Add feature gate checks
-rw-r--r--src/test/compile-fail/cast-ptr-to-int-const.rs2
-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
-rw-r--r--src/test/ui/error-codes/E0396.rs2
-rw-r--r--src/test/ui/error-codes/E0396.stderr2
5 files changed, 38 insertions, 1 deletions
diff --git a/src/test/compile-fail/cast-ptr-to-int-const.rs b/src/test/compile-fail/cast-ptr-to-int-const.rs
index 30f94e1b5da..8764cb72b8c 100644
--- a/src/test/compile-fail/cast-ptr-to-int-const.rs
+++ b/src/test/compile-fail/cast-ptr-to-int-const.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// gate-test-const_raw_ptr_to_usize_cast
+
 fn main() {
     const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable
     const Y: u32 = 0;
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`.
diff --git a/src/test/ui/error-codes/E0396.rs b/src/test/ui/error-codes/E0396.rs
index 6434620d26a..1ee8a74a465 100644
--- a/src/test/ui/error-codes/E0396.rs
+++ b/src/test/ui/error-codes/E0396.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// gate-test-const_raw_ptr_deref
+
 const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
 
 const VALUE: u8 = unsafe { *REG_ADDR };
diff --git a/src/test/ui/error-codes/E0396.stderr b/src/test/ui/error-codes/E0396.stderr
index 70331acc0e9..a2a2e724358 100644
--- a/src/test/ui/error-codes/E0396.stderr
+++ b/src/test/ui/error-codes/E0396.stderr
@@ -1,5 +1,5 @@
 error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911)
-  --> $DIR/E0396.rs:13:28
+  --> $DIR/E0396.rs:15:28
    |
 LL | const VALUE: u8 = unsafe { *REG_ADDR };
    |                            ^^^^^^^^^