Skip to content

Commit fcf7c0d

Browse files
committed
---
yaml --- r: 79387 b: refs/heads/snap-stage3 c: da042ce h: refs/heads/master i: 79385: 0a464d8 79383: fc16903 v: v3
1 parent b4b6485 commit fcf7c0d

File tree

16 files changed

+399
-218
lines changed

16 files changed

+399
-218
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: 124eb2119c78651cfaaa7a046a101fa2e20f83ca
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 41e7924670aefe4c39dd4a060452eb623854fde9
4+
refs/heads/snap-stage3: da042ce46a022d699dae792164dd180f6dd61894
55
refs/heads/try: ac820906c0e53eab79a98ee64f7231f57c3887b4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7676
rt/rust_upcall.cpp \
7777
rt/rust_uv.cpp \
7878
rt/rust_crate_map.cpp \
79-
rt/rust_log.cpp \
8079
rt/isaac/randport.cpp \
8180
rt/miniz.cpp \
8281
rt/memory_region.cpp \

branches/snap-stage3/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor {
9595
fn visit_local(&mut self, l:@Local, e:@mut GatherLoanCtxt) {
9696
gather_loans_in_local(self, l, e);
9797
}
98-
99-
// #7740: Do not visit items here, not even fn items nor methods
100-
// of impl items; the outer loop in borrowck/mod will visit them
101-
// for us in turn. Thus override visit_item's walk with a no-op.
102-
fn visit_item(&mut self, _:@ast::item, _:@mut GatherLoanCtxt) { }
10398
}
10499

105100
pub fn gather_loans(bccx: @BorrowckCtxt,
@@ -140,8 +135,10 @@ fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
140135
id: ast::NodeId,
141136
this: @mut GatherLoanCtxt) {
142137
match fk {
138+
// Do not visit items here, the outer loop in borrowck/mod
139+
// will visit them for us in turn.
143140
&visit::fk_item_fn(*) | &visit::fk_method(*) => {
144-
fail!("cannot occur, due to visit_item override");
141+
return;
145142
}
146143

147144
// Visit closures as part of the containing item.

branches/snap-stage3/src/librustpkg/conditions.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@ pub use std::path::Path;
1414
pub use package_id::PkgId;
1515

1616
condition! {
17-
bad_path: (Path, ~str) -> Path;
17+
pub bad_path: (Path, ~str) -> Path;
1818
}
1919

2020
condition! {
21-
nonexistent_package: (PkgId, ~str) -> Path;
21+
pub nonexistent_package: (PkgId, ~str) -> Path;
2222
}
2323

2424
condition! {
25-
copy_failed: (Path, Path) -> ();
25+
pub copy_failed: (Path, Path) -> ();
2626
}
2727

2828
condition! {
29-
missing_pkg_files: (PkgId) -> ();
29+
pub missing_pkg_files: (PkgId) -> ();
3030
}
3131

3232
condition! {
33-
bad_pkg_id: (Path, ~str) -> PkgId;
33+
pub bad_pkg_id: (Path, ~str) -> PkgId;
3434
}
3535

3636
condition! {
37-
no_rust_path: (~str) -> Path;
37+
pub no_rust_path: (~str) -> Path;
3838
}
3939

4040
condition! {
41-
not_a_workspace: (~str) -> Path;
41+
pub not_a_workspace: (~str) -> Path;
4242
}
4343

4444
condition! {
45-
failed_to_create_temp_dir: (~str) -> Path;
45+
pub failed_to_create_temp_dir: (~str) -> Path;
4646
}

branches/snap-stage3/src/librustpkg/package_source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct PkgSrc {
3434
}
3535

3636
condition! {
37+
// #6009: should this be pub or not, when #8215 is fixed?
3738
build_err: (~str) -> ();
3839
}
3940

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ pub enum NullByteResolution {
2828
}
2929

3030
condition! {
31-
// this should be &[u8] but there's a lifetime issue
31+
// This should be &[u8] but there's a lifetime issue (#5370).
3232
// NOTE: this super::NullByteResolution should be NullByteResolution
33-
// Change this next time the snapshot it updated.
34-
null_byte: (~[u8]) -> super::NullByteResolution;
33+
// Change this next time the snapshot is updated.
34+
pub null_byte: (~[u8]) -> super::NullByteResolution;
3535
}
3636

3737
/// The representation of a C String.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ mod test {
193193
// Issue #6009
194194
mod m {
195195
condition! {
196-
sadness: int -> int;
196+
// #6009, #8215: should this truly need a `pub` for access from n?
197+
pub sadness: int -> int;
197198
}
198199

199200
mod n {

branches/snap-stage3/src/libstd/rt/io/extensions.rs

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
use uint;
1717
use int;
18+
use iterator::Iterator;
1819
use vec;
19-
use rt::io::{Reader, Writer};
20+
use rt::io::{Reader, Writer, Decorator};
2021
use rt::io::{read_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
2122
use option::{Option, Some, None};
2223
use unstable::finally::Finally;
@@ -62,6 +63,16 @@ pub trait ReaderUtil {
6263
/// Raises the same conditions as the `read` method.
6364
fn read_to_end(&mut self) -> ~[u8];
6465

66+
/// Create an iterator that reads a single byte on
67+
/// each iteration, until EOF.
68+
///
69+
/// # Failure
70+
///
71+
/// Raises the same conditions as the `read` method, for
72+
/// each call to its `.next()` method.
73+
/// Ends the iteration if the condition is handled.
74+
fn bytes(self) -> ByteIterator<Self>;
75+
6576
}
6677

6778
pub trait ReaderByteConversions {
@@ -337,6 +348,41 @@ impl<T: Reader> ReaderUtil for T {
337348
}
338349
return buf;
339350
}
351+
352+
fn bytes(self) -> ByteIterator<T> {
353+
ByteIterator{reader: self}
354+
}
355+
}
356+
357+
/// An iterator that reads a single byte on each iteration,
358+
/// until `.read_byte()` returns `None`.
359+
///
360+
/// # Notes about the Iteration Protocol
361+
///
362+
/// The `ByteIterator` may yield `None` and thus terminate
363+
/// an iteration, but continue to yield elements if iteration
364+
/// is attempted again.
365+
///
366+
/// # Failure
367+
///
368+
/// Raises the same conditions as the `read` method, for
369+
/// each call to its `.next()` method.
370+
/// Yields `None` if the condition is handled.
371+
pub struct ByteIterator<T> {
372+
priv reader: T,
373+
}
374+
375+
impl<R> Decorator<R> for ByteIterator<R> {
376+
fn inner(self) -> R { self.reader }
377+
fn inner_ref<'a>(&'a self) -> &'a R { &self.reader }
378+
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut R { &mut self.reader }
379+
}
380+
381+
impl<'self, R: Reader> Iterator<u8> for ByteIterator<R> {
382+
#[inline]
383+
fn next(&mut self) -> Option<u8> {
384+
self.reader.read_byte()
385+
}
340386
}
341387

342388
impl<T: Reader> ReaderByteConversions for T {
@@ -646,6 +692,48 @@ mod test {
646692
}
647693
}
648694

695+
#[test]
696+
fn bytes_0_bytes() {
697+
let mut reader = MockReader::new();
698+
let count = Cell::new(0);
699+
reader.read = |buf| {
700+
do count.with_mut_ref |count| {
701+
if *count == 0 {
702+
*count = 1;
703+
Some(0)
704+
} else {
705+
buf[0] = 10;
706+
Some(1)
707+
}
708+
}
709+
};
710+
let byte = reader.bytes().next();
711+
assert!(byte == Some(10));
712+
}
713+
714+
#[test]
715+
fn bytes_eof() {
716+
let mut reader = MockReader::new();
717+
reader.read = |_| None;
718+
let byte = reader.bytes().next();
719+
assert!(byte == None);
720+
}
721+
722+
#[test]
723+
fn bytes_error() {
724+
let mut reader = MockReader::new();
725+
reader.read = |_| {
726+
read_error::cond.raise(placeholder_error());
727+
None
728+
};
729+
let mut it = reader.bytes();
730+
do read_error::cond.trap(|_| ()).inside {
731+
let byte = it.next();
732+
assert!(byte == None);
733+
}
734+
}
735+
736+
649737
#[test]
650738
fn read_bytes() {
651739
let mut reader = MemReader::new(~[10, 11, 12, 13]);

branches/snap-stage3/src/libstd/rt/io/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,19 +384,17 @@ impl ToStr for IoErrorKind {
384384
// XXX: Can't put doc comments on macros
385385
// Raised by `I/O` operations on error.
386386
condition! {
387-
// FIXME (#6009): uncomment `pub` after expansion support lands.
388387
// NOTE: this super::IoError should be IoError
389-
// Change this next time the snapshot it updated.
390-
/*pub*/ io_error: super::IoError -> ();
388+
// Change this next time the snapshot is updated.
389+
pub io_error: super::IoError -> ();
391390
}
392391

393392
// XXX: Can't put doc comments on macros
394393
// Raised by `read` on error
395394
condition! {
396-
// FIXME (#6009): uncomment `pub` after expansion support lands.
397395
// NOTE: this super::IoError should be IoError
398396
// Change this next time the snapshot it updated.
399-
/*pub*/ read_error: super::IoError -> ();
397+
pub read_error: super::IoError -> ();
400398
}
401399

402400
pub trait Reader {
@@ -453,6 +451,8 @@ pub trait Writer {
453451

454452
pub trait Stream: Reader + Writer { }
455453

454+
impl<T: Reader + Writer> Stream for T;
455+
456456
pub enum SeekStyle {
457457
/// Seek from the beginning of the stream
458458
SeekSet,

0 commit comments

Comments
 (0)