Skip to content

Commit e932d22

Browse files
committed
---
yaml --- r: 207562 b: refs/heads/tmp c: 54dbd0b h: refs/heads/master v: v3
1 parent 7a94e7d commit e932d22

File tree

12 files changed

+76
-188
lines changed

12 files changed

+76
-188
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: cd7d89af9169885642d43597302af69f842bbd78
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: bacd8bc4b7712ad40a0fca6d14addd296597015f
35+
refs/heads/tmp: 54dbd0baadae58c811b0c85de4223cbf81f24725
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 704c2ee730d2e948d11a2edd77e3f35de8329a6e
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/librbml/lib.rs

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

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;
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;
416411
}
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));
436412
}
413+
return true;
437414
}
438415

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

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,25 @@ 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-
reader::docs(path_doc).filter_map(|(tag, elt_doc)| {
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| {
279284
if tag == tag_path_elem_mod {
280285
let s = elt_doc.as_str_slice();
281-
Some(ast_map::PathMod(token::intern(s)))
286+
result.push(ast_map::PathMod(token::intern(s)));
282287
} else if tag == tag_path_elem_name {
283288
let s = elt_doc.as_str_slice();
284-
Some(ast_map::PathName(token::intern(s)))
289+
result.push(ast_map::PathName(token::intern(s)));
285290
} else {
286291
// ignore tag_path_len element
287-
None
288292
}
289-
}).collect()
293+
true
294+
});
295+
296+
result
290297
}
291298

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

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

Lines changed: 3 additions & 2 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-
for (tag, entry_doc) in reader::docs(tbl_doc) {
1729+
reader::docs(tbl_doc, |tag, entry_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,7 +1840,8 @@ fn decode_side_tables(dcx: &DecodeContext,
18401840
}
18411841

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

18461847
// ______________________________________________________________________

branches/tmp/src/librustc_trans/trans/datum.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,6 @@
7474
//! `&foo()` or `match foo() { ref x => ... }`, where the user is
7575
//! implicitly requesting a temporary.
7676
//!
77-
//! Somewhat surprisingly, not all lvalue expressions yield lvalue datums
78-
//! when trans'd. Ultimately the reason for this is to micro-optimize
79-
//! the resulting LLVM. For example, consider the following code:
80-
//!
81-
//! fn foo() -> Box<int> { ... }
82-
//! let x = *foo();
83-
//!
84-
//! The expression `*foo()` is an lvalue, but if you invoke `expr::trans`,
85-
//! it will return an rvalue datum. See `deref_once` in expr.rs for
86-
//! more details.
87-
//!
8877
//! ### Rvalues in detail
8978
//!
9079
//! Rvalues datums are values with no cleanup scheduled. One must be

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

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,8 @@ 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-
// 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))
733+
DatumBlock::new(bcx, scratch.to_expr_datum())
734+
736735
}
737736
})
738737

@@ -2248,16 +2247,20 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
22482247

22492248
let r = match datum.ty.sty {
22502249
ty::ty_uniq(content_ty) => {
2250+
// Make sure we have an lvalue datum here to get the
2251+
// proper cleanups scheduled
2252+
let datum = unpack_datum!(
2253+
bcx, datum.to_lvalue_datum(bcx, "deref", expr.id));
2254+
22512255
if type_is_sized(bcx.tcx(), content_ty) {
2252-
deref_owned_pointer(bcx, expr, datum, content_ty)
2256+
let ptr = load_ty(bcx, datum.val, datum.ty);
2257+
DatumBlock::new(bcx, Datum::new(ptr, content_ty, LvalueExpr))
22532258
} else {
22542259
// A fat pointer and a DST lvalue have the same representation
22552260
// just different types. Since there is no temporary for `*e`
22562261
// here (because it is unsized), we cannot emulate the sized
22572262
// object code path for running drop glue and free. Instead,
22582263
// we schedule cleanup for `e`, turning it into an lvalue.
2259-
let datum = unpack_datum!(
2260-
bcx, datum.to_lvalue_datum(bcx, "deref", expr.id));
22612264

22622265
let datum = Datum::new(datum.val, content_ty, LvalueExpr);
22632266
DatumBlock::new(bcx, datum)
@@ -2294,53 +2297,6 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
22942297
expr.id, method_call, r.datum.to_string(ccx));
22952298

22962299
return r;
2297-
2298-
/// We microoptimize derefs of owned pointers a bit here. Basically, the idea is to make the
2299-
/// deref of an rvalue result in an rvalue. This helps to avoid intermediate stack slots in the
2300-
/// resulting LLVM. The idea here is that, if the `Box<T>` pointer is an rvalue, then we can
2301-
/// schedule a *shallow* free of the `Box<T>` pointer, and then return a ByRef rvalue into the
2302-
/// pointer. Because the free is shallow, it is legit to return an rvalue, because we know that
2303-
/// the contents are not yet scheduled to be freed. The language rules ensure that the contents
2304-
/// will be used (or moved) before the free occurs.
2305-
fn deref_owned_pointer<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
2306-
expr: &ast::Expr,
2307-
datum: Datum<'tcx, Expr>,
2308-
content_ty: Ty<'tcx>)
2309-
-> DatumBlock<'blk, 'tcx, Expr> {
2310-
match datum.kind {
2311-
RvalueExpr(Rvalue { mode: ByRef }) => {
2312-
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
2313-
let ptr = Load(bcx, datum.val);
2314-
if !type_is_zero_size(bcx.ccx(), content_ty) {
2315-
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange, content_ty);
2316-
}
2317-
}
2318-
RvalueExpr(Rvalue { mode: ByValue }) => {
2319-
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
2320-
if !type_is_zero_size(bcx.ccx(), content_ty) {
2321-
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange,
2322-
content_ty);
2323-
}
2324-
}
2325-
LvalueExpr => { }
2326-
}
2327-
2328-
// If we had an rvalue in, we produce an rvalue out.
2329-
let (llptr, kind) = match datum.kind {
2330-
LvalueExpr => {
2331-
(Load(bcx, datum.val), LvalueExpr)
2332-
}
2333-
RvalueExpr(Rvalue { mode: ByRef }) => {
2334-
(Load(bcx, datum.val), RvalueExpr(Rvalue::new(ByRef)))
2335-
}
2336-
RvalueExpr(Rvalue { mode: ByValue }) => {
2337-
(datum.val, RvalueExpr(Rvalue::new(ByRef)))
2338-
}
2339-
};
2340-
2341-
let datum = Datum { ty: content_ty, val: llptr, kind: kind };
2342-
DatumBlock { bcx: bcx, datum: datum }
2343-
}
23442300
}
23452301

23462302
#[derive(Debug)]

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,6 @@ 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-
/// ```
4830
#[stable(feature = "rust1", since = "1.0.0")]
4931
pub struct BufReader<R> {
5032
inner: R,

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

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

509-
/// A `BufRead` is a type of reader which has some form of internal buffering to
509+
/// A Buffer 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.
517514
#[stable(feature = "rust1", since = "1.0.0")]
518515
pub trait BufRead: Read {
519516
/// Fills the internal buffer of this object, returning the buffer contents.

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

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

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-
}
67+
fs::remove_dir_all(&child_dir).unwrap();
68+
7369
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
// This used to generate invalid IR in that even if we took the
12+
// `false` branch we'd still try to free the Box from the other
13+
// arm. This was due to treating `*Box::new(9)` as an rvalue datum
14+
// instead of as an lvalue.
15+
16+
fn test(foo: bool) -> u8 {
17+
match foo {
18+
true => *Box::new(9),
19+
false => 0
20+
}
21+
}
22+
23+
fn main() {
24+
assert_eq!(9, test(true));
25+
}

branches/tmp/src/test/run-pass/issue-25515.rs renamed to branches/tmp/src/test/run-pass/issue-25497.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::rc::Rc;
11+
#[derive(Clone, Debug, PartialEq)]
12+
enum Expression {
13+
Dummy,
14+
Add(Box<Expression>),
15+
}
1216

13-
struct Foo<'r>(&'r mut i32);
17+
use Expression::*;
1418

15-
impl<'r> Drop for Foo<'r> {
16-
fn drop(&mut self) {
17-
*self.0 += 1;
19+
fn simplify(exp: Expression) -> Expression {
20+
match exp {
21+
Add(n) => *n.clone(),
22+
_ => Dummy
1823
}
1924
}
2025

2126
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);
27+
assert_eq!(simplify(Add(Box::new(Dummy))), Dummy);
2928
}

branches/tmp/src/test/run-pass/issue-25549-multiple-drop.rs

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)