Skip to content

Replace rustc_layout_scalar_valid_range_start attribute with pattern types #135996

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

Open
oli-obk opened this issue Jan 24, 2025 · 2 comments
Open
Assignees
Labels
F-pattern_types `#![feature(pattern_types)]`

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jan 24, 2025

the rustc_layout_scalar_valid_range_start and rustc_layout_scalar_valid_range_end attributes require a lot of machinery to stay sanely usable. Pattern types don't require less machinery, but they are simpler as they don't break through layers of layouts and then require surprisingly subtle unsafe code to be used correctly.

So we're ripping out the attributes, and replace their usages in libcore and rustc:

  • std::ptr::NonNull
  • std::num::NonZero
  • rustc_index_macros::newtype::NewType
  • std::num::Nanoseconds

cc @Veykril @scottmcm

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 24, 2025
@oli-obk oli-obk self-assigned this Jan 24, 2025
@oli-obk oli-obk added F-pattern_types `#![feature(pattern_types)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 24, 2025
@scottmcm
Copy link
Member

scottmcm commented Jan 25, 2025

Very cool! I'm excited to hear these are far enough along that there's a subset we can stabilize enable without incomplete_features in libcore with confidence.

EDIT: Changed "stabilize" because c-e is 100% correct about not stable.

@compiler-errors
Copy link
Member

we can stabilize in libcore with confidence.

Well, I think it's very important to note here that we are not stabilizing anything. We're just changing the underlying representation of the struct to use different machinery. We should continue to be able to remove all pattern types from the compiler and standard library and go back to using rustc_* attrs at any point in this experimentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-pattern_types `#![feature(pattern_types)]`
Projects
None yet
Development

No branches or pull requests

4 participants