Skip to content

Commit a6af7b6

Browse files
committed
---
yaml --- r: 154335 b: refs/heads/try2 c: 385c39a h: refs/heads/master i: 154333: d8893c0 154331: 395e3c9 154327: 211c0e9 154319: e4a602c 154303: b8825cf v: v3
1 parent d465705 commit a6af7b6

Some content is hidden

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

60 files changed

+1600
-187
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: fce442e75c5b3df8eea401fae1200314f0d47c40
8+
refs/heads/try2: 385c39a77b238df9371ee8bccc768b8d39258edd
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/runtest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use std::os;
3030
use std::str;
3131
use std::string::String;
3232
use std::task;
33+
use std::time::Duration;
3334
use test::MetricMap;
3435

3536
pub fn run(config: Config, testfile: String) {
@@ -400,7 +401,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
400401
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
401402
loop {
402403
//waiting 1 second for gdbserver start
403-
timer::sleep(1000);
404+
timer::sleep(Duration::milliseconds(1000));
404405
let result = task::try(proc() {
405406
tcp::TcpStream::connect("127.0.0.1", 5039).unwrap();
406407
});

branches/try2/src/doc/guide-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ itself, yet again implying that they are not defined in the standard library.
128128
The full complement of runtime features is defined by the [`Runtime`
129129
trait](std/rt/trait.Runtime.html) and the [`Task`
130130
struct](std/rt/task/struct.Task.html). A `Task` is constant among all runtime
131-
implementations, but each runtime implements has its own implementation of the
131+
implementations, but each runtime has its own implementation of the
132132
`Runtime` trait.
133133

134134
The local `Task` stores the runtime value inside of itself, and then ownership

branches/try2/src/doc/guide-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ per-iteration speed of.
198198

199199
For benchmarks relating to processing/generating data, one can set the
200200
`bytes` field to the number of bytes consumed/produced in each
201-
iteration; this will used to show the throughput of the benchmark.
201+
iteration; this will be used to show the throughput of the benchmark.
202202
This must be the amount used in each iteration, *not* the total
203203
amount.
204204

branches/try2/src/doc/guide-unsafe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ explicitly with, respectively, `value as *const T` and `value as *mut T`).
137137

138138
Going the opposite direction, from `*const` to a reference `&`, is not
139139
safe. A `&T` is always valid, and so, at a minimum, the raw pointer
140-
`*const T` has to be a valid to a valid instance of type `T`. Furthermore,
140+
`*const T` has to point to a valid instance of type `T`. Furthermore,
141141
the resulting pointer must satisfy the aliasing and mutability laws of
142142
references. The compiler assumes these properties are true for any
143143
references, no matter how they are created, and so any conversion from

branches/try2/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ This is not the same as this, which won't compile:
666666
```{ignore}
667667
let x = 5i;
668668
669-
let y: int = if x == 5 { 10i; } else { 15i; };
669+
let y: int = if x == 5i { 10i; } else { 15i; };
670670
```
671671

672672
Note the semicolons after the 10 and 15. Rust will give us the following error:

branches/try2/src/libgreen/sched.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ mod test {
10291029
use std::rt::task::TaskOpts;
10301030
use std::rt::task::Task;
10311031
use std::rt::local::Local;
1032+
use std::time::Duration;
10321033

10331034
use {TaskState, PoolConfig, SchedPool};
10341035
use basic;
@@ -1291,7 +1292,7 @@ mod test {
12911292
// doesn't exit before emptying the work queue
12921293
pool.spawn(TaskOpts::new(), proc() {
12931294
spawn(proc() {
1294-
timer::sleep(10);
1295+
timer::sleep(Duration::milliseconds(10));
12951296
});
12961297
});
12971298

branches/try2/src/librustc/driver/driver.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
360360
plugin::build::find_plugin_registrar(
361361
sess.diagnostic(), krate)));
362362

363-
let freevars = time(time_passes, "freevar finding", (), |_|
364-
freevars::annotate_freevars(&def_map, krate));
363+
let (freevars, capture_modes) =
364+
time(time_passes, "freevar finding", (), |_|
365+
freevars::annotate_freevars(&def_map, krate));
365366

366367
let region_map = time(time_passes, "region resolution", (), |_|
367368
middle::region::resolve_crate(&sess, krate));
@@ -372,8 +373,15 @@ pub fn phase_3_run_analysis_passes(sess: Session,
372373
let stability_index = time(time_passes, "stability index", (), |_|
373374
stability::Index::build(krate));
374375

375-
let ty_cx = ty::mk_ctxt(sess, def_map, named_region_map, ast_map,
376-
freevars, region_map, lang_items, stability_index);
376+
let ty_cx = ty::mk_ctxt(sess,
377+
def_map,
378+
named_region_map,
379+
ast_map,
380+
freevars,
381+
capture_modes,
382+
region_map,
383+
lang_items,
384+
stability_index);
377385

378386
// passes are timed inside typeck
379387
typeck::check_crate(&ty_cx, trait_map, krate);

branches/try2/src/librustc/metadata/common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
141141
tag_table_capture_map = 0x53,
142142
tag_table_unboxed_closure_type = 0x54,
143143
tag_table_upvar_borrow_map = 0x55,
144+
tag_table_capture_modes = 0x56,
144145
}
145146
static first_astencode_tag: uint = tag_ast as uint;
146-
static last_astencode_tag: uint = tag_table_upvar_borrow_map as uint;
147+
static last_astencode_tag: uint = tag_table_capture_modes as uint;
147148
impl astencode_tag {
148149
pub fn from_uint(value : uint) -> Option<astencode_tag> {
149150
let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use driver::session::Session;
1818
use metadata::decoder;
1919
use middle::def;
2020
use e = metadata::encoder;
21+
use middle::freevars::{CaptureMode, freevar_entry};
2122
use middle::freevars;
22-
use middle::freevars::freevar_entry;
2323
use middle::region;
2424
use metadata::tydecode;
2525
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter,
@@ -530,9 +530,14 @@ fn encode_freevar_entry(rbml_w: &mut Encoder, fv: &freevar_entry) {
530530
(*fv).encode(rbml_w).unwrap();
531531
}
532532

533+
fn encode_capture_mode(rbml_w: &mut Encoder, cm: CaptureMode) {
534+
cm.encode(rbml_w).unwrap();
535+
}
536+
533537
trait rbml_decoder_helper {
534538
fn read_freevar_entry(&mut self, xcx: &ExtendedDecodeContext)
535539
-> freevar_entry;
540+
fn read_capture_mode(&mut self) -> CaptureMode;
536541
}
537542

538543
impl<'a> rbml_decoder_helper for reader::Decoder<'a> {
@@ -541,6 +546,11 @@ impl<'a> rbml_decoder_helper for reader::Decoder<'a> {
541546
let fv: freevar_entry = Decodable::decode(self).unwrap();
542547
fv.tr(xcx)
543548
}
549+
550+
fn read_capture_mode(&mut self) -> CaptureMode {
551+
let cm: CaptureMode = Decodable::decode(self).unwrap();
552+
cm
553+
}
544554
}
545555

546556
impl tr for freevar_entry {
@@ -1096,6 +1106,15 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10961106
}
10971107
}
10981108

1109+
for &cm in tcx.capture_modes.borrow().find(&id).iter() {
1110+
rbml_w.tag(c::tag_table_capture_modes, |rbml_w| {
1111+
rbml_w.id(id);
1112+
rbml_w.tag(c::tag_table_val, |rbml_w| {
1113+
encode_capture_mode(rbml_w, *cm);
1114+
})
1115+
})
1116+
}
1117+
10991118
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
11001119
for &pty in tcx.tcache.borrow().find(&lid).iter() {
11011120
rbml_w.tag(c::tag_table_tcache, |rbml_w| {
@@ -1509,6 +1528,13 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
15091528
let ub: ty::UpvarBorrow = Decodable::decode(val_dsr).unwrap();
15101529
dcx.tcx.upvar_borrow_map.borrow_mut().insert(upvar_id, ub.tr(xcx));
15111530
}
1531+
c::tag_table_capture_modes => {
1532+
let capture_mode = val_dsr.read_capture_mode();
1533+
dcx.tcx
1534+
.capture_modes
1535+
.borrow_mut()
1536+
.insert(id, capture_mode);
1537+
}
15121538
c::tag_table_tcache => {
15131539
let pty = val_dsr.read_polytype(xcx);
15141540
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn closure_to_block(closure_id: ast::NodeId,
291291
match tcx.map.get(closure_id) {
292292
ast_map::NodeExpr(expr) => match expr.node {
293293
ast::ExprProc(_decl, block) |
294-
ast::ExprFnBlock(_decl, block) => { block.id }
294+
ast::ExprFnBlock(_, _decl, block) => { block.id }
295295
_ => fail!("encountered non-closure id: {}", closure_id)
296296
},
297297
_ => fail!("encountered non-expr id: {}", closure_id)

branches/try2/src/librustc/middle/check_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ impl<'a> Visitor<Context> for CheckLoopVisitor<'a> {
4646
self.visit_expr(&**e, cx);
4747
self.visit_block(&**b, Loop);
4848
}
49-
ast::ExprFnBlock(_, ref b) |
49+
ast::ExprFnBlock(_, _, ref b) |
5050
ast::ExprProc(_, ref b) |
51-
ast::ExprUnboxedFn(_, ref b) => {
51+
ast::ExprUnboxedFn(_, _, ref b) => {
5252
self.visit_block(&**b, Closure);
5353
}
5454
ast::ExprBreak(_) => self.require_loop("break", cx, e.span),

branches/try2/src/librustc/middle/freevars.rs

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ use middle::def;
1717
use middle::mem_categorization::Typer;
1818
use middle::resolve;
1919
use middle::ty;
20-
use util::nodemap::{DefIdSet, NodeMap, NodeSet};
20+
use util::nodemap::{NodeMap, NodeSet};
2121

22+
use syntax::ast;
2223
use syntax::codemap::Span;
23-
use syntax::{ast};
24-
use syntax::visit;
2524
use syntax::visit::Visitor;
25+
use syntax::visit;
2626

27-
#[deriving(Show)]
27+
#[deriving(Clone, Decodable, Encodable, Show)]
2828
pub enum CaptureMode {
2929
/// Copy/move the value from this llvm ValueRef into the environment.
3030
CaptureByValue,
@@ -43,12 +43,13 @@ pub struct freevar_entry {
4343

4444
pub type freevar_map = NodeMap<Vec<freevar_entry>>;
4545

46-
pub type UnboxedClosureList = DefIdSet;
46+
pub type CaptureModeMap = NodeMap<CaptureMode>;
4747

4848
struct CollectFreevarsVisitor<'a> {
4949
seen: NodeSet,
5050
refs: Vec<freevar_entry>,
5151
def_map: &'a resolve::DefMap,
52+
capture_mode_map: &'a mut CaptureModeMap,
5253
}
5354

5455
impl<'a> Visitor<int> for CollectFreevarsVisitor<'a> {
@@ -58,8 +59,27 @@ impl<'a> Visitor<int> for CollectFreevarsVisitor<'a> {
5859

5960
fn visit_expr(&mut self, expr: &ast::Expr, depth: int) {
6061
match expr.node {
61-
ast::ExprFnBlock(..) | ast::ExprProc(..) |
62-
ast::ExprUnboxedFn(..) => {
62+
ast::ExprProc(..) => {
63+
self.capture_mode_map.insert(expr.id, CaptureByValue);
64+
visit::walk_expr(self, expr, depth + 1)
65+
}
66+
ast::ExprFnBlock(_, _, _) => {
67+
// NOTE(stage0): After snapshot, change to:
68+
//
69+
//let capture_mode = match capture_clause {
70+
// ast::CaptureByValue => CaptureByValue,
71+
// ast::CaptureByRef => CaptureByRef,
72+
//};
73+
let capture_mode = CaptureByRef;
74+
self.capture_mode_map.insert(expr.id, capture_mode);
75+
visit::walk_expr(self, expr, depth + 1)
76+
}
77+
ast::ExprUnboxedFn(capture_clause, _, _) => {
78+
let capture_mode = match capture_clause {
79+
ast::CaptureByValue => CaptureByValue,
80+
ast::CaptureByRef => CaptureByRef,
81+
};
82+
self.capture_mode_map.insert(expr.id, capture_mode);
6383
visit::walk_expr(self, expr, depth + 1)
6484
}
6585
ast::ExprPath(..) => {
@@ -91,35 +111,41 @@ impl<'a> Visitor<int> for CollectFreevarsVisitor<'a> {
91111
_ => visit::walk_expr(self, expr, depth)
92112
}
93113
}
94-
95-
96114
}
97115

98116
// Searches through part of the AST for all references to locals or
99117
// upvars in this frame and returns the list of definition IDs thus found.
100118
// Since we want to be able to collect upvars in some arbitrary piece
101119
// of the AST, we take a walker function that we invoke with a visitor
102120
// in order to start the search.
103-
fn collect_freevars(def_map: &resolve::DefMap, blk: &ast::Block) -> Vec<freevar_entry> {
121+
fn collect_freevars(def_map: &resolve::DefMap,
122+
blk: &ast::Block,
123+
capture_mode_map: &mut CaptureModeMap)
124+
-> Vec<freevar_entry> {
104125
let mut v = CollectFreevarsVisitor {
105126
seen: NodeSet::new(),
106127
refs: Vec::new(),
107128
def_map: def_map,
129+
capture_mode_map: &mut *capture_mode_map,
108130
};
109131

110132
v.visit_block(blk, 1);
133+
111134
v.refs
112135
}
113136

114137
struct AnnotateFreevarsVisitor<'a> {
115138
def_map: &'a resolve::DefMap,
116139
freevars: freevar_map,
140+
capture_mode_map: CaptureModeMap,
117141
}
118142

119143
impl<'a> Visitor<()> for AnnotateFreevarsVisitor<'a> {
120144
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
121145
blk: &ast::Block, s: Span, nid: ast::NodeId, _: ()) {
122-
let vars = collect_freevars(self.def_map, blk);
146+
let vars = collect_freevars(self.def_map,
147+
blk,
148+
&mut self.capture_mode_map);
123149
self.freevars.insert(nid, vars);
124150
visit::walk_fn(self, fk, fd, blk, s, ());
125151
}
@@ -131,14 +157,20 @@ impl<'a> Visitor<()> for AnnotateFreevarsVisitor<'a> {
131157
// node of interest rather than building up the free variables in
132158
// one pass. This could be improved upon if it turns out to matter.
133159
pub fn annotate_freevars(def_map: &resolve::DefMap, krate: &ast::Crate)
134-
-> freevar_map {
160+
-> (freevar_map, CaptureModeMap) {
135161
let mut visitor = AnnotateFreevarsVisitor {
136162
def_map: def_map,
137163
freevars: NodeMap::new(),
164+
capture_mode_map: NodeMap::new(),
138165
};
139166
visit::walk_crate(&mut visitor, krate, ());
140167

141-
visitor.freevars
168+
let AnnotateFreevarsVisitor {
169+
freevars,
170+
capture_mode_map,
171+
..
172+
} = visitor;
173+
(freevars, capture_mode_map)
142174
}
143175

144176
pub fn with_freevars<T>(tcx: &ty::ctxt, fid: ast::NodeId, f: |&[freevar_entry]| -> T) -> T {
@@ -148,10 +180,7 @@ pub fn with_freevars<T>(tcx: &ty::ctxt, fid: ast::NodeId, f: |&[freevar_entry]|
148180
}
149181
}
150182

151-
pub fn get_capture_mode<T: Typer>(tcx: &T, closure_expr_id: ast::NodeId) -> CaptureMode {
152-
let fn_ty = tcx.node_ty(closure_expr_id).ok().expect("couldn't find closure ty?");
153-
match ty::ty_closure_store(fn_ty) {
154-
ty::RegionTraitStore(..) => CaptureByRef,
155-
ty::UniqTraitStore => CaptureByValue
156-
}
183+
pub fn get_capture_mode<T:Typer>(tcx: &T, closure_expr_id: ast::NodeId)
184+
-> CaptureMode {
185+
tcx.capture_mode(closure_expr_id)
157186
}

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,9 @@ impl<'a> Liveness<'a> {
965965
self.propagate_through_expr(&**e, succ)
966966
}
967967

968-
ExprFnBlock(_, ref blk) |
968+
ExprFnBlock(_, _, ref blk) |
969969
ExprProc(_, ref blk) |
970-
ExprUnboxedFn(_, ref blk) => {
970+
ExprUnboxedFn(_, _, ref blk) => {
971971
debug!("{} is an ExprFnBlock, ExprProc, or ExprUnboxedFn",
972972
expr_to_string(expr));
973973

branches/try2/src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#![allow(non_camel_case_types)]
6464

6565
use middle::def;
66+
use middle::freevars;
6667
use middle::ty;
6768
use middle::typeck;
6869
use util::nodemap::NodeMap;
@@ -270,6 +271,8 @@ pub trait Typer {
270271
fn is_method_call(&self, id: ast::NodeId) -> bool;
271272
fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId>;
272273
fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow;
274+
fn capture_mode(&self, closure_expr_id: ast::NodeId)
275+
-> freevars::CaptureMode;
273276
}
274277

275278
impl MutabilityCategory {

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5287,9 +5287,9 @@ impl<'a> Resolver<'a> {
52875287
visit::walk_expr(self, expr, ());
52885288
}
52895289

5290-
ExprFnBlock(fn_decl, block) |
5290+
ExprFnBlock(_, fn_decl, block) |
52915291
ExprProc(fn_decl, block) |
5292-
ExprUnboxedFn(fn_decl, block) => {
5292+
ExprUnboxedFn(_, fn_decl, block) => {
52935293
self.resolve_function(FunctionRibKind(expr.id, block.id),
52945294
Some(fn_decl), NoTypeParameters,
52955295
block);

0 commit comments

Comments
 (0)