Skip to content

Commit 78150ff

Browse files
committed
---
yaml --- r: 225127 b: refs/heads/stable c: cec980a h: refs/heads/master i: 225125: cdb8916 225123: 4bbe012 225119: fbc9a67 v: v3
1 parent 3ae216f commit 78150ff

File tree

10 files changed

+144
-33
lines changed

10 files changed

+144
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 54dbd0baadae58c811b0c85de4223cbf81f24725
32+
refs/heads/stable: cec980a1a706fd6afc27dd54c1eed7c51800d753
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/src/librbml/lib.rs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -397,20 +397,43 @@ pub mod reader {
397397
}
398398
}
399399

400-
pub fn docs<F>(d: Doc, mut it: F) -> bool where
401-
F: FnMut(usize, Doc) -> bool,
402-
{
403-
let mut pos = d.start;
404-
while pos < d.end {
405-
let elt_tag = try_or!(tag_at(d.data, pos), false);
406-
let elt_size = try_or!(tag_len_at(d.data, elt_tag), false);
407-
pos = elt_size.next + elt_size.val;
408-
let doc = Doc { data: d.data, start: elt_size.next, end: pos };
409-
if !it(elt_tag.val, doc) {
410-
return false;
400+
pub fn docs<'a>(d: Doc<'a>) -> DocsIterator<'a> {
401+
DocsIterator {
402+
d: d
403+
}
404+
}
405+
406+
pub struct DocsIterator<'a> {
407+
d: Doc<'a>,
408+
}
409+
410+
impl<'a> Iterator for DocsIterator<'a> {
411+
type Item = (usize, Doc<'a>);
412+
413+
fn next(&mut self) -> Option<(usize, Doc<'a>)> {
414+
if self.d.start >= self.d.end {
415+
return None;
411416
}
417+
418+
let elt_tag = try_or!(tag_at(self.d.data, self.d.start), {
419+
self.d.start = self.d.end;
420+
None
421+
});
422+
let elt_size = try_or!(tag_len_at(self.d.data, elt_tag), {
423+
self.d.start = self.d.end;
424+
None
425+
});
426+
427+
let end = elt_size.next + elt_size.val;
428+
let doc = Doc {
429+
data: self.d.data,
430+
start: elt_size.next,
431+
end: end,
432+
};
433+
434+
self.d.start = end;
435+
return Some((elt_tag.val, doc));
412436
}
413-
return true;
414437
}
415438

416439
pub fn tagged_docs<F>(d: Doc, tg: usize, mut it: F) -> bool where

branches/stable/src/librustc/metadata/decoder.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,25 +275,18 @@ fn enum_variant_ids(item: rbml::Doc, cdata: Cmd) -> Vec<ast::DefId> {
275275

276276
fn item_path(item_doc: rbml::Doc) -> Vec<ast_map::PathElem> {
277277
let path_doc = reader::get_doc(item_doc, tag_path);
278-
279-
let len_doc = reader::get_doc(path_doc, tag_path_len);
280-
let len = reader::doc_as_u32(len_doc) as usize;
281-
282-
let mut result = Vec::with_capacity(len);
283-
reader::docs(path_doc, |tag, elt_doc| {
278+
reader::docs(path_doc).filter_map(|(tag, elt_doc)| {
284279
if tag == tag_path_elem_mod {
285280
let s = elt_doc.as_str_slice();
286-
result.push(ast_map::PathMod(token::intern(s)));
281+
Some(ast_map::PathMod(token::intern(s)))
287282
} else if tag == tag_path_elem_name {
288283
let s = elt_doc.as_str_slice();
289-
result.push(ast_map::PathName(token::intern(s)));
284+
Some(ast_map::PathName(token::intern(s)))
290285
} else {
291286
// ignore tag_path_len element
287+
None
292288
}
293-
true
294-
});
295-
296-
result
289+
}).collect()
297290
}
298291

299292
fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name {

branches/stable/src/librustc/middle/astencode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
17261726
fn decode_side_tables(dcx: &DecodeContext,
17271727
ast_doc: rbml::Doc) {
17281728
let tbl_doc = ast_doc.get(c::tag_table as usize);
1729-
reader::docs(tbl_doc, |tag, entry_doc| {
1729+
for (tag, entry_doc) in reader::docs(tbl_doc) {
17301730
let mut entry_dsr = reader::Decoder::new(entry_doc);
17311731
let id0: ast::NodeId = Decodable::decode(&mut entry_dsr).unwrap();
17321732
let id = dcx.tr_id(id0);
@@ -1840,8 +1840,7 @@ fn decode_side_tables(dcx: &DecodeContext,
18401840
}
18411841

18421842
debug!(">< Side table doc loaded");
1843-
true
1844-
});
1843+
}
18451844
}
18461845

18471846
// ______________________________________________________________________

branches/stable/src/librustc_trans/trans/expr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,9 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
730730
let info = Load(bcx, get_len(bcx, base_datum.val));
731731
Store(bcx, info, get_len(bcx, scratch.val));
732732

733-
DatumBlock::new(bcx, scratch.to_expr_datum())
734-
733+
// Always generate an lvalue datum, because this pointer doesn't own
734+
// the data and cleanup is scheduled elsewhere.
735+
DatumBlock::new(bcx, Datum::new(scratch.val, scratch.ty, LvalueExpr))
735736
}
736737
})
737738

branches/stable/src/libstd/io/buffered.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ use iter;
2727
/// For example, every call to `read` on `TcpStream` results in a system call.
2828
/// A `BufReader` performs large, infrequent reads on the underlying `Read`
2929
/// and maintains an in-memory buffer of the results.
30+
///
31+
/// # Examples
32+
///
33+
/// ```no_run
34+
/// use std::io::prelude::*;
35+
/// use std::io::BufReader;
36+
/// use std::fs::File;
37+
///
38+
/// # fn foo() -> std::io::Result<()> {
39+
/// let mut f = try!(File::open("log.txt"));
40+
/// let mut reader = BufReader::new(f);
41+
///
42+
/// let mut line = String::new();
43+
/// let len = try!(reader.read_line(&mut line));
44+
/// println!("First line is {} bytes long", len);
45+
/// # Ok(())
46+
/// # }
47+
/// ```
3048
#[stable(feature = "rust1", since = "1.0.0")]
3149
pub struct BufReader<R> {
3250
inner: R,

branches/stable/src/libstd/io/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,14 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
506506
}
507507
}
508508

509-
/// A Buffer is a type of reader which has some form of internal buffering to
509+
/// A `BufRead` is a type of reader which has some form of internal buffering to
510510
/// allow certain kinds of reading operations to be more optimized than others.
511511
///
512512
/// This type extends the `Read` trait with a few methods that are not
513513
/// possible to reasonably implement with purely a read interface.
514+
///
515+
/// You can use the [`BufReader` wrapper type](struct.BufReader.html) to turn any
516+
/// reader into a buffered reader.
514517
#[stable(feature = "rust1", since = "1.0.0")]
515518
pub trait BufRead: Read {
516519
/// Fills the internal buffer of this object, returning the buffer contents.

branches/stable/src/test/run-pass-fulldeps/issue-15149.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ fn test() {
6464
str::from_utf8(&child_output.stdout).unwrap(),
6565
str::from_utf8(&child_output.stderr).unwrap()));
6666

67-
fs::remove_dir_all(&child_dir).unwrap();
68-
67+
let res = fs::remove_dir_all(&child_dir);
68+
if res.is_err() {
69+
// On Windows deleting just executed mytest.exe can fail because it's still locked
70+
std::thread::sleep_ms(1000);
71+
fs::remove_dir_all(&child_dir).unwrap();
72+
}
6973
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2015 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+
use std::rc::Rc;
12+
13+
struct Foo<'r>(&'r mut i32);
14+
15+
impl<'r> Drop for Foo<'r> {
16+
fn drop(&mut self) {
17+
*self.0 += 1;
18+
}
19+
}
20+
21+
fn main() {
22+
let mut drops = 0;
23+
24+
{
25+
let _: Rc<Send> = Rc::new(Foo(&mut drops));
26+
}
27+
28+
assert_eq!(1, drops);
29+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2015 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+
struct Foo<'r>(&'r mut i32);
12+
13+
impl<'r> Drop for Foo<'r> {
14+
fn drop(&mut self) {
15+
*self.0 += 1;
16+
}
17+
}
18+
19+
trait Trait {}
20+
impl<'r> Trait for Foo<'r> {}
21+
22+
struct Holder<T: ?Sized>(T);
23+
24+
fn main() {
25+
let mut drops = 0;
26+
27+
{
28+
let y = &Holder([Foo(&mut drops)]) as &Holder<[Foo]>;
29+
// this used to cause an extra drop of the Foo instance
30+
let x = &y.0;
31+
}
32+
assert_eq!(1, drops);
33+
34+
drops = 0;
35+
{
36+
let y = &Holder(Foo(&mut drops)) as &Holder<Trait>;
37+
// this used to cause an extra drop of the Foo instance
38+
let x = &y.0;
39+
}
40+
assert_eq!(1, drops);
41+
}

0 commit comments

Comments
 (0)