Skip to content

Commit 0d0951b

Browse files
committed
---
yaml --- r: 140616 b: refs/heads/try2 c: 7286845 h: refs/heads/master v: v3
1 parent 36101b6 commit 0d0951b

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
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: 3affc6ed4071a183da81bcc2048fff82d3e35e81
8+
refs/heads/try2: 72868450df54ff1ec80e92e3f2fc827cfb1e9f02
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/rt/local_services.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ mod test {
225225
fn rng() {
226226
do run_in_newsched_task() {
227227
use rand::{rng, Rng};
228-
let r = rng();
228+
let mut r = rng();
229229
let _ = r.next();
230230
}
231231
}
232-
}
232+
}

branches/try2/src/libsyntax/ext/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use ast;
1212
use codemap;
1313
use codemap::span;
14+
use fold;
1415
use ext::base::ext_ctxt;
1516
use ext::build;
1617

@@ -516,3 +517,20 @@ pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr {
516517
pub fn mk_unreachable_arm(cx: @ext_ctxt, span: span) -> ast::arm {
517518
mk_arm(cx, span, ~[mk_pat_wild(cx, span)], mk_unreachable(cx, span))
518519
}
520+
521+
//
522+
// Duplication functions
523+
//
524+
// These functions just duplicate AST nodes.
525+
//
526+
527+
pub fn duplicate_expr(cx: @ext_ctxt, expr: @ast::expr) -> @ast::expr {
528+
let folder = fold::default_ast_fold();
529+
let folder = @fold::AstFoldFns {
530+
new_id: |_| cx.next_id(),
531+
..*folder
532+
};
533+
let folder = fold::make_fold(folder);
534+
folder.fold_expr(expr)
535+
}
536+

branches/try2/src/libsyntax/ext/deriving/rand.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn expand_deriving_rand(cx: @ext_ctxt,
3535
self_ty: None,
3636
args: ~[
3737
Ptr(~Literal(Path::new_local(~"R")),
38-
Borrowed(None, ast::m_imm))
38+
Borrowed(None, ast::m_mutbl))
3939
],
4040
ret_ty: Self,
4141
const_nonmatching: false,
@@ -59,8 +59,10 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr
5959
cx.ident_of(~"rand")
6060
];
6161
let rand_call = || {
62-
build::mk_call_global(cx, span,
63-
copy rand_ident, copy rng)
62+
build::mk_call_global(cx,
63+
span,
64+
copy rand_ident,
65+
~[ build::duplicate_expr(cx, rng[0]) ])
6466
};
6567

6668
return match *substr.fields {
@@ -80,7 +82,10 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr
8082
let rand_name = build::mk_raw_path_(span, copy rand_ident, None, ~[ u32_ty, r_ty ]);
8183
let rand_name = build::mk_path_raw(cx, span, rand_name);
8284

83-
let rv_call = build::mk_call_(cx, span, rand_name, copy rng);
85+
let rv_call = build::mk_call_(cx,
86+
span,
87+
rand_name,
88+
~[ build::duplicate_expr(cx, rng[0]) ]);
8489

8590
// rand() % variants.len()
8691
let rand_variant = build::mk_binary(cx, span, ast::rem,
@@ -133,4 +138,4 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr
133138
}
134139
}
135140
}
136-
}
141+
}

branches/try2/src/libsyntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,3 +859,4 @@ impl AstFoldExtensions for @ast_fold {
859859
pub fn make_fold(afp: ast_fold_fns) -> @ast_fold {
860860
afp as @ast_fold
861861
}
862+

0 commit comments

Comments
 (0)