2013-07-15 08:48:57 -05:00
|
|
|
// 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.
|
|
|
|
|
2013-11-04 00:53:01 -06:00
|
|
|
// xfail-android
|
|
|
|
|
2013-07-15 08:48:57 -05:00
|
|
|
// compile-flags:-Z extra-debug-info
|
2013-09-06 09:00:08 -05:00
|
|
|
// debugger:rbreak zzz
|
2013-07-15 08:48:57 -05:00
|
|
|
// debugger:run
|
|
|
|
// debugger:finish
|
|
|
|
|
|
|
|
// debugger:print some
|
|
|
|
// check:$1 = {0x12345678}
|
|
|
|
|
|
|
|
// debugger:print none
|
|
|
|
// check:$2 = {0x0}
|
|
|
|
|
|
|
|
// debugger:print full
|
|
|
|
// check:$3 = {454545, 0x87654321, 9988}
|
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
// debugger:print empty->discr
|
|
|
|
// check:$4 = (int *) 0x0
|
2013-07-15 08:48:57 -05:00
|
|
|
|
|
|
|
// debugger:print droid
|
|
|
|
// check:$5 = {id = 675675, range = 10000001, internals = 0x43218765}
|
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
// debugger:print void_droid->internals
|
|
|
|
// check:$6 = (int *) 0x0
|
2013-07-15 08:48:57 -05:00
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
// debugger:continue
|
2013-07-15 08:48:57 -05:00
|
|
|
|
2013-10-02 22:00:54 -05:00
|
|
|
#[feature(struct_variant)];
|
|
|
|
|
2013-07-15 08:48:57 -05:00
|
|
|
// If a struct has exactly two variants, one of them is empty, and the other one
|
|
|
|
// contains a non-nullable pointer, then this value is used as the discriminator.
|
|
|
|
// The test cases in this file make sure that something readable is generated for
|
|
|
|
// this kind of types.
|
2013-08-08 07:14:52 -05:00
|
|
|
// Unfortunately (for these test cases) the content of the non-discriminant fields
|
|
|
|
// in the null-case is not defined. So we just read the discriminator field in
|
|
|
|
// this case (by casting the value to a memory-equivalent struct).
|
2013-07-15 08:48:57 -05:00
|
|
|
|
|
|
|
enum MoreFields<'self> {
|
|
|
|
Full(u32, &'self int, i16),
|
|
|
|
Empty
|
|
|
|
}
|
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
struct MoreFieldsRepr<'self> {
|
|
|
|
a: u32,
|
|
|
|
discr: &'self int,
|
|
|
|
b: i16
|
|
|
|
}
|
|
|
|
|
2013-07-15 08:48:57 -05:00
|
|
|
enum NamedFields<'self> {
|
|
|
|
Droid { id: i32, range: i64, internals: &'self int },
|
|
|
|
Void
|
|
|
|
}
|
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
struct NamedFieldsRepr<'self> {
|
|
|
|
id: i32,
|
|
|
|
range: i64,
|
|
|
|
internals: &'self int
|
|
|
|
}
|
|
|
|
|
2013-07-15 08:48:57 -05:00
|
|
|
fn main() {
|
|
|
|
|
2013-07-16 05:17:55 -05:00
|
|
|
let some: Option<&u32> = Some(unsafe { std::cast::transmute(0x12345678) });
|
|
|
|
let none: Option<&u32> = None;
|
2013-07-15 08:48:57 -05:00
|
|
|
|
|
|
|
let full = Full(454545, unsafe { std::cast::transmute(0x87654321) }, 9988);
|
|
|
|
|
|
|
|
let int_val = 0;
|
2013-08-08 07:14:52 -05:00
|
|
|
let empty: &MoreFieldsRepr = unsafe { std::cast::transmute(&Empty) };
|
2013-07-15 08:48:57 -05:00
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
let droid = Droid {
|
|
|
|
id: 675675,
|
|
|
|
range: 10000001,
|
|
|
|
internals: unsafe { std::cast::transmute(0x43218765) }
|
|
|
|
};
|
2013-07-15 08:48:57 -05:00
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
let void_droid: &NamedFieldsRepr = unsafe { std::cast::transmute(&Void) };
|
2013-07-15 08:48:57 -05:00
|
|
|
|
|
|
|
zzz();
|
|
|
|
}
|
|
|
|
|
2013-08-08 07:14:52 -05:00
|
|
|
fn zzz() {()}
|