2

Fix `-Z print-type-sizes` for generators with discriminant field ordered first b...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/105623
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

_ => Size::ZERO,

};

if layout.fields.offset(tag_field) >= variant_size {

Member

@Nilstrieb Nilstrieb Dec 13, 2022

edited

It took me a while to understand why this change was correct, probably mostly because the variant_size variable is a little confusingly named. Maybe something like last_field_end would better?

Thinking about this a little more, what this code really wants to do is variant_size.max(tag_end), maybe that would also make it simpler. Actually no, that would be incorrect if the discriminant was at the end.

Member

Author

@compiler-errors compiler-errors Dec 13, 2022

edited

I'm not sure this is any clearer with the name last_field_end, because it really is the variant size (plus the upvars), modulo a hack to deal with needing to conditionally subtract one from the variant size depending on where the layout code chooses to put the tag.

Anyways, what I can do is leave a more detailed comment explaining why this is needed. This is probably still broken, but I don't know if it's worth taking much more time to fix.

This is true, all of this code is trying to fit generator layout into a normal layout shaped hole and it's not going great. The current name is fine too and yeah, spending too much time on this is probably not worth it.

But a quick comment would be nice.

compiler-errors reacted with thumbs up emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK