Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wishlist: Allow optimization of uninhabited values #27

Open
chrysn opened this issue May 12, 2020 · 4 comments
Open

wishlist: Allow optimization of uninhabited values #27

chrysn opened this issue May 12, 2020 · 4 comments

Comments

@chrysn
Copy link
Member

chrysn commented May 12, 2020

The uX types could, conceptually, allow the compiler to do optimizations based on their constraints -- for example, an Option could fit in a u64, and (later when mechanisms to make use of Copy are in place to ensure there won't be pointer to the interior; possibly coming out of rust-lang/rust#27060) a Result<u63, u63> could be too.

This can not be done in stable Rust now, and even the means to do it that are available in unstable (rustc_layout_scalar_valid_range_end) are internal attributes never meant to become stable.

This is not an issue that would be solved quickly (unless by a possible added unstable range_optimizations feature that could break on any nightly), but more a long-term point for visibility, and to document towards the language team the usefulness of a public way to achieve this.

chrysn added a commit to chrysn-pull-requests/uX that referenced this issue May 12, 2020
@chrysn
Copy link
Member Author

chrysn commented Jul 26, 2022

The most tracking-issue-like place for that Rust feature right now is probably rust-lang/rust#94970 (which is asking for stabilization of a bunch of things, including _scalkar_valid_range_).

@Kijewski
Copy link

Kijewski commented Sep 5, 2022

@chrysn, please have a look at #49.

@chrysn
Copy link
Member Author

chrysn commented Sep 5, 2022

I think you meant #49. Thanks, looking at it.

@Kijewski
Copy link

Kijewski commented Sep 5, 2022

Oops, yes. Pasting is hard. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants