Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LowerHex on Scalar to clean up their display in rustdoc #94189

Merged
merged 1 commit into from
Feb 22, 2022

Conversation

GuillaumeGomez
Copy link
Member

Follow-up of #94091.

r? @RalfJung

@rust-highfive
Copy link
Collaborator

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 20, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 20, 2022
@RalfJung
Copy link
Member

LGTM, thanks!
@bors r+ rollup

Btw, rustc has a bunch of pretty-printing machinery for consts as part of MIR printing, e.g. here. Is there any specific reason rustdoc cannot use that code?

@bors
Copy link
Contributor

bors commented Feb 20, 2022

📌 Commit c358ffe has been approved by RalfJung

@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 Feb 20, 2022
@GuillaumeGomez
Copy link
Member Author

Btw, rustc has a bunch of pretty-printing machinery for consts as part of MIR printing, e.g. here. Is there any specific reason rustdoc cannot use that code?

Simply because we didn't know of it. I'll send a PR to use it instead. Do you me to remove the Display implementation once done?

@RalfJung
Copy link
Member

Do you me to remove the Display implementation once done?

Yeah, we can remove "dangling" instances.

This PR still makes sense though IMO, to be more explicit about how Scalars are printed. (In a follow-up change I intend to do the same with ScalarMaybeUninit, or you can do that in this PR if you want.)

Also we will have to see if the MIR printing satisfies the requirements of rustdoc. For example, I think it currently does not add _ every 3 digits. However that would probably be a change for the better, so by unifying the two printers we can improve both of them. :)

@GuillaumeGomez
Copy link
Member Author

Sounds good to me! I'll send a PR once this one is merged then.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 20, 2022
…RalfJung

Implement LowerHex on Scalar to clean up their display in rustdoc

Follow-up of rust-lang#94091.

r? `@RalfJung`
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 20, 2022
…RalfJung

Implement LowerHex on Scalar to clean up their display in rustdoc

Follow-up of rust-lang#94091.

r? ``@RalfJung``
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 21, 2022
…RalfJung

Implement LowerHex on Scalar to clean up their display in rustdoc

Follow-up of rust-lang#94091.

r? ```@RalfJung```
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2022
…askrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#91192 (Some improvements to the async docs)
 - rust-lang#94143 (rustc_const_eval: adopt let else in more places)
 - rust-lang#94156 (Gracefully handle non-UTF-8 string slices when pretty printing)
 - rust-lang#94186 (Update pin_static_ref stabilization version.)
 - rust-lang#94189 (Implement LowerHex on Scalar to clean up their display in rustdoc)
 - rust-lang#94190 (Use Metadata::modified instead of FileTime::from_last_modification_ti…)
 - rust-lang#94203 (CTFE engine: Scalar: expose size-generic to_(u)int methods)
 - rust-lang#94211 (Better error if the user tries to do assignment ... else)
 - rust-lang#94215 (trait system: comments and small nonfunctional changes)
 - rust-lang#94220 (Correctly handle miniz_oxide extern crate declaration)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f639ba6 into rust-lang:master Feb 22, 2022
@rustbot rustbot added this to the 1.61.0 milestone Feb 22, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 22, 2022
ScalarMaybeUninit is explicitly hexadecimal in its formatting

This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in rust-lang#94189.

r? `@oli-obk`
@GuillaumeGomez GuillaumeGomez deleted the scalar-lower-hex branch February 22, 2022 09:31
@GuillaumeGomez
Copy link
Member Author

I just checked for the follow-up and moving format_integer_with_underscore_sep into the formatting of ConstInt. It appears that for MIN/MAX values, it doesn't print the value but instead type::MIN/type::MAX. Also, the format_integer_with_underscore_sep function handles a few more things which would be "too much" for it to be put in rustc_middle and making us duplicate it in rustdoc.

So unless I missed something, I'll let things as is for the time being.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 22, 2022
ScalarMaybeUninit is explicitly hexadecimal in its formatting

This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in rust-lang#94189.

r? ``@oli-obk``
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants