Skip to content

Commit 4230353

Browse files
debuginfo: Fix regression in namespace handling for struct types.
1 parent a4b0481 commit 4230353

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-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,
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
23+
// lldb-command:p mod1_struct1
24+
// lldb-check:(struct_namespace::mod1::Struct1) $2 = [...]
25+
// lldb-command:p mod1_struct2
26+
// lldb-check:(struct_namespace::mod1::Struct2) $3 = [...]
27+
28+
#![allow(unused_variables)]
29+
#![allow(dead_code)]
30+
#![feature(omit_gdb_pretty_printer_section)]
31+
#![omit_gdb_pretty_printer_section]
32+
33+
struct Struct1 {
34+
a: u32,
35+
b: u64,
36+
}
37+
38+
struct Struct2(u32);
39+
40+
mod mod1 {
41+
42+
pub struct Struct1 {
43+
pub a: u32,
44+
pub b: u64,
45+
}
46+
47+
pub struct Struct2(pub u32);
48+
}
49+
50+
51+
fn main() {
52+
let struct1 = Struct1 {
53+
a: 0,
54+
b: 1,
55+
};
56+
57+
let struct2 = Struct2(2);
58+
59+
let mod1_struct1 = mod1::Struct1 {
60+
a: 3,
61+
b: 4,
62+
};
63+
64+
let mod1_struct2 = mod1::Struct2(5);
65+
66+
zzz(); // #break
67+
}
68+
69+
#[inline(never)]
70+
fn zzz() {()}

0 commit comments

Comments
 (0)