Skip to content

Commit 110e59e

Browse files
Update library functions with stability attributes
This may not be strictly minimal, but all unstable functions also need a `rustc_const_unstable` attribute.
1 parent 3dd28c7 commit 110e59e

File tree

13 files changed

+22
-0
lines changed

13 files changed

+22
-0
lines changed

library/alloc/src/borrow.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
217217
/// assert!(!bull.is_borrowed());
218218
/// ```
219219
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
220+
#[rustc_const_unstable(feature = "const_cow_is_borrowed", issue = "65143")]
220221
pub const fn is_borrowed(&self) -> bool {
221222
match *self {
222223
Borrowed(_) => true,
@@ -239,6 +240,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
239240
/// assert!(!bull.is_owned());
240241
/// ```
241242
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
243+
#[rustc_const_unstable(feature = "const_cow_is_borrowed", issue = "65143")]
242244
pub const fn is_owned(&self) -> bool {
243245
!self.is_borrowed()
244246
}

library/alloc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@
8686
#![feature(cfg_target_has_atomic)]
8787
#![feature(coerce_unsized)]
8888
#![feature(const_btree_new)]
89+
#![feature(const_fn)]
8990
#![feature(const_generics)]
9091
#![feature(const_in_array_repeat_expressions)]
9192
#![feature(cow_is_borrowed)]
93+
#![feature(const_cow_is_borrowed)]
9294
#![feature(dispatch_from_dyn)]
9395
#![feature(core_intrinsics)]
9496
#![feature(dropck_eyepatch)]

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ impl<T> RawVec<T, Global> {
150150
impl<T, A: AllocRef> RawVec<T, A> {
151151
/// Like `new`, but parameterized over the choice of allocator for
152152
/// the returned `RawVec`.
153+
#[allow_internal_unstable(const_fn)]
153154
pub const fn new_in(alloc: A) -> Self {
154155
// `cap: 0` means "unallocated". zero-sized types are ignored.
155156
Self { ptr: Unique::dangling(), cap: 0, alloc }

library/alloc/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(allocator_api)]
22
#![feature(box_syntax)]
33
#![feature(cow_is_borrowed)]
4+
#![feature(const_cow_is_borrowed)]
45
#![feature(drain_filter)]
56
#![feature(exact_size_is_empty)]
67
#![feature(new_uninit)]

library/core/src/alloc/layout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ impl Layout {
177177
/// sentinel value. Types that lazily allocate must track initialization by
178178
/// some other means.
179179
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
180+
#[rustc_const_unstable(feature = "alloc_layout_extra", issue = "55724")]
180181
#[inline]
181182
pub const fn dangling(&self) -> NonNull<u8> {
182183
// SAFETY: align is guaranteed to be non-zero

library/core/src/future/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ unsafe impl Sync for ResumeTy {}
5656
#[lang = "from_generator"]
5757
#[doc(hidden)]
5858
#[unstable(feature = "gen_future", issue = "50547")]
59+
#[rustc_const_unstable(feature = "gen_future", issue = "50547")]
5960
#[inline]
6061
pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
6162
where

library/core/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@
7575
#![feature(const_float_bits_conv)]
7676
#![feature(const_overflowing_int_methods)]
7777
#![feature(const_int_unchecked_arith)]
78+
#![feature(const_mut_refs)]
7879
#![feature(const_int_pow)]
7980
#![feature(constctlz)]
8081
#![feature(const_panic)]
8182
#![feature(const_pin)]
8283
#![feature(const_fn_union)]
84+
#![feature(const_fn)]
8385
#![feature(const_generics)]
8486
#![feature(const_option)]
8587
#![feature(const_precise_live_drops)]

library/proc_macro/src/bridge/client.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ fn run_client<A: for<'a, 's> DecodeMut<'a, 's, ()>, R: Encode<()>>(
401401
}
402402

403403
impl Client<fn(crate::TokenStream) -> crate::TokenStream> {
404+
#[allow_internal_unstable(const_fn)]
404405
pub const fn expand1(f: fn(crate::TokenStream) -> crate::TokenStream) -> Self {
405406
extern "C" fn run(
406407
bridge: Bridge<'_>,
@@ -413,6 +414,7 @@ impl Client<fn(crate::TokenStream) -> crate::TokenStream> {
413414
}
414415

415416
impl Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream> {
417+
#[allow_internal_unstable(const_fn)]
416418
pub const fn expand2(
417419
f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream,
418420
) -> Self {
@@ -457,6 +459,7 @@ impl ProcMacro {
457459
}
458460
}
459461

462+
#[allow_internal_unstable(const_fn)]
460463
pub const fn custom_derive(
461464
trait_name: &'static str,
462465
attributes: &'static [&'static str],
@@ -465,13 +468,15 @@ impl ProcMacro {
465468
ProcMacro::CustomDerive { trait_name, attributes, client: Client::expand1(expand) }
466469
}
467470

471+
#[allow_internal_unstable(const_fn)]
468472
pub const fn attr(
469473
name: &'static str,
470474
expand: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream,
471475
) -> Self {
472476
ProcMacro::Attr { name, client: Client::expand2(expand) }
473477
}
474478

479+
#[allow_internal_unstable(const_fn)]
475480
pub const fn bang(
476481
name: &'static str,
477482
expand: fn(crate::TokenStream) -> crate::TokenStream,

library/proc_macro/src/bridge/scoped_cell.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl<'a, 'b, T: LambdaL> DerefMut for RefMutL<'a, 'b, T> {
3535
pub struct ScopedCell<T: LambdaL>(Cell<<T as ApplyL<'static>>::Out>);
3636

3737
impl<T: LambdaL> ScopedCell<T> {
38+
#[allow_internal_unstable(const_fn)]
3839
pub const fn new(value: <T as ApplyL<'static>>::Out) -> Self {
3940
ScopedCell(Cell::new(value))
4041
}

library/proc_macro/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)]
2121
#![feature(nll)]
2222
#![feature(staged_api)]
23+
#![feature(const_fn)]
2324
#![feature(allow_internal_unstable)]
2425
#![feature(decl_macro)]
2526
#![feature(extern_types)]

0 commit comments

Comments
 (0)