about summary refs log tree commit diff
path: root/src/test/ui/consts
diff options
context:
space:
mode:
authorsd234678 <sd234678@protonmail.com>2019-08-19 22:31:46 +0100
committersd234678 <sd234678@protonmail.com>2019-08-19 22:31:46 +0100
commit4eec03d33e0a833cb48998f5d8e47c01b9e32cf4 (patch)
tree1fcbcf2cfb532ca21bec2fcfdd2f312b278a74d4 /src/test/ui/consts
parent14890954ce17c44d944eda988c5a64bb4c5ec9eb (diff)
downloadrust-4eec03d33e0a833cb48998f5d8e47c01b9e32cf4.tar.gz
rust-4eec03d33e0a833cb48998f5d8e47c01b9e32cf4.zip
Cherry-pick src/test changes with Centril's changes
Diffstat (limited to 'src/test/ui/consts')
-rw-r--r--src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs16
-rw-r--r--src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr (renamed from src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr)10
-rw-r--r--src/test/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs (renamed from src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs)23
3 files changed, 22 insertions, 27 deletions
diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs
new file mode 100644
index 00000000000..4281874a031
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs
@@ -0,0 +1,16 @@
+const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } } //~ is unsafe
+//~^ dereferencing raw pointers in constant functions
+
+const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
+//~^ dereferencing raw pointers in constant functions
+
+const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
+//~^ dereferencing raw pointers in constant functions
+
+fn main() {}
+
+const unsafe fn no_union() {
+    union Foo { x: (), y: () }
+    Foo { x: () }.y
+    //~^ unions in const fn
+}
diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr
index d3f2ece1f92..9de0e732f33 100644
--- a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr
+++ b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr
@@ -1,5 +1,5 @@
 error[E0658]: dereferencing raw pointers in constant functions is unstable
-  --> $DIR/min_const_fn_unsafe.rs:50:77
+  --> $DIR/min_const_fn_unsafe_bad.rs:1:77
    |
 LL | const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } }
    |                                                                             ^^^
@@ -8,7 +8,7 @@ LL | const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe {
    = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
 
 error[E0658]: dereferencing raw pointers in constant functions is unstable
-  --> $DIR/min_const_fn_unsafe.rs:53:70
+  --> $DIR/min_const_fn_unsafe_bad.rs:4:70
    |
 LL | const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
    |                                                                      ^^
@@ -17,7 +17,7 @@ LL | const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
    = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
 
 error[E0658]: dereferencing raw pointers in constant functions is unstable
-  --> $DIR/min_const_fn_unsafe.rs:56:83
+  --> $DIR/min_const_fn_unsafe_bad.rs:7:83
    |
 LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
    |                                                                                   ^^^
@@ -26,7 +26,7 @@ LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static u
    = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
 
 error[E0658]: unions in const fn are unstable
-  --> $DIR/min_const_fn_unsafe.rs:63:5
+  --> $DIR/min_const_fn_unsafe_bad.rs:14:5
    |
 LL |     Foo { x: () }.y
    |     ^^^^^^^^^^^^^^^
@@ -35,7 +35,7 @@ LL |     Foo { x: () }.y
    = help: add `#![feature(const_fn_union)]` to the crate attributes to enable
 
 error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
-  --> $DIR/min_const_fn_unsafe.rs:50:77
+  --> $DIR/min_const_fn_unsafe_bad.rs:1:77
    |
 LL | const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } }
    |                                                                             ^^^ dereference of raw pointer
diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs
index 0152561aefc..02c7970deca 100644
--- a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs
+++ b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs
@@ -1,6 +1,4 @@
-//------------------------------------------------------------------------------
-// OK
-//------------------------------------------------------------------------------
+// check-pass
 
 const unsafe fn ret_i32_no_unsafe() -> i32 { 42 }
 const unsafe fn ret_null_ptr_no_unsafe<T>() -> *const T { std::ptr::null() }
@@ -43,23 +41,4 @@ const unsafe fn call_unsafe_generic_cell_const_unsafe_fn_immediate()
     ret_null_mut_ptr_no_unsafe::<Vec<std::cell::Cell<u32>>>()
 }
 
-//------------------------------------------------------------------------------
-// NOT OK
-//------------------------------------------------------------------------------
-
-const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } } //~ is unsafe
-//~^ dereferencing raw pointers in constant functions
-
-const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
-//~^ dereferencing raw pointers in constant functions
-
-const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
-//~^ dereferencing raw pointers in constant functions
-
 fn main() {}
-
-const unsafe fn no_union() {
-    union Foo { x: (), y: () }
-    Foo { x: () }.y
-    //~^ unions in const fn
-}