Skip to content

Commit 952fdf2

Browse files
committed
Auto merge of rust-lang#86891 - JohnTitor:rollup-gy2gan9, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#83581 (Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr) - rust-lang#85377 (aborts: Clarify documentation and comments) - rust-lang#86685 (double-check mutability inside Allocation) - rust-lang#86794 (Stabilize `Seek::rewind()`) - rust-lang#86852 (Remove some doc aliases) - rust-lang#86878 (:arrow_up: rust-analyzer) - rust-lang#86886 (Remove `impl Clean for {Ident, Symbol}`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 969a6c2 + 952deae commit 952fdf2

File tree

27 files changed

+103
-61
lines changed

27 files changed

+103
-61
lines changed

Diff for: compiler/rustc_middle/src/mir/interpret/allocation.rs

+3
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
361361
range: AllocRange,
362362
val: ScalarMaybeUninit<Tag>,
363363
) -> AllocResult {
364+
assert!(self.mutability == Mutability::Mut);
365+
364366
let val = match val {
365367
ScalarMaybeUninit::Scalar(scalar) => scalar,
366368
ScalarMaybeUninit::Uninit => {
@@ -484,6 +486,7 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
484486
if range.size.bytes() == 0 {
485487
return;
486488
}
489+
assert!(self.mutability == Mutability::Mut);
487490
self.init_mask.set_range(range.start, range.end(), is_init);
488491
}
489492
}

Diff for: library/alloc/src/boxed.rs

-3
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ impl<T> Box<T> {
187187
/// ```
188188
#[cfg(not(no_global_oom_handling))]
189189
#[inline(always)]
190-
#[doc(alias = "alloc")]
191-
#[doc(alias = "malloc")]
192190
#[stable(feature = "rust1", since = "1.0.0")]
193191
pub fn new(x: T) -> Self {
194192
box x
@@ -239,7 +237,6 @@ impl<T> Box<T> {
239237
/// [zeroed]: mem::MaybeUninit::zeroed
240238
#[cfg(not(no_global_oom_handling))]
241239
#[inline]
242-
#[doc(alias = "calloc")]
243240
#[unstable(feature = "new_uninit", issue = "63291")]
244241
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
245242
Self::new_zeroed_in(Global)

Diff for: library/alloc/src/collections/binary_heap.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,6 @@ impl<T> BinaryHeap<T> {
10341034
///
10351035
/// assert_eq!(heap.len(), 2);
10361036
/// ```
1037-
#[doc(alias = "length")]
10381037
#[stable(feature = "rust1", since = "1.0.0")]
10391038
pub fn len(&self) -> usize {
10401039
self.data.len()

Diff for: library/alloc/src/collections/btree/map.rs

-2
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ impl<K, V> BTreeMap<K, V> {
889889
/// assert_eq!(map.remove(&1), Some("a"));
890890
/// assert_eq!(map.remove(&1), None);
891891
/// ```
892-
#[doc(alias = "delete")]
893892
#[stable(feature = "rust1", since = "1.0.0")]
894893
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
895894
where
@@ -2165,7 +2164,6 @@ impl<K, V> BTreeMap<K, V> {
21652164
/// a.insert(1, "a");
21662165
/// assert_eq!(a.len(), 1);
21672166
/// ```
2168-
#[doc(alias = "length")]
21692167
#[stable(feature = "rust1", since = "1.0.0")]
21702168
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
21712169
pub const fn len(&self) -> usize {

Diff for: library/alloc/src/collections/btree/set.rs

-2
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ impl<T> BTreeSet<T> {
810810
/// assert_eq!(set.remove(&2), true);
811811
/// assert_eq!(set.remove(&2), false);
812812
/// ```
813-
#[doc(alias = "delete")]
814813
#[stable(feature = "rust1", since = "1.0.0")]
815814
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
816815
where
@@ -1021,7 +1020,6 @@ impl<T> BTreeSet<T> {
10211020
/// v.insert(1);
10221021
/// assert_eq!(v.len(), 1);
10231022
/// ```
1024-
#[doc(alias = "length")]
10251023
#[stable(feature = "rust1", since = "1.0.0")]
10261024
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
10271025
pub const fn len(&self) -> usize {

Diff for: library/alloc/src/collections/linked_list.rs

-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ impl<T> LinkedList<T> {
586586
/// dl.push_back(3);
587587
/// assert_eq!(dl.len(), 3);
588588
/// ```
589-
#[doc(alias = "length")]
590589
#[inline]
591590
#[stable(feature = "rust1", since = "1.0.0")]
592591
pub fn len(&self) -> usize {

Diff for: library/alloc/src/collections/vec_deque/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,6 @@ impl<T> VecDeque<T> {
10361036
/// v.push_back(1);
10371037
/// assert_eq!(v.len(), 1);
10381038
/// ```
1039-
#[doc(alias = "length")]
10401039
#[stable(feature = "rust1", since = "1.0.0")]
10411040
pub fn len(&self) -> usize {
10421041
count(self.tail, self.head, self.cap())

Diff for: library/alloc/src/macros.rs

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
///
3636
/// [`Vec`]: crate::vec::Vec
3737
#[cfg(not(test))]
38-
#[doc(alias = "alloc")]
39-
#[doc(alias = "malloc")]
4038
#[macro_export]
4139
#[stable(feature = "rust1", since = "1.0.0")]
4240
#[allow_internal_unstable(box_syntax, liballoc_internals)]

Diff for: library/alloc/src/string.rs

-3
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ impl String {
419419
/// ```
420420
#[cfg(not(no_global_oom_handling))]
421421
#[inline]
422-
#[doc(alias = "alloc")]
423-
#[doc(alias = "malloc")]
424422
#[stable(feature = "rust1", since = "1.0.0")]
425423
pub fn with_capacity(capacity: usize) -> String {
426424
String { vec: Vec::with_capacity(capacity) }
@@ -1534,7 +1532,6 @@ impl String {
15341532
/// assert_eq!(fancy_f.len(), 4);
15351533
/// assert_eq!(fancy_f.chars().count(), 3);
15361534
/// ```
1537-
#[doc(alias = "length")]
15381535
#[inline]
15391536
#[stable(feature = "rust1", since = "1.0.0")]
15401537
pub fn len(&self) -> usize {

Diff for: library/alloc/src/vec/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ impl<T> Vec<T> {
459459
/// ```
460460
#[cfg(not(no_global_oom_handling))]
461461
#[inline]
462-
#[doc(alias = "malloc")]
463462
#[stable(feature = "rust1", since = "1.0.0")]
464463
pub fn with_capacity(capacity: usize) -> Self {
465464
Self::with_capacity_in(capacity, Global)
@@ -799,7 +798,6 @@ impl<T, A: Allocator> Vec<T, A> {
799798
/// assert!(vec.capacity() >= 11);
800799
/// ```
801800
#[cfg(not(no_global_oom_handling))]
802-
#[doc(alias = "realloc")]
803801
#[stable(feature = "rust1", since = "1.0.0")]
804802
pub fn reserve(&mut self, additional: usize) {
805803
self.buf.reserve(self.len, additional);
@@ -826,7 +824,6 @@ impl<T, A: Allocator> Vec<T, A> {
826824
/// assert!(vec.capacity() >= 11);
827825
/// ```
828826
#[cfg(not(no_global_oom_handling))]
829-
#[doc(alias = "realloc")]
830827
#[stable(feature = "rust1", since = "1.0.0")]
831828
pub fn reserve_exact(&mut self, additional: usize) {
832829
self.buf.reserve_exact(self.len, additional);
@@ -864,7 +861,6 @@ impl<T, A: Allocator> Vec<T, A> {
864861
/// }
865862
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
866863
/// ```
867-
#[doc(alias = "realloc")]
868864
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
869865
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
870866
self.buf.try_reserve(self.len, additional)
@@ -906,7 +902,6 @@ impl<T, A: Allocator> Vec<T, A> {
906902
/// }
907903
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
908904
/// ```
909-
#[doc(alias = "realloc")]
910905
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
911906
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
912907
self.buf.try_reserve_exact(self.len, additional)
@@ -927,7 +922,6 @@ impl<T, A: Allocator> Vec<T, A> {
927922
/// assert!(vec.capacity() >= 3);
928923
/// ```
929924
#[cfg(not(no_global_oom_handling))]
930-
#[doc(alias = "realloc")]
931925
#[stable(feature = "rust1", since = "1.0.0")]
932926
pub fn shrink_to_fit(&mut self) {
933927
// 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> {
958952
/// assert!(vec.capacity() >= 3);
959953
/// ```
960954
#[cfg(not(no_global_oom_handling))]
961-
#[doc(alias = "realloc")]
962955
#[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
963956
pub fn shrink_to(&mut self, min_capacity: usize) {
964957
if self.capacity() > min_capacity {
@@ -1820,7 +1813,6 @@ impl<T, A: Allocator> Vec<T, A> {
18201813
/// let a = vec![1, 2, 3];
18211814
/// assert_eq!(a.len(), 3);
18221815
/// ```
1823-
#[doc(alias = "length")]
18241816
#[inline]
18251817
#[stable(feature = "rust1", since = "1.0.0")]
18261818
pub fn len(&self) -> usize {

Diff for: library/core/src/intrinsics.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,14 @@ extern "rust-intrinsic" {
717717
/// Therefore, implementations must not require the user to uphold
718718
/// any safety invariants.
719719
///
720-
/// A more user-friendly and stable version of this operation is
721-
/// [`std::process::abort`](../../std/process/fn.abort.html).
720+
/// [`std::process::abort`](../../std/process/fn.abort.html) is to be preferred if possible,
721+
/// as its behavior is more user-friendly and more stable.
722+
///
723+
/// The current implementation of `intrinsics::abort` is to invoke an invalid instruction,
724+
/// on most platforms.
725+
/// On Unix, the
726+
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or
727+
/// `SIGBUS`. The precise behaviour is not guaranteed and not stable.
722728
pub fn abort() -> !;
723729

724730
/// Informs the optimizer that this point in the code is not reachable,

Diff for: library/core/src/iter/traits/exact_size.rs

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ pub trait ExactSizeIterator: Iterator {
9797
///
9898
/// assert_eq!(5, five.len());
9999
/// ```
100-
#[doc(alias = "length")]
101100
#[inline]
102101
#[stable(feature = "rust1", since = "1.0.0")]
103102
fn len(&self) -> usize {

Diff for: library/core/src/slice/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ impl<T> [T] {
9595
/// let a = [1, 2, 3];
9696
/// assert_eq!(a.len(), 3);
9797
/// ```
98-
#[doc(alias = "length")]
9998
#[cfg_attr(not(bootstrap), lang = "slice_len_fn")]
10099
#[stable(feature = "rust1", since = "1.0.0")]
101100
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]

Diff for: library/core/src/str/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ impl str {
138138
/// assert_eq!("ƒoo".len(), 4); // fancy f!
139139
/// assert_eq!("ƒoo".chars().count(), 3);
140140
/// ```
141-
#[doc(alias = "length")]
142141
#[stable(feature = "rust1", since = "1.0.0")]
143142
#[rustc_const_stable(feature = "const_str_len", since = "1.39.0")]
144143
#[inline]

Diff for: library/std/src/collections/hash/map.rs

-2
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ impl<K, V, S> HashMap<K, V, S> {
454454
/// a.insert(1, "a");
455455
/// assert_eq!(a.len(), 1);
456456
/// ```
457-
#[doc(alias = "length")]
458457
#[stable(feature = "rust1", since = "1.0.0")]
459458
pub fn len(&self) -> usize {
460459
self.base.len()
@@ -893,7 +892,6 @@ where
893892
/// assert_eq!(map.remove(&1), Some("a"));
894893
/// assert_eq!(map.remove(&1), None);
895894
/// ```
896-
#[doc(alias = "delete")]
897895
#[inline]
898896
#[stable(feature = "rust1", since = "1.0.0")]
899897
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>

Diff for: library/std/src/collections/hash/set.rs

-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ impl<T, S> HashSet<T, S> {
202202
/// v.insert(1);
203203
/// assert_eq!(v.len(), 1);
204204
/// ```
205-
#[doc(alias = "length")]
206205
#[inline]
207206
#[stable(feature = "rust1", since = "1.0.0")]
208207
pub fn len(&self) -> usize {
@@ -875,7 +874,6 @@ where
875874
/// assert_eq!(set.remove(&2), true);
876875
/// assert_eq!(set.remove(&2), false);
877876
/// ```
878-
#[doc(alias = "delete")]
879877
#[inline]
880878
#[stable(feature = "rust1", since = "1.0.0")]
881879
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool

Diff for: library/std/src/ffi/os_str.rs

-1
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,6 @@ impl OsStr {
694694
/// let os_str = OsStr::new("foo");
695695
/// assert_eq!(os_str.len(), 3);
696696
/// ```
697-
#[doc(alias = "length")]
698697
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
699698
#[inline]
700699
pub fn len(&self) -> usize {

Diff for: library/std/src/fs.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,6 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
15511551
/// Ok(())
15521552
/// }
15531553
/// ```
1554-
#[doc(alias = "delete")]
15551554
#[stable(feature = "rust1", since = "1.0.0")]
15561555
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
15571556
fs_imp::unlink(path.as_ref())
@@ -1986,7 +1985,6 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
19861985
/// Ok(())
19871986
/// }
19881987
/// ```
1989-
#[doc(alias = "delete")]
19901988
#[stable(feature = "rust1", since = "1.0.0")]
19911989
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
19921990
fs_imp::rmdir(path.as_ref())
@@ -2024,7 +2022,6 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
20242022
/// Ok(())
20252023
/// }
20262024
/// ```
2027-
#[doc(alias = "delete")]
20282025
#[stable(feature = "rust1", since = "1.0.0")]
20292026
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
20302027
fs_imp::remove_dir_all(path.as_ref())

Diff for: library/std/src/io/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,6 @@ pub trait Seek {
17591759
/// # Example
17601760
///
17611761
/// ```no_run
1762-
/// #![feature(seek_rewind)]
17631762
/// use std::io::{Read, Seek, Write};
17641763
/// use std::fs::OpenOptions;
17651764
///
@@ -1777,7 +1776,7 @@ pub trait Seek {
17771776
/// f.read_to_string(&mut buf).unwrap();
17781777
/// assert_eq!(&buf, hello);
17791778
/// ```
1780-
#[unstable(feature = "seek_rewind", issue = "85149")]
1779+
#[stable(feature = "seek_rewind", since = "1.55.0")]
17811780
fn rewind(&mut self) -> Result<()> {
17821781
self.seek(SeekFrom::Start(0))?;
17831782
Ok(())

Diff for: library/std/src/io/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ fn seek_position() -> io::Result<()> {
336336
assert_eq!(c.stream_position()?, 8);
337337
assert_eq!(c.stream_position()?, 8);
338338

339+
c.rewind()?;
340+
assert_eq!(c.stream_position()?, 0);
341+
assert_eq!(c.stream_position()?, 0);
342+
339343
Ok(())
340344
}
341345

Diff for: library/std/src/os/unix/fs.rs

+39
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use crate::path::Path;
99
use crate::sys;
1010
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
1111
// Used for `File::read` on intra-doc links
12+
use crate::ffi::OsStr;
13+
use crate::sealed::Sealed;
1214
#[allow(unused_imports)]
1315
use io::{Read, Write};
1416

@@ -839,6 +841,43 @@ impl DirEntryExt for fs::DirEntry {
839841
}
840842
}
841843

844+
/// Sealed Unix-specific extension methods for [`fs::DirEntry`].
845+
#[unstable(feature = "dir_entry_ext2", issue = "85573")]
846+
pub trait DirEntryExt2: Sealed {
847+
/// Returns a reference to the underlying `OsStr` of this entry's filename.
848+
///
849+
/// # Examples
850+
///
851+
/// ```
852+
/// #![feature(dir_entry_ext2)]
853+
/// use std::os::unix::fs::DirEntryExt2;
854+
/// use std::{fs, io};
855+
///
856+
/// fn main() -> io::Result<()> {
857+
/// let mut entries = fs::read_dir(".")?.collect::<Result<Vec<_>, io::Error>>()?;
858+
/// entries.sort_unstable_by(|a, b| a.file_name_ref().cmp(b.file_name_ref()));
859+
///
860+
/// for p in entries {
861+
/// println!("{:?}", p);
862+
/// }
863+
///
864+
/// Ok(())
865+
/// }
866+
/// ```
867+
fn file_name_ref(&self) -> &OsStr;
868+
}
869+
870+
/// Allows extension traits within `std`.
871+
#[unstable(feature = "sealed", issue = "none")]
872+
impl Sealed for fs::DirEntry {}
873+
874+
#[unstable(feature = "dir_entry_ext2", issue = "85573")]
875+
impl DirEntryExt2 for fs::DirEntry {
876+
fn file_name_ref(&self) -> &OsStr {
877+
self.as_inner().file_name_os_str()
878+
}
879+
}
880+
842881
/// Creates a new symbolic link on the filesystem.
843882
///
844883
/// The `link` path will be a symbolic link pointing to the `original` path.

Diff for: library/std/src/process.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,9 @@ pub fn exit(code: i32) -> ! {
18981898
/// process, no destructors on the current stack or any other thread's stack
18991899
/// will be run.
19001900
///
1901+
/// Rust IO buffers (eg, from `BufWriter`) will not be flushed.
1902+
/// Likewise, C stdio buffers will (on most platforms) not be flushed.
1903+
///
19011904
/// This is in contrast to the default behaviour of [`panic!`] which unwinds
19021905
/// the current thread's stack and calls all destructors.
19031906
/// When `panic="abort"` is set, either as an argument to `rustc` or in a
@@ -1908,6 +1911,10 @@ pub fn exit(code: i32) -> ! {
19081911
/// this function at a known point where there are no more destructors left
19091912
/// to run.
19101913
///
1914+
/// The process's termination will be similar to that from the C `abort()`
1915+
/// function. On Unix, the process will terminate with signal `SIGABRT`, which
1916+
/// typically means that the shell prints "Aborted".
1917+
///
19111918
/// # Examples
19121919
///
19131920
/// ```no_run

Diff for: library/std/src/sys/unix/fs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ impl DirEntry {
647647
fn name_bytes(&self) -> &[u8] {
648648
&*self.name
649649
}
650+
651+
pub fn file_name_os_str(&self) -> &OsStr {
652+
OsStr::from_bytes(self.name_bytes())
653+
}
650654
}
651655

652656
impl OpenOptions {

0 commit comments

Comments
 (0)