rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.33k stars 12.58k forks source link

regression: pointer functions not yet stable as const fn #123284

Closed Mark-Simulacrum closed 1 month ago

Mark-Simulacrum commented 6 months ago
[INFO] [stdout] error: `core::ptr::const_ptr::<impl *const T>::copy_to_nonoverlapping` is not yet stable as a const fn
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/bnum-0.8.0/src/bint/endian.rs:146:25
[INFO] [stdout]     |
[INFO] [stdout] 146 | /                         slice_ptr
[INFO] [stdout] 147 | |                             .add(i << digit::$Digit::BYTE_SHIFT)
[INFO] [stdout] 148 | |                             .copy_to_nonoverlapping(ptr, digit::$Digit::BYTES as usize);
[INFO] [stdout]     | |_______________________________________________________________________________________^
[INFO] [stdout] ...
[INFO] [stdout] 240 |   crate::macro_impl!(endian);
[INFO] [stdout]     |   -------------------------- in this macro invocation
[INFO] [stdout]     |
[INFO] [stdout]     = note: this error originates in the macro `endian` which comes from the expansion of the macro `crate::macro_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
[INFO] [stdout] 

non-bnum cases:

Mark-Simulacrum commented 6 months ago

Docs indicate these aren't const-stable (e.g., https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.copy_to_nonoverlapping-1 has const: unstable). But this code seems to have worked before, so either (a) we aren't checking const-stability prior to 1.78 on inherent pointer methods or (b) something else fishy is going on.

zachs18 commented 6 months ago

IIUC these were intentionally destabilized by #117905, which was merged after 1.77 branched but before 1.78 branched.

Yeah, they were const-stable in 1.77.1 https://doc.rust-lang.org/1.77.1/std/primitive.pointer.html#method.copy_to_nonoverlapping-1 but no longer are.

Mark-Simulacrum commented 6 months ago

I see. The vast majority of the regressions seem to still be bnum (likely mostly due to Crater not bumping the lockfiles for committed lockfiles). It seems like this is pretty similar in spirit to https://github.com/rust-lang/rust/issues/123285 where we're mostly just detecting a bunch of new UB now (just via de-stabilization).

I think that means we're likely to move forward here but will want to call this out in release notes.

RalfJung commented 1 month ago

Closing as this was a deliberate de-stabilization. https://github.com/rust-lang/rust/issues/80697 tracks this now-again-unstable feature.