Skip to content

Commit abac55e

Browse files
committed
---
yaml --- r: 195302 b: refs/heads/snap-stage3 c: e2fd2df h: refs/heads/master v: v3
1 parent d45744a commit abac55e

File tree

5 files changed

+53
-29
lines changed

5 files changed

+53
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 14192d6df5cc714e5c9a3ca70b08f2514d977be2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e58f05717d49a4404638da81cb5ae431d2c7a6b6
4+
refs/heads/snap-stage3: e2fd2dffde52a59f7d59d67460aeb2ebf33f77dd
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcore/iter.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,6 @@ pub trait IteratorExt: Iterator + Sized {
244244
/// assert_eq!(it.next().unwrap(), (&0, &1));
245245
/// assert!(it.next().is_none());
246246
/// ```
247-
///
248-
/// `zip` can provide similar functionality to `enumerate`:
249-
///
250-
/// ```
251-
/// for pair in "foo".chars().enumerate() {
252-
/// println!("{:?}", pair);
253-
/// }
254-
///
255-
/// for pair in (0..).zip("foo".chars()) {
256-
/// println!("{:?}", pair);
257-
/// }
258-
/// ```
259-
///
260-
/// both produce the same output.
261247
#[inline]
262248
#[stable(feature = "rust1", since = "1.0.0")]
263249
fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> {
@@ -327,9 +313,6 @@ pub trait IteratorExt: Iterator + Sized {
327313
/// Creates an iterator that yields a pair of the value returned by this
328314
/// iterator plus the current index of iteration.
329315
///
330-
/// `enumerate` keeps its count as a `usize`. If you want to count by a
331-
/// different sized integer, the `zip` function provides similar functionality.
332-
///
333316
/// # Examples
334317
///
335318
/// ```

branches/snap-stage3/src/libstd/io/stdio.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use prelude::v1::*;
1212
use io::prelude::*;
1313

14-
use cell::RefCell;
14+
use cell::{RefCell, BorrowState};
1515
use cmp;
1616
use fmt;
1717
use io::lazy::Lazy;
@@ -264,9 +264,8 @@ impl Write for Stdout {
264264
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
265265
self.lock().write_all(buf)
266266
}
267-
fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
268-
self.lock().write_fmt(fmt)
269-
}
267+
// Don't override write_fmt as it's possible to run arbitrary code during a
268+
// write_fmt, allowing the possibility of a recursive lock (aka deadlock)
270269
}
271270
#[stable(feature = "rust1", since = "1.0.0")]
272271
impl<'a> Write for StdoutLock<'a> {
@@ -334,9 +333,7 @@ impl Write for Stderr {
334333
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
335334
self.lock().write_all(buf)
336335
}
337-
fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
338-
self.lock().write_fmt(fmt)
339-
}
336+
// Don't override write_fmt for the same reasons as Stdout
340337
}
341338
#[stable(feature = "rust1", since = "1.0.0")]
342339
impl<'a> Write for StderrLock<'a> {
@@ -395,10 +392,15 @@ pub fn set_print(sink: Box<Write + Send>) -> Option<Box<Write + Send>> {
395392
reason = "implementation detail which may disappear or be replaced at any time")]
396393
#[doc(hidden)]
397394
pub fn _print(args: fmt::Arguments) {
398-
if let Err(e) = LOCAL_STDOUT.with(|s| match s.borrow_mut().as_mut() {
399-
Some(w) => w.write_fmt(args),
400-
None => stdout().write_fmt(args)
401-
}) {
395+
let result = LOCAL_STDOUT.with(|s| {
396+
if s.borrow_state() == BorrowState::Unused {
397+
if let Some(w) = s.borrow_mut().as_mut() {
398+
return w.write_fmt(args);
399+
}
400+
}
401+
stdout().write_fmt(args)
402+
});
403+
if let Err(e) = result {
402404
panic!("failed printing to stdout: {}", e);
403405
}
404406
}

branches/snap-stage3/src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
#![feature(str_char)]
128128
#![feature(into_cow)]
129129
#![feature(slice_patterns)]
130+
#![feature(std_misc)]
130131
#![cfg_attr(test, feature(test, rustc_private, std_misc))]
131132

132133
// Don't link to std. We are std.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::fmt;
12+
13+
struct Foo;
14+
impl fmt::Debug for Foo {
15+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
16+
println!("<Foo as Debug>::fmt()");
17+
18+
write!(fmt, "")
19+
}
20+
}
21+
22+
fn test1() {
23+
let foo_str = format!("{:?}", Foo);
24+
25+
println!("{}", foo_str);
26+
}
27+
28+
fn test2() {
29+
println!("{:?}", Foo);
30+
}
31+
32+
fn main() {
33+
// This works fine
34+
test1();
35+
36+
// This fails
37+
test2();
38+
}

0 commit comments

Comments
 (0)