Skip to content

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Apr 25, 2025

Box opening/closing is really easy to get wrong in the pretty-printers. This PR makes it much harder to get wrong.

r? @Urgau

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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 Apr 25, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Apr 27, 2025

☔ The latest upstream changes (presumably #140366) made this pull request unmergeable. Please resolve the merge conflicts.

@nnethercote
Copy link
Contributor Author

Details in the individual commits.

@nnethercote nnethercote marked this pull request as ready for review April 28, 2025 00:16
The pretty-printers open and close "boxes" of text a lot. The open and
close operations must be matched. The matching is currently all implicit
and very easy to get wrong. (rust-lang#140280 and rust-lang#140246 are two recent
pretty-printing fixes that both involved unclosed boxes.)

This commit introduces `BoxMarker`, a marker type that represents an
open box. It makes box opening/closing explicit, which makes it much
easier to understand and harder to get wrong.

The commit also removes many comments are on `end` calls saying things
like "end outer head-block", "Close the outer-box". These demonstrate
how confusing the implicit approach was, but aren't necessary any more.
They all have a single call site, aren't that big, and removing them
avoids having to pass some `BoxMarker`s.
@nnethercote
Copy link
Contributor Author

I addressed @dtolnay's comments.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thank you!

@dtolnay
Copy link
Member

dtolnay commented Apr 28, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 28, 2025

📌 Commit bb04e11 has been approved by dtolnay

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 Apr 28, 2025
@dtolnay dtolnay assigned dtolnay and unassigned Urgau Apr 28, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140056 (Fix a wrong error message in 2024 edition)
 - rust-lang#140220 (Fix detection of main function if there are expressions around it)
 - rust-lang#140249 (Remove `weak` alias terminology)
 - rust-lang#140316 (Introduce `BoxMarker` to improve pretty-printing correctness)
 - rust-lang#140347 (ci: clean more disk space in codebuild)
 - rust-lang#140349 (ci: use aws codebuild for the `dist-x86_64-linux` job)
 - rust-lang#140379 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140056 (Fix a wrong error message in 2024 edition)
 - rust-lang#140220 (Fix detection of main function if there are expressions around it)
 - rust-lang#140249 (Remove `weak` alias terminology)
 - rust-lang#140316 (Introduce `BoxMarker` to improve pretty-printing correctness)
 - rust-lang#140347 (ci: clean more disk space in codebuild)
 - rust-lang#140349 (ci: use aws codebuild for the `dist-x86_64-linux` job)
 - rust-lang#140379 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cbc40c7 into rust-lang:master Apr 28, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 28, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
Rollup merge of rust-lang#140316 - nnethercote:BoxMarker, r=dtolnay

Introduce `BoxMarker` to improve pretty-printing correctness

Box opening/closing is really easy to get wrong in the pretty-printers. This PR makes it much harder to get wrong.

r? `@Urgau`
@nnethercote nnethercote deleted the BoxMarker branch April 28, 2025 20:43
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.

6 participants