Skip to content

Commit 7b3d930

Browse files
committed
Libstd only has min_const_fn const fns
1 parent 472ca71 commit 7b3d930

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/libstd/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@
250250
#![feature(cfg_target_vendor)]
251251
#![feature(char_error_internals)]
252252
#![feature(compiler_builtins_lib)]
253-
#![feature(const_fn)]
253+
#![cfg_attr(stage0, feature(const_fn))]
254+
#![cfg_attr(not(stage0), feature(min_const_fn))]
254255
#![feature(const_int_ops)]
255256
#![feature(const_ip)]
256257
#![feature(core_intrinsics)]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(integer_atomics, min_const_fn)]
12+
13+
// compile-pass
14+
15+
use std::cell::UnsafeCell;
16+
use std::sync::atomic::AtomicU32;
17+
pub struct Condvar {
18+
condvar: UnsafeCell<AtomicU32>,
19+
}
20+
21+
unsafe impl Send for Condvar {}
22+
unsafe impl Sync for Condvar {}
23+
24+
#[repr(C)]
25+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
26+
struct NoWait(u32);
27+
28+
const CONDVAR_HAS_NO_WAITERS: NoWait = NoWait(42);
29+
30+
impl Condvar {
31+
pub const fn new() -> Condvar {
32+
Condvar {
33+
condvar: UnsafeCell::new(AtomicU32::new(CONDVAR_HAS_NO_WAITERS.0)),
34+
}
35+
}
36+
}
37+
38+
fn main() {}

0 commit comments

Comments
 (0)