about summary refs log tree commit diff
path: root/src/test/run-pass
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-08-14 19:36:13 -0700
committerAlex Crichton <alex@alexcrichton.com>2017-08-14 19:36:13 -0700
commit1413253a41de87ce7da73f0733aa3f433b1f5a3b (patch)
tree111cba46a53aaaa0733b6b8ba19aece25b6f8533 /src/test/run-pass
parentb045c201b2086073f43d76290b9cb2a5a8e16f89 (diff)
parent56fe3b2ad0055bb28325f412395577e2b842719a (diff)
downloadrust-1413253a41de87ce7da73f0733aa3f433b1f5a3b.tar.gz
rust-1413253a41de87ce7da73f0733aa3f433b1f5a3b.zip
Merge remote-tracking branch 'origin/master' into gen
Diffstat (limited to 'src/test/run-pass')
-rw-r--r--src/test/run-pass/auxiliary/thread-local-extern-static.rs11
-rw-r--r--src/test/run-pass/impl-trait/auxiliary/xcrate.rs11
-rw-r--r--src/test/run-pass/impl-trait/xcrate.rs1
-rw-r--r--src/test/run-pass/issue-30756.rs2
-rw-r--r--src/test/run-pass/issue-39827.rs42
-rw-r--r--src/test/run-pass/issue-43853.rs24
-rw-r--r--src/test/run-pass/thread-local-extern-static.rs18
7 files changed, 99 insertions, 10 deletions
diff --git a/src/test/run-pass/auxiliary/thread-local-extern-static.rs b/src/test/run-pass/auxiliary/thread-local-extern-static.rs
index d1971a5e1ae..e9457886be8 100644
--- a/src/test/run-pass/auxiliary/thread-local-extern-static.rs
+++ b/src/test/run-pass/auxiliary/thread-local-extern-static.rs
@@ -8,10 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(thread_local)]
-#![feature(cfg_target_thread_local)]
+#![feature(cfg_target_thread_local, const_fn, thread_local)]
 #![crate_type = "lib"]
 
+#[cfg(target_thread_local)]
+use std::cell::Cell;
+
 #[no_mangle]
-#[cfg_attr(target_thread_local, thread_local)]
-pub static FOO: u32 = 3;
+#[cfg(target_thread_local)]
+#[thread_local]
+pub static FOO: Cell<u32> = Cell::new(3);
diff --git a/src/test/run-pass/impl-trait/auxiliary/xcrate.rs b/src/test/run-pass/impl-trait/auxiliary/xcrate.rs
index be353f6d563..e9074f8c230 100644
--- a/src/test/run-pass/impl-trait/auxiliary/xcrate.rs
+++ b/src/test/run-pass/impl-trait/auxiliary/xcrate.rs
@@ -13,3 +13,14 @@
 pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 {
     move |b| move |c| move |d| a + b + c + d
 }
+
+fn some_internal_fn() -> u32 {
+    1
+}
+
+// See #40839
+pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 {
+    || {
+        some_internal_fn() + 1
+    }
+}
diff --git a/src/test/run-pass/impl-trait/xcrate.rs b/src/test/run-pass/impl-trait/xcrate.rs
index fe3ed7b3465..6d00c46fa35 100644
--- a/src/test/run-pass/impl-trait/xcrate.rs
+++ b/src/test/run-pass/impl-trait/xcrate.rs
@@ -14,4 +14,5 @@ extern crate xcrate;
 
 fn main() {
     assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10);
+    xcrate::return_closure_accessing_internal_fn()();
 }
diff --git a/src/test/run-pass/issue-30756.rs b/src/test/run-pass/issue-30756.rs
index d21b42f8c87..621607e5f6f 100644
--- a/src/test/run-pass/issue-30756.rs
+++ b/src/test/run-pass/issue-30756.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(unsafe_code)]
+#![forbid(unsafe_code)]
 
 thread_local!(static FOO: u8 = 1);
 
diff --git a/src/test/run-pass/issue-39827.rs b/src/test/run-pass/issue-39827.rs
new file mode 100644
index 00000000000..b753cf5844f
--- /dev/null
+++ b/src/test/run-pass/issue-39827.rs
@@ -0,0 +1,42 @@
+// 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::{ volatile_copy_memory, volatile_store, volatile_load,
+                       volatile_copy_nonoverlapping_memory,
+                       volatile_set_memory };
+
+//
+// This test ensures that volatile intrinsics can be specialised with
+// zero-sized types and, in case of copy/set functions, can accept
+// number of elements equal to zero.
+//
+fn main () {
+    let mut dst_pair = (1, 2);
+    let src_pair = (3, 4);
+    let mut dst_empty = ();
+    let src_empty = ();
+
+    const COUNT_0: usize = 0;
+    const COUNT_100: usize = 100;
+
+    unsafe {
+        volatile_copy_memory(&mut dst_pair, &dst_pair, COUNT_0);
+        volatile_copy_nonoverlapping_memory(&mut dst_pair, &src_pair, 0);
+        volatile_copy_memory(&mut dst_empty, &dst_empty, 100);
+        volatile_copy_nonoverlapping_memory(&mut dst_empty, &src_empty,
+                                            COUNT_100);
+        volatile_set_memory(&mut dst_empty, 0, COUNT_100);
+        volatile_set_memory(&mut dst_pair, 0, COUNT_0);
+        volatile_store(&mut dst_empty, ());
+        volatile_store(&mut dst_empty, src_empty);
+        volatile_load(&src_empty);
+    }
+}
diff --git a/src/test/run-pass/issue-43853.rs b/src/test/run-pass/issue-43853.rs
new file mode 100644
index 00000000000..f55d584ea24
--- /dev/null
+++ b/src/test/run-pass/issue-43853.rs
@@ -0,0 +1,24 @@
+// 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.
+
+use std::panic;
+
+fn test() {
+    wait(|| panic!());
+}
+
+fn wait<T, F: FnOnce() -> T>(f: F) -> F::Output {
+    From::from(f())
+}
+
+fn main() {
+    let result = panic::catch_unwind(move || test());
+    assert!(result.is_err());
+}
diff --git a/src/test/run-pass/thread-local-extern-static.rs b/src/test/run-pass/thread-local-extern-static.rs
index 87188db9dc0..09c8b64776c 100644
--- a/src/test/run-pass/thread-local-extern-static.rs
+++ b/src/test/run-pass/thread-local-extern-static.rs
@@ -11,18 +11,26 @@
 // ignore-windows
 // aux-build:thread-local-extern-static.rs
 
-#![feature(thread_local)]
-#![feature(cfg_target_thread_local)]
+#![feature(cfg_target_thread_local, thread_local)]
 
+#[cfg(target_thread_local)]
 extern crate thread_local_extern_static;
 
+#[cfg(target_thread_local)]
+use std::cell::Cell;
+
+#[cfg(target_thread_local)]
 extern {
-    #[cfg_attr(target_thread_local, thread_local)]
-    static FOO: u32;
+    #[thread_local]
+    static FOO: Cell<u32>;
 }
 
+#[cfg(target_thread_local)]
 fn main() {
     unsafe {
-        assert_eq!(FOO, 3);
+        assert_eq!(FOO.get(), 3);
     }
 }
+
+#[cfg(not(target_thread_local))]
+fn main() {}