Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Access the original type's fields through a pointercast, under the Logical addressing model.#469

Merged
khyperia merged 3 commits intoEmbarkStudios:mainfrom
LykenSol:simple-enums
Mar 4, 2021
Merged

Access the original type's fields through a pointercast, under the Logical addressing model.#469
khyperia merged 3 commits intoEmbarkStudios:mainfrom
LykenSol:simple-enums

Conversation

@eddyb
Copy link
Copy Markdown
Contributor

@eddyb eddyb commented Mar 4, 2021

This allows simple enums, like Option<u32>, to work, since they already have the variant fields in the enum itself
(thanks to ScalarPair ABI - but this could easily be extended to at least all Option<T> without much effort).

for loops that rely on those Option types also work, except Range's implementation of Iterator uses mem::swap, and that happens to have a pretty severe case of microoptimization, that we'll have to turn off upstream (frankly, given that this kind of library optimization blocks MIR optimizations, generating that SIMD loop should probably be done in the backend, not in a library).

You can see a working example of a for loop with a custom Range-like iterator, in the third commit.

@eddyb eddyb requested a review from khyperia March 4, 2021 13:34
@khyperia khyperia merged commit 7723f5d into EmbarkStudios:main Mar 4, 2021
@eddyb eddyb deleted the simple-enums branch March 4, 2021 14:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants