Auto merge of #86891 - JohnTitor:rollup-gy2gan9, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #83581 (Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr) - #85377 (aborts: Clarify documentation and comments) - #86685 (double-check mutability inside Allocation) - #86794 (Stabilize `Seek::rewind()`) - #86852 (Remove some doc aliases) - #86878 (⬆️ rust-analyzer) - #86886 (Remove `impl Clean for {Ident, Symbol}`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
952fdf2a11
27 changed files with 103 additions and 61 deletions
|
@ -361,6 +361,8 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
|
||||||
range: AllocRange,
|
range: AllocRange,
|
||||||
val: ScalarMaybeUninit<Tag>,
|
val: ScalarMaybeUninit<Tag>,
|
||||||
) -> AllocResult {
|
) -> AllocResult {
|
||||||
|
assert!(self.mutability == Mutability::Mut);
|
||||||
|
|
||||||
let val = match val {
|
let val = match val {
|
||||||
ScalarMaybeUninit::Scalar(scalar) => scalar,
|
ScalarMaybeUninit::Scalar(scalar) => scalar,
|
||||||
ScalarMaybeUninit::Uninit => {
|
ScalarMaybeUninit::Uninit => {
|
||||||
|
@ -484,6 +486,7 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
|
||||||
if range.size.bytes() == 0 {
|
if range.size.bytes() == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
assert!(self.mutability == Mutability::Mut);
|
||||||
self.init_mask.set_range(range.start, range.end(), is_init);
|
self.init_mask.set_range(range.start, range.end(), is_init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,6 @@ impl<T> Box<T> {
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[doc(alias = "alloc")]
|
|
||||||
#[doc(alias = "malloc")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn new(x: T) -> Self {
|
pub fn new(x: T) -> Self {
|
||||||
box x
|
box x
|
||||||
|
@ -239,7 +237,6 @@ impl<T> Box<T> {
|
||||||
/// [zeroed]: mem::MaybeUninit::zeroed
|
/// [zeroed]: mem::MaybeUninit::zeroed
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(alias = "calloc")]
|
|
||||||
#[unstable(feature = "new_uninit", issue = "63291")]
|
#[unstable(feature = "new_uninit", issue = "63291")]
|
||||||
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
|
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
|
||||||
Self::new_zeroed_in(Global)
|
Self::new_zeroed_in(Global)
|
||||||
|
|
|
@ -1034,7 +1034,6 @@ impl<T> BinaryHeap<T> {
|
||||||
///
|
///
|
||||||
/// assert_eq!(heap.len(), 2);
|
/// assert_eq!(heap.len(), 2);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.data.len()
|
self.data.len()
|
||||||
|
|
|
@ -889,7 +889,6 @@ impl<K, V> BTreeMap<K, V> {
|
||||||
/// assert_eq!(map.remove(&1), Some("a"));
|
/// assert_eq!(map.remove(&1), Some("a"));
|
||||||
/// assert_eq!(map.remove(&1), None);
|
/// assert_eq!(map.remove(&1), None);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
|
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
|
||||||
where
|
where
|
||||||
|
@ -2165,7 +2164,6 @@ impl<K, V> BTreeMap<K, V> {
|
||||||
/// a.insert(1, "a");
|
/// a.insert(1, "a");
|
||||||
/// assert_eq!(a.len(), 1);
|
/// assert_eq!(a.len(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
|
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
|
||||||
pub const fn len(&self) -> usize {
|
pub const fn len(&self) -> usize {
|
||||||
|
|
|
@ -810,7 +810,6 @@ impl<T> BTreeSet<T> {
|
||||||
/// assert_eq!(set.remove(&2), true);
|
/// assert_eq!(set.remove(&2), true);
|
||||||
/// assert_eq!(set.remove(&2), false);
|
/// assert_eq!(set.remove(&2), false);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
||||||
where
|
where
|
||||||
|
@ -1021,7 +1020,6 @@ impl<T> BTreeSet<T> {
|
||||||
/// v.insert(1);
|
/// v.insert(1);
|
||||||
/// assert_eq!(v.len(), 1);
|
/// assert_eq!(v.len(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
|
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
|
||||||
pub const fn len(&self) -> usize {
|
pub const fn len(&self) -> usize {
|
||||||
|
|
|
@ -586,7 +586,6 @@ impl<T> LinkedList<T> {
|
||||||
/// dl.push_back(3);
|
/// dl.push_back(3);
|
||||||
/// assert_eq!(dl.len(), 3);
|
/// assert_eq!(dl.len(), 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
|
|
@ -1036,7 +1036,6 @@ impl<T> VecDeque<T> {
|
||||||
/// v.push_back(1);
|
/// v.push_back(1);
|
||||||
/// assert_eq!(v.len(), 1);
|
/// assert_eq!(v.len(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
count(self.tail, self.head, self.cap())
|
count(self.tail, self.head, self.cap())
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
///
|
///
|
||||||
/// [`Vec`]: crate::vec::Vec
|
/// [`Vec`]: crate::vec::Vec
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
#[doc(alias = "alloc")]
|
|
||||||
#[doc(alias = "malloc")]
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[allow_internal_unstable(box_syntax, liballoc_internals)]
|
#[allow_internal_unstable(box_syntax, liballoc_internals)]
|
||||||
|
|
|
@ -419,8 +419,6 @@ impl String {
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(alias = "alloc")]
|
|
||||||
#[doc(alias = "malloc")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn with_capacity(capacity: usize) -> String {
|
pub fn with_capacity(capacity: usize) -> String {
|
||||||
String { vec: Vec::with_capacity(capacity) }
|
String { vec: Vec::with_capacity(capacity) }
|
||||||
|
@ -1534,7 +1532,6 @@ impl String {
|
||||||
/// assert_eq!(fancy_f.len(), 4);
|
/// assert_eq!(fancy_f.len(), 4);
|
||||||
/// assert_eq!(fancy_f.chars().count(), 3);
|
/// assert_eq!(fancy_f.chars().count(), 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
|
|
@ -459,7 +459,6 @@ impl<T> Vec<T> {
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(alias = "malloc")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn with_capacity(capacity: usize) -> Self {
|
pub fn with_capacity(capacity: usize) -> Self {
|
||||||
Self::with_capacity_in(capacity, Global)
|
Self::with_capacity_in(capacity, Global)
|
||||||
|
@ -799,7 +798,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// assert!(vec.capacity() >= 11);
|
/// assert!(vec.capacity() >= 11);
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[doc(alias = "realloc")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn reserve(&mut self, additional: usize) {
|
pub fn reserve(&mut self, additional: usize) {
|
||||||
self.buf.reserve(self.len, additional);
|
self.buf.reserve(self.len, additional);
|
||||||
|
@ -826,7 +824,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// assert!(vec.capacity() >= 11);
|
/// assert!(vec.capacity() >= 11);
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[doc(alias = "realloc")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn reserve_exact(&mut self, additional: usize) {
|
pub fn reserve_exact(&mut self, additional: usize) {
|
||||||
self.buf.reserve_exact(self.len, additional);
|
self.buf.reserve_exact(self.len, additional);
|
||||||
|
@ -864,7 +861,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// }
|
/// }
|
||||||
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "realloc")]
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
||||||
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.buf.try_reserve(self.len, additional)
|
self.buf.try_reserve(self.len, additional)
|
||||||
|
@ -906,7 +902,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// }
|
/// }
|
||||||
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "realloc")]
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
||||||
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.buf.try_reserve_exact(self.len, additional)
|
self.buf.try_reserve_exact(self.len, additional)
|
||||||
|
@ -927,7 +922,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// assert!(vec.capacity() >= 3);
|
/// assert!(vec.capacity() >= 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[doc(alias = "realloc")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn shrink_to_fit(&mut self) {
|
pub fn shrink_to_fit(&mut self) {
|
||||||
// The capacity is never less than the length, and there's nothing to do when
|
// The capacity is never less than the length, and there's nothing to do when
|
||||||
|
@ -958,7 +952,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// assert!(vec.capacity() >= 3);
|
/// assert!(vec.capacity() >= 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[doc(alias = "realloc")]
|
|
||||||
#[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
|
#[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
|
||||||
pub fn shrink_to(&mut self, min_capacity: usize) {
|
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||||
if self.capacity() > min_capacity {
|
if self.capacity() > min_capacity {
|
||||||
|
@ -1820,7 +1813,6 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// let a = vec![1, 2, 3];
|
/// let a = vec![1, 2, 3];
|
||||||
/// assert_eq!(a.len(), 3);
|
/// assert_eq!(a.len(), 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
|
|
@ -717,8 +717,14 @@ extern "rust-intrinsic" {
|
||||||
/// Therefore, implementations must not require the user to uphold
|
/// Therefore, implementations must not require the user to uphold
|
||||||
/// any safety invariants.
|
/// any safety invariants.
|
||||||
///
|
///
|
||||||
/// A more user-friendly and stable version of this operation is
|
/// [`std::process::abort`](../../std/process/fn.abort.html) is to be preferred if possible,
|
||||||
/// [`std::process::abort`](../../std/process/fn.abort.html).
|
/// as its behavior is more user-friendly and more stable.
|
||||||
|
///
|
||||||
|
/// The current implementation of `intrinsics::abort` is to invoke an invalid instruction,
|
||||||
|
/// on most platforms.
|
||||||
|
/// On Unix, the
|
||||||
|
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or
|
||||||
|
/// `SIGBUS`. The precise behaviour is not guaranteed and not stable.
|
||||||
pub fn abort() -> !;
|
pub fn abort() -> !;
|
||||||
|
|
||||||
/// Informs the optimizer that this point in the code is not reachable,
|
/// Informs the optimizer that this point in the code is not reachable,
|
||||||
|
|
|
@ -97,7 +97,6 @@ pub trait ExactSizeIterator: Iterator {
|
||||||
///
|
///
|
||||||
/// assert_eq!(5, five.len());
|
/// assert_eq!(5, five.len());
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
|
|
|
@ -95,7 +95,6 @@ impl<T> [T] {
|
||||||
/// let a = [1, 2, 3];
|
/// let a = [1, 2, 3];
|
||||||
/// assert_eq!(a.len(), 3);
|
/// assert_eq!(a.len(), 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[cfg_attr(not(bootstrap), lang = "slice_len_fn")]
|
#[cfg_attr(not(bootstrap), lang = "slice_len_fn")]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]
|
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]
|
||||||
|
|
|
@ -138,7 +138,6 @@ impl str {
|
||||||
/// assert_eq!("ƒoo".len(), 4); // fancy f!
|
/// assert_eq!("ƒoo".len(), 4); // fancy f!
|
||||||
/// assert_eq!("ƒoo".chars().count(), 3);
|
/// assert_eq!("ƒoo".chars().count(), 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_stable(feature = "const_str_len", since = "1.39.0")]
|
#[rustc_const_stable(feature = "const_str_len", since = "1.39.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -454,7 +454,6 @@ impl<K, V, S> HashMap<K, V, S> {
|
||||||
/// a.insert(1, "a");
|
/// a.insert(1, "a");
|
||||||
/// assert_eq!(a.len(), 1);
|
/// assert_eq!(a.len(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.base.len()
|
self.base.len()
|
||||||
|
@ -893,7 +892,6 @@ where
|
||||||
/// assert_eq!(map.remove(&1), Some("a"));
|
/// assert_eq!(map.remove(&1), Some("a"));
|
||||||
/// assert_eq!(map.remove(&1), None);
|
/// assert_eq!(map.remove(&1), None);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
|
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
|
||||||
|
|
|
@ -202,7 +202,6 @@ impl<T, S> HashSet<T, S> {
|
||||||
/// v.insert(1);
|
/// v.insert(1);
|
||||||
/// assert_eq!(v.len(), 1);
|
/// assert_eq!(v.len(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
@ -875,7 +874,6 @@ where
|
||||||
/// assert_eq!(set.remove(&2), true);
|
/// assert_eq!(set.remove(&2), true);
|
||||||
/// assert_eq!(set.remove(&2), false);
|
/// assert_eq!(set.remove(&2), false);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
||||||
|
|
|
@ -694,7 +694,6 @@ impl OsStr {
|
||||||
/// let os_str = OsStr::new("foo");
|
/// let os_str = OsStr::new("foo");
|
||||||
/// assert_eq!(os_str.len(), 3);
|
/// assert_eq!(os_str.len(), 3);
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "length")]
|
|
||||||
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
|
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
|
|
@ -1551,7 +1551,6 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
||||||
fs_imp::unlink(path.as_ref())
|
fs_imp::unlink(path.as_ref())
|
||||||
|
@ -1986,7 +1985,6 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
||||||
fs_imp::rmdir(path.as_ref())
|
fs_imp::rmdir(path.as_ref())
|
||||||
|
@ -2024,7 +2022,6 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "delete")]
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
||||||
fs_imp::remove_dir_all(path.as_ref())
|
fs_imp::remove_dir_all(path.as_ref())
|
||||||
|
|
|
@ -1759,7 +1759,6 @@ pub trait Seek {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(seek_rewind)]
|
|
||||||
/// use std::io::{Read, Seek, Write};
|
/// use std::io::{Read, Seek, Write};
|
||||||
/// use std::fs::OpenOptions;
|
/// use std::fs::OpenOptions;
|
||||||
///
|
///
|
||||||
|
@ -1777,7 +1776,7 @@ pub trait Seek {
|
||||||
/// f.read_to_string(&mut buf).unwrap();
|
/// f.read_to_string(&mut buf).unwrap();
|
||||||
/// assert_eq!(&buf, hello);
|
/// assert_eq!(&buf, hello);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "seek_rewind", issue = "85149")]
|
#[stable(feature = "seek_rewind", since = "1.55.0")]
|
||||||
fn rewind(&mut self) -> Result<()> {
|
fn rewind(&mut self) -> Result<()> {
|
||||||
self.seek(SeekFrom::Start(0))?;
|
self.seek(SeekFrom::Start(0))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -336,6 +336,10 @@ fn seek_position() -> io::Result<()> {
|
||||||
assert_eq!(c.stream_position()?, 8);
|
assert_eq!(c.stream_position()?, 8);
|
||||||
assert_eq!(c.stream_position()?, 8);
|
assert_eq!(c.stream_position()?, 8);
|
||||||
|
|
||||||
|
c.rewind()?;
|
||||||
|
assert_eq!(c.stream_position()?, 0);
|
||||||
|
assert_eq!(c.stream_position()?, 0);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ use crate::path::Path;
|
||||||
use crate::sys;
|
use crate::sys;
|
||||||
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
|
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
|
||||||
// Used for `File::read` on intra-doc links
|
// Used for `File::read` on intra-doc links
|
||||||
|
use crate::ffi::OsStr;
|
||||||
|
use crate::sealed::Sealed;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use io::{Read, Write};
|
use io::{Read, Write};
|
||||||
|
|
||||||
|
@ -839,6 +841,43 @@ impl DirEntryExt for fs::DirEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sealed Unix-specific extension methods for [`fs::DirEntry`].
|
||||||
|
#[unstable(feature = "dir_entry_ext2", issue = "85573")]
|
||||||
|
pub trait DirEntryExt2: Sealed {
|
||||||
|
/// Returns a reference to the underlying `OsStr` of this entry's filename.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(dir_entry_ext2)]
|
||||||
|
/// use std::os::unix::fs::DirEntryExt2;
|
||||||
|
/// use std::{fs, io};
|
||||||
|
///
|
||||||
|
/// fn main() -> io::Result<()> {
|
||||||
|
/// let mut entries = fs::read_dir(".")?.collect::<Result<Vec<_>, io::Error>>()?;
|
||||||
|
/// entries.sort_unstable_by(|a, b| a.file_name_ref().cmp(b.file_name_ref()));
|
||||||
|
///
|
||||||
|
/// for p in entries {
|
||||||
|
/// println!("{:?}", p);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// Ok(())
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
fn file_name_ref(&self) -> &OsStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Allows extension traits within `std`.
|
||||||
|
#[unstable(feature = "sealed", issue = "none")]
|
||||||
|
impl Sealed for fs::DirEntry {}
|
||||||
|
|
||||||
|
#[unstable(feature = "dir_entry_ext2", issue = "85573")]
|
||||||
|
impl DirEntryExt2 for fs::DirEntry {
|
||||||
|
fn file_name_ref(&self) -> &OsStr {
|
||||||
|
self.as_inner().file_name_os_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a new symbolic link on the filesystem.
|
/// Creates a new symbolic link on the filesystem.
|
||||||
///
|
///
|
||||||
/// The `link` path will be a symbolic link pointing to the `original` path.
|
/// The `link` path will be a symbolic link pointing to the `original` path.
|
||||||
|
|
|
@ -1898,6 +1898,9 @@ pub fn exit(code: i32) -> ! {
|
||||||
/// process, no destructors on the current stack or any other thread's stack
|
/// process, no destructors on the current stack or any other thread's stack
|
||||||
/// will be run.
|
/// will be run.
|
||||||
///
|
///
|
||||||
|
/// Rust IO buffers (eg, from `BufWriter`) will not be flushed.
|
||||||
|
/// Likewise, C stdio buffers will (on most platforms) not be flushed.
|
||||||
|
///
|
||||||
/// This is in contrast to the default behaviour of [`panic!`] which unwinds
|
/// This is in contrast to the default behaviour of [`panic!`] which unwinds
|
||||||
/// the current thread's stack and calls all destructors.
|
/// the current thread's stack and calls all destructors.
|
||||||
/// When `panic="abort"` is set, either as an argument to `rustc` or in a
|
/// When `panic="abort"` is set, either as an argument to `rustc` or in a
|
||||||
|
@ -1908,6 +1911,10 @@ pub fn exit(code: i32) -> ! {
|
||||||
/// this function at a known point where there are no more destructors left
|
/// this function at a known point where there are no more destructors left
|
||||||
/// to run.
|
/// to run.
|
||||||
///
|
///
|
||||||
|
/// The process's termination will be similar to that from the C `abort()`
|
||||||
|
/// function. On Unix, the process will terminate with signal `SIGABRT`, which
|
||||||
|
/// typically means that the shell prints "Aborted".
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
|
|
|
@ -647,6 +647,10 @@ impl DirEntry {
|
||||||
fn name_bytes(&self) -> &[u8] {
|
fn name_bytes(&self) -> &[u8] {
|
||||||
&*self.name
|
&*self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn file_name_os_str(&self) -> &OsStr {
|
||||||
|
OsStr::from_bytes(self.name_bytes())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OpenOptions {
|
impl OpenOptions {
|
||||||
|
|
|
@ -217,13 +217,41 @@ pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> {
|
||||||
if error == 0 { Ok(()) } else { Err(crate::io::Error::from_raw_os_error(error)) }
|
if error == 0 { Ok(()) } else { Err(crate::io::Error::from_raw_os_error(error)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Unix-like platforms, libc::abort will unregister signal handlers
|
// libc::abort() will run the SIGABRT handler. That's fine because anyone who
|
||||||
// including the SIGABRT handler, preventing the abort from being blocked, and
|
// installs a SIGABRT handler already has to expect it to run in Very Bad
|
||||||
// fclose streams, with the side effect of flushing them so libc buffered
|
// situations (eg, malloc crashing).
|
||||||
// output will be printed. Additionally the shell will generally print a more
|
//
|
||||||
// understandable error message like "Abort trap" rather than "Illegal
|
// Current glibc's abort() function unblocks SIGABRT, raises SIGABRT, clears the
|
||||||
// instruction" that intrinsics::abort would cause, as intrinsics::abort is
|
// SIGABRT handler and raises it again, and then starts to get creative.
|
||||||
// implemented as an illegal instruction.
|
//
|
||||||
|
// See the public documentation for `intrinsics::abort()` and `process::abort()`
|
||||||
|
// for further discussion.
|
||||||
|
//
|
||||||
|
// There is confusion about whether libc::abort() flushes stdio streams.
|
||||||
|
// libc::abort() is required by ISO C 99 (7.14.1.1p5) to be async-signal-safe,
|
||||||
|
// so flushing streams is at least extremely hard, if not entirely impossible.
|
||||||
|
//
|
||||||
|
// However, some versions of POSIX (eg IEEE Std 1003.1-2001) required abort to
|
||||||
|
// do so. In 1003.1-2004 this was fixed.
|
||||||
|
//
|
||||||
|
// glibc's implementation did the flush, unsafely, before glibc commit
|
||||||
|
// 91e7cf982d01 `abort: Do not flush stdio streams [BZ #15436]' by Florian
|
||||||
|
// Weimer. According to glibc's NEWS:
|
||||||
|
//
|
||||||
|
// The abort function terminates the process immediately, without flushing
|
||||||
|
// stdio streams. Previous glibc versions used to flush streams, resulting
|
||||||
|
// in deadlocks and further data corruption. This change also affects
|
||||||
|
// process aborts as the result of assertion failures.
|
||||||
|
//
|
||||||
|
// This is an accurate description of the problem. The only solution for
|
||||||
|
// program with nontrivial use of C stdio is a fixed libc - one which does not
|
||||||
|
// try to flush in abort - since even libc-internal errors, and assertion
|
||||||
|
// failures generated from C, will go via abort().
|
||||||
|
//
|
||||||
|
// On systems with old, buggy, libcs, the impact can be severe for a
|
||||||
|
// multithreaded C program. It is much less severe for Rust, because Rust
|
||||||
|
// stdlib doesn't use libc stdio buffering. In a typical Rust program, which
|
||||||
|
// does not use C stdio, even a buggy libc::abort() is, in fact, safe.
|
||||||
pub fn abort_internal() -> ! {
|
pub fn abort_internal() -> ! {
|
||||||
unsafe { libc::abort() }
|
unsafe { libc::abort() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,7 @@ fn build_macro(cx: &mut DocContext<'_>, did: DefId, name: Symbol) -> clean::Item
|
||||||
|
|
||||||
let source = format!(
|
let source = format!(
|
||||||
"macro_rules! {} {{\n{}}}",
|
"macro_rules! {} {{\n{}}}",
|
||||||
name.clean(cx),
|
name,
|
||||||
utils::render_macro_arms(matchers, ";")
|
utils::render_macro_arms(matchers, ";")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1814,20 +1814,6 @@ impl Clean<PathSegment> for hir::PathSegment<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<String> for Ident {
|
|
||||||
#[inline]
|
|
||||||
fn clean(&self, cx: &mut DocContext<'_>) -> String {
|
|
||||||
self.name.clean(cx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Clean<String> for Symbol {
|
|
||||||
#[inline]
|
|
||||||
fn clean(&self, _: &mut DocContext<'_>) -> String {
|
|
||||||
self.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
|
impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
|
||||||
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
|
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
|
||||||
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
|
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1fa82adfdca502a13f4dd952f9a50574870f5b7b
|
Subproject commit e5c1c8cf2fcfae3e15c8bcf5256e84cad3bd3436
|
Loading…
Add table
Add a link
Reference in a new issue