From 7d1c14a32d9b09681d8050b30e35c30c7058d8b7 Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Sat, 7 Oct 2017 18:04:23 +0200 Subject: [PATCH 01/11] Fix typo in codegen test --- src/test/codegen/float_math.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/codegen/float_math.rs b/src/test/codegen/float_math.rs index bc458d45446fe..6a6d6f90b2e69 100644 --- a/src/test/codegen/float_math.rs +++ b/src/test/codegen/float_math.rs @@ -19,7 +19,7 @@ use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast}; #[no_mangle] pub fn add(x: f32, y: f32) -> f32 { // CHECK: fadd float -// CHECK-NOT fast +// CHECK-NOT: fast x + y } From 3fff2d95bf90514e66892ca9be666c35eeae9165 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 7 Oct 2017 21:33:36 +0200 Subject: [PATCH 02/11] core: Ensure std::mem::Discriminant is Send + Sync `PhantomData<*const T>` has the implication of Send / Syncness following the *const T type, but the discriminant should always be Send and Sync. Use `PhantomData T>` which has the same variance in T, but is Send + Sync --- src/libcore/mem.rs | 2 +- src/libcore/tests/mem.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index e085d427b8ce9..680a0f5b2c03f 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -836,7 +836,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { /// /// See the `discriminant` function in this module for more information. #[stable(feature = "discriminant_value", since = "1.21.0")] -pub struct Discriminant(u64, PhantomData<*const T>); +pub struct Discriminant(u64, PhantomData T>); // N.B. These trait implementations cannot be derived because we don't want any bounds on T. diff --git a/src/libcore/tests/mem.rs b/src/libcore/tests/mem.rs index 86e59c736ba4a..f55a1c81463f7 100644 --- a/src/libcore/tests/mem.rs +++ b/src/libcore/tests/mem.rs @@ -121,3 +121,19 @@ fn test_transmute() { } } +#[test] +#[allow(dead_code)] +fn test_discriminant_send_sync() { + enum Regular { + A, + B(i32) + } + enum NotSendSync { + A(*const i32) + } + + fn is_send_sync() { } + + is_send_sync::>(); + is_send_sync::>(); +} From 6f4e942ef96f92e61f40c0d1bd889e66b0de3cfd Mon Sep 17 00:00:00 2001 From: Michael Hewson Date: Sat, 7 Oct 2017 23:51:43 -0400 Subject: [PATCH 03/11] update comments referring to old check_method_self_type - function has been renamed to check_method_receiver --- src/librustc_typeck/astconv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index af8cc2c806adf..6b7a5b3af9669 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1464,7 +1464,7 @@ impl<'tcx> ExplicitSelf<'tcx> { /// declaration like `self: SomeType` into either `self`, /// `&self`, `&mut self`, or `Box`. We do this here /// by some simple pattern matching. A more precise check - /// is done later in `check_method_self_type()`. + /// is done later in `check_method_receiver()`. /// /// Examples: /// @@ -1475,7 +1475,7 @@ impl<'tcx> ExplicitSelf<'tcx> { /// fn method2(self: &T); // ExplicitSelf::ByValue /// fn method3(self: Box<&T>); // ExplicitSelf::ByBox /// - /// // Invalid cases will be caught later by `check_method_self_type`: + /// // Invalid cases will be caught later by `check_method_receiver`: /// fn method_err1(self: &mut T); // ExplicitSelf::ByReference /// } /// ``` From f108fce21cd025ead58ced8c21a8156fe339e26f Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Sun, 8 Oct 2017 21:42:33 +1300 Subject: [PATCH 04/11] Make the result of `Literal::string()` more readable Closes #45076 --- src/libproc_macro/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index e6307f10c139f..cf30966fa8971 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -488,7 +488,7 @@ impl Literal { pub fn string(string: &str) -> Literal { let mut escaped = String::new(); for ch in string.chars() { - escaped.extend(ch.escape_unicode()); + escaped.extend(ch.escape_debug()); } Literal(token::Literal(token::Lit::Str_(Symbol::intern(&escaped)), None)) } From e8ba32e7a07dbcba124cceeee8c75535309084aa Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 8 Oct 2017 18:19:51 +0200 Subject: [PATCH 05/11] Fix data-layout field The value was generated according to [this comment by @japaric](https://github.com/rust-lang/rust/issues/31367#issuecomment-213595571). --- src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json b/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json index c1dd0cf406366..3ae01d72fcc18 100644 --- a/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json +++ b/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json @@ -1,6 +1,6 @@ { "pre-link-args": ["-m64"], - "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", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", "linker-flavor": "gcc", "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "little", From 1c4add9c7cebc1220cb3c05da88b11830bb16ecd Mon Sep 17 00:00:00 2001 From: johnthagen Date: Sun, 8 Oct 2017 19:11:34 -0400 Subject: [PATCH 06/11] Fix typo in comment --- src/bootstrap/configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 67337bf44214e..29eee0442e29a 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -346,7 +346,7 @@ def set(key, value): targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target) # Here we walk through the constructed configuration we have from the parsed -# command line arguemnts. We then apply each piece of configuration by +# command line arguments. We then apply each piece of configuration by # basically just doing a `sed` to change the various configuration line to what # we've got configure. def to_toml(value): From 9e569d7671339ceaecfde6e0c86f9494cf1f3d04 Mon Sep 17 00:00:00 2001 From: johnthagen Date: Sun, 8 Oct 2017 19:15:17 -0400 Subject: [PATCH 07/11] Fix typo in README --- src/bootstrap/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index e543b8c070bcc..ebacc62b0fdda 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -39,7 +39,7 @@ The script accepts commands, flags, and arguments to determine what to do: ``` If files are dirty that would normally be rebuilt from stage 0, that can be - overidden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps + overridden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps that belong to stage n or earlier: ``` From 4a9df0ec6256d0318b9679c8da62cff3f84d1fe4 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 9 Oct 2017 15:38:51 +0200 Subject: [PATCH 08/11] incr.comp.: Move macro-export test case to src/test/incremental. --- .../macro_export.rs} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename src/test/{compile-fail/incr_comp_with_macro_export.rs => incremental/macro_export.rs} (90%) diff --git a/src/test/compile-fail/incr_comp_with_macro_export.rs b/src/test/incremental/macro_export.rs similarity index 90% rename from src/test/compile-fail/incr_comp_with_macro_export.rs rename to src/test/incremental/macro_export.rs index eafef17230367..914632e96ba31 100644 --- a/src/test/compile-fail/incr_comp_with_macro_export.rs +++ b/src/test/incremental/macro_export.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Zincremental=tmp/cfail-tests/incr_comp_with_macro_export +// revisions: cfail1 cfail2 cfail3 // must-compile-successfully - // This test case makes sure that we can compile with incremental compilation // enabled when there are macros exported from this crate. (See #37756) From 3e4d9df02bf8a801fb6f4903697ec523590210a9 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 9 Oct 2017 20:02:17 +0300 Subject: [PATCH 09/11] Fix a bug in diagnostics for `x as usize < y` Improve diagnostics for `x as usize << y` --- src/libsyntax/parse/parser.rs | 19 ++++++++++++++++--- src/test/ui/issue-22644.rs | 2 ++ src/test/ui/issue-22644.stderr | 13 +++++++++++-- src/test/ui/issue-44406.rs | 19 +++++++++++++++++++ src/test/ui/issue-44406.stderr | 26 ++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/issue-44406.rs create mode 100644 src/test/ui/issue-44406.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 978e06c75dd46..ff020445715d4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2890,17 +2890,30 @@ impl<'a> Parser<'a> { match self.parse_path(PathStyle::Expr) { Ok(path) => { + let (op_noun, op_verb) = match self.token { + token::Lt => ("comparison", "comparing"), + token::BinOp(token::Shl) => ("shift", "shifting"), + _ => { + // We can end up here even without `<` being the next token, for + // example because `parse_ty_no_plus` returns `Err` on keywords, + // but `parse_path` returns `Ok` on them due to error recovery. + // Return original error and parser state. + mem::replace(self, parser_snapshot_after_type); + return Err(type_err); + } + }; + // Successfully parsed the type path leaving a `<` yet to parse. type_err.cancel(); // Report non-fatal diagnostics, keep `x as usize` as an expression // in AST and continue parsing. let msg = format!("`<` is interpreted as a start of generic \ - arguments for `{}`, not a comparison", path); + arguments for `{}`, not a {}", path, op_noun); let mut err = self.sess.span_diagnostic.struct_span_err(self.span, &msg); err.span_label(self.look_ahead_span(1).to(parser_snapshot_after_type.span), "interpreted as generic arguments"); - err.span_label(self.span, "not interpreted as comparison"); + err.span_label(self.span, format!("not interpreted as {}", op_noun)); let expr = mk_expr(self, P(Ty { span: path.span, @@ -2911,7 +2924,7 @@ impl<'a> Parser<'a> { let expr_str = self.sess.codemap().span_to_snippet(expr.span) .unwrap_or(pprust::expr_to_string(&expr)); err.span_suggestion(expr.span, - "try comparing the casted value", + &format!("try {} the casted value", op_verb), format!("({})", expr_str)); err.emit(); diff --git a/src/test/ui/issue-22644.rs b/src/test/ui/issue-22644.rs index b482d0595f7b6..c8e0cd1763ffa 100644 --- a/src/test/ui/issue-22644.rs +++ b/src/test/ui/issue-22644.rs @@ -35,5 +35,7 @@ fn main() { < 5); + println!("{}", a as usize << long_name); + println!("{}", a: &mut 4); } diff --git a/src/test/ui/issue-22644.stderr b/src/test/ui/issue-22644.stderr index 54c325b24a3b7..f4967c4803bee 100644 --- a/src/test/ui/issue-22644.stderr +++ b/src/test/ui/issue-22644.stderr @@ -76,9 +76,18 @@ help: try comparing the casted value 33 | ... +error: `<` is interpreted as a start of generic arguments for `usize`, not a shift + --> $DIR/issue-22644.rs:38:31 + | +38 | println!("{}", a as usize << long_name); + | ---------- ^^ --------- interpreted as generic arguments + | | | + | | not interpreted as shift + | help: try shifting the casted value: `(a as usize)` + error: expected type, found `4` - --> $DIR/issue-22644.rs:38:28 + --> $DIR/issue-22644.rs:40:28 | -38 | println!("{}", a: &mut 4); +40 | println!("{}", a: &mut 4); | ^ expecting a type here because of type ascription diff --git a/src/test/ui/issue-44406.rs b/src/test/ui/issue-44406.rs new file mode 100644 index 0000000000000..abf572118fc68 --- /dev/null +++ b/src/test/ui/issue-44406.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($rest: tt) => { + bar(baz: $rest) + } +} + +fn main() { + foo!(true); +} diff --git a/src/test/ui/issue-44406.stderr b/src/test/ui/issue-44406.stderr new file mode 100644 index 0000000000000..e07face24bab7 --- /dev/null +++ b/src/test/ui/issue-44406.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `true` + --> $DIR/issue-44406.rs:18:10 + | +18 | foo!(true); + | ^^^^ + +error: expected type, found keyword `true` + --> $DIR/issue-44406.rs:18:10 + | +13 | bar(baz: $rest) + | - help: did you mean to use `;` here? +... +18 | foo!(true); + | ^^^^ expecting a type here because of type ascription + +error: expected one of `!`, `&&`, `&`, `(`, `*`, `.`, `;`, `<`, `?`, `[`, `_`, `extern`, `fn`, `for`, `impl`, `unsafe`, `}`, an operator, or lifetime, found `true` + --> $DIR/issue-44406.rs:18:10 + | +13 | bar(baz: $rest) + | - expected one of 19 possible tokens here +... +18 | foo!(true); + | ^^^^ unexpected token + +error: aborting due to 3 previous errors + From 679457ad2a0f33aed6b206107afedcccf5124374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20Jaffr=C3=A9?= Date: Mon, 9 Oct 2017 20:09:08 +0200 Subject: [PATCH 10/11] Refactor to use `debug_struct` in several Debug impls Fixes #44771. --- src/librustc_data_structures/graph/mod.rs | 15 ++------------ src/libstd/sync/mpsc/mod.rs | 24 +++-------------------- src/libstd/sync/mpsc/select.rs | 18 ++--------------- src/libstd/sync/mutex.rs | 13 +++++++++--- src/libstd/sync/rwlock.rs | 13 +++++++++--- src/libstd/sys_common/remutex.rs | 13 +++++++++--- src/libsyntax_pos/lib.rs | 7 +++++-- 7 files changed, 42 insertions(+), 61 deletions(-) diff --git a/src/librustc_data_structures/graph/mod.rs b/src/librustc_data_structures/graph/mod.rs index 474622f366913..56d5f5ffa3f6c 100644 --- a/src/librustc_data_structures/graph/mod.rs +++ b/src/librustc_data_structures/graph/mod.rs @@ -31,7 +31,7 @@ //! be indexed by the direction (see the type `Direction`). use bitvec::BitVector; -use std::fmt::{Formatter, Error, Debug}; +use std::fmt::Debug; use std::usize; use snapshot_vec::{SnapshotVec, SnapshotVecDelegate}; @@ -48,6 +48,7 @@ pub struct Node { pub data: N, } +#[derive(Debug)] pub struct Edge { next_edge: [EdgeIndex; 2], // see module comment source: NodeIndex, @@ -69,18 +70,6 @@ impl SnapshotVecDelegate for Edge { fn reverse(_: &mut Vec>, _: ()) {} } -impl Debug for Edge { - fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { - write!(f, - "Edge {{ next_edge: [{:?}, {:?}], source: {:?}, target: {:?}, data: {:?} }}", - self.next_edge[0], - self.next_edge[1], - self.source, - self.target, - self.data) - } -} - #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] pub struct NodeIndex(pub usize); diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index dcd4c8dfdf549..ce1a07b31b2ed 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -919,7 +919,7 @@ impl Drop for Sender { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl fmt::Debug for Sender { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Sender {{ .. }}") + f.debug_struct("Sender").finish() } } @@ -1049,7 +1049,7 @@ impl Drop for SyncSender { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl fmt::Debug for SyncSender { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "SyncSender {{ .. }}") + f.debug_struct("SyncSender").finish() } } @@ -1551,7 +1551,7 @@ impl Drop for Receiver { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl fmt::Debug for Receiver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Receiver {{ .. }}") + f.debug_struct("Receiver").finish() } } @@ -3009,22 +3009,4 @@ mod sync_tests { repro() } } - - #[test] - fn fmt_debug_sender() { - let (tx, _) = channel::(); - assert_eq!(format!("{:?}", tx), "Sender { .. }"); - } - - #[test] - fn fmt_debug_recv() { - let (_, rx) = channel::(); - assert_eq!(format!("{:?}", rx), "Receiver { .. }"); - } - - #[test] - fn fmt_debug_sync_sender() { - let (tx, _) = sync_channel::(1); - assert_eq!(format!("{:?}", tx), "SyncSender { .. }"); - } } diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index e49f4cff02403..a9f3cea243f36 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -354,13 +354,13 @@ impl Iterator for Packets { impl fmt::Debug for Select { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Select {{ .. }}") + f.debug_struct("Select").finish() } } impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Handle {{ .. }}") + f.debug_struct("Handle").finish() } } @@ -774,18 +774,4 @@ mod tests { } } } - - #[test] - fn fmt_debug_select() { - let sel = Select::new(); - assert_eq!(format!("{:?}", sel), "Select { .. }"); - } - - #[test] - fn fmt_debug_handle() { - let (_, rx) = channel::(); - let sel = Select::new(); - let handle = sel.handle(&rx); - assert_eq!(format!("{:?}", handle), "Handle { .. }"); - } } diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 62d8de18f4b45..a0349fe9d8bc1 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -384,11 +384,18 @@ impl Default for Mutex { impl fmt::Debug for Mutex { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_lock() { - Ok(guard) => write!(f, "Mutex {{ data: {:?} }}", &*guard), + Ok(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(), Err(TryLockError::Poisoned(err)) => { - write!(f, "Mutex {{ data: Poisoned({:?}) }}", &**err.get_ref()) + f.debug_struct("Mutex").field("data", &&**err.get_ref()).finish() }, - Err(TryLockError::WouldBlock) => write!(f, "Mutex {{ }}") + Err(TryLockError::WouldBlock) => { + struct LockedPlaceholder; + impl fmt::Debug for LockedPlaceholder { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("") } + } + + f.debug_struct("Mutex").field("data", &LockedPlaceholder).finish() + } } } } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 4757faabfb873..5c49d6b58459c 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -428,11 +428,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock { impl fmt::Debug for RwLock { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_read() { - Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", &*guard), + Ok(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), Err(TryLockError::Poisoned(err)) => { - write!(f, "RwLock {{ data: Poisoned({:?}) }}", &**err.get_ref()) + f.debug_struct("RwLock").field("data", &&**err.get_ref()).finish() }, - Err(TryLockError::WouldBlock) => write!(f, "RwLock {{ }}") + Err(TryLockError::WouldBlock) => { + struct LockedPlaceholder; + impl fmt::Debug for LockedPlaceholder { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("") } + } + + f.debug_struct("RwLock").field("data", &LockedPlaceholder).finish() + } } } } diff --git a/src/libstd/sys_common/remutex.rs b/src/libstd/sys_common/remutex.rs index 4d0407ccf6c89..ce43ec6d9abf5 100644 --- a/src/libstd/sys_common/remutex.rs +++ b/src/libstd/sys_common/remutex.rs @@ -116,11 +116,18 @@ impl Drop for ReentrantMutex { impl fmt::Debug for ReentrantMutex { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_lock() { - Ok(guard) => write!(f, "ReentrantMutex {{ data: {:?} }}", &*guard), + Ok(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(), Err(TryLockError::Poisoned(err)) => { - write!(f, "ReentrantMutex {{ data: Poisoned({:?}) }}", &**err.get_ref()) + f.debug_struct("ReentrantMutex").field("data", &**err.get_ref()).finish() }, - Err(TryLockError::WouldBlock) => write!(f, "ReentrantMutex {{ }}") + Err(TryLockError::WouldBlock) => { + struct LockedPlaceholder; + impl fmt::Debug for LockedPlaceholder { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("") } + } + + f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish() + } } } } diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 582f279818134..a06873aac0eb9 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -338,8 +338,11 @@ impl serialize::UseSpecializedDecodable for Span { } fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Span {{ lo: {:?}, hi: {:?}, ctxt: {:?} }}", - span.lo(), span.hi(), span.ctxt()) + f.debug_struct("Span") + .field("lo", &span.lo()) + .field("hi", &span.hi()) + .field("ctxt", &span.ctxt()) + .finish() } impl fmt::Debug for Span { From 06b9168d3362dc60a2e87d475319686332634319 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 10 Oct 2017 10:05:29 +0200 Subject: [PATCH 11/11] Rename test Linux target to avoid conflict with built-in target It seems like the file wasn't actually used, since there is a built-in target with the same name. See https://github.com/rust-lang/rust/pull/45108#issuecomment-335173165 for more details. --- src/test/run-make/target-specs/Makefile | 2 +- ...linux-gnu.json => my-x86_64-unknown-linux-gnu-platform.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/test/run-make/target-specs/{x86_64-unknown-linux-gnu.json => my-x86_64-unknown-linux-gnu-platform.json} (100%) diff --git a/src/test/run-make/target-specs/Makefile b/src/test/run-make/target-specs/Makefile index 6b58ad7b6dff0..5ea96daa3ef85 100644 --- a/src/test/run-make/target-specs/Makefile +++ b/src/test/run-make/target-specs/Makefile @@ -5,5 +5,5 @@ all: $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | grep -q "Error loading target specification" $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | grep 'Field llvm-target' RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm - RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=x86_64-unknown-linux-gnu --crate-type=lib --emit=asm + RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm $(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 - diff --git a/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json b/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json similarity index 100% rename from src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json rename to src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json