Skip to content

Commit a7db349

Browse files
committed
---
yaml --- r: 60128 b: refs/heads/master c: 7286845 h: refs/heads/master v: v3
1 parent 5efe764 commit a7db349

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3affc6ed4071a183da81bcc2048fff82d3e35e81
2+
refs/heads/master: 72868450df54ff1ec80e92e3f2fc827cfb1e9f02
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/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+
}

trunk/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+

trunk/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+
}

trunk/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)