about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-09-25 00:52:15 +0000
committerbors <bors@rust-lang.org>2017-09-25 00:52:15 +0000
commit7a9cdc4c2a98c3a889604762dccd463757079798 (patch)
tree03cda00ac7f79b231036fc4de37af657cbb209a0 /src/test
parent48c1c548e1a61d1c27cdfb3425db4bbdecf6f303 (diff)
parent516534ffdf2d267d5706443d5bd2bd7987d7498e (diff)
Auto merge of #44700 - arielb1:mir-effectck, r=nikomatsakis
Move effect-checking to MIR

This allows emitting lints from MIR and moves the effect-checking pass to work on it.

I'll make `repr(packed)` misuse unsafe in a separate PR.

r? @eddyb
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs4
-rw-r--r--src/test/compile-fail/issue-43733.rs4
-rw-r--r--src/test/compile-fail/union/union-unsafe.rs4
-rw-r--r--src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs3
-rw-r--r--src/test/compile-fail/unsafe-move-val-init.rs20
5 files changed, 29 insertions, 6 deletions
diff --git a/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs b/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs
index 7284fa7a850..9a39ff6206b 100644
--- a/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs
+++ b/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 
-fn foo(x: *const Box<isize>) -> Box<isize> {
-    let y = *x; //~ ERROR dereference of raw pointer requires unsafe function or block
+unsafe fn foo(x: *const Box<isize>) -> Box<isize> {
+    let y = *x; //~ ERROR cannot move out of dereference of raw pointer
     return y;
 }
 
diff --git a/src/test/compile-fail/issue-43733.rs b/src/test/compile-fail/issue-43733.rs
index f10531e407d..90ccc589b4e 100644
--- a/src/test/compile-fail/issue-43733.rs
+++ b/src/test/compile-fail/issue-43733.rs
@@ -9,11 +9,13 @@
 // except according to those terms.
 
 #![feature(const_fn)]
+#![feature(thread_local)]
 #![feature(cfg_target_thread_local, thread_local_internals)]
 
 type Foo = std::cell::RefCell<String>;
 
 #[cfg(target_thread_local)]
+#[thread_local]
 static __KEY: std::thread::__FastLocalKeyInner<Foo> =
     std::thread::__FastLocalKeyInner::new();
 
@@ -25,7 +27,7 @@ fn __getit() -> std::option::Option<
     &'static std::cell::UnsafeCell<
         std::option::Option<Foo>>>
 {
-    __KEY.get() //~ ERROR  invocation of unsafe method requires unsafe
+    __KEY.get() //~ ERROR call to unsafe function requires unsafe
 }
 
 static FOO: std::thread::LocalKey<Foo> =
diff --git a/src/test/compile-fail/union/union-unsafe.rs b/src/test/compile-fail/union/union-unsafe.rs
index 2e018e696a4..e57d65dcb89 100644
--- a/src/test/compile-fail/union/union-unsafe.rs
+++ b/src/test/compile-fail/union/union-unsafe.rs
@@ -42,8 +42,8 @@ fn main() {
     let mut u1 = U1 { a: 10 }; // OK
     let a = u1.a; //~ ERROR access to union field requires unsafe
     u1.a = 11; // OK
-    let U1 { a } = u1; //~ ERROR matching on union field requires unsafe
-    if let U1 { a: 12 } = u1 {} //~ ERROR matching on union field requires unsafe
+    let U1 { a } = u1; //~ ERROR access to union field requires unsafe
+    if let U1 { a: 12 } = u1 {} //~ ERROR access to union field requires unsafe
     // let U1 { .. } = u1; // OK
 
     let mut u2 = U2 { a: String::from("old") }; // OK
diff --git a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs
index cff10329b85..f30da250f6a 100644
--- a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs
+++ b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs
@@ -1,3 +1,4 @@
+
 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
@@ -9,7 +10,7 @@
 // except according to those terms.
 
 
-fn f(p: *const u8) {
+fn f(p: *mut u8) {
     *p = 0; //~ ERROR dereference of raw pointer requires unsafe function or block
     return;
 }
diff --git a/src/test/compile-fail/unsafe-move-val-init.rs b/src/test/compile-fail/unsafe-move-val-init.rs
new file mode 100644
index 00000000000..84a8c84a0db
--- /dev/null
+++ b/src/test/compile-fail/unsafe-move-val-init.rs
@@ -0,0 +1,20 @@
+// Copyright 2017 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(core_intrinsics)]
+
+use std::intrinsics;
+
+// `move_val_init` has an odd desugaring, check that it is still treated
+// as unsafe.
+fn main() {
+    intrinsics::move_val_init(1 as *mut u32, 1);
+    //~^ ERROR dereference of raw pointer requires unsafe function or block
+}