Skip to content

Mark <*const _>::align_offset and <*mut _>::align_offset as const fn #90958

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

WaffleLapkin
Copy link
Member

This PR marks the following APIs as const:

impl<T> *const T {
    pub const fn align_offset(self, align: usize) -> usize;
}

impl<T> *mut T {
    pub const fn align_offset(self, align: usize) -> usize;
}

const implementation simply returns usize::MAX.


Previous discussion: #90607 (comment)


r? @oli-obk

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 16, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Nov 16, 2021

Thanks for doing this one first!

Please add a tracking issue that raises the concern that at compile time we will always get usize::MAX and that it is important that this gets talked about before stabilisation

@WaffleLapkin
Copy link
Member Author

@oli-obk done

@oli-obk
Copy link
Contributor

oli-obk commented Nov 16, 2021

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 16, 2021

📌 Commit f926c0e has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 17, 2021
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#90733 (Build musl dist artifacts with debuginfo enabled)
 - rust-lang#90787 (Add `#[inline]`s to `SortedIndexMultiMap`)
 - rust-lang#90920 (:arrow_up: rust-analyzer)
 - rust-lang#90933 (Fix await suggestion on non-future type)
 - rust-lang#90935 (Alphabetize language features)
 - rust-lang#90949 (update miri)
 - rust-lang#90958 (Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0c3a662 into rust-lang:master Nov 17, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 17, 2021
@WaffleLapkin WaffleLapkin deleted the const_align_offset branch November 17, 2021 21:19
@RalfJung
Copy link
Member

RalfJung commented Nov 28, 2021

Please make sure to Cc @rust-lang/wg-const-eval for every new use of const_eval_select... this one actually breaks its safety requirements.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants