Skip to content

Commit 249b356

Browse files
committed
make unit structs immediate
struct Foo; fn foo() -> Foo { Foo } Before: ; Function Attrs: nounwind readnone uwtable define void @_ZN3foo18he8ca29755dedebbaf4v0.0E(%struct.Foo* noalias nocapture sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture) #0 { "function top level": ret void } After: ; Function Attrs: nounwind readnone uwtable define %struct.Foo @_ZN3foo18he8ca29755dedebbaf4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #0 { "function top level": ret %struct.Foo undef }
1 parent ccd9a96 commit 249b356

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustc/middle/trans/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub fn type_is_immediate(ccx: &mut CrateContext, ty: ty::t) -> bool {
7575
}
7676
match ty::get(ty).sty {
7777
// FIXME: #9651: small `ty_struct` should also be immediate
78+
ty::ty_struct(def_id, ref substs) => {
79+
ty::struct_fields(tcx, def_id, substs).is_empty()
80+
}
7881
ty::ty_enum(*) | ty::ty_tup(*) => {
7982
let llty = sizing_type_of(ccx, ty);
8083
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type)

0 commit comments

Comments
 (0)