Skip to content

Commit 8122f22

Browse files
---
yaml --- r: 63769 b: refs/heads/snap-stage3 c: 168eba9 h: refs/heads/master i: 63767: d487488 v: v3
1 parent 60f1678 commit 8122f22

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 0b5fef3b267510dc9abd890f80b076f11543a919
4+
refs/heads/snap-stage3: 168eba9201011e34a70febc8395d5e0808585600
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
// debugger:finish
17+
// debugger:print simple
18+
// check:$1 = {x = 10, y = 20}
19+
20+
// debugger:print noDestructor
21+
// check:$2 = {a = {x = 10, y = 20}, guard = -1}
22+
23+
// debugger:print withDestructor
24+
// check:$3 = {a = {x = 10, y = 20}, guard = -1}
25+
26+
struct NoDestructor {
27+
x : i32,
28+
y : i64
29+
}
30+
31+
struct WithDestructor {
32+
x : i32,
33+
y : i64
34+
}
35+
36+
impl Drop for WithDestructor {
37+
fn finalize(&self) {}
38+
}
39+
40+
struct NoDestructorGuarded
41+
{
42+
a: NoDestructor,
43+
guard: i64
44+
}
45+
46+
struct WithDestructorGuarded
47+
{
48+
a: WithDestructor,
49+
guard: i64
50+
}
51+
52+
53+
// The compiler adds a 'destructed' boolean field to structs implementing Drop. This field is used
54+
// at runtime to prevent finalize() to be executed more than once (see middle::trans::adt).
55+
// This field must be incorporated by the debug info generation. Otherwise the debugger assumes a
56+
// wrong size/layout for the struct.
57+
fn main() {
58+
59+
let simple = WithDestructor { x: 10, y: 20 };
60+
61+
let noDestructor = NoDestructorGuarded {
62+
a: NoDestructor { x: 10, y: 20 },
63+
guard: -1
64+
};
65+
66+
// If the destructor flag field is not incorporated into the debug info for 'WithDestructor'
67+
// then the debugger will have an invalid offset for the field 'guard' and thus should not be
68+
// able to read its value correctly.
69+
let withDestructor = WithDestructorGuarded {
70+
a: WithDestructor { x: 10, y: 20 },
71+
guard: -1
72+
};
73+
74+
zzz();
75+
}
76+
77+
fn zzz() {()}

0 commit comments

Comments
 (0)