Skip to content

Commit 745a020

Browse files
jldcatamorphism
authored andcommitted
Make () actually size 0
1 parent d5dc66a commit 745a020

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/librustc/middle/trans/common.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -722,28 +722,13 @@ impl block {
722722

723723
// LLVM type constructors.
724724
fn T_void() -> TypeRef {
725-
// Note: For the time being llvm is kinda busted here, it has the notion
726-
// of a 'void' type that can only occur as part of the signature of a
727-
// function, but no general unit type of 0-sized value. This is, afaict,
728-
// vestigial from its C heritage, and we'll be attempting to submit a
729-
// patch upstream to fix it. In the mean time we only model function
730-
// outputs (Rust functions and C functions) using T_void, and model the
731-
// Rust general purpose nil type you can construct as 1-bit (always
732-
// zero). This makes the result incorrect for now -- things like a tuple
733-
// of 10 nil values will have 10-bit size -- but it doesn't seem like we
734-
// have any other options until it's fixed upstream.
735-
736725
unsafe {
737726
return llvm::LLVMVoidType();
738727
}
739728
}
740729

741730
fn T_nil() -> TypeRef {
742-
// NB: See above in T_void().
743-
744-
unsafe {
745-
return llvm::LLVMInt1Type();
746-
}
731+
return T_struct(~[])
747732
}
748733

749734
fn T_metadata() -> TypeRef { unsafe { return llvm::LLVMMetadataType(); } }
@@ -1098,9 +1083,7 @@ fn C_floating(s: ~str, t: TypeRef) -> ValueRef {
10981083
}
10991084

11001085
fn C_nil() -> ValueRef {
1101-
// NB: See comment above in T_void().
1102-
1103-
return C_integral(T_i1(), 0u64, False);
1086+
return C_struct(~[]);
11041087
}
11051088

11061089
fn C_bool(b: bool) -> ValueRef {

0 commit comments

Comments
 (0)