Skip to content

libcore float tests: replace macro shadowing by const-compatible macro#153485

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
RalfJung:float-macros-const
Mar 6, 2026
Merged

libcore float tests: replace macro shadowing by const-compatible macro#153485
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
RalfJung:float-macros-const

Conversation

@RalfJung
Copy link
Member

@RalfJung RalfJung commented Mar 6, 2026

This lets us avoid #153478.
However this means we generate 3 function items per assertion -- or rather, 3*8, since every assertion gets duplicated 8 times (4 float types, each in a const and a non-const variant). That's a lot; is it enough to be concerned about?
coretest already takes forever to build. In a quick test, build time increased from 29.8s to 30.8s, but that may also entirely be noise.

r? @tgross35

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2026
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Mar 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

assert_approx_eq_const as assert_approx_eq,
assert_biteq_const as assert_biteq,
};
use super::*;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being able to import super::* here is the main payoff from this change (aside from the reduced code duplication).

type Float = f128;
#[allow(unused)]
const fn flt (x: $fty) -> $fty { x }
const fn flt (x: Float) -> Float { x }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally made this Float name a parameter to avoid magically bringing names into scope, but meanwhile flt has been added which is magically brought in scope so we might as well also do that with Float.

Comment on lines -289 to -293
if !l.is_nan() && !r.is_nan() {
// Also check that standard equality holds, since most tests use `assert_biteq` rather
// than `assert_eq`.
assert!(l == r);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why this was added. If the values are bit-equal and not NaN then they are always also float-equal, so there's no good reason to compare them as floats here I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not to test the float values but rather to check the equality operator. Seems fine to remove though

@RalfJung RalfJung force-pushed the float-macros-const branch from 80f76af to 0fd3ac4 Compare March 6, 2026 11:07
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, r=me with CI

View changes since this review

@tgross35
Copy link
Contributor

tgross35 commented Mar 6, 2026

Lib tests should be done

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 6, 2026

📌 Commit 0fd3ac4 has been approved by tgross35

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Mar 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 6, 2026
…oss35

libcore float tests: replace macro shadowing by const-compatible macro

This lets us avoid rust-lang#153478.
However this means we generate 3 function items per assertion -- or rather, 3*8, since every assertion gets duplicated 8 times (4 float types, each in a const and a non-const variant). That's a lot; is it enough to be concerned about?
coretest already takes forever to build. In a quick test, build time increased from 29.8s to 30.8s, but that may also entirely be noise.

r? @tgross35
rust-bors bot pushed a commit that referenced this pull request Mar 6, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #153466 (`rust-analyzer` subtree update)
 - #151280 (Fix incorrect trailing comma suggested in no_accessible_fields)
 - #152593 (Box in `ValTreeKind::Branch(Box<[I::Const]>)` changed to `List`)
 - #153174 (std: add wasm64 to sync::Once and thread_parking atomics cfg guards)
 - #153485 (libcore float tests: replace macro shadowing by const-compatible macro)
 - #153495 (Fix ICE in `offset_of!` error recovery)
 - #152040 (Do not emit ConstEvaluatable goals if type-const)
 - #152741 (Suppress invalid suggestions in destructuring assignment)
 - #153189 (refactor: move `check_align` to `parse_alignment`)
 - #153230 (Roll rustfmt reviewers for in-tree rustfmt)
 - #153445 (Consider try blocks as block-like for overflowed expr)
 - #153452 (Cleanup unused diagnostic emission methods)
 - #153476 (bootstrap.py: fix typo "parallle")
 - #153483 (Preserve parentheses around `Fn` trait bounds in pretty printer)
@rust-bors rust-bors bot merged commit 6b42067 into rust-lang:main Mar 6, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 6, 2026
rust-timer added a commit that referenced this pull request Mar 6, 2026
Rollup merge of #153485 - RalfJung:float-macros-const, r=tgross35

libcore float tests: replace macro shadowing by const-compatible macro

This lets us avoid #153478.
However this means we generate 3 function items per assertion -- or rather, 3*8, since every assertion gets duplicated 8 times (4 float types, each in a const and a non-const variant). That's a lot; is it enough to be concerned about?
coretest already takes forever to build. In a quick test, build time increased from 29.8s to 30.8s, but that may also entirely be noise.

r? @tgross35
@RalfJung RalfJung deleted the float-macros-const branch March 8, 2026 11:27
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Mar 9, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#153466 (`rust-analyzer` subtree update)
 - rust-lang/rust#151280 (Fix incorrect trailing comma suggested in no_accessible_fields)
 - rust-lang/rust#152593 (Box in `ValTreeKind::Branch(Box<[I::Const]>)` changed to `List`)
 - rust-lang/rust#153174 (std: add wasm64 to sync::Once and thread_parking atomics cfg guards)
 - rust-lang/rust#153485 (libcore float tests: replace macro shadowing by const-compatible macro)
 - rust-lang/rust#153495 (Fix ICE in `offset_of!` error recovery)
 - rust-lang/rust#152040 (Do not emit ConstEvaluatable goals if type-const)
 - rust-lang/rust#152741 (Suppress invalid suggestions in destructuring assignment)
 - rust-lang/rust#153189 (refactor: move `check_align` to `parse_alignment`)
 - rust-lang/rust#153230 (Roll rustfmt reviewers for in-tree rustfmt)
 - rust-lang/rust#153445 (Consider try blocks as block-like for overflowed expr)
 - rust-lang/rust#153452 (Cleanup unused diagnostic emission methods)
 - rust-lang/rust#153476 (bootstrap.py: fix typo "parallle")
 - rust-lang/rust#153483 (Preserve parentheses around `Fn` trait bounds in pretty printer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants