Skip to content

Commit 2abf281

Browse files
committed
Auto merge of #33225 - michaelwoerister:fix-debuginfo-struct-ns, r=eddyb
debuginfo: Fix regression in namespace handling for struct types. Fixes a small regression that has been introduced in recent refactorings. Fixes #33193 r? @eddyb
2 parents 8da2bca + 6074463 commit 2abf281

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

src/librustc_trans/debuginfo/metadata.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1159,12 +1159,12 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
11591159
let struct_name = compute_debuginfo_type_name(cx, struct_type, false);
11601160
let struct_llvm_type = type_of::in_memory_type_of(cx, struct_type);
11611161

1162-
let (variant, substs) = match struct_type.sty {
1163-
ty::TyStruct(def, substs) => (def.struct_variant(), substs),
1162+
let (struct_def_id, variant, substs) = match struct_type.sty {
1163+
ty::TyStruct(def, substs) => (def.did, def.struct_variant(), substs),
11641164
_ => bug!("prepare_struct_metadata on a non-struct")
11651165
};
11661166

1167-
let (containing_scope, _) = get_namespace_and_span_for_item(cx, variant.did);
1167+
let (containing_scope, _) = get_namespace_and_span_for_item(cx, struct_def_id);
11681168

11691169
let struct_metadata_stub = create_struct_stub(cx,
11701170
struct_llvm_type,
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2013-2016 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+
// ignore-gdb
12+
// compile-flags:-g
13+
// min-lldb-version: 310
14+
15+
// Check that structs get placed in the correct namespace
16+
17+
// lldb-command:run
18+
// lldb-command:p struct1
19+
// lldb-check:(struct_namespace::Struct1) $0 = [...]
20+
// lldb-command:p struct2
21+
// lldb-check:(struct_namespace::Struct2) $1 = [...]
22+
// lldb-command:p struct3
23+
// lldb-check:(struct_namespace::Struct3) $2 = [...]
24+
25+
// lldb-command:p mod1_struct1
26+
// lldb-check:(struct_namespace::mod1::Struct1) $3 = [...]
27+
// lldb-command:p mod1_struct2
28+
// lldb-check:(struct_namespace::mod1::Struct2) $4 = [...]
29+
// lldb-command:p mod1_struct3
30+
// lldb-check:(struct_namespace::mod1::Struct3) $5 = [...]
31+
32+
#![allow(unused_variables)]
33+
#![allow(dead_code)]
34+
#![feature(omit_gdb_pretty_printer_section)]
35+
#![omit_gdb_pretty_printer_section]
36+
37+
struct Struct1;
38+
struct Struct2 {
39+
a: u32,
40+
b: u64,
41+
}
42+
struct Struct3(u32);
43+
44+
mod mod1 {
45+
46+
pub struct Struct1;
47+
pub struct Struct2 {
48+
pub a: u32,
49+
pub b: u64,
50+
}
51+
pub struct Struct3(pub u32);
52+
}
53+
54+
55+
fn main() {
56+
let struct1 = Struct1;
57+
let struct2 = Struct2 {
58+
a: 0,
59+
b: 1,
60+
};
61+
let struct3 = Struct3(2);
62+
63+
let mod1_struct1 = mod1::Struct1;
64+
let mod1_struct2 = mod1::Struct2 {
65+
a: 3,
66+
b: 4,
67+
};
68+
let mod1_struct3 = mod1::Struct3(5);
69+
70+
zzz(); // #break
71+
}
72+
73+
#[inline(never)]
74+
fn zzz() {()}

0 commit comments

Comments
 (0)