Skip to content

Commit 71965ab

Browse files
committed
Auto merge of rust-lang#84411 - m-ou-se:rollup-9btsp2t, r=m-ou-se
Rollup of 12 pull requests Successful merges: - rust-lang#84013 (Replace all `fmt.pad` with `debug_struct`) - rust-lang#84119 (Move `sys::vxworks` code to `sys::unix`) - rust-lang#84212 (Replace `Void` in `sys` with never type) - rust-lang#84251 (fix 'const-stable since' for NonZeroU*::new_unchecked) - rust-lang#84301 (Document that `index` and `index_mut` can panic) - rust-lang#84365 (Improve the docstrings of the `Lto` struct.) - rust-lang#84378 (Fix broken doc link) - rust-lang#84379 (Add GAT related tests) - rust-lang#84380 (Write Rustdoc titles like "x in crate::mod - Rust") - rust-lang#84390 (Format `Struct { .. }` on one line even with `{:#?}`.) - rust-lang#84393 (Support `x.py doc std --open`) - rust-lang#84406 (Remove `delete` alias from `mem::drop`.) Failed merges: - rust-lang#84387 (Move `sys_common::poison` to `sync::poison`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c757729 + 268d29d commit 71965ab

Some content is hidden

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

77 files changed

+793
-589
lines changed

compiler/rustc_session/src/config.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,21 @@ impl_stable_hash_via_hash!(OptLevel);
7575

7676
/// This is what the `LtoCli` values get mapped to after resolving defaults and
7777
/// and taking other command line options into account.
78+
///
79+
/// Note that linker plugin-based LTO is a different mechanism entirely.
7880
#[derive(Clone, PartialEq)]
7981
pub enum Lto {
80-
/// Don't do any LTO whatsoever
82+
/// Don't do any LTO whatsoever.
8183
No,
8284

83-
/// Do a full crate graph LTO with ThinLTO
85+
/// Do a full-crate-graph (inter-crate) LTO with ThinLTO.
8486
Thin,
8587

86-
/// Do a local graph LTO with ThinLTO (only relevant for multiple codegen
87-
/// units).
88+
/// Do a local ThinLTO (intra-crate, over the CodeGen Units of the local crate only). This is
89+
/// only relevant if multiple CGUs are used.
8890
ThinLocal,
8991

90-
/// Do a full crate graph LTO with "fat" LTO
92+
/// Do a full-crate-graph (inter-crate) LTO with "fat" LTO.
9193
Fat,
9294
}
9395

library/alloc/src/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ fn test_show() {
4949
let b = Box::new(Test) as Box<dyn Any>;
5050
let a_str = format!("{:?}", a);
5151
let b_str = format!("{:?}", b);
52-
assert_eq!(a_str, "Any");
53-
assert_eq!(b_str, "Any");
52+
assert_eq!(a_str, "Any { .. }");
53+
assert_eq!(b_str, "Any { .. }");
5454

5555
static EIGHT: usize = 8;
5656
static TEST: Test = Test;
5757
let a = &EIGHT as &dyn Any;
5858
let b = &TEST as &dyn Any;
5959
let s = format!("{:?}", a);
60-
assert_eq!(s, "Any");
60+
assert_eq!(s, "Any { .. }");
6161
let s = format!("{:?}", b);
62-
assert_eq!(s, "Any");
62+
assert_eq!(s, "Any { .. }");
6363
}
6464

6565
#[test]

library/core/src/any.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<T: 'static + ?Sized> Any for T {
141141
#[stable(feature = "rust1", since = "1.0.0")]
142142
impl fmt::Debug for dyn Any {
143143
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
144-
f.pad("Any")
144+
f.debug_struct("Any").finish_non_exhaustive()
145145
}
146146
}
147147

@@ -151,14 +151,14 @@ impl fmt::Debug for dyn Any {
151151
#[stable(feature = "rust1", since = "1.0.0")]
152152
impl fmt::Debug for dyn Any + Send {
153153
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
154-
f.pad("Any")
154+
f.debug_struct("Any").finish_non_exhaustive()
155155
}
156156
}
157157

158158
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
159159
impl fmt::Debug for dyn Any + Send + Sync {
160160
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
161-
f.pad("Any")
161+
f.debug_struct("Any").finish_non_exhaustive()
162162
}
163163
}
164164

library/core/src/ascii.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ impl fmt::Display for EscapeDefault {
145145
#[stable(feature = "std_debug", since = "1.16.0")]
146146
impl fmt::Debug for EscapeDefault {
147147
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
148-
f.pad("EscapeDefault { .. }")
148+
f.debug_struct("EscapeDefault").finish_non_exhaustive()
149149
}
150150
}

library/core/src/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum c_void {
5353
#[stable(feature = "std_debug", since = "1.16.0")]
5454
impl fmt::Debug for c_void {
5555
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56-
f.pad("c_void")
56+
f.debug_struct("c_void").finish()
5757
}
5858
}
5959

library/core/src/fmt/builders.rs

+9-18
Original file line numberDiff line numberDiff line change
@@ -188,28 +188,19 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
188188
#[stable(feature = "debug_non_exhaustive", since = "1.53.0")]
189189
pub fn finish_non_exhaustive(&mut self) -> fmt::Result {
190190
self.result = self.result.and_then(|_| {
191-
// Draw non-exhaustive dots (`..`), and open brace if necessary (no fields).
192-
if self.is_pretty() {
193-
if !self.has_fields {
194-
self.fmt.write_str(" {\n")?;
195-
}
196-
let mut slot = None;
197-
let mut state = Default::default();
198-
let mut writer = PadAdapter::wrap(&mut self.fmt, &mut slot, &mut state);
199-
writer.write_str("..\n")?;
200-
} else {
201-
if self.has_fields {
202-
self.fmt.write_str(", ..")?;
191+
if self.has_fields {
192+
if self.is_pretty() {
193+
let mut slot = None;
194+
let mut state = Default::default();
195+
let mut writer = PadAdapter::wrap(&mut self.fmt, &mut slot, &mut state);
196+
writer.write_str("..\n")?;
197+
self.fmt.write_str("}")
203198
} else {
204-
self.fmt.write_str(" { ..")?;
199+
self.fmt.write_str(", .. }")
205200
}
206-
}
207-
if self.is_pretty() {
208-
self.fmt.write_str("}")?
209201
} else {
210-
self.fmt.write_str(" }")?;
202+
self.fmt.write_str(" { .. }")
211203
}
212-
Ok(())
213204
});
214205
self.result
215206
}

library/core/src/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ impl Debug for () {
22202220
#[stable(feature = "rust1", since = "1.0.0")]
22212221
impl<T: ?Sized> Debug for PhantomData<T> {
22222222
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
2223-
f.pad("PhantomData")
2223+
f.debug_struct("PhantomData").finish()
22242224
}
22252225
}
22262226

@@ -2270,7 +2270,7 @@ impl<T: ?Sized + Debug> Debug for RefMut<'_, T> {
22702270
#[stable(feature = "core_impl_debug", since = "1.9.0")]
22712271
impl<T: ?Sized> Debug for UnsafeCell<T> {
22722272
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
2273-
f.pad("UnsafeCell")
2273+
f.debug_struct("UnsafeCell").finish_non_exhaustive()
22742274
}
22752275
}
22762276

library/core/src/hash/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ pub struct BuildHasherDefault<H>(marker::PhantomData<H>);
507507
#[stable(since = "1.9.0", feature = "core_impl_debug")]
508508
impl<H> fmt::Debug for BuildHasherDefault<H> {
509509
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
510-
f.pad("BuildHasherDefault")
510+
f.debug_struct("BuildHasherDefault").finish()
511511
}
512512
}
513513

library/core/src/iter/sources/empty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ unsafe impl<T> Sync for Empty<T> {}
3636
#[stable(feature = "core_impl_debug", since = "1.9.0")]
3737
impl<T> fmt::Debug for Empty<T> {
3838
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39-
f.pad("Empty")
39+
f.debug_struct("Empty").finish()
4040
}
4141
}
4242

library/core/src/mem/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
886886
/// ```
887887
///
888888
/// [`RefCell`]: crate::cell::RefCell
889-
#[doc(alias = "delete")]
890889
#[inline]
891890
#[stable(feature = "rust1", since = "1.0.0")]
892891
pub fn drop<T>(_x: T) {}

library/core/src/num/nonzero.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ macro_rules! impl_nonzero_fmt {
2323
}
2424

2525
macro_rules! nonzero_integers {
26-
( $( #[$stability: meta] $Ty: ident($Int: ty); )+ ) => {
26+
( $( #[$stability: meta] #[$const_new_unchecked_stability: meta] $Ty: ident($Int: ty); )+ ) => {
2727
$(
2828
/// An integer that is known not to equal zero.
2929
///
@@ -48,7 +48,7 @@ macro_rules! nonzero_integers {
4848
///
4949
/// The value must not be zero.
5050
#[$stability]
51-
#[rustc_const_stable(feature = "nonzero", since = "1.34.0")]
51+
#[$const_new_unchecked_stability]
5252
#[inline]
5353
pub const unsafe fn new_unchecked(n: $Int) -> Self {
5454
// SAFETY: this is guaranteed to be safe by the caller.
@@ -146,18 +146,18 @@ macro_rules! nonzero_integers {
146146
}
147147

148148
nonzero_integers! {
149-
#[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
150-
#[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
151-
#[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
152-
#[stable(feature = "nonzero", since = "1.28.0")] NonZeroU64(u64);
153-
#[stable(feature = "nonzero", since = "1.28.0")] NonZeroU128(u128);
154-
#[stable(feature = "nonzero", since = "1.28.0")] NonZeroUsize(usize);
155-
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI8(i8);
156-
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI16(i16);
157-
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI32(i32);
158-
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI64(i64);
159-
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI128(i128);
160-
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
149+
#[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
150+
#[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
151+
#[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
152+
#[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU64(u64);
153+
#[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU128(u128);
154+
#[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroUsize(usize);
155+
#[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI8(i8);
156+
#[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI16(i16);
157+
#[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI32(i32);
158+
#[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI64(i64);
159+
#[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI128(i128);
160+
#[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
161161
}
162162

163163
macro_rules! from_str_radix_nzint_impl {

library/core/src/ops/index.rs

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub trait Index<Idx: ?Sized> {
6161
type Output: ?Sized;
6262

6363
/// Performs the indexing (`container[index]`) operation.
64+
///
65+
/// # Panics
66+
///
67+
/// May panic if the index is out of bounds.
6468
#[stable(feature = "rust1", since = "1.0.0")]
6569
#[track_caller]
6670
fn index(&self, index: Idx) -> &Self::Output;
@@ -161,6 +165,10 @@ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#ind
161165
#[doc(alias = "[]")]
162166
pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
163167
/// Performs the mutable indexing (`container[index]`) operation.
168+
///
169+
/// # Panics
170+
///
171+
/// May panic if the index is out of bounds.
164172
#[stable(feature = "rust1", since = "1.0.0")]
165173
#[track_caller]
166174
fn index_mut(&mut self, index: Idx) -> &mut Self::Output;

library/core/src/slice/ascii.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a> fmt::Display for EscapeAscii<'a> {
146146
#[unstable(feature = "inherent_ascii_escape", issue = "77174")]
147147
impl<'a> fmt::Debug for EscapeAscii<'a> {
148148
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
149-
f.pad("EscapeAscii { .. }")
149+
f.debug_struct("EscapeAscii").finish_non_exhaustive()
150150
}
151151
}
152152

library/core/src/str/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ pub struct EncodeUtf16<'a> {
13591359
#[stable(feature = "collection_debug", since = "1.17.0")]
13601360
impl fmt::Debug for EncodeUtf16<'_> {
13611361
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1362-
f.pad("EncodeUtf16 { .. }")
1362+
f.debug_struct("EncodeUtf16").finish_non_exhaustive()
13631363
}
13641364
}
13651365

library/core/tests/fmt/builders.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,7 @@ mod debug_struct {
105105
}
106106

107107
assert_eq!("Foo { .. }", format!("{:?}", Foo));
108-
assert_eq!(
109-
"Foo {
110-
..
111-
}",
112-
format!("{:#?}", Foo)
113-
);
108+
assert_eq!("Foo { .. }", format!("{:#?}", Foo));
114109
}
115110

116111
#[test]

library/std/src/collections/hash/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ where
22572257
F: FnMut(&K, &mut V) -> bool,
22582258
{
22592259
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2260-
f.pad("DrainFilter { .. }")
2260+
f.debug_struct("DrainFilter").finish_non_exhaustive()
22612261
}
22622262
}
22632263

@@ -2957,7 +2957,7 @@ impl Default for RandomState {
29572957
#[stable(feature = "std_debug", since = "1.16.0")]
29582958
impl fmt::Debug for RandomState {
29592959
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2960-
f.pad("RandomState { .. }")
2960+
f.debug_struct("RandomState").finish_non_exhaustive()
29612961
}
29622962
}
29632963

library/std/src/collections/hash/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ where
15331533
F: FnMut(&K) -> bool,
15341534
{
15351535
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1536-
f.pad("DrainFilter { .. }")
1536+
f.debug_struct("DrainFilter").finish_non_exhaustive()
15371537
}
15381538
}
15391539

library/std/src/env.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Iterator for Vars {
154154
#[stable(feature = "std_debug", since = "1.16.0")]
155155
impl fmt::Debug for Vars {
156156
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
157-
f.pad("Vars { .. }")
157+
f.debug_struct("Vars").finish_non_exhaustive()
158158
}
159159
}
160160

@@ -172,7 +172,7 @@ impl Iterator for VarsOs {
172172
#[stable(feature = "std_debug", since = "1.16.0")]
173173
impl fmt::Debug for VarsOs {
174174
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
175-
f.pad("VarsOs { .. }")
175+
f.debug_struct("VarOs").finish_non_exhaustive()
176176
}
177177
}
178178

@@ -419,7 +419,7 @@ impl<'a> Iterator for SplitPaths<'a> {
419419
#[stable(feature = "std_debug", since = "1.16.0")]
420420
impl fmt::Debug for SplitPaths<'_> {
421421
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
422-
f.pad("SplitPaths { .. }")
422+
f.debug_struct("SplitPaths").finish_non_exhaustive()
423423
}
424424
}
425425

library/std/src/io/stdio.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl Stdin {
373373
#[stable(feature = "std_debug", since = "1.16.0")]
374374
impl fmt::Debug for Stdin {
375375
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
376-
f.pad("Stdin { .. }")
376+
f.debug_struct("Stdin").finish_non_exhaustive()
377377
}
378378
}
379379

@@ -467,7 +467,7 @@ impl BufRead for StdinLock<'_> {
467467
#[stable(feature = "std_debug", since = "1.16.0")]
468468
impl fmt::Debug for StdinLock<'_> {
469469
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
470-
f.pad("StdinLock { .. }")
470+
f.debug_struct("StdinLock").finish_non_exhaustive()
471471
}
472472
}
473473

@@ -607,7 +607,7 @@ impl Stdout {
607607
#[stable(feature = "std_debug", since = "1.16.0")]
608608
impl fmt::Debug for Stdout {
609609
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
610-
f.pad("Stdout { .. }")
610+
f.debug_struct("Stdout").finish_non_exhaustive()
611611
}
612612
}
613613

@@ -689,7 +689,7 @@ impl Write for StdoutLock<'_> {
689689
#[stable(feature = "std_debug", since = "1.16.0")]
690690
impl fmt::Debug for StdoutLock<'_> {
691691
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
692-
f.pad("StdoutLock { .. }")
692+
f.debug_struct("StdoutLock").finish_non_exhaustive()
693693
}
694694
}
695695

@@ -804,7 +804,7 @@ impl Stderr {
804804
#[stable(feature = "std_debug", since = "1.16.0")]
805805
impl fmt::Debug for Stderr {
806806
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
807-
f.pad("Stderr { .. }")
807+
f.debug_struct("Stderr").finish_non_exhaustive()
808808
}
809809
}
810810

@@ -886,7 +886,7 @@ impl Write for StderrLock<'_> {
886886
#[stable(feature = "std_debug", since = "1.16.0")]
887887
impl fmt::Debug for StderrLock<'_> {
888888
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
889-
f.pad("StderrLock { .. }")
889+
f.debug_struct("StderrLock").finish_non_exhaustive()
890890
}
891891
}
892892

0 commit comments

Comments
 (0)