Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
src/test/run-pass/const-endianess.rs
Outdated
| const LE_I128: i128 = -999999i128.to_le(); | ||
|
|
||
| fn main() { | ||
| assert_eq!(BE_U32, 55u32.to_be()); |
There was a problem hiding this comment.
To ensure that the right hand side isn't const evaluated you need to pass the literal through a dummy function that isn't const fn and is also #[inline(never)]
There was a problem hiding this comment.
@oli-obk Doesn't the codebase have a dedicated black-boxing function for that purpose?
There was a problem hiding this comment.
It does, I think it's test::black_box, not sure if that's available in run-pass tests.
There was a problem hiding this comment.
Fixed. I was able to use test::black_box.
Btw. Do you think this test is correctly placed? I first put it under ui to just make sure it compiled, never ran any assertions. Then I moved it to run-pass 🤷♂️
Also, should I add tests for all methods I made const fns?
There was a problem hiding this comment.
More tests are always great ;)
run-pass is the right place for it
|
@bors r+ |
|
📌 Commit 7df0099 has been approved by |
|
⌛ Testing commit 7df0099 with merge 6e0afd14bc500ff47a5cc315a21e24536525d7c7... |
|
💔 Test failed - status-travis |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/test/run-pass/const-endianess.rs
Outdated
| fn main() { | ||
| assert_eq!(BE_U32, b(55u32).to_be()); | ||
| assert_eq!(LE_U32, b(55u32).to_le()); | ||
| assert_eq!(BE_U128, b(999999u128).to_be()); |
There was a problem hiding this comment.
You should ignore this test on asm-js, because it doesn't support 128 bit integers
There was a problem hiding this comment.
From the error it looks like the call to black_box was the problem. But I realized after pushing the fix ignoring that assertion only that I might have to disable the entire test for.. ?
There was a problem hiding this comment.
I force-pushed a change to the test to conditionally compile everything related to 128 bit integers.
|
@bors r+ |
|
📌 Commit 8b5f962 has been approved by |
const fn integer operations A follow up to rust-lang#51171 Fixes rust-lang#51267 Makes a lot of the integer methods (`swap_bytes`, `count_ones` etc) `const fn`s. See rust-lang#51267 for a discussion about why this is wanted and the solution used.
Rollup of 6 pull requests Successful merges: - #51288 (Remove rustdoc-specific is_import field from HIR) - #51299 (const fn integer operations) - #51317 (Allow enabling incremental via config.toml) - #51323 (Generate br for all two target SwitchInts) - #51326 (Various minor slice iterator cleanups) - #51329 (Remove the unused `-Z trans-time-graph` flag.) Failed merges:
|
☔ The latest upstream changes (presumably #51334) made this pull request unmergeable. Please resolve the merge conflicts. |
|
💥 Test timed out |
|
What happened here? Bors tried to test this while a rollup which contained this pr was already merged. |
A follow up to #51171
Fixes #51267
Makes a lot of the integer methods (
swap_bytes,count_onesetc)const fns. See #51267 for a discussion about why this is wanted and the solution used.