]> git.proxmox.com Git - rustc.git/blame - tests/debuginfo/unreachable-locals.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / debuginfo / unreachable-locals.rs
CommitLineData
1a4d82fc
JJ
1// min-lldb-version: 310
2
3// compile-flags:-g
4
5#![allow(unused_variables)]
b039eaaf 6#![feature(omit_gdb_pretty_printer_section)]
1a4d82fc
JJ
7#![omit_gdb_pretty_printer_section]
8
9// No need to actually run the debugger, just make sure that the compiler can
10// handle locals in unreachable code.
11
12fn after_return() {
13 return;
14 let x = "0";
15 let (ref y,z) = (1i32, 2u32);
16 match (20i32, 'c') {
17 (a, ref b) => {}
18 }
85aaf69f 19 for a in &[111i32] {}
c34b1796
AL
20 let test = if some_predicate() { 1 } else { 2 };
21 while some_predicate() {
22 let abc = !some_predicate();
23 }
24 loop {
25 let abc = !some_predicate();
26 break;
27 }
28 // nested block
29 {
30 let abc = !some_predicate();
31
32 {
33 let def = !some_predicate();
34 }
35 }
1a4d82fc
JJ
36}
37
38fn after_panic() {
39 panic!();
40 let x = "0";
41 let (ref y,z) = (1i32, 2u32);
42 match (20i32, 'c') {
43 (a, ref b) => {}
44 }
85aaf69f 45 for a in &[111i32] {}
c34b1796
AL
46 let test = if some_predicate() { 1 } else { 2 };
47 while some_predicate() {
48 let abc = !some_predicate();
49 }
50 loop {
51 let abc = !some_predicate();
52 break;
53 }
54 // nested block
55 {
56 let abc = !some_predicate();
57
58 {
59 let def = !some_predicate();
60 }
61 }
1a4d82fc
JJ
62}
63
64fn after_diverging_function() {
65 diverge();
66 let x = "0";
67 let (ref y,z) = (1i32, 2u32);
68 match (20i32, 'c') {
69 (a, ref b) => {}
70 }
85aaf69f 71 for a in &[111i32] {}
c34b1796
AL
72 let test = if some_predicate() { 1 } else { 2 };
73 while some_predicate() {
74 let abc = !some_predicate();
75 }
76 loop {
77 let abc = !some_predicate();
78 break;
79 }
80 // nested block
81 {
82 let abc = !some_predicate();
83
84 {
85 let def = !some_predicate();
86 }
87 }
1a4d82fc
JJ
88}
89
90fn after_break() {
91 loop {
92 break;
93 let x = "0";
94 let (ref y,z) = (1i32, 2u32);
95 match (20i32, 'c') {
96 (a, ref b) => {}
97 }
85aaf69f 98 for a in &[111i32] {}
c34b1796
AL
99 let test = if some_predicate() { 1 } else { 2 };
100 while some_predicate() {
101 let abc = !some_predicate();
102 }
103 loop {
104 let abc = !some_predicate();
105 break;
106 }
107 // nested block
108 {
109 let abc = !some_predicate();
110
111 {
112 let def = !some_predicate();
113 }
114 }
1a4d82fc
JJ
115 }
116}
117
118fn after_continue() {
85aaf69f 119 for _ in 0..10i32 {
c34b1796 120 continue;
1a4d82fc
JJ
121 let x = "0";
122 let (ref y,z) = (1i32, 2u32);
123 match (20i32, 'c') {
124 (a, ref b) => {}
125 }
85aaf69f 126 for a in &[111i32] {}
c34b1796
AL
127 let test = if some_predicate() { 1 } else { 2 };
128 while some_predicate() {
129 let abc = !some_predicate();
130 }
131 loop {
132 let abc = !some_predicate();
133 break;
134 }
135 // nested block
136 {
137 let abc = !some_predicate();
138
139 {
140 let def = !some_predicate();
141 }
142 }
1a4d82fc
JJ
143 }
144}
145
146fn main() {
147 after_return();
148 after_panic();
149 after_diverging_function();
150 after_break();
151 after_continue();
152}
153
154fn diverge() -> ! {
155 panic!();
156}
c34b1796
AL
157
158fn some_predicate() -> bool { true || false }