diff options
| author | bors <bors@rust-lang.org> | 2019-12-14 10:21:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-14 10:21:32 +0000 |
| commit | c8ea4ace9213ae045123fdfeb59d1ac887656d31 (patch) | |
| tree | 2a7d207294b6f2c99d1ddbe193b1d5af8ee46a09 /src/libstd | |
| parent | 12307b3b08edee543a78fb9d4a837fbd6d6ac0fa (diff) | |
| parent | 0b47ba7019adf06f6687a8c94040e63ae1ea4fba (diff) | |
| download | rust-c8ea4ace9213ae045123fdfeb59d1ac887656d31.tar.gz rust-c8ea4ace9213ae045123fdfeb59d1ac887656d31.zip | |
Auto merge of #67136 - oli-obk:const_stability, r=Centril
Require stable/unstable annotations for the constness of all stable fns with a const modifier r? @RalfJung @Centril Every `#[stable]` const fn now needs either a `#[rustc_const_unstable]` attribute or a `#[rustc_const_stable]` attribute. You can't silently stabilize the constness of a function anymore.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 4 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 2 | ||||
| -rw-r--r-- | src/libstd/net/ip.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/once.rs | 1 |
4 files changed, 9 insertions, 2 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 6dcda986310..14ca0423d8b 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -1065,7 +1065,8 @@ impl CStr { /// ``` #[inline] #[stable(feature = "cstr_from_bytes", since = "1.10.0")] - #[rustc_const_unstable(feature = "const_cstr_unchecked")] + #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_cstr_unchecked"))] + #[cfg_attr(not(bootstrap), rustc_const_unstable(feature = "const_cstr_unchecked", issue = "0"))] pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr { &*(bytes as *const [u8] as *const CStr) } @@ -1119,6 +1120,7 @@ impl CStr { /// [`CString`]: struct.CString.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_str_as_ptr", since = "1.32.0"))] pub const fn as_ptr(&self) -> *const c_char { self.inner.as_ptr() } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 1dbb0c6ec83..8198ae73a31 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -293,7 +293,7 @@ #![feature(raw)] #![feature(renamed_spin_loop)] #![feature(rustc_attrs)] -#![feature(rustc_const_unstable)] +#![cfg_attr(bootstrap, feature(rustc_const_unstable))] #![feature(rustc_private)] #![feature(shrink_to)] #![feature(slice_concat_ext)] diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index e51a9b62449..7d69f8f4b8d 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -319,6 +319,7 @@ impl Ipv4Addr { /// let addr = Ipv4Addr::new(127, 0, 0, 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ipv4", since = "1.32.0"))] pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { // FIXME: should just be u32::from_be_bytes([a, b, c, d]), // once that method is no longer rustc_const_unstable @@ -406,6 +407,7 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(45, 22, 13, 197).is_unspecified(), false); /// ``` #[stable(feature = "ip_shared", since = "1.12.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ipv4", since = "1.32.0"))] pub const fn is_unspecified(&self) -> bool { self.inner.s_addr == 0 } @@ -1015,6 +1017,7 @@ impl Ipv6Addr { /// let addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ipv6", since = "1.32.0"))] pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr { Ipv6Addr { @@ -1480,6 +1483,7 @@ impl Ipv6Addr { /// [255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); /// ``` #[stable(feature = "ipv6_to_octets", since = "1.12.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ipv6", since = "1.32.0"))] pub const fn octets(&self) -> [u8; 16] { self.inner.s6_addr } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index e8e395247f9..d8df09071cd 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -188,6 +188,7 @@ struct WaiterQueue<'a> { impl Once { /// Creates a new `Once` value. #[stable(feature = "once_new", since = "1.2.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_once_new", since = "1.32.0"))] pub const fn new() -> Once { Once { state_and_queue: AtomicUsize::new(INCOMPLETE), _marker: marker::PhantomData } } |
