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

+1-1
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

+1-1
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

+1-1
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

+16
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

+1-1
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

+2-13
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

+2-2
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

+3-21
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

+2-16
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

+10-3
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
}

src/libstd/sync/rwlock.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> {
428428
impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
429429
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
430430
match self.try_read() {
431-
Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", &*guard),
431+
Ok(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(),
432432
Err(TryLockError::Poisoned(err)) => {
433-
write!(f, "RwLock {{ data: Poisoned({:?}) }}", &**err.get_ref())
433+
f.debug_struct("RwLock").field("data", &&**err.get_ref()).finish()
434434
},
435-
Err(TryLockError::WouldBlock) => write!(f, "RwLock {{ <locked> }}")
435+
Err(TryLockError::WouldBlock) => {
436+
struct LockedPlaceholder;
437+
impl fmt::Debug for LockedPlaceholder {
438+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
439+
}
440+
441+
f.debug_struct("RwLock").field("data", &LockedPlaceholder).finish()
442+
}
436443
}
437444
}
438445
}

src/libstd/sys_common/remutex.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,18 @@ impl<T> Drop for ReentrantMutex<T> {
116116
impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
117117
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
118118
match self.try_lock() {
119-
Ok(guard) => write!(f, "ReentrantMutex {{ data: {:?} }}", &*guard),
119+
Ok(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(),
120120
Err(TryLockError::Poisoned(err)) => {
121-
write!(f, "ReentrantMutex {{ data: Poisoned({:?}) }}", &**err.get_ref())
121+
f.debug_struct("ReentrantMutex").field("data", &**err.get_ref()).finish()
122122
},
123-
Err(TryLockError::WouldBlock) => write!(f, "ReentrantMutex {{ <locked> }}")
123+
Err(TryLockError::WouldBlock) => {
124+
struct LockedPlaceholder;
125+
impl fmt::Debug for LockedPlaceholder {
126+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
127+
}
128+
129+
f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish()
130+
}
124131
}
125132
}
126133
}

src/libsyntax/parse/parser.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -2890,17 +2890,30 @@ impl<'a> Parser<'a> {
28902890

28912891
match self.parse_path(PathStyle::Expr) {
28922892
Ok(path) => {
2893+
let (op_noun, op_verb) = match self.token {
2894+
token::Lt => ("comparison", "comparing"),
2895+
token::BinOp(token::Shl) => ("shift", "shifting"),
2896+
_ => {
2897+
// We can end up here even without `<` being the next token, for
2898+
// example because `parse_ty_no_plus` returns `Err` on keywords,
2899+
// but `parse_path` returns `Ok` on them due to error recovery.
2900+
// Return original error and parser state.
2901+
mem::replace(self, parser_snapshot_after_type);
2902+
return Err(type_err);
2903+
}
2904+
};
2905+
28932906
// Successfully parsed the type path leaving a `<` yet to parse.
28942907
type_err.cancel();
28952908

28962909
// Report non-fatal diagnostics, keep `x as usize` as an expression
28972910
// in AST and continue parsing.
28982911
let msg = format!("`<` is interpreted as a start of generic \
2899-
arguments for `{}`, not a comparison", path);
2912+
arguments for `{}`, not a {}", path, op_noun);
29002913
let mut err = self.sess.span_diagnostic.struct_span_err(self.span, &msg);
29012914
err.span_label(self.look_ahead_span(1).to(parser_snapshot_after_type.span),
29022915
"interpreted as generic arguments");
2903-
err.span_label(self.span, "not interpreted as comparison");
2916+
err.span_label(self.span, format!("not interpreted as {}", op_noun));
29042917

29052918
let expr = mk_expr(self, P(Ty {
29062919
span: path.span,
@@ -2911,7 +2924,7 @@ impl<'a> Parser<'a> {
29112924
let expr_str = self.sess.codemap().span_to_snippet(expr.span)
29122925
.unwrap_or(pprust::expr_to_string(&expr));
29132926
err.span_suggestion(expr.span,
2914-
"try comparing the casted value",
2927+
&format!("try {} the casted value", op_verb),
29152928
format!("({})", expr_str));
29162929
err.emit();
29172930

src/libsyntax_pos/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,11 @@ impl serialize::UseSpecializedDecodable for Span {
339339
}
340340

341341
fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
342-
write!(f, "Span {{ lo: {:?}, hi: {:?}, ctxt: {:?} }}",
343-
span.lo(), span.hi(), span.ctxt())
342+
f.debug_struct("Span")
343+
.field("lo", &span.lo())
344+
.field("hi", &span.hi())
345+
.field("ctxt", &span.ctxt())
346+
.finish()
344347
}
345348

346349
impl fmt::Debug for Span {

src/test/codegen/float_math.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
1919
#[no_mangle]
2020
pub fn add(x: f32, y: f32) -> f32 {
2121
// CHECK: fadd float
22-
// CHECK-NOT fast
22+
// CHECK-NOT: fast
2323
x + y
2424
}
2525

src/test/compile-fail/incr_comp_with_macro_export.rs src/test/incremental/macro_export.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags: -Zincremental=tmp/cfail-tests/incr_comp_with_macro_export
11+
// revisions: cfail1 cfail2 cfail3
1212
// must-compile-successfully
1313

14-
1514
// This test case makes sure that we can compile with incremental compilation
1615
// enabled when there are macros exported from this crate. (See #37756)
1716

src/test/run-make/target-specs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ all:
55
$(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | grep -q "Error loading target specification"
66
$(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | grep 'Field llvm-target'
77
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
8-
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=x86_64-unknown-linux-gnu --crate-type=lib --emit=asm
8+
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
99
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -

src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pre-link-args": ["-m64"],
3-
"data-layout": "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128",
3+
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
44
"linker-flavor": "gcc",
55
"llvm-target": "x86_64-unknown-linux-gnu",
66
"target-endian": "little",

src/test/ui/issue-22644.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ fn main() {
3535
<
3636
5);
3737

38+
println!("{}", a as usize << long_name);
39+
3840
println!("{}", a: &mut 4);
3941
}

src/test/ui/issue-22644.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,18 @@ help: try comparing the casted value
7676
33 |
7777
...
7878

79+
error: `<` is interpreted as a start of generic arguments for `usize`, not a shift
80+
--> $DIR/issue-22644.rs:38:31
81+
|
82+
38 | println!("{}", a as usize << long_name);
83+
| ---------- ^^ --------- interpreted as generic arguments
84+
| | |
85+
| | not interpreted as shift
86+
| help: try shifting the casted value: `(a as usize)`
87+
7988
error: expected type, found `4`
80-
--> $DIR/issue-22644.rs:38:28
89+
--> $DIR/issue-22644.rs:40:28
8190
|
82-
38 | println!("{}", a: &mut 4);
91+
40 | println!("{}", a: &mut 4);
8392
| ^ expecting a type here because of type ascription
8493

0 commit comments

Comments
 (0)