Skip to content

Commit 8fe144e

Browse files
committed
---
yaml --- r: 80790 b: refs/heads/try c: 653ffa8 h: refs/heads/master v: v3
1 parent abc917c commit 8fe144e

File tree

7 files changed

+99
-151
lines changed

7 files changed

+99
-151
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: a18038f3b2ee338de05ef4489d6ac7067c9198fd
5+
refs/heads/try: 653ffa845d70b26a49e227ae4445729c369c9f80
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/comm.rs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ pub fn stream<T: Send>() -> (Port<T>, Chan<T>) {
6666
(Port { x: p }, Chan { x: c })
6767
}
6868

69-
pub struct SharedChan<T> { x: rtcomm::SharedChan<T> }
70-
71-
impl<T: Send> SharedChan<T> {
72-
pub fn new(c: Chan<T>) -> SharedChan<T> {
73-
let Chan { x: c } = c;
74-
SharedChan { x: rtcomm::SharedChan::new(c) }
75-
}
76-
}
77-
7869
impl<T: Send> ChanOne<T> {
7970
pub fn send(self, val: T) {
8071
let ChanOne { x: c } = self;
@@ -161,6 +152,16 @@ impl<T: Send> Peekable<T> for Port<T> {
161152
}
162153
}
163154

155+
156+
pub struct SharedChan<T> { x: rtcomm::SharedChan<T> }
157+
158+
impl<T: Send> SharedChan<T> {
159+
pub fn new(c: Chan<T>) -> SharedChan<T> {
160+
let Chan { x: c } = c;
161+
SharedChan { x: rtcomm::SharedChan::new(c) }
162+
}
163+
}
164+
164165
impl<T: Send> GenericChan<T> for SharedChan<T> {
165166
fn send(&self, val: T) {
166167
let &SharedChan { x: ref c } = self;
@@ -193,3 +194,31 @@ impl<T> Clone for SharedChan<T> {
193194
SharedChan { x: c.clone() }
194195
}
195196
}
197+
198+
pub struct SharedPort<T> { x: rtcomm::SharedPort<T> }
199+
200+
impl<T: Send> SharedPort<T> {
201+
pub fn new(p: Port<T>) -> SharedPort<T> {
202+
let Port { x: p } = p;
203+
SharedPort { x: rtcomm::SharedPort::new(p) }
204+
}
205+
}
206+
207+
impl<T: Send> GenericPort<T> for SharedPort<T> {
208+
fn recv(&self) -> T {
209+
let &SharedPort { x: ref p } = self;
210+
p.recv()
211+
}
212+
213+
fn try_recv(&self) -> Option<T> {
214+
let &SharedPort { x: ref p } = self;
215+
p.try_recv()
216+
}
217+
}
218+
219+
impl<T> Clone for SharedPort<T> {
220+
fn clone(&self) -> SharedPort<T> {
221+
let &SharedPort { x: ref p } = self;
222+
SharedPort { x: p.clone() }
223+
}
224+
}

branches/try/src/libstd/iter.rs

Lines changed: 14 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use cmp;
2121
use num::{Zero, One, Integer, CheckedAdd, CheckedSub, Saturating};
2222
use option::{Option, Some, None};
2323
use ops::{Add, Mul, Sub};
24-
use cmp::{Eq, Ord};
24+
use cmp::Ord;
2525
use clone::Clone;
2626
use uint;
2727
use util;
@@ -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,78 +1826,17 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu
18381826
}
18391827
}
18401828

1841-
/// An iterator over the range [start, stop) by `step`. It handles overflow by stopping.
1842-
#[deriving(Clone, DeepClone)]
1843-
pub struct RangeStep<A> {
1844-
priv state: A,
1845-
priv stop: A,
1846-
priv step: A,
1847-
priv rev: bool
1848-
}
1849-
1850-
/// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping.
1851-
#[inline]
1852-
pub fn range_step<A: CheckedAdd + Ord + Clone + Zero>(start: A, stop: A, step: A) -> RangeStep<A> {
1853-
let rev = step < Zero::zero();
1854-
RangeStep{state: start, stop: stop, step: step, rev: rev}
1855-
}
1856-
1857-
impl<A: CheckedAdd + Ord + Clone> Iterator<A> for RangeStep<A> {
1829+
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
18581830
#[inline]
18591831
fn next(&mut self) -> Option<A> {
1860-
if (self.rev && self.state > self.stop) || self.state < self.stop {
1861-
let result = self.state.clone();
1862-
match self.state.checked_add(&self.step) {
1863-
Some(x) => self.state = x,
1864-
None => self.state = self.stop.clone()
1865-
}
1866-
Some(result)
1867-
} else {
1868-
None
1869-
}
1832+
let result = self.state.clone();
1833+
self.state = self.state + self.step;
1834+
Some(result)
18701835
}
1871-
}
1872-
1873-
/// An iterator over the range [start, stop] by `step`. It handles overflow by stopping.
1874-
#[deriving(Clone, DeepClone)]
1875-
pub struct RangeStepInclusive<A> {
1876-
priv state: A,
1877-
priv stop: A,
1878-
priv step: A,
1879-
priv rev: bool,
1880-
priv done: bool
1881-
}
18821836

1883-
/// Return an iterator over the range [start, stop] by `step`. It handles overflow by stopping.
1884-
#[inline]
1885-
pub fn range_step_inclusive<A: CheckedAdd + Ord + Clone + Zero>(start: A, stop: A,
1886-
step: A) -> RangeStepInclusive<A> {
1887-
let rev = step < Zero::zero();
1888-
RangeStepInclusive{state: start, stop: stop, step: step, rev: rev, done: false}
1889-
}
1890-
1891-
impl<A: CheckedAdd + Ord + Clone + Eq> Iterator<A> for RangeStepInclusive<A> {
18921837
#[inline]
1893-
fn next(&mut self) -> Option<A> {
1894-
if !self.done {
1895-
if (self.rev && self.state > self.stop) || self.state < self.stop {
1896-
let result = self.state.clone();
1897-
match self.state.checked_add(&self.step) {
1898-
Some(x) => self.state = x,
1899-
None => self.done = true
1900-
}
1901-
Some(result)
1902-
} else {
1903-
if self.state == self.stop {
1904-
self.done = true;
1905-
Some(self.state.clone())
1906-
} else {
1907-
None
1908-
}
1909-
}
1910-
} else {
1911-
None
1912-
}
1838+
fn size_hint(&self) -> (uint, Option<uint>) {
1839+
(uint::max_value, None) // Too bad we can't specify an infinite lower bound
19131840
}
19141841
}
19151842

@@ -2722,20 +2649,6 @@ mod tests {
27222649
assert_eq!(range_inclusive(0i, 5).invert().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]);
27232650
}
27242651

2725-
#[test]
2726-
fn test_range_step() {
2727-
assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15]);
2728-
assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]);
2729-
assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2730-
}
2731-
2732-
#[test]
2733-
fn test_range_step_inclusive() {
2734-
assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15, 20]);
2735-
assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]);
2736-
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2737-
}
2738-
27392652
#[test]
27402653
fn test_reverse() {
27412654
let mut ys = [1, 2, 3, 4, 5];

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/ast_util.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -519,20 +519,11 @@ impl Visitor<()> for IdVisitor {
519519
visit::walk_stmt(self, statement, env)
520520
}
521521

522-
// XXX: Default
523-
fn visit_arm(&mut self, arm: &Arm, env: ()) {
524-
visit::walk_arm(self, arm, env)
525-
}
526-
527522
fn visit_pat(&mut self, pattern: @Pat, env: ()) {
528523
(self.visit_callback)(pattern.id);
529524
visit::walk_pat(self, pattern, env)
530525
}
531526

532-
// XXX: Default
533-
fn visit_decl(&mut self, declaration: @Decl, env: ()) {
534-
visit::walk_decl(self, declaration, env)
535-
}
536527

537528
fn visit_expr(&mut self, expression: @Expr, env: ()) {
538529
{
@@ -545,11 +536,6 @@ impl Visitor<()> for IdVisitor {
545536
visit::walk_expr(self, expression, env)
546537
}
547538

548-
// XXX: Default
549-
fn visit_expr_post(&mut self, _: @Expr, _: ()) {
550-
// Empty!
551-
}
552-
553539
fn visit_ty(&mut self, typ: &Ty, env: ()) {
554540
(self.visit_callback)(typ.id);
555541
match typ.node {
@@ -612,31 +598,6 @@ impl Visitor<()> for IdVisitor {
612598
}
613599
}
614600

615-
// XXX: Default
616-
fn visit_ty_method(&mut self, type_method: &TypeMethod, env: ()) {
617-
visit::walk_ty_method(self, type_method, env)
618-
}
619-
620-
// XXX: Default
621-
fn visit_trait_method(&mut self, trait_method: &trait_method, env: ()) {
622-
visit::walk_trait_method(self, trait_method, env)
623-
}
624-
625-
// XXX: Default
626-
fn visit_struct_def(&mut self,
627-
struct_definition: @struct_def,
628-
identifier: Ident,
629-
generics: &Generics,
630-
node_id: NodeId,
631-
env: ()) {
632-
visit::walk_struct_def(self,
633-
struct_definition,
634-
identifier,
635-
generics,
636-
node_id,
637-
env)
638-
}
639-
640601
fn visit_struct_field(&mut self, struct_field: @struct_field, env: ()) {
641602
(self.visit_callback)(struct_field.node.id);
642603
visit::walk_struct_field(self, struct_field, env)

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)