Skip to content

Commit ed3a3ee

Browse files
committed
---
yaml --- r: 48110 b: refs/heads/incoming c: 3c23589 h: refs/heads/master v: v3
1 parent 19bb818 commit ed3a3ee

Some content is hidden

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

41 files changed

+126
-121
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: af645e848713536ac3c0a0c52de7b4d96f96fbc6
9+
refs/heads/incoming: 3c23589b08678221132bce88c741853d1fd841af
1010
refs/heads/dist-snap: 8b98e5a296d95c5e832db0756828e5bec31c6f50
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ pub fn load_props(testfile: &Path) -> TestProps {
5959
pp_exact = parse_pp_exact(ln, testfile);
6060
}
6161

62-
for parse_aux_build(ln).each |ab| {
62+
do parse_aux_build(ln).iter |ab| {
6363
aux_builds.push(*ab);
6464
}
6565

66-
for parse_exec_env(ln).each |ee| {
66+
do parse_exec_env(ln).iter |ee| {
6767
exec_env.push(*ee);
6868
}
6969

branches/incoming/src/etc/x86.supp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@
429429
...
430430
}
431431

432+
{
433+
enum-instruction-scheduling-10
434+
Memcheck:Cond
435+
fun:*config_from_opts*
436+
...
437+
}
438+
432439
{
433440
llvm-user-new-leak
434441
Memcheck:Leak

branches/incoming/src/libcore/core.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ pub mod container;
132132
/* Common data structures */
133133

134134
pub mod option;
135+
#[path="iter-trait.rs"] #[merge = "iter-trait/option.rs"]
136+
pub mod option_iter;
135137
pub mod result;
136138
pub mod either;
137139
pub mod dvec;

branches/incoming/src/libcore/option.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use ptr;
4848
use str;
4949
use util;
5050
use num::Zero;
51-
use iter::BaseIter;
5251

5352
/// The option type
5453
#[deriving_eq]
@@ -229,6 +228,12 @@ pub pure fn map_default<T, U>(opt: &r/Option<T>, def: U,
229228
match *opt { None => def, Some(ref t) => f(t) }
230229
}
231230
231+
#[inline(always)]
232+
pub pure fn iter<T>(opt: &r/Option<T>, f: fn(x: &r/T)) {
233+
//! Performs an operation on the contained value by reference
234+
match *opt { None => (), Some(ref t) => f(t) }
235+
}
236+
232237
#[inline(always)]
233238
pub pure fn unwrap<T>(opt: Option<T>) -> T {
234239
/*!
@@ -276,19 +281,6 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T {
276281
}
277282
}
278283
279-
impl<T> BaseIter<T> for Option<T> {
280-
/// Performs an operation on the contained value by reference
281-
#[inline(always)]
282-
pure fn each(&self, f: fn(x: &self/T) -> bool) {
283-
match *self { None => (), Some(ref t) => { f(t); } }
284-
}
285-
286-
#[inline(always)]
287-
pure fn size_hint(&self) -> Option<uint> {
288-
if self.is_some() { Some(1) } else { Some(0) }
289-
}
290-
}
291-
292284
pub impl<T> Option<T> {
293285
/// Returns true if the option equals `none`
294286
#[inline(always)]
@@ -347,6 +339,10 @@ pub impl<T> Option<T> {
347339
}
348340
}
349341
342+
/// Performs an operation on the contained value by reference
343+
#[inline(always)]
344+
pure fn iter(&self, f: fn(x: &self/T)) { iter(self, f) }
345+
350346
/**
351347
Gets an immutable reference to the value inside an option.
352348
@@ -480,7 +476,7 @@ fn test_option_dance() {
480476
let x = Some(());
481477
let mut y = Some(5);
482478
let mut y2 = 0;
483-
for x.each |_x| {
479+
do x.iter |_x| {
484480
y2 = swap_unwrap(&mut y);
485481
}
486482
assert y2 == 5;

branches/incoming/src/libcore/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ mod tests {
12371237
setenv(~"HOME", ~"");
12381238
assert os::homedir().is_none();
12391239
1240-
for oldhome.each |s| { setenv(~"HOME", *s) }
1240+
oldhome.iter(|s| setenv(~"HOME", *s));
12411241
}
12421242
12431243
#[test]

branches/incoming/src/libcore/task/spawn.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn each_ancestor(list: &mut AncestorList,
268268
* Step 3: Maybe unwind; compute return info for our caller.
269269
*##########################################################*/
270270
if need_unwind && !nobe_is_dead {
271-
for bail_opt.each |bail_blk| {
271+
do bail_opt.iter |bail_blk| {
272272
do with_parent_tg(&mut nobe.parent_group) |tg_opt| {
273273
(*bail_blk)(tg_opt)
274274
}
@@ -317,7 +317,7 @@ impl Drop for TCB {
317317
unsafe {
318318
// If we are failing, the whole taskgroup needs to die.
319319
if rt::rust_task_is_unwinding(self.me) {
320-
for self.notifier.each |x| { x.failed = true; }
320+
self.notifier.iter(|x| { x.failed = true; });
321321
// Take everybody down with us.
322322
do access_group(&self.tasks) |tg| {
323323
kill_taskgroup(tg, self.me, self.is_main);
@@ -341,7 +341,9 @@ impl Drop for TCB {
341341

342342
fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
343343
is_main: bool, notifier: Option<AutoNotify>) -> TCB {
344-
for notifier.each |x| { x.failed = false; }
344+
345+
let notifier = notifier;
346+
notifier.iter(|x| { x.failed = false; });
345347

346348
TCB {
347349
me: me,

branches/incoming/src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
715715
let idx = encode_info_for_struct(ecx, ebml_w, path,
716716
struct_def.fields, index);
717717
/* Encode the dtor */
718-
for struct_def.dtor.each |dtor| {
718+
do struct_def.dtor.iter |dtor| {
719719
index.push(entry {val: dtor.node.id, pos: ebml_w.writer.tell()});
720720
encode_info_for_ctor(ecx,
721721
ebml_w,
@@ -767,7 +767,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
767767
encode_region_param(ecx, ebml_w, item);
768768
/* Encode the dtor */
769769
/* Encode id for dtor */
770-
for struct_def.dtor.each |dtor| {
770+
do struct_def.dtor.iter |dtor| {
771771
do ebml_w.wr_tag(tag_item_dtor) {
772772
encode_def_id(ebml_w, local_def(dtor.node.id));
773773
}
@@ -821,7 +821,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
821821
ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id)));
822822
ebml_w.end_tag();
823823
}
824-
for opt_trait.each |associated_trait| {
824+
do opt_trait.iter() |associated_trait| {
825825
encode_trait_ref(ebml_w, ecx, *associated_trait);
826826
}
827827
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -860,16 +860,15 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
860860
861861
debug!("Encoding side tables for id %d", id);
862862
863-
for tcx.def_map.find(&id).each |def| {
863+
do option::iter(&tcx.def_map.find(&id)) |def| {
864864
do ebml_w.tag(c::tag_table_def) {
865865
ebml_w.id(id);
866866
do ebml_w.tag(c::tag_table_val) {
867867
(*def).encode(&ebml_w)
868868
}
869869
}
870870
}
871-
872-
for tcx.node_types.find(&(id as uint)).each |&ty| {
871+
do option::iter(&tcx.node_types.find(&(id as uint))) |&ty| {
873872
do ebml_w.tag(c::tag_table_node_type) {
874873
ebml_w.id(id);
875874
do ebml_w.tag(c::tag_table_val) {
@@ -878,7 +877,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
878877
}
879878
}
880879
881-
for tcx.node_type_substs.find(&id).each |tys| {
880+
do option::iter(&tcx.node_type_substs.find(&id)) |tys| {
882881
do ebml_w.tag(c::tag_table_node_type_subst) {
883882
ebml_w.id(id);
884883
do ebml_w.tag(c::tag_table_val) {
@@ -887,7 +886,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
887886
}
888887
}
889888
890-
for tcx.freevars.find(&id).each |fv| {
889+
do option::iter(&tcx.freevars.find(&id)) |fv| {
891890
do ebml_w.tag(c::tag_table_freevars) {
892891
ebml_w.id(id);
893892
do ebml_w.tag(c::tag_table_val) {
@@ -899,7 +898,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
899898
}
900899
901900
let lid = ast::def_id { crate: ast::local_crate, node: id };
902-
for tcx.tcache.find(&lid).each |tpbt| {
901+
do option::iter(&tcx.tcache.find(&lid)) |tpbt| {
903902
do ebml_w.tag(c::tag_table_tcache) {
904903
ebml_w.id(id);
905904
do ebml_w.tag(c::tag_table_val) {
@@ -908,7 +907,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
908907
}
909908
}
910909
911-
for tcx.ty_param_bounds.find(&id).each |pbs| {
910+
do option::iter(&tcx.ty_param_bounds.find(&id)) |pbs| {
912911
do ebml_w.tag(c::tag_table_param_bounds) {
913912
ebml_w.id(id);
914913
do ebml_w.tag(c::tag_table_val) {
@@ -922,7 +921,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
922921
// is what we actually use in trans, all modes will have been
923922
// resolved.
924923
//
925-
//for tcx.inferred_modes.find(&id).each |m| {
924+
//option::iter(tcx.inferred_modes.find(&id)) {|m|
926925
// ebml_w.tag(c::tag_table_inferred_modes) {||
927926
// ebml_w.id(id);
928927
// ebml_w.tag(c::tag_table_val) {||
@@ -931,13 +930,13 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
931930
// }
932931
//}
933932
934-
if maps.mutbl_map.contains_key(&id) {
933+
do option::iter(&maps.mutbl_map.find(&id)) |_m| {
935934
do ebml_w.tag(c::tag_table_mutbl) {
936935
ebml_w.id(id);
937936
}
938937
}
939938
940-
for maps.last_use_map.find(&id).each |m| {
939+
do option::iter(&maps.last_use_map.find(&id)) |m| {
941940
do ebml_w.tag(c::tag_table_last_use) {
942941
ebml_w.id(id);
943942
do ebml_w.tag(c::tag_table_val) {
@@ -948,7 +947,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
948947
}
949948
}
950949
951-
for maps.method_map.find(&id).each |mme| {
950+
do option::iter(&maps.method_map.find(&id)) |mme| {
952951
do ebml_w.tag(c::tag_table_method_map) {
953952
ebml_w.id(id);
954953
do ebml_w.tag(c::tag_table_val) {
@@ -957,7 +956,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
957956
}
958957
}
959958
960-
for maps.vtable_map.find(&id).each |dr| {
959+
do option::iter(&maps.vtable_map.find(&id)) |dr| {
961960
do ebml_w.tag(c::tag_table_vtable_map) {
962961
ebml_w.id(id);
963962
do ebml_w.tag(c::tag_table_val) {
@@ -966,7 +965,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
966965
}
967966
}
968967
969-
for tcx.adjustments.find(&id).each |adj| {
968+
do option::iter(&tcx.adjustments.find(&id)) |adj| {
970969
do ebml_w.tag(c::tag_table_adjustments) {
971970
ebml_w.id(id);
972971
do ebml_w.tag(c::tag_table_val) {

branches/incoming/src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn check_item(sess: Session,
5151
}
5252
item_enum(ref enum_definition, _) => {
5353
for (*enum_definition).variants.each |var| {
54-
for var.node.disr_expr.each |ex| {
54+
do option::iter(&var.node.disr_expr) |ex| {
5555
(v.visit_expr)(*ex, true, v);
5656
}
5757
}

branches/incoming/src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
365365
ty::ty_enum(eid, _) => {
366366
let mut found = ~[];
367367
for m.each |r| {
368-
for pat_ctor_id(cx, r[0]).each |id| {
368+
do option::iter(&pat_ctor_id(cx, r[0])) |id| {
369369
if !vec::contains(found, id) {
370370
found.push(/*bad*/copy *id);
371371
}

branches/incoming/src/librustc/middle/kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
194194
expr_unary(*)|expr_binary(*)|expr_method_call(*) => e.callee_id,
195195
_ => e.id
196196
};
197-
for cx.tcx.node_type_substs.find(&type_parameter_id).each |ts| {
197+
do option::iter(&cx.tcx.node_type_substs.find(&type_parameter_id)) |ts| {
198198
let bounds = match e.node {
199199
expr_path(_) => {
200200
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(&e.id));
@@ -255,7 +255,7 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
255255
fn check_ty(aty: @Ty, cx: Context, v: visit::vt<Context>) {
256256
match aty.node {
257257
ty_path(_, id) => {
258-
for cx.tcx.node_type_substs.find(&id).each |ts| {
258+
do option::iter(&cx.tcx.node_type_substs.find(&id)) |ts| {
259259
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(&id));
260260
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
261261
for vec::each2(*ts, *bounds) |ty, bound| {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ pub impl Liveness {
11011101

11021102
fn propagate_through_opt_expr(&self, opt_expr: Option<@expr>,
11031103
succ: LiveNode) -> LiveNode {
1104-
do iter::foldl(&opt_expr, succ) |succ, expr| {
1104+
do opt_expr.foldl(succ) |succ, expr| {
11051105
self.propagate_through_expr(*expr, *succ)
11061106
}
11071107
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ pub impl Resolver {
10221022
fmt!("duplicate definition of %s %s",
10231023
namespace_to_str(ns),
10241024
*self.session.str_of(name)));
1025-
for child.span_for_namespace(ns).each |sp| {
1025+
do child.span_for_namespace(ns).iter() |sp| {
10261026
self.session.span_note(*sp,
10271027
fmt!("first definition of %s %s here:",
10281028
namespace_to_str(ns),
@@ -3463,7 +3463,7 @@ pub impl Resolver {
34633463
// then resolve the ty params
34643464
item_enum(ref enum_def, ref generics) => {
34653465
for (*enum_def).variants.each() |variant| {
3466-
for variant.node.disr_expr.each |dis_expr| {
3466+
do variant.node.disr_expr.iter() |dis_expr| {
34673467
// resolve the discriminator expr
34683468
// as a constant
34693469
self.with_constant_rib(|| {

branches/incoming/src/librustc/middle/trans/base.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,10 +1221,10 @@ pub fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
12211221
is_lpad,
12221222
opt_node_info,
12231223
cx);
1224-
for parent.each |cx| {
1224+
do option::iter(&parent) |cx| {
12251225
if cx.unreachable { Unreachable(bcx); }
12261226
};
1227-
bcx
1227+
return bcx;
12281228
}
12291229
}
12301230

@@ -1452,7 +1452,7 @@ pub fn alloc_local(cx: block, local: @ast::local) -> block {
14521452
};
14531453
let val = alloc_ty(cx, t);
14541454
if cx.sess().opts.debuginfo {
1455-
for simple_name.each |name| {
1455+
do option::iter(&simple_name) |name| {
14561456
str::as_c_str(*cx.ccx().sess.str_of(*name), |buf| {
14571457
unsafe {
14581458
llvm::LLVMSetValueName(val, buf)
@@ -1461,7 +1461,7 @@ pub fn alloc_local(cx: block, local: @ast::local) -> block {
14611461
}
14621462
}
14631463
cx.fcx.lllocals.insert(local.node.id, local_mem(val));
1464-
cx
1464+
return cx;
14651465
}
14661466

14671467

@@ -2017,7 +2017,7 @@ pub fn trans_struct_dtor(ccx: @CrateContext,
20172017
/* Look up the parent class's def_id */
20182018
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
20192019
/* Substitute in the class type if necessary */
2020-
for psubsts.each |ss| {
2020+
do option::iter(&psubsts) |ss| {
20212021
class_ty = ty::subst_tps(tcx, ss.tys, ss.self_ty, class_ty);
20222022
}
20232023
@@ -2034,7 +2034,7 @@ pub fn trans_struct_dtor(ccx: @CrateContext,
20342034
20352035
/* If we're monomorphizing, register the monomorphized decl
20362036
for the dtor */
2037-
for hash_id.each |h_id| {
2037+
do option::iter(&hash_id) |h_id| {
20382038
ccx.monomorphized.insert(*h_id, lldecl);
20392039
}
20402040
/* Translate the dtor body */
@@ -2148,7 +2148,7 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def,
21482148
path: @ast_map::path,
21492149
id: ast::node_id) {
21502150
// Translate the destructor.
2151-
for struct_def.dtor.each |dtor| {
2151+
do option::iter(&struct_def.dtor) |dtor| {
21522152
trans_struct_dtor(ccx, /*bad*/copy *path, &dtor.node.body,
21532153
dtor.node.id, None, None, local_def(id));
21542154
};

0 commit comments

Comments
 (0)