rust
rust copied to clipboard
stabilize const_float_bits_conv
This stabilizes const_float_bits_conv, and thus fixes https://github.com/rust-lang/rust/issues/72447. With https://github.com/rust-lang/rust/pull/128596 having landed, this is entirely a libs-only question now.
impl f32 {
pub const fn to_bits(self) -> u32;
pub const fn from_bits(v: u32) -> Self;
pub const fn to_be_bytes(self) -> [u8; 4];
pub const fn to_le_bytes(self) -> [u8; 4]
pub const fn to_ne_bytes(self) -> [u8; 4];
pub const fn from_be_bytes(bytes: [u8; 4]) -> Self;
pub const fn from_le_bytes(bytes: [u8; 4]) -> Self;
pub const fn from_ne_bytes(bytes: [u8; 4]) -> Self;
}
impl f64 {
pub const fn to_bits(self) -> u64;
pub const fn from_bits(v: u64) -> Self;
pub const fn to_be_bytes(self) -> [u8; 8];
pub const fn to_le_bytes(self) -> [u8; 8]
pub const fn to_ne_bytes(self) -> [u8; 8];
pub const fn from_be_bytes(bytes: [u8; 8]) -> Self;
pub const fn from_le_bytes(bytes: [u8; 8]) -> Self;
pub const fn from_ne_bytes(bytes: [u8; 8]) -> Self;
}
Cc @rust-lang/wg-const-eval @rust-lang/libs-api
r? @Mark-Simulacrum
rustbot has assigned @Mark-Simulacrum. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
Some changes occurred in src/tools/clippy
cc @rust-lang/clippy
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)
#16 2.696 Building wheels for collected packages: reuse
#16 2.697 Building wheel for reuse (pyproject.toml): started
#16 2.943 Building wheel for reuse (pyproject.toml): finished with status 'done'
#16 2.944 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#16 2.944 Stored in directory: /tmp/pip-ephem-wheel-cache-alw0en77/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#16 2.947 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#16 3.353 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#16 3.354 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#16 DONE 3.4s
This seems fine from the libs-api side, as long as wg-const-eval is happy with it.
@rfcbot fcp merge
Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:
- [x] @Amanieu
- [x] @BurntSushi
- [x] @dtolnay
- [ ] @joshtriplett
- [ ] @m-ou-se
No concerns currently listed.
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
:bell: This is now entering its final comment period, as per the review above. :bell:
The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:20d3b4d4a2629cbf7865cdbf92fe47512a7c96658c24253a045ff38e8075cd7fb37ca6fcadfa6e6d093333943ad24f6fc4f163ec5b74fd940de9d5bb03eb4d3b:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-17]
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-17', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-17/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id := 99999999
---
---- [ui] tests/ui/consts/const-float-bits-conv.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/consts/const-float-bits-conv.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-float-bits-conv/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-float-bits-conv/auxiliary" "-Zmir-opt-level=0"
--- stderr -------------------------------
--- stderr -------------------------------
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((1f16).to_bits(), 0x3c00);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_be_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(u16::from_be_bytes(1f16.to_be_bytes()), 0x3c00);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((12.5f16).to_bits(), 0x4a40);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_le_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(u16::from_le_bytes(12.5f16.to_le_bytes()), 0x4a40);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
LL | const_assert!((1337f16).to_bits(), 0x6539);
| ^^^^^^^^^^^^^^^^^^^
|
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_ne_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(u16::from_ne_bytes(1337f16.to_ne_bytes()), 0x6539);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((-14.25f16).to_bits(), 0xcb20);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(0x3c00), 1.0);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_be_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_be_bytes(0x3c00u16.to_be_bytes()), 1.0);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(0x4a40), 12.5);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_le_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_le_bytes(0x4a40u16.to_le_bytes()), 12.5);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(0x5be0), 252.0);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_ne_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_ne_bytes(0x5be0u16.to_ne_bytes()), 252.0);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(0xcb20), -14.25);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const QUIET_NAN: u16 = f16::NAN.to_bits() ^ 0x0155;
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const SIGNALING_NAN: u16 = f16::NAN.to_bits() ^ 0x02AA;
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(QUIET_NAN).is_nan());
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(SIGNALING_NAN).is_nan());
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f16::<impl f16>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f16::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
|
= help: add `#![feature(f16_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((1f128).to_bits(), 0x3fff0000000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_be_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(u128::from_be_bytes(1f128.to_be_bytes()), 0x3fff0000000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((12.5f128).to_bits(), 0x40029000000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_le_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(u128::from_le_bytes(12.5f128.to_le_bytes()), 0x40029000000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((1337f128).to_bits(), 0x40094e40000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_ne_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(u128::from_ne_bytes(1337f128.to_ne_bytes()), 0x40094e40000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!((-14.25f128).to_bits(), 0xc002c800000000000000000000000000);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(0x3fff0000000000000000000000000000), 1.0);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_be_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_be_bytes(0x3fff0000000000000000000000000000u128.to_be_bytes()), 1.0);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(0x40029000000000000000000000000000), 12.5);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_le_bytes` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_le_bytes(0x40029000000000000000000000000000u128.to_le_bytes()), 12.5);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(0x40094e40000000000000000000000000), 1337.0);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(0xc002c800000000000000000000000000), -14.25);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const QUIET_NAN: u128 = f128::NAN.to_bits() | 0x0000_AAAA_AAAA_AAAA_AAAA_AAAA_AAAA_AAAA;
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const SIGNALING_NAN: u128 = f128::NAN.to_bits() ^ 0x0000_5555_5555_5555_5555_5555_5555_5555;
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(QUIET_NAN).is_nan());
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(SIGNALING_NAN).is_nan());
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::from_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: `core::f128::<impl f128>::to_bits` is not yet stable as a const fn
|
|
LL | const_assert!(f128::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
|
= help: add `#![feature(f128_const)]` to the crate attributes to enable
error: aborting due to 43 previous errors
The final comment period, with a disposition to merge, as per the review above, is now complete.
As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.
This will be merged soon.
@Amanieu can I take your comment above as "r=me once FCP passes"?
Otherwise, @Mark-Simulacrum this is now in your court. :)
@bors r+
:pushpin: Commit 19908ff7a37a9a431399bb6f2868efc22820f2b6 has been approved by dtolnay
It is now in the queue for this repository.