Skip to content

Commit 3129654

Browse files
committed
---
yaml --- r: 80787 b: refs/heads/try c: 5c4f65e h: refs/heads/master i: 80785: 8095428 80783: 2b5e242 v: v3
1 parent 9ef7a1c commit 3129654

File tree

5 files changed

+68
-21
lines changed

5 files changed

+68
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: 3aead52586d26f375e6318fb6980280db18b70b7
5+
refs/heads/try: 5c4f65e6f593ed790a9d6328c9ff0093572e87ef
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/iter.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,21 +1719,7 @@ pub fn count<A>(start: A, step: A) -> Counter<A> {
17191719
Counter{state: start, step: step}
17201720
}
17211721

1722-
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
1723-
#[inline]
1724-
fn next(&mut self) -> Option<A> {
1725-
let result = self.state.clone();
1726-
self.state = self.state + self.step;
1727-
Some(result)
1728-
}
1729-
1730-
#[inline]
1731-
fn size_hint(&self) -> (uint, Option<uint>) {
1732-
(uint::max_value, None) // Too bad we can't specify an infinite lower bound
1733-
}
1734-
}
1735-
1736-
/// An iterator over the range [start, stop)
1722+
/// A range of numbers from [0, N)
17371723
#[deriving(Clone, DeepClone)]
17381724
pub struct Range<A> {
17391725
priv state: A,
@@ -1763,12 +1749,14 @@ impl<A: Add<A, A> + Ord + Clone> Iterator<A> for Range<A> {
17631749
// Blocked on #8605 Need numeric trait for converting to `Option<uint>`
17641750
}
17651751

1766-
/// `Integer` is required to ensure the range will be the same regardless of
1767-
/// the direction it is consumed.
1768-
impl<A: Integer + Ord + Clone> DoubleEndedIterator<A> for Range<A> {
1752+
impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for Range<A> {
17691753
#[inline]
17701754
fn next_back(&mut self) -> Option<A> {
17711755
if self.stop > self.state {
1756+
// Integer doesn't technically define this rule, but we're going to assume that every
1757+
// Integer is reachable from every other one by adding or subtracting enough Ones. This
1758+
// seems like a reasonable-enough rule that every Integer should conform to, even if it
1759+
// can't be statically checked.
17721760
self.stop = self.stop - self.one;
17731761
Some(self.stop.clone())
17741762
} else {
@@ -1777,7 +1765,7 @@ impl<A: Integer + Ord + Clone> DoubleEndedIterator<A> for Range<A> {
17771765
}
17781766
}
17791767

1780-
/// An iterator over the range [start, stop]
1768+
/// A range of numbers from [0, N]
17811769
#[deriving(Clone, DeepClone)]
17821770
pub struct RangeInclusive<A> {
17831771
priv range: Range<A>,
@@ -1838,6 +1826,20 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu
18381826
}
18391827
}
18401828

1829+
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
1830+
#[inline]
1831+
fn next(&mut self) -> Option<A> {
1832+
let result = self.state.clone();
1833+
self.state = self.state + self.step;
1834+
Some(result)
1835+
}
1836+
1837+
#[inline]
1838+
fn size_hint(&self) -> (uint, Option<uint>) {
1839+
(uint::max_value, None) // Too bad we can't specify an infinite lower bound
1840+
}
1841+
}
1842+
18411843
/// An iterator that repeats an element endlessly
18421844
#[deriving(Clone, DeepClone)]
18431845
pub struct Repeat<A> {

branches/try/src/libstd/rt/io/timer.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ use rt::local::Local;
1717

1818
pub struct Timer(~RtioTimerObject);
1919

20+
/// Sleep the current task for `msecs` milliseconds.
21+
pub fn sleep(msecs: u64) {
22+
let mut timer = Timer::new().expect("timer::sleep: could not create a Timer");
23+
24+
timer.sleep(msecs)
25+
}
26+
2027
impl Timer {
2128

2229
pub fn new() -> Option<Timer> {
@@ -52,4 +59,11 @@ mod test {
5259
do timer.map_move |mut t| { t.sleep(1) };
5360
}
5461
}
62+
63+
#[test]
64+
fn test_io_timer_sleep_standalone() {
65+
do run_in_mt_newsched_task {
66+
sleep(1)
67+
}
68+
}
5569
}

branches/try/src/libsyntax/ext/expand.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,26 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
7676
// mark before:
7777
let marked_before = mark_tts(*tts,fm);
7878
let marked_ctxt = new_mark(fm, ctxt);
79+
80+
// The span that we pass to the expanders we want to
81+
// be the root of the call stack. That's the most
82+
// relevant span and it's the actual invocation of
83+
// the macro.
84+
let mut relevant_info = cx.backtrace();
85+
let mut einfo = relevant_info.unwrap();
86+
loop {
87+
match relevant_info {
88+
None => { break }
89+
Some(e) => {
90+
einfo = e;
91+
relevant_info = einfo.call_site.expn_info;
92+
}
93+
}
94+
}
95+
7996
let expanded =
80-
match expandfun(cx, mac.span, marked_before, marked_ctxt) {
97+
match expandfun(cx, einfo.call_site,
98+
marked_before, marked_ctxt) {
8199
MRExpr(e) => e,
82100
MRAny(expr_maker,_,_) => expr_maker(),
83101
_ => {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2013 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+
fn main() {
12+
debug!("%s %s", 3); //~ ERROR: not enough arguments
13+
}

0 commit comments

Comments
 (0)