Skip to content

Commit 7286845

Browse files
committed
libcore: Fix more merge fallout.
1 parent 3affc6e commit 7286845

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

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

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+

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

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)