Skip to content

Commit 58ad12b

Browse files
---
yaml --- r: 67039 b: refs/heads/master c: 7cf0aac h: refs/heads/master i: 67037: 3c72acd 67035: affe88b 67031: 5befe91 67023: b120c7e 67007: e888bd1 v: v3
1 parent b3e174e commit 58ad12b

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f389bd8f2a72020c25e37b81757643abd481bc11
2+
refs/heads/master: 7cf0aac6cf2435e068c4bd62cd34e06f8ef0bd91
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/librustc/middle/trans/debuginfo.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,22 @@ fn create_enum_md(cx: &mut CrateContext,
606606
return discriminant_type_md;
607607
}
608608

609+
let is_univariant = variants.len() == 1;
610+
609611
let variants_md = do variants.map |&vi| {
610612

611613
let raw_types : &[ty::t] = vi.args;
612614
let arg_types = do raw_types.map |&raw_type| { ty::subst(cx.tcx, substs, raw_type) };
613-
let arg_llvm_types = ~[discriminant_llvm_type] + do arg_types.map |&ty| { type_of::type_of(cx, ty) };
614-
let arg_names = ~[~""] + arg_types.map(|_| ~"");
615-
let arg_md = ~[discriminant_type_md] + do arg_types.map |&ty| { get_or_create_type(cx, ty, span) };
615+
616+
let mut arg_llvm_types = do arg_types.map |&ty| { type_of::type_of(cx, ty) };
617+
let mut arg_names = arg_types.map(|_| ~"");
618+
let mut arg_md = do arg_types.map |&ty| { get_or_create_type(cx, ty, span) };
619+
620+
if !is_univariant {
621+
arg_llvm_types.insert(0, discriminant_llvm_type);
622+
arg_names.insert(0, ~"");
623+
arg_md.insert(0, discriminant_type_md);
624+
}
616625

617626
let variant_llvm_type = Type::struct_(arg_llvm_types, false);
618627
let variant_type_size = machine::llsize_of_alloc(cx, variant_llvm_type);
@@ -646,7 +655,7 @@ fn create_enum_md(cx: &mut CrateContext,
646655
let enum_type_size = machine::llsize_of_alloc(cx, enum_llvm_type);
647656
let enum_type_align = machine::llalign_of_min(cx, enum_llvm_type);
648657

649-
return do "".as_c_str |enum_name| { unsafe { llvm::LLVMDIBuilderCreateUnionType(
658+
return do enum_name.as_c_str |enum_name| { unsafe { llvm::LLVMDIBuilderCreateUnionType(
650659
DIB(cx),
651660
file_metadata,
652661
enum_name,

trunk/src/test/debug-info/tuple-style-enum.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,29 @@
1414
// debugger:run
1515
// debugger:finish
1616

17-
// debugger:print case2
18-
// check:$1 = {Case1, 0, 1}
17+
// d ebugger:print case2
18+
// c heck:$1 = {Case1, 0, 1}
1919

20-
enum Test {
20+
// debugger:print univariant
21+
// check:$1 = {{-1}}
22+
23+
24+
enum Regular {
2125
Case1(i32, i64),
2226
Case2(bool, i16, i32)
2327
}
2428

29+
enum Univariant {
30+
TheOnlyCase(i64)
31+
}
32+
2533
fn main() {
2634

2735
let case1 = Case1(110, 220);
2836
let case2 = Case2(false, 2, 3);
2937

38+
let univariant = TheOnlyCase(-1);
39+
3040
zzz();
3141
}
3242

0 commit comments

Comments
 (0)