Skip to content

Commit a17248f

Browse files
---
yaml --- r: 143044 b: refs/heads/try2 c: 7cf0aac h: refs/heads/master v: v3
1 parent cbcea63 commit a17248f

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f389bd8f2a72020c25e37b81757643abd481bc11
8+
refs/heads/try2: 7cf0aac6cf2435e068c4bd62cd34e06f8ef0bd91
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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,

branches/try2/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)