Skip to content

Commit c43e260

Browse files
committed
---
yaml --- r: 160638 b: refs/heads/master c: bbe1a9b h: refs/heads/master v: v3
1 parent 891ad0e commit c43e260

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1246
-2050
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 377d7524a897ae91dfd48e7e34847af88dac49cb
2+
refs/heads/master: bbe1a9b9c18d6dce6140ef16cbc9c29ad586564d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c9f6d696420107f82304b992cf623b806995fe18
55
refs/heads/try: 225de0d60f8ca8dcc62ab2fd8818ebbda4b58cfe

trunk/src/libcollections/binary_heap.rs

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ use core::mem::{zeroed, replace, swap};
160160
use core::ptr;
161161

162162
use slice;
163-
use vec::{mod, Vec};
163+
use vec::Vec;
164+
165+
// FIXME(conventions): implement into_iter
164166

165167
/// A priority queue implemented with a binary heap.
166168
///
@@ -241,27 +243,6 @@ impl<T: Ord> BinaryHeap<T> {
241243
Items { iter: self.data.iter() }
242244
}
243245

244-
/// Creates a consuming iterator, that is, one that moves each value out of
245-
/// the binary heap in arbitrary order. The binary heap cannot be used
246-
/// after calling this.
247-
///
248-
/// # Example
249-
///
250-
/// ```
251-
/// use std::collections::BinaryHeap;
252-
/// let pq = BinaryHeap::from_vec(vec![1i, 2, 3, 4]);
253-
///
254-
/// // Print 1, 2, 3, 4 in arbitrary order
255-
/// for x in pq.into_iter() {
256-
/// // x has type int, not &int
257-
/// println!("{}", x);
258-
/// }
259-
/// ```
260-
#[unstable = "matches collection reform specification, waiting for dust to settle"]
261-
pub fn into_iter(self) -> MoveItems<T> {
262-
MoveItems { iter: self.data.into_iter() }
263-
}
264-
265246
/// Returns the greatest item in a queue, or `None` if it is empty.
266247
///
267248
/// # Example
@@ -567,26 +548,6 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
567548
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
568549
}
569550

570-
/// An iterator that moves out of a `BinaryHeap`.
571-
pub struct MoveItems<T> {
572-
iter: vec::MoveItems<T>,
573-
}
574-
575-
impl<T> Iterator<T> for MoveItems<T> {
576-
#[inline]
577-
fn next(&mut self) -> Option<T> { self.iter.next() }
578-
579-
#[inline]
580-
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
581-
}
582-
583-
impl<T> DoubleEndedIterator<T> for MoveItems<T> {
584-
#[inline]
585-
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
586-
}
587-
588-
impl<T> ExactSize<T> for MoveItems<T> {}
589-
590551
impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
591552
fn from_iter<Iter: Iterator<T>>(mut iter: Iter) -> BinaryHeap<T> {
592553
let vec: Vec<T> = iter.collect();
@@ -625,43 +586,6 @@ mod tests {
625586
}
626587
}
627588

628-
#[test]
629-
fn test_move_iter() {
630-
let data = vec!(5i, 9, 3);
631-
let iterout = vec!(9i, 5, 3);
632-
let pq = BinaryHeap::from_vec(data);
633-
634-
let v: Vec<int> = pq.into_iter().collect();
635-
assert_eq!(v, iterout);
636-
}
637-
638-
#[test]
639-
fn test_move_iter_size_hint() {
640-
let data = vec!(5i, 9);
641-
let pq = BinaryHeap::from_vec(data);
642-
643-
let mut it = pq.into_iter();
644-
645-
assert_eq!(it.size_hint(), (2, Some(2)));
646-
assert_eq!(it.next(), Some(9i));
647-
648-
assert_eq!(it.size_hint(), (1, Some(1)));
649-
assert_eq!(it.next(), Some(5i));
650-
651-
assert_eq!(it.size_hint(), (0, Some(0)));
652-
assert_eq!(it.next(), None);
653-
}
654-
655-
#[test]
656-
fn test_move_iter_reverse() {
657-
let data = vec!(5i, 9, 3);
658-
let iterout = vec!(3i, 5, 9);
659-
let pq = BinaryHeap::from_vec(data);
660-
661-
let v: Vec<int> = pq.into_iter().rev().collect();
662-
assert_eq!(v, iterout);
663-
}
664-
665589
#[test]
666590
fn test_top_and_pop() {
667591
let data = vec!(2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1);

trunk/src/libcollections/str.rs

Lines changed: 36 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<S: Str> StrVector for [S] {
163163
}
164164
}
165165

166-
impl<S: Str, T: AsSlice<S>> StrVector for T {
166+
impl<S: Str> StrVector for Vec<S> {
167167
#[inline]
168168
fn concat(&self) -> String {
169169
self.as_slice().concat()
@@ -929,93 +929,54 @@ mod tests {
929929
assert_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".slice_chars(2, 8));
930930
}
931931

932-
struct S {
933-
x: [String, .. 2]
934-
}
935-
936-
impl AsSlice<String> for S {
937-
fn as_slice<'a> (&'a self) -> &'a [String] {
938-
&self.x
939-
}
940-
}
941-
942-
fn s(x: &str) -> String { x.into_string() }
943-
944-
macro_rules! test_concat {
945-
($expected: expr, $string: expr) => {
946-
{
947-
let s = $string.concat();
948-
assert_eq!($expected, s.as_slice());
949-
}
950-
}
951-
}
952-
953932
#[test]
954-
fn test_concat_for_different_types() {
955-
test_concat!("ab", ["a", "b"]);
956-
test_concat!("ab", [s("a"), s("b")]);
957-
test_concat!("ab", vec!["a", "b"]);
958-
test_concat!("ab", vec!["a", "b"].as_slice());
959-
test_concat!("ab", vec![s("a"), s("b")]);
960-
961-
let mut v0 = ["a", "b"];
962-
let mut v1 = [s("a"), s("b")];
963-
unsafe {
964-
use std::c_vec::CVec;
965-
966-
test_concat!("ab", CVec::new(v0.as_mut_ptr(), v0.len()));
967-
test_concat!("ab", CVec::new(v1.as_mut_ptr(), v1.len()));
933+
fn test_concat() {
934+
fn t(v: &[String], s: &str) {
935+
assert_eq!(v.concat().as_slice(), s);
968936
}
969-
970-
test_concat!("ab", S { x: [s("a"), s("b")] });
937+
t(&[String::from_str("you"), String::from_str("know"),
938+
String::from_str("I'm"),
939+
String::from_str("no"), String::from_str("good")],
940+
"youknowI'mnogood");
941+
let v: &[String] = &[];
942+
t(v, "");
943+
t(&[String::from_str("hi")], "hi");
971944
}
972945

973946
#[test]
974-
fn test_concat_for_different_lengths() {
975-
let empty: &[&str] = &[];
976-
test_concat!("", empty);
977-
test_concat!("a", ["a"]);
978-
test_concat!("ab", ["a", "b"]);
979-
test_concat!("abc", ["", "a", "bc"]);
980-
}
981-
982-
macro_rules! test_connect {
983-
($expected: expr, $string: expr, $delim: expr) => {
984-
{
985-
let s = $string.connect($delim);
986-
assert_eq!($expected, s.as_slice());
987-
}
947+
fn test_connect() {
948+
fn t(v: &[String], sep: &str, s: &str) {
949+
assert_eq!(v.connect(sep).as_slice(), s);
988950
}
951+
t(&[String::from_str("you"), String::from_str("know"),
952+
String::from_str("I'm"),
953+
String::from_str("no"), String::from_str("good")],
954+
" ", "you know I'm no good");
955+
let v: &[String] = &[];
956+
t(v, " ", "");
957+
t(&[String::from_str("hi")], " ", "hi");
989958
}
990959

991960
#[test]
992-
fn test_connect_for_different_types() {
993-
test_connect!("a-b", ["a", "b"], "-");
994-
let hyphen = "-".into_string();
995-
test_connect!("a-b", [s("a"), s("b")], hyphen.as_slice());
996-
test_connect!("a-b", vec!["a", "b"], hyphen.as_slice());
997-
test_connect!("a-b", vec!["a", "b"].as_slice(), "-");
998-
test_connect!("a-b", vec![s("a"), s("b")], "-");
999-
1000-
let mut v0 = ["a", "b"];
1001-
let mut v1 = [s("a"), s("b")];
1002-
unsafe {
1003-
use std::c_vec::CVec;
1004-
1005-
test_connect!("a-b", CVec::new(v0.as_mut_ptr(), v0.len()), "-");
1006-
test_connect!("a-b", CVec::new(v1.as_mut_ptr(), v1.len()), hyphen.as_slice());
961+
fn test_concat_slices() {
962+
fn t(v: &[&str], s: &str) {
963+
assert_eq!(v.concat().as_slice(), s);
1007964
}
1008-
1009-
test_connect!("a-b", S { x: [s("a"), s("b")] }, "-");
965+
t(&["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
966+
let v: &[&str] = &[];
967+
t(v, "");
968+
t(&["hi"], "hi");
1010969
}
1011970

1012971
#[test]
1013-
fn test_connect_for_different_lengths() {
1014-
let empty: &[&str] = &[];
1015-
test_connect!("", empty, "-");
1016-
test_connect!("a", ["a"], "-");
1017-
test_connect!("a-b", ["a", "b"], "-");
1018-
test_connect!("-a-bc", ["", "a", "bc"], "-");
972+
fn test_connect_slices() {
973+
fn t(v: &[&str], sep: &str, s: &str) {
974+
assert_eq!(v.connect(sep).as_slice(), s);
975+
}
976+
t(&["you", "know", "I'm", "no", "good"],
977+
" ", "you know I'm no good");
978+
t(&[], " ", "");
979+
t(&["hi"], " ", "hi");
1019980
}
1020981

1021982
#[test]

trunk/src/libcore/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ use intrinsics::TypeId;
8888
#[stable]
8989
pub trait Any: 'static {
9090
/// Get the `TypeId` of `self`
91-
#[experimental = "this method will likely be replaced by an associated static"]
91+
#[stable]
9292
fn get_type_id(&self) -> TypeId;
9393
}
9494

trunk/src/libcore/str.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,19 +1277,14 @@ pub mod traits {
12771277
}
12781278

12791279
/// Any string that can be represented as a slice
1280-
pub trait Str for Sized? {
1280+
pub trait Str {
12811281
/// Work with `self` as a slice.
12821282
fn as_slice<'a>(&'a self) -> &'a str;
12831283
}
12841284

1285-
impl Str for str {
1285+
impl<'a> Str for &'a str {
12861286
#[inline]
1287-
fn as_slice<'a>(&'a self) -> &'a str { self }
1288-
}
1289-
1290-
impl<'a, Sized? S> Str for &'a S where S: Str {
1291-
#[inline]
1292-
fn as_slice(&self) -> &str { Str::as_slice(*self) }
1287+
fn as_slice<'a>(&'a self) -> &'a str { *self }
12931288
}
12941289

12951290
/// Methods for string slices

trunk/src/liblog/lib.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171

172172
extern crate regex;
173173

174-
use std::cell::RefCell;
174+
use regex::Regex;
175175
use std::fmt;
176176
use std::io::LineBufferedWriter;
177177
use std::io;
@@ -181,8 +181,6 @@ use std::rt;
181181
use std::slice;
182182
use std::sync::{Once, ONCE_INIT};
183183

184-
use regex::Regex;
185-
186184
use directive::LOG_LEVEL_NAMES;
187185

188186
pub mod macros;
@@ -215,9 +213,7 @@ pub const WARN: u32 = 2;
215213
/// Error log level
216214
pub const ERROR: u32 = 1;
217215

218-
thread_local!(static LOCAL_LOGGER: RefCell<Option<Box<Logger + Send>>> = {
219-
RefCell::new(None)
220-
})
216+
local_data_key!(local_logger: Box<Logger + Send>)
221217

222218
/// A trait used to represent an interface to a task-local logger. Each task
223219
/// can have its own custom logger which can respond to logging messages
@@ -287,9 +283,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: &fmt::Arguments) {
287283
// Completely remove the local logger from TLS in case anyone attempts to
288284
// frob the slot while we're doing the logging. This will destroy any logger
289285
// set during logging.
290-
let mut logger = LOCAL_LOGGER.with(|s| {
291-
s.borrow_mut().take()
292-
}).unwrap_or_else(|| {
286+
let mut logger = local_logger.replace(None).unwrap_or_else(|| {
293287
box DefaultLogger { handle: io::stderr() } as Box<Logger + Send>
294288
});
295289
logger.log(&LogRecord {
@@ -299,7 +293,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: &fmt::Arguments) {
299293
module_path: loc.module_path,
300294
line: loc.line,
301295
});
302-
set_logger(logger);
296+
local_logger.replace(Some(logger));
303297
}
304298

305299
/// Getter for the global log level. This is a function so that it can be called
@@ -311,10 +305,7 @@ pub fn log_level() -> u32 { unsafe { LOG_LEVEL } }
311305
/// Replaces the task-local logger with the specified logger, returning the old
312306
/// logger.
313307
pub fn set_logger(logger: Box<Logger + Send>) -> Option<Box<Logger + Send>> {
314-
let mut l = Some(logger);
315-
LOCAL_LOGGER.with(|slot| {
316-
mem::replace(&mut *slot.borrow_mut(), l.take())
317-
})
308+
local_logger.replace(Some(logger))
318309
}
319310

320311
/// A LogRecord is created by the logging macros, and passed as the only

trunk/src/librustc/util/common.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![allow(non_camel_case_types)]
1212

13-
use std::cell::{RefCell, Cell};
13+
use std::cell::RefCell;
1414
use std::collections::HashMap;
1515
use std::fmt::Show;
1616
use std::hash::{Hash, Hasher};
@@ -26,14 +26,11 @@ use syntax::visit::Visitor;
2626
pub struct ErrorReported;
2727

2828
pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T {
29-
thread_local!(static DEPTH: Cell<uint> = Cell::new(0));
29+
local_data_key!(depth: uint);
3030
if !do_it { return f(u); }
3131

32-
let old = DEPTH.with(|slot| {
33-
let r = slot.get();
34-
slot.set(r + 1);
35-
r
36-
});
32+
let old = depth.get().map(|d| *d).unwrap_or(0);
33+
depth.replace(Some(old + 1));
3734

3835
let mut u = Some(u);
3936
let mut rv = None;
@@ -44,7 +41,7 @@ pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T {
4441

4542
println!("{}time: {}.{:03} \t{}", " ".repeat(old),
4643
dur.num_seconds(), dur.num_milliseconds() % 1000, what);
47-
DEPTH.with(|slot| slot.set(old));
44+
depth.replace(Some(old));
4845

4946
rv
5047
}

trunk/src/librustc_trans/save/recorder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'a> FmtStrs<'a> {
171171

172172
let pairs = fields.iter().zip(values);
173173
let mut strs = pairs.map(|(f, v)| format!(",{},\"{}\"", f, escape(
174-
if *f == "qualname" {
174+
if *f == "qualname" && v.len() > 0 {
175175
let mut n = self.krate.clone();
176176
n.push_str("::");
177177
n.push_str(v);

0 commit comments

Comments
 (0)