commit
c83bceddbb
@ -79,11 +79,12 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
|
|||||||
let variant_count = cx.expr_uint(span, variants.len());
|
let variant_count = cx.expr_uint(span, variants.len());
|
||||||
|
|
||||||
// need to specify the uint-ness of the random number
|
// need to specify the uint-ness of the random number
|
||||||
let u32_ty = cx.ty_ident(span, cx.ident_of("uint"));
|
let uint_ty = cx.ty_ident(span, cx.ident_of("uint"));
|
||||||
let r_ty = cx.ty_ident(span, cx.ident_of("R"));
|
let r_ty = cx.ty_ident(span, cx.ident_of("R"));
|
||||||
let rand_name = cx.path_all(span, false, copy rand_ident, None, ~[ u32_ty, r_ty ]);
|
let rand_name = cx.path_all(span, true, copy rand_ident, None, ~[ uint_ty, r_ty ]);
|
||||||
let rand_name = cx.expr_path(rand_name);
|
let rand_name = cx.expr_path(rand_name);
|
||||||
|
|
||||||
|
// ::std::rand::Rand::rand::<uint>(rng)
|
||||||
let rv_call = cx.expr_call(span,
|
let rv_call = cx.expr_call(span,
|
||||||
rand_name,
|
rand_name,
|
||||||
~[ rng[0].duplicate(cx) ]);
|
~[ rng[0].duplicate(cx) ]);
|
||||||
|
41
src/test/run-pass/deriving-global.rs
Normal file
41
src/test/run-pass/deriving-global.rs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// xfail-test #7103 `extern mod` does not work on windows
|
||||||
|
|
||||||
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
extern mod extra; // {En,De}codable
|
||||||
|
mod submod {
|
||||||
|
// if any of these are implemented without global calls for any
|
||||||
|
// function calls, then being in a submodule will (correctly)
|
||||||
|
// cause errors about unrecognised module `std` (or `extra`)
|
||||||
|
#[deriving(Eq, Ord, TotalEq, TotalOrd,
|
||||||
|
IterBytes,
|
||||||
|
Clone, DeepClone,
|
||||||
|
ToStr, Rand,
|
||||||
|
Encodable, Decodable)]
|
||||||
|
enum A { A1(uint), A2(int) }
|
||||||
|
|
||||||
|
#[deriving(Eq, Ord, TotalEq, TotalOrd,
|
||||||
|
IterBytes,
|
||||||
|
Clone, DeepClone,
|
||||||
|
ToStr, Rand,
|
||||||
|
Encodable, Decodable)]
|
||||||
|
struct B { x: uint, y: int }
|
||||||
|
|
||||||
|
#[deriving(Eq, Ord, TotalEq, TotalOrd,
|
||||||
|
IterBytes,
|
||||||
|
Clone, DeepClone,
|
||||||
|
ToStr, Rand,
|
||||||
|
Encodable, Decodable)]
|
||||||
|
struct C(uint, int);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user