Skip to content

Commit c14d86f

Browse files
committed
core: Split apart the global core feature
This commit shards the broad `core` feature of the libcore library into finer grained features. This split groups together similar APIs and enables tracking each API separately, giving a better sense of where each feature is within the stabilization process. A few minor APIs were deprecated along the way: * Iterator::reverse_in_place * marker::NoCopy
1 parent e7a5a1c commit c14d86f

File tree

54 files changed

+379
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+379
-288
lines changed

src/liballoc/boxed.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
//! A pointer type for heap allocation.
1212
//!
13-
//! `Box<T>`, casually referred to as a 'box', provides the simplest form of heap allocation in
14-
//! Rust. Boxes provide ownership for this allocation, and drop their contents when they go out of
15-
//! scope.
13+
//! `Box<T>`, casually referred to as a 'box', provides the simplest form of
14+
//! heap allocation in Rust. Boxes provide ownership for this allocation, and
15+
//! drop their contents when they go out of scope.
1616
//!
1717
//! # Examples
1818
//!
@@ -39,15 +39,17 @@
3939
//!
4040
//! This will print `Cons(1, Cons(2, Nil))`.
4141
//!
42-
//! Recursive structures must be boxed, because if the definition of `Cons` looked like this:
42+
//! Recursive structures must be boxed, because if the definition of `Cons`
43+
//! looked like this:
4344
//!
4445
//! ```rust,ignore
4546
//! Cons(T, List<T>),
4647
//! ```
4748
//!
48-
//! It wouldn't work. This is because the size of a `List` depends on how many elements are in the
49-
//! list, and so we don't know how much memory to allocate for a `Cons`. By introducing a `Box`,
50-
//! which has a defined size, we know how big `Cons` needs to be.
49+
//! It wouldn't work. This is because the size of a `List` depends on how many
50+
//! elements are in the list, and so we don't know how much memory to allocate
51+
//! for a `Cons`. By introducing a `Box`, which has a defined size, we know how
52+
//! big `Cons` needs to be.
5153
5254
#![stable(feature = "rust1", since = "1.0.0")]
5355

@@ -355,7 +357,7 @@ impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
355357
/// }
356358
/// ```
357359
#[rustc_paren_sugar]
358-
#[unstable(feature = "core", reason = "Newly introduced")]
360+
#[unstable(feature = "fnbox", reason = "Newly introduced")]
359361
pub trait FnBox<A> {
360362
type Output;
361363

src/liballoc/lib.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,32 @@
6060
#![cfg_attr(stage0, feature(custom_attribute))]
6161
#![crate_name = "alloc"]
6262
#![unstable(feature = "alloc")]
63-
#![feature(staged_api)]
6463
#![staged_api]
6564
#![crate_type = "rlib"]
6665
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
6766
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
68-
html_root_url = "http://doc.rust-lang.org/nightly/")]
69-
#![doc(test(no_crate_inject))]
70-
71-
#![feature(no_std)]
67+
html_root_url = "http://doc.rust-lang.org/nightly/",
68+
test(no_crate_inject))]
7269
#![no_std]
70+
7371
#![feature(allocator)]
72+
#![feature(box_syntax)]
73+
#![feature(coerce_unsized)]
74+
#![feature(core)]
75+
#![feature(core_intrinsics)]
76+
#![feature(core_prelude)]
7477
#![feature(custom_attribute)]
7578
#![feature(fundamental)]
7679
#![feature(lang_items)]
77-
#![feature(box_syntax)]
80+
#![feature(no_std)]
81+
#![feature(nonzero)]
7882
#![feature(optin_builtin_traits)]
83+
#![feature(raw)]
84+
#![feature(staged_api)]
7985
#![feature(unboxed_closures)]
80-
#![feature(unsafe_no_drop_flag, filling_drop)]
81-
#![feature(core)]
8286
#![feature(unique)]
87+
#![feature(unsafe_no_drop_flag, filling_drop)]
88+
#![feature(unsize)]
8389
#![cfg_attr(test, feature(test, alloc, rustc_private))]
8490
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
8591
feature(libc))]

src/libarena/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232

3333
#![feature(alloc)]
3434
#![feature(box_syntax)]
35-
#![feature(core)]
35+
#![feature(core_intrinsics)]
36+
#![feature(ptr_as_ref)]
37+
#![feature(raw)]
3638
#![feature(staged_api)]
3739
#![feature(unboxed_closures)]
3840
#![cfg_attr(test, feature(test))]

src/libcollections/lib.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,42 @@
2121
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "http://doc.rust-lang.org/nightly/",
24-
html_playground_url = "http://play.rust-lang.org/")]
25-
#![doc(test(no_crate_inject))]
24+
html_playground_url = "http://play.rust-lang.org/",
25+
test(no_crate_inject))]
2626

2727
#![allow(trivial_casts)]
28+
#![cfg_attr(test, allow(deprecated))] // rand
29+
2830
#![feature(alloc)]
29-
#![feature(box_syntax)]
3031
#![feature(box_patterns)]
32+
#![feature(box_syntax)]
33+
#![feature(copy_lifetime)]
3134
#![feature(core)]
35+
#![feature(core_intrinsics)]
36+
#![feature(core_prelude)]
37+
#![feature(core_slice_ext)]
38+
#![feature(core_str_ext)]
39+
#![feature(iter_cmp)]
40+
#![feature(iter_idx)]
41+
#![feature(iter_order)]
42+
#![feature(iter_product)]
43+
#![feature(iter_sum)]
3244
#![feature(lang_items)]
45+
#![feature(num_bits_bytes)]
46+
#![feature(pattern)]
47+
#![feature(ptr_as_ref)]
48+
#![feature(raw)]
49+
#![feature(slice_patterns)]
3350
#![feature(staged_api)]
51+
#![feature(step_by)]
52+
#![feature(str_char)]
53+
#![feature(str_internals)]
3454
#![feature(unboxed_closures)]
3555
#![feature(unicode)]
3656
#![feature(unique)]
3757
#![feature(unsafe_no_drop_flag, filling_drop)]
38-
#![feature(step_by)]
39-
#![feature(str_char)]
40-
#![feature(slice_patterns)]
4158
#![feature(utf8_error)]
4259
#![cfg_attr(test, feature(rand, test))]
43-
#![cfg_attr(test, allow(deprecated))] // rand
4460
#![cfg_attr(not(test), feature(str_words))]
4561

4662
#![feature(no_std)]

src/libcore/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use marker::{Reflect, Sized};
9292
#[stable(feature = "rust1", since = "1.0.0")]
9393
pub trait Any: Reflect + 'static {
9494
/// Gets the `TypeId` of `self`.
95-
#[unstable(feature = "core",
95+
#[unstable(feature = "get_type_id",
9696
reason = "this method will likely be replaced by an associated static")]
9797
fn get_type_id(&self) -> TypeId;
9898
}

src/libcore/array.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
//! up to a certain length. Eventually we should able to generalize
1313
//! to all lengths.
1414
15-
#![unstable(feature = "core")] // not yet reviewed
16-
1715
#![doc(primitive = "array")]
16+
#![unstable(feature = "fixed_size_array",
17+
reason = "traits and impls are better expressed through generic \
18+
integer constants")]
1819

1920
use clone::Clone;
2021
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
@@ -30,7 +31,6 @@ use slice::{Iter, IterMut, SliceExt};
3031
///
3132
/// This trait can be used to implement other traits on fixed-size arrays
3233
/// without causing much metadata bloat.
33-
#[unstable(feature = "core")]
3434
pub trait FixedSizeArray<T> {
3535
/// Converts the array to immutable slice
3636
fn as_slice(&self) -> &[T];
@@ -42,7 +42,6 @@ pub trait FixedSizeArray<T> {
4242
macro_rules! array_impls {
4343
($($N:expr)+) => {
4444
$(
45-
#[unstable(feature = "core")]
4645
impl<T> FixedSizeArray<T> for [T; $N] {
4746
#[inline]
4847
fn as_slice(&self) -> &[T] {
@@ -54,17 +53,13 @@ macro_rules! array_impls {
5453
}
5554
}
5655

57-
#[unstable(feature = "array_as_ref",
58-
reason = "should ideally be implemented for all fixed-sized arrays")]
5956
impl<T> AsRef<[T]> for [T; $N] {
6057
#[inline]
6158
fn as_ref(&self) -> &[T] {
6259
&self[..]
6360
}
6461
}
6562

66-
#[unstable(feature = "array_as_ref",
67-
reason = "should ideally be implemented for all fixed-sized arrays")]
6863
impl<T> AsMut<[T]> for [T; $N] {
6964
#[inline]
7065
fn as_mut(&mut self) -> &mut [T] {

src/libcore/cell.rs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<T:Copy> Cell<T> {
229229
/// let uc = unsafe { c.as_unsafe_cell() };
230230
/// ```
231231
#[inline]
232-
#[unstable(feature = "core")]
232+
#[unstable(feature = "as_unsafe_cell")]
233233
pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
234234
&self.value
235235
}
@@ -277,7 +277,7 @@ pub struct RefCell<T: ?Sized> {
277277

278278
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
279279
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
280-
#[unstable(feature = "std_misc")]
280+
#[unstable(feature = "borrow_state")]
281281
pub enum BorrowState {
282282
/// The cell is currently being read, there is at least one active `borrow`.
283283
Reading,
@@ -339,7 +339,7 @@ impl<T: ?Sized> RefCell<T> {
339339
///
340340
/// The returned value can be dispatched on to determine if a call to
341341
/// `borrow` or `borrow_mut` would succeed.
342-
#[unstable(feature = "std_misc")]
342+
#[unstable(feature = "borrow_state")]
343343
#[inline]
344344
pub fn borrow_state(&self) -> BorrowState {
345345
match self.borrow.get() {
@@ -448,7 +448,7 @@ impl<T: ?Sized> RefCell<T> {
448448
///
449449
/// This function is `unsafe` because `UnsafeCell`'s field is public.
450450
#[inline]
451-
#[unstable(feature = "core")]
451+
#[unstable(feature = "as_unsafe_cell")]
452452
pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
453453
&self.value
454454
}
@@ -564,9 +564,10 @@ impl<'b, T: ?Sized> Ref<'b, T> {
564564
///
565565
/// The `RefCell` is already immutably borrowed, so this cannot fail.
566566
///
567-
/// This is an associated function that needs to be used as `Ref::clone(...)`.
568-
/// A `Clone` implementation or a method would interfere with the widespread
569-
/// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
567+
/// This is an associated function that needs to be used as
568+
/// `Ref::clone(...)`. A `Clone` implementation or a method would interfere
569+
/// with the widespread use of `r.borrow().clone()` to clone the contents of
570+
/// a `RefCell`.
570571
#[unstable(feature = "cell_extras",
571572
reason = "likely to be moved to a method, pending language changes")]
572573
#[inline]
@@ -582,8 +583,8 @@ impl<'b, T: ?Sized> Ref<'b, T> {
582583
/// The `RefCell` is already immutably borrowed, so this cannot fail.
583584
///
584585
/// This is an associated function that needs to be used as `Ref::map(...)`.
585-
/// A method would interfere with methods of the same name on the contents of a `RefCell`
586-
/// used through `Deref`.
586+
/// A method would interfere with methods of the same name on the contents
587+
/// of a `RefCell` used through `Deref`.
587588
///
588589
/// # Example
589590
///
@@ -607,13 +608,14 @@ impl<'b, T: ?Sized> Ref<'b, T> {
607608
}
608609
}
609610

610-
/// Make a new `Ref` for a optional component of the borrowed data, e.g. an enum variant.
611+
/// Make a new `Ref` for a optional component of the borrowed data, e.g. an
612+
/// enum variant.
611613
///
612614
/// The `RefCell` is already immutably borrowed, so this cannot fail.
613615
///
614-
/// This is an associated function that needs to be used as `Ref::filter_map(...)`.
615-
/// A method would interfere with methods of the same name on the contents of a `RefCell`
616-
/// used through `Deref`.
616+
/// This is an associated function that needs to be used as
617+
/// `Ref::filter_map(...)`. A method would interfere with methods of the
618+
/// same name on the contents of a `RefCell` used through `Deref`.
617619
///
618620
/// # Example
619621
///
@@ -639,13 +641,14 @@ impl<'b, T: ?Sized> Ref<'b, T> {
639641
}
640642

641643
impl<'b, T: ?Sized> RefMut<'b, T> {
642-
/// Make a new `RefMut` for a component of the borrowed data, e.g. an enum variant.
644+
/// Make a new `RefMut` for a component of the borrowed data, e.g. an enum
645+
/// variant.
643646
///
644647
/// The `RefCell` is already mutably borrowed, so this cannot fail.
645648
///
646-
/// This is an associated function that needs to be used as `RefMut::map(...)`.
647-
/// A method would interfere with methods of the same name on the contents of a `RefCell`
648-
/// used through `Deref`.
649+
/// This is an associated function that needs to be used as
650+
/// `RefMut::map(...)`. A method would interfere with methods of the same
651+
/// name on the contents of a `RefCell` used through `Deref`.
649652
///
650653
/// # Example
651654
///
@@ -673,13 +676,14 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
673676
}
674677
}
675678

676-
/// Make a new `RefMut` for a optional component of the borrowed data, e.g. an enum variant.
679+
/// Make a new `RefMut` for a optional component of the borrowed data, e.g.
680+
/// an enum variant.
677681
///
678682
/// The `RefCell` is already mutably borrowed, so this cannot fail.
679683
///
680-
/// This is an associated function that needs to be used as `RefMut::filter_map(...)`.
681-
/// A method would interfere with methods of the same name on the contents of a `RefCell`
682-
/// used through `Deref`.
684+
/// This is an associated function that needs to be used as
685+
/// `RefMut::filter_map(...)`. A method would interfere with methods of the
686+
/// same name on the contents of a `RefCell` used through `Deref`.
683687
///
684688
/// # Example
685689
///
@@ -690,7 +694,9 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
690694
/// let c = RefCell::new(Ok(5));
691695
/// {
692696
/// let b1: RefMut<Result<u32, ()>> = c.borrow_mut();
693-
/// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| o.as_mut().ok()).unwrap();
697+
/// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| {
698+
/// o.as_mut().ok()
699+
/// }).unwrap();
694700
/// assert_eq!(*b2, 5);
695701
/// *b2 = 42;
696702
/// }

src/libcore/char.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
1515
#![allow(non_snake_case)]
1616
#![doc(primitive = "char")]
17+
#![stable(feature = "rust1", since = "1.0.0")]
1718

1819
use iter::Iterator;
1920
use mem::transmute;
@@ -131,6 +132,8 @@ pub fn from_digit(num: u32, radix: u32) -> Option<char> {
131132
// unicode/char.rs, not here
132133
#[allow(missing_docs)] // docs in libunicode/u_char.rs
133134
#[doc(hidden)]
135+
#[unstable(feature = "core_char_ext",
136+
reason = "the stable interface is `impl char` in later crate")]
134137
pub trait CharExt {
135138
fn is_digit(self, radix: u32) -> bool;
136139
fn to_digit(self, radix: u32) -> Option<u32>;
@@ -220,6 +223,8 @@ impl CharExt for char {
220223
/// If the buffer is not large enough, nothing will be written into it
221224
/// and a `None` will be returned.
222225
#[inline]
226+
#[unstable(feature = "char_internals",
227+
reason = "this function should not be exposed publicly")]
223228
pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
224229
// Marked #[inline] to allow llvm optimizing it away
225230
if code < MAX_ONE_B && !dst.is_empty() {
@@ -251,6 +256,8 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
251256
/// If the buffer is not large enough, nothing will be written into it
252257
/// and a `None` will be returned.
253258
#[inline]
259+
#[unstable(feature = "char_internals",
260+
reason = "this function should not be exposed publicly")]
254261
pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option<usize> {
255262
// Marked #[inline] to allow llvm optimizing it away
256263
if (ch & 0xFFFF) == ch && !dst.is_empty() {

src/libcore/clone.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,28 @@ clone_impl! { char }
8989

9090
macro_rules! extern_fn_clone {
9191
($($A:ident),*) => (
92-
#[unstable(feature = "core",
93-
reason = "this may not be sufficient for fns with region parameters")]
92+
#[stable(feature = "rust1", since = "1.0.0")]
9493
impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType {
9594
/// Returns a copy of a function pointer.
9695
#[inline]
9796
fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
9897
}
9998

100-
#[unstable(feature = "core", reason = "brand new")]
99+
#[stable(feature = "rust1", since = "1.0.0")]
101100
impl<$($A,)* ReturnType> Clone for extern "C" fn($($A),*) -> ReturnType {
102101
/// Returns a copy of a function pointer.
103102
#[inline]
104103
fn clone(&self) -> extern "C" fn($($A),*) -> ReturnType { *self }
105104
}
106105

107-
#[unstable(feature = "core", reason = "brand new")]
106+
#[stable(feature = "rust1", since = "1.0.0")]
108107
impl<$($A,)* ReturnType> Clone for unsafe extern "Rust" fn($($A),*) -> ReturnType {
109108
/// Returns a copy of a function pointer.
110109
#[inline]
111110
fn clone(&self) -> unsafe extern "Rust" fn($($A),*) -> ReturnType { *self }
112111
}
113112

114-
#[unstable(feature = "core", reason = "brand new")]
113+
#[stable(feature = "rust1", since = "1.0.0")]
115114
impl<$($A,)* ReturnType> Clone for unsafe extern "C" fn($($A),*) -> ReturnType {
116115
/// Returns a copy of a function pointer.
117116
#[inline]

0 commit comments

Comments
 (0)