about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-08-29 13:00:14 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-08-31 08:39:59 +0200
commit7b3d930ca6f8269d07bce30ace4a9be2f316a63a (patch)
tree69038fa1da8720e6c14b1b4604107004c145f35c
parent472ca7159812f8c360697f63454ee7bda1e02570 (diff)
downloadrust-7b3d930ca6f8269d07bce30ace4a9be2f316a63a.tar.gz
rust-7b3d930ca6f8269d07bce30ace4a9be2f316a63a.zip
Libstd only has `min_const_fn` const fns
-rw-r--r--src/libstd/lib.rs3
-rw-r--r--src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs38
2 files changed, 40 insertions, 1 deletions
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 310475d31fd..e7195b3e21e 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -250,7 +250,8 @@
 #![feature(cfg_target_vendor)]
 #![feature(char_error_internals)]
 #![feature(compiler_builtins_lib)]
-#![feature(const_fn)]
+#![cfg_attr(stage0, feature(const_fn))]
+#![cfg_attr(not(stage0), feature(min_const_fn))]
 #![feature(const_int_ops)]
 #![feature(const_ip)]
 #![feature(core_intrinsics)]
diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs b/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs
new file mode 100644
index 00000000000..fcc9545d97f
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs
@@ -0,0 +1,38 @@
+// 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(integer_atomics, min_const_fn)]
+
+// compile-pass
+
+use std::cell::UnsafeCell;
+use std::sync::atomic::AtomicU32;
+pub struct Condvar {
+    condvar: UnsafeCell<AtomicU32>,
+}
+
+unsafe impl Send for Condvar {}
+unsafe impl Sync for Condvar {}
+
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+struct NoWait(u32);
+
+const CONDVAR_HAS_NO_WAITERS: NoWait = NoWait(42);
+
+impl Condvar {
+    pub const fn new() -> Condvar {
+        Condvar {
+            condvar: UnsafeCell::new(AtomicU32::new(CONDVAR_HAS_NO_WAITERS.0)),
+        }
+    }
+}
+
+fn main() {}