Skip to content

Commit 2e7cdec

Browse files
committed
---
yaml --- r: 115583 b: refs/heads/try c: e454851 h: refs/heads/master i: 115581: ff2d2bd 115579: a714c9e 115575: 4be36af 115567: adc080d 115551: 9c80667 115519: 96d68a9 115455: 820261f v: v3
1 parent 6e99730 commit 2e7cdec

File tree

49 files changed

+2183
-1141
lines changed

Some content is hidden

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

49 files changed

+2183
-1141
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: bee4e6adac17f87b1cdc26ab69f8c0f5d82575a3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
5-
refs/heads/try: 6aefce6f16d4ecddbc225c23a5ebeb481c19ea2c
5+
refs/heads/try: e45485181338137136ea2816d78ed108440f7d50
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ The keywords are the following strings:
208208

209209
~~~~ {.notrust .keyword}
210210
as
211-
break
211+
box break
212212
crate
213213
else enum extern
214214
false fn for

branches/try/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<keyword>as</keyword>
3939
<keyword>assert</keyword>
4040
<keyword>break</keyword>
41+
<keyword>box</keyword>
4142
<keyword>const</keyword>
4243
<keyword>continue</keyword>
4344
<keyword>crate</keyword>

branches/try/src/etc/kate/rust.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<list name="keywords">
1919
<item> as </item>
2020
<item> break </item>
21+
<item> box </item>
2122
<item> continue </item>
2223
<item> crate </item>
2324
<item> do </item>

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ syn keyword rustOperator as
1818

1919
syn match rustAssert "\<assert\(\w\)*!" contained
2020
syn match rustFail "\<fail\(\w\)*!" contained
21-
syn keyword rustKeyword break continue
21+
syn keyword rustKeyword break box continue
2222
syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite
2323
syn keyword rustKeyword for in if impl let
2424
syn keyword rustKeyword loop once priv pub

branches/try/src/libcollections/hashmap.rs

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,7 @@ mod test_map {
16171617
use std::cmp::Equiv;
16181618
use std::hash::Hash;
16191619
use std::iter::{Iterator,range_inclusive,range_step_inclusive};
1620-
use std::local_data;
1621-
use std::vec;
1620+
use std::cell::RefCell;
16221621

16231622
struct KindaIntLike(int);
16241623

@@ -1657,7 +1656,7 @@ mod test_map {
16571656
assert_eq!(*m.find(&2).unwrap(), 4);
16581657
}
16591658

1660-
local_data_key!(drop_vector: vec::Vec<int>)
1659+
local_data_key!(drop_vector: RefCell<Vec<int>>)
16611660

16621661
#[deriving(Hash, Eq, TotalEq)]
16631662
struct Dropable {
@@ -1667,75 +1666,72 @@ mod test_map {
16671666

16681667
impl Dropable {
16691668
fn new(k: uint) -> Dropable {
1670-
local_data::get_mut(drop_vector,
1671-
|v| { v.unwrap().as_mut_slice()[k] += 1; });
1669+
let v = drop_vector.get().unwrap();
1670+
v.borrow_mut().as_mut_slice()[k] += 1;
16721671

16731672
Dropable { k: k }
16741673
}
16751674
}
16761675

16771676
impl Drop for Dropable {
16781677
fn drop(&mut self) {
1679-
local_data::get_mut(drop_vector, |v|
1680-
{ v.unwrap().as_mut_slice()[self.k] -= 1; });
1678+
let v = drop_vector.get().unwrap();
1679+
v.borrow_mut().as_mut_slice()[self.k] -= 1;
16811680
}
16821681
}
16831682

16841683
#[test]
16851684
fn test_drops() {
1686-
local_data::set(drop_vector, vec::Vec::from_elem(200, 0));
1685+
drop_vector.replace(Some(RefCell::new(Vec::from_elem(200, 0))));
16871686

16881687
{
16891688
let mut m = HashMap::new();
16901689

1691-
local_data::get(drop_vector, |v| {
1692-
for i in range(0u, 200) {
1693-
assert_eq!(v.unwrap().as_slice()[i], 0);
1694-
}
1695-
});
1690+
let v = drop_vector.get().unwrap();
1691+
for i in range(0u, 200) {
1692+
assert_eq!(v.borrow().as_slice()[i], 0);
1693+
}
1694+
drop(v);
16961695

16971696
for i in range(0u, 100) {
16981697
let d1 = Dropable::new(i);
16991698
let d2 = Dropable::new(i+100);
17001699
m.insert(d1, d2);
17011700
}
17021701

1703-
local_data::get(drop_vector, |v| {
1704-
for i in range(0u, 200) {
1705-
assert_eq!(v.unwrap().as_slice()[i], 1);
1706-
}
1707-
});
1702+
let v = drop_vector.get().unwrap();
1703+
for i in range(0u, 200) {
1704+
assert_eq!(v.borrow().as_slice()[i], 1);
1705+
}
1706+
drop(v);
17081707

17091708
for i in range(0u, 50) {
17101709
let k = Dropable::new(i);
17111710
let v = m.pop(&k);
17121711

17131712
assert!(v.is_some());
17141713

1715-
local_data::get(drop_vector, |v| {
1716-
assert_eq!(v.unwrap().as_slice()[i], 1);
1717-
assert_eq!(v.unwrap().as_slice()[i+100], 1);
1718-
});
1714+
let v = drop_vector.get().unwrap();
1715+
assert_eq!(v.borrow().as_slice()[i], 1);
1716+
assert_eq!(v.borrow().as_slice()[i+100], 1);
17191717
}
17201718

1721-
local_data::get(drop_vector, |v| {
1722-
for i in range(0u, 50) {
1723-
assert_eq!(v.unwrap().as_slice()[i], 0);
1724-
assert_eq!(v.unwrap().as_slice()[i+100], 0);
1725-
}
1719+
let v = drop_vector.get().unwrap();
1720+
for i in range(0u, 50) {
1721+
assert_eq!(v.borrow().as_slice()[i], 0);
1722+
assert_eq!(v.borrow().as_slice()[i+100], 0);
1723+
}
17261724

1727-
for i in range(50u, 100) {
1728-
assert_eq!(v.unwrap().as_slice()[i], 1);
1729-
assert_eq!(v.unwrap().as_slice()[i+100], 1);
1730-
}
1731-
});
1725+
for i in range(50u, 100) {
1726+
assert_eq!(v.borrow().as_slice()[i], 1);
1727+
assert_eq!(v.borrow().as_slice()[i+100], 1);
1728+
}
17321729
}
17331730

1734-
local_data::get(drop_vector, |v| {
1735-
for i in range(0u, 200) {
1736-
assert_eq!(v.unwrap().as_slice()[i], 0);
1737-
}
1738-
});
1731+
let v = drop_vector.get().unwrap();
1732+
for i in range(0u, 200) {
1733+
assert_eq!(v.borrow().as_slice()[i], 0);
1734+
}
17391735
}
17401736

17411737
#[test]

branches/try/src/libgraphviz/lib.rs

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ type Nd = int;
5454
type Ed = (int,int);
5555
struct Edges(Vec<Ed>);
5656
57-
pub fn main() {
58-
use std::io::File;
57+
pub fn render_to<W:Writer>(output: &mut W) {
5958
let edges = Edges(vec!((0,1), (0,2), (1,3), (2,3), (3,4), (4,4)));
60-
let mut f = File::create(&Path::new("example1.dot"));
61-
dot::render(&edges, &mut f).unwrap()
59+
dot::render(&edges, output).unwrap()
6260
}
6361
6462
impl<'a> dot::Labeller<'a, Nd, Ed> for Edges {
@@ -91,6 +89,17 @@ impl<'a> dot::GraphWalk<'a, Nd, Ed> for Edges {
9189
9290
fn target(&self, e: &Ed) -> Nd { let &(_,t) = e; t }
9391
}
92+
93+
# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
94+
```
95+
96+
```no_run
97+
# pub fn render_to<W:Writer>(output: &mut W) { unimplemented!() }
98+
pub fn main() {
99+
use std::io::File;
100+
let mut f = File::create(&Path::new("example1.dot"));
101+
render_to(&mut f)
102+
}
94103
```
95104
96105
Output from first example (in `example1.dot`):
@@ -140,19 +149,17 @@ entity `&sube`).
140149
```rust
141150
use dot = graphviz;
142151
use std::str;
143-
use std::io::File;
144152
145153
type Nd = uint;
146154
type Ed<'a> = &'a (uint, uint);
147155
struct Graph { nodes: Vec<&'static str>, edges: Vec<(uint,uint)> }
148156
149-
pub fn main() {
157+
pub fn render_to<W:Writer>(output: &mut W) {
150158
let nodes = vec!("{x,y}","{x}","{y}","{}");
151159
let edges = vec!((0,1), (0,2), (1,3), (2,3));
152160
let graph = Graph { nodes: nodes, edges: edges };
153161
154-
let mut f = File::create(&Path::new("example2.dot"));
155-
dot::render(&graph, &mut f).unwrap()
162+
dot::render(&graph, output).unwrap()
156163
}
157164
158165
impl<'a> dot::Labeller<'a, Nd, Ed<'a>> for Graph {
@@ -174,6 +181,17 @@ impl<'a> dot::GraphWalk<'a, Nd, Ed<'a>> for Graph {
174181
fn source(&self, e: &Ed) -> Nd { let & &(s,_) = e; s }
175182
fn target(&self, e: &Ed) -> Nd { let & &(_,t) = e; t }
176183
}
184+
185+
# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
186+
```
187+
188+
```no_run
189+
# pub fn render_to<W:Writer>(output: &mut W) { unimplemented!() }
190+
pub fn main() {
191+
use std::io::File;
192+
let mut f = File::create(&Path::new("example2.dot"));
193+
render_to(&mut f)
194+
}
177195
```
178196
179197
The third example is similar to the second, except now each node and
@@ -187,19 +205,17 @@ Hasse-diagram for the subsets of the set `{x, y}`.
187205
```rust
188206
use dot = graphviz;
189207
use std::str;
190-
use std::io::File;
191208
192209
type Nd<'a> = (uint, &'a str);
193210
type Ed<'a> = (Nd<'a>, Nd<'a>);
194211
struct Graph { nodes: Vec<&'static str>, edges: Vec<(uint,uint)> }
195212
196-
pub fn main() {
213+
pub fn render_to<W:Writer>(output: &mut W) {
197214
let nodes = vec!("{x,y}","{x}","{y}","{}");
198215
let edges = vec!((0,1), (0,2), (1,3), (2,3));
199216
let graph = Graph { nodes: nodes, edges: edges };
200217
201-
let mut f = File::create(&Path::new("example3.dot"));
202-
dot::render(&graph, &mut f).unwrap()
218+
dot::render(&graph, output).unwrap()
203219
}
204220
205221
impl<'a> dot::Labeller<'a, Nd<'a>, Ed<'a>> for Graph {
@@ -229,6 +245,17 @@ impl<'a> dot::GraphWalk<'a, Nd<'a>, Ed<'a>> for Graph {
229245
fn source(&self, e: &Ed<'a>) -> Nd<'a> { let &(s,_) = e; s }
230246
fn target(&self, e: &Ed<'a>) -> Nd<'a> { let &(_,t) = e; t }
231247
}
248+
249+
# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
250+
```
251+
252+
```no_run
253+
# pub fn render_to<W:Writer>(output: &mut W) { unimplemented!() }
254+
pub fn main() {
255+
use std::io::File;
256+
let mut f = File::create(&Path::new("example3.dot"));
257+
render_to(&mut f)
258+
}
232259
```
233260
234261
# References

branches/try/src/liblog/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ use std::cast;
122122
use std::fmt;
123123
use std::io::LineBufferedWriter;
124124
use std::io;
125-
use std::local_data;
126125
use std::os;
127126
use std::rt;
128127
use std::slice;
@@ -228,7 +227,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: &fmt::Arguments) {
228227
// Completely remove the local logger from TLS in case anyone attempts to
229228
// frob the slot while we're doing the logging. This will destroy any logger
230229
// set during logging.
231-
let mut logger = local_data::pop(local_logger).unwrap_or_else(|| {
230+
let mut logger = local_logger.replace(None).unwrap_or_else(|| {
232231
box DefaultLogger { handle: io::stderr() } as Box<Logger:Send>
233232
});
234233
logger.log(&LogRecord {
@@ -238,7 +237,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: &fmt::Arguments) {
238237
module_path: loc.module_path,
239238
line: loc.line,
240239
});
241-
local_data::set(local_logger, logger);
240+
local_logger.replace(Some(logger));
242241
}
243242

244243
/// Getter for the global log level. This is a function so that it can be called
@@ -250,9 +249,7 @@ pub fn log_level() -> u32 { unsafe { LOG_LEVEL } }
250249
/// Replaces the task-local logger with the specified logger, returning the old
251250
/// logger.
252251
pub fn set_logger(logger: Box<Logger:Send>) -> Option<Box<Logger:Send>> {
253-
let prev = local_data::pop(local_logger);
254-
local_data::set(local_logger, logger);
255-
return prev;
252+
local_logger.replace(Some(logger))
256253
}
257254

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

branches/try/src/libnative/io/c_unix.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ pub static FIOCLEX: libc::c_ulong = 0x20006601;
2727
#[cfg(target_os = "android")]
2828
pub static FIOCLEX: libc::c_ulong = 0x5451;
2929

30+
#[cfg(target_os = "macos")]
31+
#[cfg(target_os = "freebsd")]
32+
pub static MSG_DONTWAIT: libc::c_int = 0x80;
33+
#[cfg(target_os = "linux")]
34+
#[cfg(target_os = "android")]
35+
pub static MSG_DONTWAIT: libc::c_int = 0x40;
36+
3037
extern {
3138
pub fn gettimeofday(timeval: *mut libc::timeval,
3239
tzp: *libc::c_void) -> libc::c_int;

branches/try/src/libnative/io/c_win32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub static WSADESCRIPTION_LEN: uint = 256;
1818
pub static WSASYS_STATUS_LEN: uint = 128;
1919
pub static FIONBIO: libc::c_long = 0x8004667e;
2020
static FD_SETSIZE: uint = 64;
21+
pub static MSG_DONTWAIT: libc::c_int = 0;
2122

2223
pub struct WSADATA {
2324
pub wVersion: libc::WORD,

branches/try/src/libnative/io/file_unix.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ impl rtio::RtioPipe for FileDesc {
189189
fn close_write(&mut self) -> Result<(), IoError> {
190190
Err(io::standard_error(io::InvalidInput))
191191
}
192+
fn set_timeout(&mut self, _t: Option<u64>) {}
193+
fn set_read_timeout(&mut self, _t: Option<u64>) {}
194+
fn set_write_timeout(&mut self, _t: Option<u64>) {}
192195
}
193196

194197
impl rtio::RtioTTY for FileDesc {

branches/try/src/libnative/io/file_win32.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ impl rtio::RtioPipe for FileDesc {
221221
fn close_write(&mut self) -> IoResult<()> {
222222
Err(io::standard_error(io::InvalidInput))
223223
}
224+
fn set_timeout(&mut self, _t: Option<u64>) {}
225+
fn set_read_timeout(&mut self, _t: Option<u64>) {}
226+
fn set_write_timeout(&mut self, _t: Option<u64>) {}
224227
}
225228

226229
impl rtio::RtioTTY for FileDesc {

0 commit comments

Comments
 (0)