Skip to content

Commit 26b7e56

Browse files
committed
---
yaml --- r: 151223 b: refs/heads/try2 c: 0006671 h: refs/heads/master i: 151221: c860930 151219: c0704aa 151215: 914dfd5 v: v3
1 parent 9b1f854 commit 26b7e56

38 files changed

+1671
-1367
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: ee03529fa9c84471f0e24d749017ce88b7d2b81e
8+
refs/heads/try2: 000667158b7fc7f72e7ca6e8a43e9aaca834726f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ fn eq(xs: &List, ys: &List) -> bool {
11971197
match (xs, ys) {
11981198
// If we have reached the end of both lists, they are equal.
11991199
(&Nil, &Nil) => true,
1200-
// If the current element in both lists is equal, keep going.
1200+
// If the current elements of both lists are equal, keep going.
12011201
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys))
12021202
if x == y => eq(next_xs, next_ys),
12031203
// If the current elements are not equal, the lists are not equal.
@@ -1304,7 +1304,7 @@ fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
13041304
match (xs, ys) {
13051305
// If we have reached the end of both lists, they are equal.
13061306
(&Nil, &Nil) => true,
1307-
// If the current element in both lists is equal, keep going.
1307+
// If the current elements of both lists are equal, keep going.
13081308
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
13091309
if x == y => eq(next_xs, next_ys),
13101310
// If the current elements are not equal, the lists are not equal.
@@ -1333,7 +1333,7 @@ impl<T: Eq> Eq for List<T> {
13331333
match (self, ys) {
13341334
// If we have reached the end of both lists, they are equal.
13351335
(&Nil, &Nil) => true,
1336-
// If the current element in both lists is equal, keep going.
1336+
// If the current elements of both lists are equal, keep going.
13371337
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
13381338
if x == y => next_xs == next_ys,
13391339
// If the current elements are not equal, the lists are not equal.

branches/try2/src/librustc/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
133133
}
134134

135135
pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> ~str {
136-
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
136+
let install_prefix = env!("CFG_PREFIX");
137137

138138
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
139139
let mut path = Path::new(install_prefix);
@@ -171,7 +171,7 @@ mod test {
171171
fn test_prefix_rpath() {
172172
let sysroot = filesearch::get_or_default_sysroot();
173173
let res = get_install_prefix_rpath(&sysroot, "triple");
174-
let mut d = Path::new((option_env!("CFG_PREFIX")).expect("CFG_PREFIX"));
174+
let mut d = Path::new(env!("CFG_PREFIX"));
175175
d.push("lib");
176176
d.push(filesearch::rustlibdir());
177177
d.push("triple/lib");

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use metadata::{creader, filesearch};
2323
use metadata::cstore::CStore;
2424
use metadata::creader::Loader;
2525
use metadata;
26-
use middle::{trans, freevars, kind, ty, typeck, lint, reachable};
26+
use middle::{trans, freevars, kind, ty, typeck, lint, astencode, reachable};
2727
use middle;
2828
use util::common::time;
2929
use util::ppaux;
@@ -35,6 +35,7 @@ use std::cell::{Cell, RefCell};
3535
use std::io;
3636
use std::io::fs;
3737
use std::io::MemReader;
38+
use std::mem::drop;
3839
use std::os;
3940
use getopts::{optopt, optmulti, optflag, optflagopt};
4041
use getopts;
@@ -277,6 +278,7 @@ pub struct CrateAnalysis {
277278
pub exported_items: middle::privacy::ExportedItems,
278279
pub public_items: middle::privacy::PublicItems,
279280
pub ty_cx: ty::ctxt,
281+
pub maps: astencode::Maps,
280282
pub reachable: NodeSet,
281283
}
282284

@@ -352,14 +354,21 @@ pub fn phase_3_run_analysis_passes(sess: Session,
352354
time(time_passes, "effect checking", (), |_|
353355
middle::effect::check_crate(&ty_cx, krate));
354356

357+
let middle::moves::MoveMaps {moves_map, capture_map} =
358+
time(time_passes, "compute moves", (), |_|
359+
middle::moves::compute_moves(&ty_cx, krate));
360+
355361
time(time_passes, "match checking", (), |_|
356-
middle::check_match::check_crate(&ty_cx, krate));
362+
middle::check_match::check_crate(&ty_cx, &moves_map, krate));
357363

358364
time(time_passes, "liveness checking", (), |_|
359-
middle::liveness::check_crate(&ty_cx, krate));
365+
middle::liveness::check_crate(&ty_cx, &capture_map, krate));
360366

361367
time(time_passes, "borrow checking", (), |_|
362-
middle::borrowck::check_crate(&ty_cx, krate));
368+
middle::borrowck::check_crate(&ty_cx, &moves_map,
369+
&capture_map, krate));
370+
371+
drop(moves_map);
363372

364373
time(time_passes, "kind checking", (), |_|
365374
kind::check_crate(&ty_cx, krate));
@@ -383,6 +392,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
383392
ty_cx: ty_cx,
384393
exported_items: exported_items,
385394
public_items: public_items,
395+
maps: astencode::Maps {
396+
capture_map: RefCell::new(capture_map)
397+
},
386398
reachable: reachable_map
387399
}
388400
}
@@ -798,8 +810,7 @@ pub fn host_triple() -> &'static str {
798810
// Instead of grabbing the host triple (for the current host), we grab (at
799811
// compile time) the target triple that this rustc is built with and
800812
// calling that (at runtime) the host triple.
801-
(option_env!("CFG_COMPILER_HOST_TRIPLE")).
802-
expect("CFG_COMPILER_HOST_TRIPLE")
813+
env!("CFG_COMPILER_HOST_TRIPLE")
803814
}
804815

805816
pub fn build_session_options(matches: &getopts::Matches) -> session::Options {

branches/try2/src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ pub mod middle {
8686
pub mod astencode;
8787
pub mod lang_items;
8888
pub mod privacy;
89+
pub mod moves;
8990
pub mod entry;
9091
pub mod effect;
9192
pub mod reachable;
9293
pub mod graph;
9394
pub mod cfg;
9495
pub mod dead;
95-
pub mod expr_use_visitor;
9696
}
9797

9898
pub mod front {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ fn each_child_of_item_or_crate(intr: Rc<IdentInterner>,
610610
// Hand off the item to the callback.
611611
let def_like = item_to_def_like(child_item_doc,
612612
child_def_id,
613-
child_def_id.krate);
613+
cdata.cnum);
614614
// These items have a public visibility because they're part of
615615
// a public re-export.
616616
callback(def_like, token::str_to_ident(name), ast::Public);

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

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter,
2424
RegionParameter};
2525
use metadata::tyencode;
2626
use middle::typeck::{MethodCall, MethodCallee, MethodOrigin};
27-
use middle::{ty, typeck};
27+
use middle::{ty, typeck, moves};
28+
use middle;
2829
use util::ppaux::ty_to_str;
2930

3031
use syntax::{ast, ast_map, ast_util, codemap, fold};
@@ -35,6 +36,7 @@ use syntax;
3536

3637
use libc;
3738
use std::cast;
39+
use std::cell::RefCell;
3840
use std::io::Seek;
3941
use std::io::MemWriter;
4042
use std::rc::Rc;
@@ -50,9 +52,15 @@ use writer = serialize::ebml::writer;
5052
#[cfg(test)] use syntax::parse;
5153
#[cfg(test)] use syntax::print::pprust;
5254

55+
// Auxiliary maps of things to be encoded
56+
pub struct Maps {
57+
pub capture_map: RefCell<middle::moves::CaptureMap>,
58+
}
59+
5360
struct DecodeContext<'a> {
5461
cdata: &'a cstore::crate_metadata,
5562
tcx: &'a ty::ctxt,
63+
maps: &'a Maps
5664
}
5765

5866
struct ExtendedDecodeContext<'a> {
@@ -76,7 +84,8 @@ pub type Encoder<'a> = writer::Encoder<'a, MemWriter>;
7684

7785
pub fn encode_inlined_item(ecx: &e::EncodeContext,
7886
ebml_w: &mut Encoder,
79-
ii: e::InlinedItemRef) {
87+
ii: e::InlinedItemRef,
88+
maps: &Maps) {
8089
let id = match ii {
8190
e::IIItemRef(i) => i.id,
8291
e::IIForeignRef(i) => i.id,
@@ -92,7 +101,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext,
92101
ebml_w.start_tag(c::tag_ast as uint);
93102
id_range.encode(ebml_w);
94103
encode_ast(ebml_w, ii);
95-
encode_side_tables_for_ii(ecx, ebml_w, &ii);
104+
encode_side_tables_for_ii(ecx, maps, ebml_w, &ii);
96105
ebml_w.end_tag();
97106

98107
debug!("< Encoded inlined fn: {} ({})",
@@ -102,12 +111,14 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext,
102111

103112
pub fn decode_inlined_item(cdata: &cstore::crate_metadata,
104113
tcx: &ty::ctxt,
114+
maps: &Maps,
105115
path: Vec<ast_map::PathElem>,
106116
par_doc: ebml::Doc)
107117
-> Result<ast::InlinedItem, Vec<ast_map::PathElem>> {
108118
let dcx = &DecodeContext {
109119
cdata: cdata,
110120
tcx: tcx,
121+
maps: maps
111122
};
112123
match par_doc.opt_child(c::tag_ast) {
113124
None => Err(path),
@@ -540,6 +551,32 @@ impl tr for freevar_entry {
540551
}
541552
}
542553

554+
// ______________________________________________________________________
555+
// Encoding and decoding of CaptureVar information
556+
557+
trait capture_var_helper {
558+
fn read_capture_var(&mut self, xcx: &ExtendedDecodeContext)
559+
-> moves::CaptureVar;
560+
}
561+
562+
impl<'a> capture_var_helper for reader::Decoder<'a> {
563+
fn read_capture_var(&mut self, xcx: &ExtendedDecodeContext)
564+
-> moves::CaptureVar {
565+
let cvar: moves::CaptureVar = Decodable::decode(self).unwrap();
566+
cvar.tr(xcx)
567+
}
568+
}
569+
570+
impl tr for moves::CaptureVar {
571+
fn tr(&self, xcx: &ExtendedDecodeContext) -> moves::CaptureVar {
572+
moves::CaptureVar {
573+
def: self.def.tr(xcx),
574+
span: self.span.tr(xcx),
575+
mode: self.mode
576+
}
577+
}
578+
}
579+
543580
// ______________________________________________________________________
544581
// Encoding and decoding of MethodCallee
545582

@@ -898,6 +935,7 @@ impl<'a> write_tag_and_id for Encoder<'a> {
898935
struct SideTableEncodingIdVisitor<'a,'b> {
899936
ecx_ptr: *libc::c_void,
900937
new_ebml_w: &'a mut Encoder<'b>,
938+
maps: &'a Maps,
901939
}
902940

903941
impl<'a,'b> ast_util::IdVisitingOperation for
@@ -915,11 +953,12 @@ impl<'a,'b> ast_util::IdVisitingOperation for
915953
let ecx: &e::EncodeContext = unsafe {
916954
cast::transmute(self.ecx_ptr)
917955
};
918-
encode_side_tables_for_id(ecx, &mut new_ebml_w, id)
956+
encode_side_tables_for_id(ecx, self.maps, &mut new_ebml_w, id)
919957
}
920958
}
921959

922960
fn encode_side_tables_for_ii(ecx: &e::EncodeContext,
961+
maps: &Maps,
923962
ebml_w: &mut Encoder,
924963
ii: &ast::InlinedItem) {
925964
ebml_w.start_tag(c::tag_table as uint);
@@ -935,11 +974,13 @@ fn encode_side_tables_for_ii(ecx: &e::EncodeContext,
935974
cast::transmute(ecx)
936975
},
937976
new_ebml_w: &mut new_ebml_w,
977+
maps: maps,
938978
});
939979
ebml_w.end_tag();
940980
}
941981

942982
fn encode_side_tables_for_id(ecx: &e::EncodeContext,
983+
maps: &Maps,
943984
ebml_w: &mut Encoder,
944985
id: ast::NodeId) {
945986
let tcx = ecx.tcx;
@@ -1055,6 +1096,17 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10551096
})
10561097
})
10571098
}
1099+
1100+
for &cap_vars in maps.capture_map.borrow().find(&id).iter() {
1101+
ebml_w.tag(c::tag_table_capture_map, |ebml_w| {
1102+
ebml_w.id(id);
1103+
ebml_w.tag(c::tag_table_val, |ebml_w| {
1104+
ebml_w.emit_from_vec(cap_vars.as_slice(), |ebml_w, cap_var| {
1105+
cap_var.encode(ebml_w)
1106+
});
1107+
})
1108+
})
1109+
}
10581110
}
10591111

10601112
trait doc_decoder_helpers {
@@ -1353,6 +1405,15 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
13531405
let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(xcx);
13541406
dcx.tcx.adjustments.borrow_mut().insert(id, adj);
13551407
}
1408+
c::tag_table_capture_map => {
1409+
let cvars =
1410+
val_dsr.read_to_vec(
1411+
|val_dsr| Ok(val_dsr.read_capture_var(xcx)))
1412+
.unwrap()
1413+
.move_iter()
1414+
.collect();
1415+
dcx.maps.capture_map.borrow_mut().insert(id, Rc::new(cvars));
1416+
}
13561417
_ => {
13571418
xcx.dcx.tcx.sess.bug(
13581419
format!("unknown tag found in side tables: {:x}", tag));

0 commit comments

Comments
 (0)