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

Update a bunch of library types for MCP807 #135236

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Jan 8, 2025

This greatly reduces the number of places that actually use the rustc_layout_scalar_valid_range_* attributes down to just 3:

library/core\src\ptr\non_null.rs
68:#[rustc_layout_scalar_valid_range_start(1)]

library/core\src\num\niche_types.rs
19:        #[rustc_layout_scalar_valid_range_start($low)]
20:        #[rustc_layout_scalar_valid_range_end($high)]

Everything else -- PAL Nanoseconds, alloc's Cap, niched FDs, etc -- all just wrap those niche_types types.

r? ghost

@rustbot rustbot added O-solid Operating System: SOLID O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 8, 2025
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 9afba99 to 32606ca Compare January 8, 2025 08:17
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 32606ca to 91c7fde Compare January 8, 2025 08:28
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 91c7fde to 1df19d1 Compare January 9, 2025 02:33
@rust-log-analyzer

This comment has been minimized.

#[derive(Clone, Copy)]
#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this attribute in the new code for the non zero integers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thank you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, actually, I think it's fine. The inner ones don't need it because they're not exactly the guaranteed ones, rather the NonZero wrapper struct has it:

#[stable(feature = "generic_nonzero", since = "1.79.0")]
#[repr(transparent)]
#[rustc_nonnull_optimization_guaranteed]
#[rustc_diagnostic_item = "NonZero"]
pub struct NonZero<T: ZeroablePrimitive>(T::NonZeroInner);

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 1df19d1 to 6eb893e Compare January 9, 2025 17:49
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 6eb893e to f10ae9d Compare January 10, 2025 06:13
@rust-log-analyzer

This comment has been minimized.

This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3:
```
library/core\src\ptr\non_null.rs
68:#[rustc_layout_scalar_valid_range_start(1)]

library/core\src\num\niche_types.rs
19:        #[rustc_layout_scalar_valid_range_start($low)]
20:        #[rustc_layout_scalar_valid_range_end($high)]
```

Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from f10ae9d to 6f2a783 Compare January 10, 2025 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-solid Operating System: SOLID O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants