2013-06-25 21:54:03 +02: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.
|
|
|
|
|
|
|
|
// compile-flags:-Z extra-debug-info
|
|
|
|
// debugger:break zzz
|
|
|
|
// debugger:run
|
|
|
|
// debugger:finish
|
|
|
|
|
|
|
|
// debugger:print a
|
2013-07-12 10:16:54 +02:00
|
|
|
// check:$1 = 1
|
2013-06-25 21:54:03 +02:00
|
|
|
// debugger:print b
|
|
|
|
// check:$2 = false
|
|
|
|
|
2013-07-12 10:16:54 +02:00
|
|
|
// debugger:print c
|
|
|
|
// check:$3 = 2
|
|
|
|
// debugger:print d
|
|
|
|
// check:$4 = 3
|
|
|
|
// debugger:print e
|
|
|
|
// check:$5 = 4
|
|
|
|
|
|
|
|
// debugger:print f
|
|
|
|
// check:$6 = 5
|
|
|
|
// debugger:print g
|
|
|
|
// check:$7 = {6, 7}
|
|
|
|
|
|
|
|
// debugger:print h
|
|
|
|
// check:$8 = 8
|
|
|
|
// debugger:print i
|
|
|
|
// check:$9 = {a = 9, b = 10}
|
|
|
|
// debugger:print j
|
|
|
|
// check:$10 = 11
|
|
|
|
|
|
|
|
// debugger:print k
|
|
|
|
// check:$11 = 12
|
|
|
|
// debugger:print l
|
|
|
|
// check:$12 = 13
|
|
|
|
|
|
|
|
// debugger:print m
|
|
|
|
// check:$13 = 14
|
|
|
|
// debugger:print n
|
|
|
|
// check:$14 = 16
|
|
|
|
|
|
|
|
// debugger:print o
|
|
|
|
// check:$15 = 18
|
|
|
|
|
|
|
|
// debugger:print p
|
|
|
|
// check:$16 = 19
|
|
|
|
// debugger:print q
|
|
|
|
// check:$17 = 20
|
|
|
|
// debugger:print r
|
|
|
|
// check:$18 = {a = 21, b = 22}
|
|
|
|
|
|
|
|
// debugger:print s
|
|
|
|
// check:$19 = 24
|
|
|
|
// debugger:print t
|
|
|
|
// check:$20 = 23
|
|
|
|
|
|
|
|
// debugger:print u
|
|
|
|
// check:$21 = 25
|
|
|
|
// debugger:print v
|
|
|
|
// check:$22 = 26
|
|
|
|
// debugger:print w
|
|
|
|
// check:$23 = 27
|
|
|
|
// debugger:print x
|
|
|
|
// check:$24 = 28
|
|
|
|
// debugger:print y
|
|
|
|
// check:$25 = 29
|
|
|
|
// debugger:print z
|
|
|
|
// check:$26 = 30
|
|
|
|
// debugger:print ae
|
|
|
|
// check:$27 = 31
|
|
|
|
// debugger:print oe
|
|
|
|
// check:$28 = 32
|
|
|
|
// debugger:print ue
|
|
|
|
// check:$29 = 33
|
|
|
|
|
|
|
|
// debugger:print aa
|
|
|
|
// check:$30 = {34, 35}
|
|
|
|
|
|
|
|
// debugger:print bb
|
|
|
|
// check:$31 = {36, 37}
|
|
|
|
|
|
|
|
// debugger:print cc
|
|
|
|
// check:$32 = 38
|
|
|
|
|
|
|
|
// debugger:print dd
|
|
|
|
// check:$33 = {40, 41, 42}
|
|
|
|
|
|
|
|
// debugger:print *ee
|
|
|
|
// check:$34 = {43, 44, 45}
|
|
|
|
|
|
|
|
// debugger:print *ff
|
|
|
|
// check:$35 = 46
|
|
|
|
|
|
|
|
// debugger:print gg
|
|
|
|
// check:$36 = {47, 48}
|
|
|
|
|
|
|
|
// debugger:print *hh
|
|
|
|
// check:$37 = 50
|
|
|
|
|
|
|
|
// debugger:print ii
|
|
|
|
// check:$38 = 51
|
|
|
|
|
|
|
|
// debugger:print *jj
|
|
|
|
// check:$39 = 52
|
|
|
|
|
|
|
|
// debugger:print kk
|
|
|
|
// check:$40 = 53
|
|
|
|
|
|
|
|
// debugger:print ll
|
|
|
|
// check:$41 = 54
|
|
|
|
|
|
|
|
// debugger:print mm
|
|
|
|
// check:$42 = 55
|
|
|
|
|
|
|
|
// debugger:print *nn
|
|
|
|
// check:$43 = 56
|
|
|
|
|
2013-08-17 08:37:42 -07:00
|
|
|
#[allow(unused_variable)];
|
2013-07-12 10:16:54 +02:00
|
|
|
|
|
|
|
struct Struct {
|
2013-07-25 19:46:57 +02:00
|
|
|
a: i64,
|
|
|
|
b: i32
|
2013-07-12 10:16:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Univariant {
|
|
|
|
Unit(i32)
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TupleStruct (float, int);
|
|
|
|
|
|
|
|
|
2013-06-25 21:54:03 +02:00
|
|
|
fn main() {
|
2013-07-25 19:46:57 +02:00
|
|
|
// simple tuple
|
2013-07-12 10:16:54 +02: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
|
|
|
|
let (m, _, n) = (14, 15, 16);
|
|
|
|
|
|
|
|
// ignored struct field
|
|
|
|
let Struct { b: o, _ } = Struct { a: 17, b: 18 };
|
|
|
|
|
|
|
|
// 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 19:46:57 +02:00
|
|
|
let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
|
2013-07-12 10:16:54 +02:00
|
|
|
|
2013-07-25 19:46:57 +02:00
|
|
|
// complex nesting
|
|
|
|
let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
|
|
|
|
((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
|
2013-07-12 10:16:54 +02:00
|
|
|
|
2013-07-25 19:46:57 +02:00
|
|
|
// managed box
|
|
|
|
let @aa = @(34, 35);
|
2013-07-12 10:16:54 +02:00
|
|
|
|
|
|
|
// borrowed pointer
|
|
|
|
let &bb = &(36, 37);
|
|
|
|
|
|
|
|
// contained borrowed pointer
|
|
|
|
let (&cc, _) = (&38, 39);
|
|
|
|
|
|
|
|
// unique pointer
|
|
|
|
let ~dd = ~(40, 41, 42);
|
|
|
|
|
|
|
|
// ref binding
|
|
|
|
let ref ee = (43, 44, 45);
|
|
|
|
|
|
|
|
// ref binding in tuple
|
|
|
|
let (ref ff, gg) = (46, (47, 48));
|
|
|
|
|
|
|
|
// ref binding in struct
|
|
|
|
let Struct { b: ref hh, _ } = Struct { a: 49, b: 50 };
|
|
|
|
|
|
|
|
// univariant enum
|
|
|
|
let Unit(ii) = Unit(51);
|
|
|
|
|
2013-07-25 19:46:57 +02:00
|
|
|
// univariant enum with ref binding
|
2013-07-12 10:16:54 +02:00
|
|
|
let Unit(ref jj) = Unit(52);
|
|
|
|
|
|
|
|
// tuple struct
|
|
|
|
let TupleStruct(kk, ll) = TupleStruct(53.0, 54);
|
|
|
|
|
|
|
|
// tuple struct with ref binding
|
|
|
|
let TupleStruct(mm, ref nn) = TupleStruct(55.0, 56);
|
2013-06-25 21:54:03 +02:00
|
|
|
|
|
|
|
zzz();
|
|
|
|
}
|
|
|
|
|
2013-08-17 08:37:42 -07:00
|
|
|
fn zzz() {()}
|