Stream: t-compiler

Topic: fields-ordered-by-offset


RalfJ (Nov 05 2018 at 14:16, on Zulip):

@eddyb is there a cheap way to iterate an aggregate's fields sorted by offset? Seems the list on the layout is sorted by original field definition order. Currently I then sort a list of indices by their offsets, but that requires an allocation.

eddyb (Nov 05 2018 at 14:16, on Zulip):

yes it's how the LLVM backend works

eddyb (Nov 05 2018 at 14:17, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/type_of.rs#L124

eddyb (Nov 05 2018 at 14:17, on Zulip):

you could've also just, you know, looked at the API :D

RalfJ (Nov 06 2018 at 12:11, on Zulip):

I did, but it seems I was blind. Sorry!

eddyb (Nov 06 2018 at 14:22, on Zulip):

heh, it's fine. I was mostly happy that it was at least somewhat discoverable, since there's a general issue of not being able to find "how do I do X" in rustc's codebase

Last update: Nov 16 2019 at 02:35UTC