2014-02-07 19:08:32 +00:00
|
|
|
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
2013-06-25 19:54:03 +00:00
|
|
|
// 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.
|
|
|
|
|
2014-02-07 19:08:32 +00:00
|
|
|
// ignore-android: FIXME(#10381)
|
2014-10-09 14:31:03 +00:00
|
|
|
// min-lldb-version: 310
|
2013-12-13 23:45:08 +00:00
|
|
|
|
2014-02-07 03:57:09 +00:00
|
|
|
// compile-flags:-g
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === GDB TESTS ===================================================================================
|
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:rbreak zzz
|
|
|
|
// gdb-command:run
|
|
|
|
// gdb-command:finish
|
|
|
|
|
|
|
|
// gdb-command:print a
|
|
|
|
// gdb-check:$1 = 1
|
|
|
|
// gdb-command:print b
|
|
|
|
// gdb-check:$2 = false
|
|
|
|
|
|
|
|
// gdb-command:print c
|
|
|
|
// gdb-check:$3 = 2
|
|
|
|
// gdb-command:print d
|
|
|
|
// gdb-check:$4 = 3
|
|
|
|
// gdb-command:print e
|
|
|
|
// gdb-check:$5 = 4
|
|
|
|
|
|
|
|
// gdb-command:print f
|
|
|
|
// gdb-check:$6 = 5
|
|
|
|
// gdb-command:print g
|
|
|
|
// gdb-check:$7 = {6, 7}
|
|
|
|
|
|
|
|
// gdb-command:print h
|
|
|
|
// gdb-check:$8 = 8
|
|
|
|
// gdb-command:print i
|
|
|
|
// gdb-check:$9 = {a = 9, b = 10}
|
|
|
|
// gdb-command:print j
|
|
|
|
// gdb-check:$10 = 11
|
|
|
|
|
|
|
|
// gdb-command:print k
|
|
|
|
// gdb-check:$11 = 12
|
|
|
|
// gdb-command:print l
|
|
|
|
// gdb-check:$12 = 13
|
|
|
|
|
|
|
|
// gdb-command:print m
|
|
|
|
// gdb-check:$13 = 14
|
|
|
|
// gdb-command:print n
|
|
|
|
// gdb-check:$14 = 16
|
|
|
|
|
|
|
|
// gdb-command:print o
|
|
|
|
// gdb-check:$15 = 18
|
|
|
|
|
|
|
|
// gdb-command:print p
|
|
|
|
// gdb-check:$16 = 19
|
|
|
|
// gdb-command:print q
|
|
|
|
// gdb-check:$17 = 20
|
|
|
|
// gdb-command:print r
|
|
|
|
// gdb-check:$18 = {a = 21, b = 22}
|
|
|
|
|
|
|
|
// gdb-command:print s
|
|
|
|
// gdb-check:$19 = 24
|
|
|
|
// gdb-command:print t
|
|
|
|
// gdb-check:$20 = 23
|
|
|
|
|
|
|
|
// gdb-command:print u
|
|
|
|
// gdb-check:$21 = 25
|
|
|
|
// gdb-command:print v
|
|
|
|
// gdb-check:$22 = 26
|
|
|
|
// gdb-command:print w
|
|
|
|
// gdb-check:$23 = 27
|
|
|
|
// gdb-command:print x
|
|
|
|
// gdb-check:$24 = 28
|
|
|
|
// gdb-command:print y
|
|
|
|
// gdb-check:$25 = 29
|
|
|
|
// gdb-command:print z
|
|
|
|
// gdb-check:$26 = 30
|
|
|
|
// gdb-command:print ae
|
|
|
|
// gdb-check:$27 = 31
|
|
|
|
// gdb-command:print oe
|
|
|
|
// gdb-check:$28 = 32
|
|
|
|
// gdb-command:print ue
|
|
|
|
// gdb-check:$29 = 33
|
|
|
|
|
|
|
|
// gdb-command:print aa
|
|
|
|
// gdb-check:$30 = {34, 35}
|
|
|
|
|
|
|
|
// gdb-command:print bb
|
|
|
|
// gdb-check:$31 = {36, 37}
|
|
|
|
|
|
|
|
// gdb-command:print cc
|
|
|
|
// gdb-check:$32 = 38
|
|
|
|
|
|
|
|
// gdb-command:print dd
|
|
|
|
// gdb-check:$33 = {40, 41, 42}
|
|
|
|
|
|
|
|
// gdb-command:print *ee
|
|
|
|
// gdb-check:$34 = {43, 44, 45}
|
|
|
|
|
|
|
|
// gdb-command:print *ff
|
|
|
|
// gdb-check:$35 = 46
|
|
|
|
|
|
|
|
// gdb-command:print gg
|
|
|
|
// gdb-check:$36 = {47, 48}
|
|
|
|
|
|
|
|
// gdb-command:print *hh
|
|
|
|
// gdb-check:$37 = 50
|
|
|
|
|
|
|
|
// gdb-command:print ii
|
|
|
|
// gdb-check:$38 = 51
|
|
|
|
|
|
|
|
// gdb-command:print *jj
|
|
|
|
// gdb-check:$39 = 52
|
|
|
|
|
|
|
|
// gdb-command:print kk
|
|
|
|
// gdb-check:$40 = 53
|
|
|
|
|
|
|
|
// gdb-command:print ll
|
|
|
|
// gdb-check:$41 = 54
|
|
|
|
|
|
|
|
// gdb-command:print mm
|
|
|
|
// gdb-check:$42 = 55
|
|
|
|
|
|
|
|
// gdb-command:print *nn
|
|
|
|
// gdb-check:$43 = 56
|
2013-07-12 08:16:54 +00:00
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
|
|
|
|
// lldb-command:run
|
|
|
|
|
|
|
|
// lldb-command:print a
|
|
|
|
// lldb-check:[...]$0 = 1
|
|
|
|
// lldb-command:print b
|
|
|
|
// lldb-check:[...]$1 = false
|
|
|
|
|
|
|
|
// lldb-command:print c
|
|
|
|
// lldb-check:[...]$2 = 2
|
|
|
|
// lldb-command:print d
|
|
|
|
// lldb-check:[...]$3 = 3
|
|
|
|
// lldb-command:print e
|
|
|
|
// lldb-check:[...]$4 = 4
|
|
|
|
|
|
|
|
// lldb-command:print f
|
|
|
|
// lldb-check:[...]$5 = 5
|
|
|
|
// lldb-command:print g
|
|
|
|
// lldb-check:[...]$6 = (6, 7)
|
|
|
|
|
|
|
|
// lldb-command:print h
|
|
|
|
// lldb-check:[...]$7 = 8
|
|
|
|
// lldb-command:print i
|
|
|
|
// lldb-check:[...]$8 = Struct { a: 9, b: 10 }
|
|
|
|
// lldb-command:print j
|
|
|
|
// lldb-check:[...]$9 = 11
|
|
|
|
|
|
|
|
// lldb-command:print k
|
|
|
|
// lldb-check:[...]$10 = 12
|
|
|
|
// lldb-command:print l
|
|
|
|
// lldb-check:[...]$11 = 13
|
|
|
|
|
|
|
|
// lldb-command:print m
|
|
|
|
// lldb-check:[...]$12 = 14
|
|
|
|
// lldb-command:print n
|
|
|
|
// lldb-check:[...]$13 = 16
|
|
|
|
|
|
|
|
// lldb-command:print o
|
|
|
|
// lldb-check:[...]$14 = 18
|
|
|
|
|
|
|
|
// lldb-command:print p
|
|
|
|
// lldb-check:[...]$15 = 19
|
|
|
|
// lldb-command:print q
|
|
|
|
// lldb-check:[...]$16 = 20
|
|
|
|
// lldb-command:print r
|
|
|
|
// lldb-check:[...]$17 = Struct { a: 21, b: 22 }
|
|
|
|
|
|
|
|
// lldb-command:print s
|
|
|
|
// lldb-check:[...]$18 = 24
|
|
|
|
// lldb-command:print t
|
|
|
|
// lldb-check:[...]$19 = 23
|
|
|
|
|
|
|
|
// lldb-command:print u
|
|
|
|
// lldb-check:[...]$20 = 25
|
|
|
|
// lldb-command:print v
|
|
|
|
// lldb-check:[...]$21 = 26
|
|
|
|
// lldb-command:print w
|
|
|
|
// lldb-check:[...]$22 = 27
|
|
|
|
// lldb-command:print x
|
|
|
|
// lldb-check:[...]$23 = 28
|
|
|
|
// lldb-command:print y
|
|
|
|
// lldb-check:[...]$24 = 29
|
|
|
|
// lldb-command:print z
|
|
|
|
// lldb-check:[...]$25 = 30
|
|
|
|
// lldb-command:print ae
|
|
|
|
// lldb-check:[...]$26 = 31
|
|
|
|
// lldb-command:print oe
|
|
|
|
// lldb-check:[...]$27 = 32
|
|
|
|
// lldb-command:print ue
|
|
|
|
// lldb-check:[...]$28 = 33
|
|
|
|
|
|
|
|
// lldb-command:print aa
|
|
|
|
// lldb-check:[...]$29 = (34, 35)
|
|
|
|
|
|
|
|
// lldb-command:print bb
|
|
|
|
// lldb-check:[...]$30 = (36, 37)
|
|
|
|
|
|
|
|
// lldb-command:print cc
|
|
|
|
// lldb-check:[...]$31 = 38
|
|
|
|
|
|
|
|
// lldb-command:print dd
|
|
|
|
// lldb-check:[...]$32 = (40, 41, 42)
|
|
|
|
|
|
|
|
// lldb-command:print *ee
|
|
|
|
// lldb-check:[...]$33 = (43, 44, 45)
|
|
|
|
|
|
|
|
// lldb-command:print *ff
|
|
|
|
// lldb-check:[...]$34 = 46
|
|
|
|
|
|
|
|
// lldb-command:print gg
|
|
|
|
// lldb-check:[...]$35 = (47, 48)
|
|
|
|
|
|
|
|
// lldb-command:print *hh
|
|
|
|
// lldb-check:[...]$36 = 50
|
|
|
|
|
|
|
|
// lldb-command:print ii
|
|
|
|
// lldb-check:[...]$37 = 51
|
|
|
|
|
|
|
|
// lldb-command:print *jj
|
|
|
|
// lldb-check:[...]$38 = 52
|
|
|
|
|
|
|
|
// lldb-command:print kk
|
|
|
|
// lldb-check:[...]$39 = 53
|
|
|
|
|
|
|
|
// lldb-command:print ll
|
|
|
|
// lldb-check:[...]$40 = 54
|
|
|
|
|
|
|
|
// lldb-command:print mm
|
|
|
|
// lldb-check:[...]$41 = 55
|
|
|
|
|
|
|
|
// lldb-command:print *nn
|
|
|
|
// lldb-check:[...]$42 = 56
|
|
|
|
|
|
|
|
|
2014-04-14 15:30:31 +00:00
|
|
|
#![allow(unused_variable)]
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
struct Struct {
|
2013-07-25 17:46:57 +00:00
|
|
|
a: i64,
|
|
|
|
b: i32
|
2013-07-12 08:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Univariant {
|
|
|
|
Unit(i32)
|
|
|
|
}
|
|
|
|
|
2013-09-26 06:26:09 +00:00
|
|
|
struct TupleStruct (f64, int);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
|
2013-06-25 19:54:03 +00:00
|
|
|
fn main() {
|
2013-07-25 17:46:57 +00:00
|
|
|
// simple tuple
|
2013-07-12 08:16:54 +00:00
|
|
|
let (a, b) : (int, bool) = (1, false);
|
|
|
|
|
|
|
|
// nested tuple
|
|
|
|
let (c, (d, e)) : (int, (u16, u16)) = (2, (3, 4));
|
|
|
|
|
|
|
|
// bind tuple-typed value to one name (destructure only first level)
|
|
|
|
let (f, g) : (int, (u32, u32)) = (5, (6, 7));
|
|
|
|
|
|
|
|
// struct as tuple element
|
|
|
|
let (h, i, j) : (i16, Struct, i16) = (8, Struct { a: 9, b: 10 }, 11);
|
|
|
|
|
|
|
|
// struct pattern
|
|
|
|
let Struct { a: k, b: l } = Struct { a: 12, b: 13 };
|
|
|
|
|
|
|
|
// ignored tuple element
|
2014-06-27 19:30:25 +00:00
|
|
|
let (m, _, n) = (14i, 15i, 16i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// ignored struct field
|
2013-11-28 20:22:53 +00:00
|
|
|
let Struct { b: o, .. } = Struct { a: 17, b: 18 };
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// one struct destructured, one not
|
|
|
|
let (Struct { a: p, b: q }, r) = (Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 });
|
|
|
|
|
|
|
|
// different order of struct fields
|
2013-07-25 17:46:57 +00:00
|
|
|
let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
|
2013-07-12 08:16:54 +00:00
|
|
|
|
2013-07-25 17:46:57 +00:00
|
|
|
// complex nesting
|
|
|
|
let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
|
2014-06-27 19:30:25 +00:00
|
|
|
((25i, 26i), ((27i, (28i, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
2014-01-03 23:08:48 +00:00
|
|
|
// reference
|
2014-06-27 19:30:25 +00:00
|
|
|
let &aa = &(34i, 35i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
2014-01-08 02:49:13 +00:00
|
|
|
// reference
|
2014-06-27 19:30:25 +00:00
|
|
|
let &bb = &(36i, 37i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
2014-01-08 02:49:13 +00:00
|
|
|
// contained reference
|
2014-06-27 19:30:25 +00:00
|
|
|
let (&cc, _) = (&38i, 39i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// unique pointer
|
2014-06-27 19:30:25 +00:00
|
|
|
let box dd = box() (40i, 41i, 42i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// ref binding
|
2014-06-27 19:30:25 +00:00
|
|
|
let ref ee = (43i, 44i, 45i);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// ref binding in tuple
|
2014-06-27 19:30:25 +00:00
|
|
|
let (ref ff, gg) = (46i, (47i, 48i));
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// ref binding in struct
|
2013-11-28 20:22:53 +00:00
|
|
|
let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// univariant enum
|
|
|
|
let Unit(ii) = Unit(51);
|
|
|
|
|
2013-07-25 17:46:57 +00:00
|
|
|
// univariant enum with ref binding
|
2014-01-17 13:03:43 +00:00
|
|
|
let &Unit(ref jj) = &Unit(52);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// tuple struct
|
2014-01-17 13:03:43 +00:00
|
|
|
let &TupleStruct(kk, ll) = &TupleStruct(53.0, 54);
|
2013-07-12 08:16:54 +00:00
|
|
|
|
|
|
|
// tuple struct with ref binding
|
2014-01-17 13:03:43 +00:00
|
|
|
let &TupleStruct(mm, ref nn) = &TupleStruct(55.0, 56);
|
2013-06-25 19:54:03 +00:00
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
zzz(); // #break
|
2013-06-25 19:54:03 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
fn zzz() { () }
|