rust icon indicating copy to clipboard operation
rust copied to clipboard

Constify remaining `Layout` methods

Open CraftSpider opened this issue 1 year ago • 9 comments

Makes the methods on Layout that aren't yet unstably const, under the same feature and issue, #67521. Most of them required no changes, only non-trivial change is probably constifying ValidAlignment which may affect #102072

CraftSpider avatar Sep 23 '22 20:09 CraftSpider

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

rustbot avatar Sep 23 '22 20:09 rustbot

r? @scottmcm

(rust-highfive has picked a reviewer for you, use r? to override)

rust-highfive avatar Sep 23 '22 20:09 rust-highfive

Thanks for mentioning #102072!

My inclination here to to avoid further changes around Layout until #101899 settles a bit.

Otherwise this seems perfectly reasonable to me.

scottmcm avatar Sep 24 '22 04:09 scottmcm

:umbrella: The latest upstream changes (presumably #102850) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 09 '22 21:10 bors

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Finished dev [unoptimized] target(s) in 0.05s
Skipping Set({test::src/tools/tidy}) because it is excluded
Skipping Set({test::src/tools/tidy}) because it is excluded
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.

rust-log-analyzer avatar Oct 17 '22 16:10 rust-log-analyzer

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

rust-log-analyzer avatar Oct 17 '22 16:10 rust-log-analyzer

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling unwind v0.0.0 (/checkout/library/unwind)
error: implementation has missing stability attribute
   --> library/core/src/ptr/alignment.rs:166:1
    |
166 | / impl const cmp::PartialEq for Alignment {
167 | |     #[inline]
168 | |     fn eq(&self, other: &Self) -> bool {
169 | |         self.as_nonzero().get() == other.as_nonzero().get()
171 | | }
    | |_^

error: implementation has missing stability attribute
error: implementation has missing stability attribute
   --> library/core/src/ptr/alignment.rs:174:1
    |
174 | / impl const cmp::Ord for Alignment {
175 | |     #[inline]
176 | |     fn cmp(&self, other: &Self) -> cmp::Ordering {
177 | |         self.as_nonzero().get().cmp(&other.as_nonzero().get())
179 | | }
    | |_^

error: could not compile `core` due to 2 previous errors

rust-log-analyzer avatar Oct 17 '22 16:10 rust-log-analyzer

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling cc v1.0.73
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/checkout/library/std)
   Compiling unwind v0.0.0 (/checkout/library/unwind)
error: to use a constant of type `alignment::Alignment` in a pattern, `alignment::Alignment` must be annotated with `#[derive(PartialEq, Eq)]`
   |
   |
21 |     matches!(a, Alignment::MIN)

error: unreachable pattern
   --> library/core/src/macros/mod.rs:346:13
    |
    |
342 | / macro_rules! matches {
343 | |     ($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
344 | |         match $expression {
345 | |             $( $pattern )|+ $( if $guard )? => true,
    | |             ^ unreachable pattern
347 | |         }
348 | |     };
349 | | }
349 | | }
    | |_- in this expansion of `matches!`
    |
   ::: library/core/src/ptr/alignment.rs:21:17
    |
21  |       matches!(a, Alignment::MIN)
    |       |           |
    |       |           matches any value
    |       in this macro invocation
    |
    |
    = note: `-D unreachable-patterns` implied by `-D warnings`
error: could not compile `core` due to 2 previous errors
Build completed unsuccessfully in 0:00:10

rust-log-analyzer avatar Oct 17 '22 16:10 rust-log-analyzer

This is also blocked on #102049, since Alignment can't derive PartialEq for structural matching till that lands

CraftSpider avatar Oct 17 '22 16:10 CraftSpider

It looks like the size limit will stick (https://github.com/rust-lang/rust/issues/101899#issuecomment-1290805223) so I think that part is unblocked, but https://github.com/rust-lang/rust/pull/102049 is a good callout.

scottmcm avatar Nov 09 '22 05:11 scottmcm