Skip to content

Commit

Permalink
Auto merge of #45169 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

- Successful merges: #44775, #45089, #45095, #45099, #45101, #45108, #45116, #45135, #45146
- Failed merges:
  • Loading branch information
bors committed Oct 10, 2017
2 parents ec016f8 + ce0a1cf commit d6d711d
Show file tree
Hide file tree
Showing 22 changed files with 142 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/README.md
Expand Up @@ -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:

```
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/configure.py
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem.rs
Expand Up @@ -836,7 +836,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
///
/// See the `discriminant` function in this module for more information.
#[stable(feature = "discriminant_value", since = "1.21.0")]
pub struct Discriminant<T>(u64, PhantomData<*const T>);
pub struct Discriminant<T>(u64, PhantomData<fn() -> T>);

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

Expand Down
16 changes: 16 additions & 0 deletions src/libcore/tests/mem.rs
Expand Up @@ -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<T: Send + Sync>() { }

is_send_sync::<Discriminant<Regular>>();
is_send_sync::<Discriminant<NotSendSync>>();
}
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Expand Up @@ -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))
}
Expand Down
15 changes: 2 additions & 13 deletions src/librustc_data_structures/graph/mod.rs
Expand Up @@ -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};

Expand All @@ -48,6 +48,7 @@ pub struct Node<N> {
pub data: N,
}

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

impl<E: Debug> Debug for Edge<E> {
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);

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -1464,7 +1464,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
/// declaration like `self: SomeType` into either `self`,
/// `&self`, `&mut self`, or `Box<self>`. 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:
///
Expand All @@ -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
/// }
/// ```
Expand Down
24 changes: 3 additions & 21 deletions src/libstd/sync/mpsc/mod.rs
Expand Up @@ -919,7 +919,7 @@ impl<T> Drop for Sender<T> {
#[stable(feature = "mpsc_debug", since = "1.8.0")]
impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Sender {{ .. }}")
f.debug_struct("Sender").finish()
}
}

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

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

Expand Down Expand Up @@ -3009,22 +3009,4 @@ mod sync_tests {
repro()
}
}

#[test]
fn fmt_debug_sender() {
let (tx, _) = channel::<i32>();
assert_eq!(format!("{:?}", tx), "Sender { .. }");
}

#[test]
fn fmt_debug_recv() {
let (_, rx) = channel::<i32>();
assert_eq!(format!("{:?}", rx), "Receiver { .. }");
}

#[test]
fn fmt_debug_sync_sender() {
let (tx, _) = sync_channel::<i32>(1);
assert_eq!(format!("{:?}", tx), "SyncSender { .. }");
}
}
18 changes: 2 additions & 16 deletions src/libstd/sync/mpsc/select.rs
Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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::<i32>();
let sel = Select::new();
let handle = sel.handle(&rx);
assert_eq!(format!("{:?}", handle), "Handle { .. }");
}
}
13 changes: 10 additions & 3 deletions src/libstd/sync/mutex.rs
Expand Up @@ -394,11 +394,18 @@ impl<T: ?Sized + Default> Default for Mutex<T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
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 {{ <locked> }}")
Err(TryLockError::WouldBlock) => {
struct LockedPlaceholder;
impl fmt::Debug for LockedPlaceholder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
}

f.debug_struct("Mutex").field("data", &LockedPlaceholder).finish()
}
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/libstd/sync/rwlock.rs
Expand Up @@ -428,11 +428,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
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 {{ <locked> }}")
Err(TryLockError::WouldBlock) => {
struct LockedPlaceholder;
impl fmt::Debug for LockedPlaceholder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
}

f.debug_struct("RwLock").field("data", &LockedPlaceholder).finish()
}
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/libstd/sys_common/remutex.rs
Expand Up @@ -116,11 +116,18 @@ impl<T> Drop for ReentrantMutex<T> {
impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
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 {{ <locked> }}")
Err(TryLockError::WouldBlock) => {
struct LockedPlaceholder;
impl fmt::Debug for LockedPlaceholder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("<locked>") }
}

f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish()
}
}
}
}
Expand Down
19 changes: 16 additions & 3 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -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,
Expand All @@ -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();

Expand Down
7 changes: 5 additions & 2 deletions src/libsyntax_pos/lib.rs
Expand Up @@ -339,8 +339,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 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/float_math.rs
Expand Up @@ -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
}

Expand Down
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make/target-specs/Makefile
Expand Up @@ -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 -
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/issue-22644.rs
Expand Up @@ -35,5 +35,7 @@ fn main() {
<
5);

println!("{}", a as usize << long_name);

println!("{}", a: &mut 4);
}
13 changes: 11 additions & 2 deletions src/test/ui/issue-22644.stderr
Expand Up @@ -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

0 comments on commit d6d711d

Please sign in to comment.