Skip to content

Commit d6d711d

Browse files
committed
Auto merge of #45169 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #44775, #45089, #45095, #45099, #45101, #45108, #45116, #45135, #45146 - Failed merges:
2 parents ec016f8 + ce0a1cf commit d6d711d

File tree

22 files changed

+142
-77
lines changed

22 files changed

+142
-77
lines changed

src/bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The script accepts commands, flags, and arguments to determine what to do:
3939
```
4040

4141
If files are dirty that would normally be rebuilt from stage 0, that can be
42-
overidden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps
42+
overridden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps
4343
that belong to stage n or earlier:
4444

4545
```

src/bootstrap/configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def set(key, value):
346346
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target)
347347

348348
# Here we walk through the constructed configuration we have from the parsed
349-
# command line arguemnts. We then apply each piece of configuration by
349+
# command line arguments. We then apply each piece of configuration by
350350
# basically just doing a `sed` to change the various configuration line to what
351351
# we've got configure.
352352
def to_toml(value):

src/libcore/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
836836
///
837837
/// See the `discriminant` function in this module for more information.
838838
#[stable(feature = "discriminant_value", since = "1.21.0")]
839-
pub struct Discriminant<T>(u64, PhantomData<*const T>);
839+
pub struct Discriminant<T>(u64, PhantomData<fn() -> T>);
840840

841841
// N.B. These trait implementations cannot be derived because we don't want any bounds on T.
842842

src/libcore/tests/mem.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,19 @@ fn test_transmute() {
121121
}
122122
}
123123

124+
#[test]
125+
#[allow(dead_code)]
126+
fn test_discriminant_send_sync() {
127+
enum Regular {
128+
A,
129+
B(i32)
130+
}
131+
enum NotSendSync {
132+
A(*const i32)
133+
}
134+
135+
fn is_send_sync<T: Send + Sync>() { }
136+
137+
is_send_sync::<Discriminant<Regular>>();
138+
is_send_sync::<Discriminant<NotSendSync>>();
139+
}

src/libproc_macro/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl Literal {
488488
pub fn string(string: &str) -> Literal {
489489
let mut escaped = String::new();
490490
for ch in string.chars() {
491-
escaped.extend(ch.escape_unicode());
491+
escaped.extend(ch.escape_debug());
492492
}
493493
Literal(token::Literal(token::Lit::Str_(Symbol::intern(&escaped)), None))
494494
}

src/librustc_data_structures/graph/mod.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//! be indexed by the direction (see the type `Direction`).
3232
3333
use bitvec::BitVector;
34-
use std::fmt::{Formatter, Error, Debug};
34+
use std::fmt::Debug;
3535
use std::usize;
3636
use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
3737

@@ -48,6 +48,7 @@ pub struct Node<N> {
4848
pub data: N,
4949
}
5050

51+
#[derive(Debug)]
5152
pub struct Edge<E> {
5253
next_edge: [EdgeIndex; 2], // see module comment
5354
source: NodeIndex,
@@ -69,18 +70,6 @@ impl<N> SnapshotVecDelegate for Edge<N> {
6970
fn reverse(_: &mut Vec<Edge<N>>, _: ()) {}
7071
}
7172

72-
impl<E: Debug> Debug for Edge<E> {
73-
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
74-
write!(f,
75-
"Edge {{ next_edge: [{:?}, {:?}], source: {:?}, target: {:?}, data: {:?} }}",
76-
self.next_edge[0],
77-
self.next_edge[1],
78-
self.source,
79-
self.target,
80-
self.data)
81-
}
82-
}
83-
8473
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
8574
pub struct NodeIndex(pub usize);
8675

src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
14641464
/// declaration like `self: SomeType` into either `self`,
14651465
/// `&self`, `&mut self`, or `Box<self>`. We do this here
14661466
/// by some simple pattern matching. A more precise check
1467-
/// is done later in `check_method_self_type()`.
1467+
/// is done later in `check_method_receiver()`.
14681468
///
14691469
/// Examples:
14701470
///
@@ -1475,7 +1475,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
14751475
/// fn method2(self: &T); // ExplicitSelf::ByValue
14761476
/// fn method3(self: Box<&T>); // ExplicitSelf::ByBox
14771477
///
1478-
/// // Invalid cases will be caught later by `check_method_self_type`:
1478+
/// // Invalid cases will be caught later by `check_method_receiver`:
14791479
/// fn method_err1(self: &mut T); // ExplicitSelf::ByReference
14801480
/// }
14811481
/// ```

src/libstd/sync/mpsc/mod.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl<T> Drop for Sender<T> {
919919
#[stable(feature = "mpsc_debug", since = "1.8.0")]
920920
impl<T> fmt::Debug for Sender<T> {
921921
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
922-
write!(f, "Sender {{ .. }}")
922+
f.debug_struct("Sender").finish()
923923
}
924924
}
925925

@@ -1049,7 +1049,7 @@ impl<T> Drop for SyncSender<T> {
10491049
#[stable(feature = "mpsc_debug", since = "1.8.0")]
10501050
impl<T> fmt::Debug for SyncSender<T> {
10511051
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1052-
write!(f, "SyncSender {{ .. }}")
1052+
f.debug_struct("SyncSender").finish()
10531053
}
10541054
}
10551055

@@ -1551,7 +1551,7 @@ impl<T> Drop for Receiver<T> {
15511551
#[stable(feature = "mpsc_debug", since = "1.8.0")]
15521552
impl<T> fmt::Debug for Receiver<T> {
15531553
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1554-
write!(f, "Receiver {{ .. }}")
1554+
f.debug_struct("Receiver").finish()
15551555
}
15561556
}
15571557

@@ -3009,22 +3009,4 @@ mod sync_tests {
30093009
repro()
30103010
}
30113011
}
3012-
3013-
#[test]
3014-
fn fmt_debug_sender() {
3015-
let (tx, _) = channel::<i32>();
3016-
assert_eq!(format!("{:?}", tx), "Sender { .. }");
3017-
}
3018-
3019-
#[test]
3020-
fn fmt_debug_recv() {
3021-
let (_, rx) = channel::<i32>();
3022-
assert_eq!(format!("{:?}", rx), "Receiver { .. }");
3023-
}
3024-
3025-
#[test]
3026-
fn fmt_debug_sync_sender() {
3027-
let (tx, _) = sync_channel::<i32>(1);
3028-
assert_eq!(format!("{:?}", tx), "SyncSender { .. }");
3029-
}
30303012
}

src/libstd/sync/mpsc/select.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,13 @@ impl Iterator for Packets {
354354

355355
impl fmt::Debug for Select {
356356
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
357-
write!(f, "Select {{ .. }}")
357+
f.debug_struct("Select").finish()
358358
}
359359
}
360360

361361
impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> {
362362
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
363-
write!(f, "Handle {{ .. }}")
363+
f.debug_struct("Handle").finish()
364364
}
365365
}
366366

@@ -774,18 +774,4 @@ mod tests {
774774
}
775775
}
776776
}
777-
778-
#[test]
779-
fn fmt_debug_select() {
780-
let sel = Select::new();
781-
assert_eq!(format!("{:?}", sel), "Select { .. }");
782-
}
783-
784-
#[test]
785-
fn fmt_debug_handle() {
786-
let (_, rx) = channel::<i32>();
787-
let sel = Select::new();
788-
let handle = sel.handle(&rx);
789-
assert_eq!(format!("{:?}", handle), "Handle { .. }");
790-
}
791777
}

src/libstd/sync/mutex.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,18 @@ impl<T: ?Sized + Default> Default for Mutex<T> {
394394
impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
395395
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
396396
match self.try_lock() {
397-
Ok(guard) => write!(f, "Mutex {{ data: {:?} }}", &*guard),
397+
Ok(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(),
398398
Err(TryLockError::Poisoned(err)) => {
399-
write!(f, "Mutex {{ data: Poisoned({:?}) }}", &**err.get_ref())
399+
f.debug_struct("Mutex").field("data", &&**err.get_ref()).finish()
400400
},
401-
Err(TryLockError::WouldBlock) => write!(f, "Mutex {{ <locked> }}")
401+
Err(TryLockError::WouldBlock) => {
402+
struct LockedPlaceholder;
403+
impl fmt::Debug for LockedPlaceholder {
404+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
405+
}
406+
407+
f.debug_struct("Mutex").field("data", &LockedPlaceholder).finish()
408+
}
402409
}
403410
}
404411
}

0 commit comments

Comments
 (0)