1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
//@ compile-flags:-g
// === GDB TESTS ===================================================================================
// gdb-command:run
// gdb-command:print arg
// gdb-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
// gdb-command:continue
// gdb-command:print inferred
// gdb-check:$2 = 1
// gdb-command:print explicitly
// gdb-check:$3 = 1
// gdb-command:continue
// gdb-command:print arg
// gdb-check:$4 = 2
// gdb-command:continue
// gdb-command:print arg
// gdb-check:$5 = (4, 5)
// gdb-command:continue
// gdb-command:print a
// gdb-check:$6 = 6
// gdb-command:print b
// gdb-check:$7 = 7
// gdb-command:continue
// gdb-command:print a
// gdb-check:$8 = 8
// gdb-command:print b
// gdb-check:$9 = 9
// gdb-command:continue
// === LLDB TESTS ==================================================================================
// lldb-command:run
// lldb-command:v arg
// lldb-check:[...] { b = -1 b1 = 0 }
// lldb-command:continue
// lldb-command:v inferred
// lldb-check:[...] 1
// lldb-command:v explicitly
// lldb-check:[...] 1
// lldb-command:continue
// lldb-command:v arg
// lldb-check:[...] 2
// lldb-command:continue
// lldb-command:v arg
// lldb-check:[...] { 0 = 4 1 = 5 }
// lldb-command:continue
// lldb-command:v a
// lldb-check:[...] 6
// lldb-command:v b
// lldb-check:[...] 7
// lldb-command:continue
// lldb-command:v a
// lldb-check:[...] 8
// lldb-command:v b
// lldb-check:[...] 9
// lldb-command:continue
#![allow(unused_variables)]
#![allow(dead_code)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
trait TraitWithAssocType {
type Type;
fn get_value(&self) -> Self::Type;
}
impl TraitWithAssocType for i32 {
type Type = i64;
fn get_value(&self) -> i64 { *self as i64 }
}
struct Struct<T: TraitWithAssocType> {
b: T,
b1: T::Type,
}
enum Enum<T: TraitWithAssocType> {
Variant1(T, T::Type),
Variant2(T::Type, T)
}
fn assoc_struct<T: TraitWithAssocType>(arg: Struct<T>) {
zzz(); // #break
}
fn assoc_local<T: TraitWithAssocType>(x: T) {
let inferred = x.get_value();
let explicitly: T::Type = x.get_value();
zzz(); // #break
}
fn assoc_arg<T: TraitWithAssocType>(arg: T::Type) {
zzz(); // #break
}
fn assoc_return_value<T: TraitWithAssocType>(arg: T) -> T::Type {
return arg.get_value();
}
fn assoc_tuple<T: TraitWithAssocType>(arg: (T, T::Type)) {
zzz(); // #break
}
fn assoc_enum<T: TraitWithAssocType>(arg: Enum<T>) {
match arg {
Enum::Variant1(a, b) => {
zzz(); // #break
}
Enum::Variant2(a, b) => {
zzz(); // #break
}
}
}
fn main() {
assoc_struct(Struct { b: -1, b1: 0 });
assoc_local(1);
assoc_arg::<i32>(2);
assoc_return_value(3);
assoc_tuple((4, 5));
assoc_enum(Enum::Variant1(6, 7));
assoc_enum(Enum::Variant2(8, 9));
}
fn zzz() { () }
|