Skip to content

Conversation

@josh-kaplan
Copy link
Contributor

@josh-kaplan josh-kaplan commented Oct 8, 2025

Summary

This PR proposes a fix for #103747 implementing IEEE-754 S4.3 roundTiesToEven for Duration Debug implementation.

Testing

Added new test in time.rs for validating roundTiesToEven behavior in Duration formatting. Reran all debug formatting tests in time.rs with ./x test library/coretests --test-args time::debug_formatting.

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

rustbot commented Oct 8, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
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

@hkBst
Copy link
Member

hkBst commented Oct 12, 2025

Maybe also add a test-case for println!("{:.0?}", Duration::MAX);, unless it is already there?

@josh-kaplan
Copy link
Contributor Author

Maybe also add a test-case for println!("{:.0?}", Duration::MAX);, unless it is already there?

Fair! It looks like it already exists on line 330 in debug_formatting_extreme_values.

I also updated the comment above the new rounding behavior to accurately reflect the behavior change.

@scottmcm
Copy link
Member

scottmcm commented Dec 6, 2025

r? libs

@rustbot rustbot assigned Mark-Simulacrum and unassigned scottmcm Dec 6, 2025
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

Hm, I hadn't realized how complex the logic already is for Duration's Debug impl. I'm not convinced that there's a strong use case for being this careful in a Debug impl for Duration -- no one should be parsing those outputs, IMO, or relying on particular rounding there. This differs from Display/Debug for floats which are much more likely to be in the critical path for correctness.

That said, the diff here doesn't seem too complicated, so maybe it's OK, especially if we can simplify it a bit (per my inline comment).

View changes since this review

} else {
Some(integer_part)
}
} else if fractional_part > 0 && fractional_part > divisor * 5 {
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to merge this code with the below - in particular to not duplicate or miss having the useful comments. It seems to me that if we modified is_last_digit_odd in the if here to be or'd with fractional_part > divisor * 5 that would work out? Or am I missing some case?

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@josh-kaplan
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 22, 2025
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 28, 2025

📌 Commit c74aa91 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors 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 Dec 28, 2025
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Dec 28, 2025
Implement round-ties-to-even for Duration Debug for consistency with f64

## Summary

This PR proposes a fix for rust-lang#103747 implementing IEEE-754 S4.3 roundTiesToEven for Duration Debug implementation.

## Testing

Added new test in `time.rs` for  validating roundTiesToEven behavior in Duration formatting. Reran all debug formatting tests in `time.rs` with `./x test library/coretests --test-args time::debug_formatting`.
bors added a commit that referenced this pull request Dec 28, 2025
…uwer

Rollup of 5 pull requests

Successful merges:

 - #147499 (Implement round-ties-to-even for Duration Debug for consistency with f64)
 - #149447 (Rewrite `String::replace_range`)
 - #149469 (Leverage &mut in OnceLock when possible)
 - #149921 (Add new source component that includes GPL-licensed source)
 - #150460 (fix ManuallyDrop::into_inner aliasing (Miri) issues)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2c0daa2 into rust-lang:main Dec 28, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 28, 2025
rust-timer added a commit that referenced this pull request Dec 28, 2025
Rollup merge of #147499 - josh-kaplan:master, r=Mark-Simulacrum

Implement round-ties-to-even for Duration Debug for consistency with f64

## Summary

This PR proposes a fix for #103747 implementing IEEE-754 S4.3 roundTiesToEven for Duration Debug implementation.

## Testing

Added new test in `time.rs` for  validating roundTiesToEven behavior in Duration formatting. Reran all debug formatting tests in `time.rs` with `./x test library/coretests --test-args time::debug_formatting`.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 29, 2025
…uwer

Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#147499 (Implement round-ties-to-even for Duration Debug for consistency with f64)
 - rust-lang/rust#149447 (Rewrite `String::replace_range`)
 - rust-lang/rust#149469 (Leverage &mut in OnceLock when possible)
 - rust-lang/rust#149921 (Add new source component that includes GPL-licensed source)
 - rust-lang/rust#150460 (fix ManuallyDrop::into_inner aliasing (Miri) issues)

r? `@ghost`
`@rustbot` modify labels: rollup
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.

6 participants