-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Some more cleanups to syntax::print #62532
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
(Feel free to reassign to someone else, I think anyone can do the review for this since it's just cleanup) |
This has some conflicts with #62393 (with that PR token and ident printing have some extra arguments and don't fit into |
This comment has been minimized.
This comment has been minimized.
I can drop those commits -- maybe easiest to just wait after your PR lands? |
I'll reassign #62393 to you then, otherwise it's unlikely to land soon. |
3497fb1
to
a47fac4
Compare
I've dropped what I think are the conflicting commits from this PR. |
This comment has been minimized.
This comment has been minimized.
a47fac4
to
9c67233
Compare
@bors r+ |
📌 Commit 9c672338e80aee5a437e106917efd5139a56f0a4 has been approved by |
☔ The latest upstream changes (presumably #62555) made this pull request unmergeable. Please resolve the merge conflicts. |
attribute_to_string exists.
We always check against the length before indexing anyway.
There was only one callsite for each and this removes the unwrap_or_default's on the comments argument
This also permits sharing the underlying code between pprust and hir::print.
Presumably the code was from an older age of Rust and can now be written much simpler.
These are somewhat ambiguous (beginning/end of what?) so it's better to inline their one use into the code.
This is also easier to understand because the scan and print "tasks" are separate, but previously were both called "print" or "pretty print."
It was always set to the string's length
Also moves it to pp::Printer from PrintState.
We're always indenting by INDENT_UNIT anyway
9c67233
to
56a9237
Compare
@bors r=petrochenkov |
📌 Commit 56a9237 has been approved by |
…p, r=petrochenkov Some more cleanups to syntax::print All of these changes should be functionally equivalent to previous code. Each commit mostly stands alone and this PR is easiest to review by-commit.
Rollup of 5 pull requests Successful merges: - #62275 (rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.) - #62465 (Sometimes generate storage statements for temporaries with type `!`) - #62481 (Use `fold` in `Iterator::last` default implementation) - #62493 (#62357: doc(ptr): add example for {read,write}_unaligned) - #62532 (Some more cleanups to syntax::print) Failed merges: r? @ghost
Rollup of 5 pull requests Successful merges: - #62275 (rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.) - #62465 (Sometimes generate storage statements for temporaries with type `!`) - #62481 (Use `fold` in `Iterator::last` default implementation) - #62493 (#62357: doc(ptr): add example for {read,write}_unaligned) - #62532 (Some more cleanups to syntax::print) Failed merges: r? @ghost
…crum Remove unneeded access to pretty printer's `s` field in favor of deref I found it taxing in some of my recent PRs touching the pretty printer to maintain consistency with the surrounding code, since the current code is all over the place about whether it uses `self.s.…()` or `self.…()` for invoking methods of `rustc_ast_pretty::pp::Printer`. This PR standardizes on `self.…()` — relying on the `Deref` and `DerefMut` impls introduced by [rust-lang#62532](rust-lang@cab4532).
…crum Remove unneeded access to pretty printer's `s` field in favor of deref I found it taxing in some of my recent PRs touching the pretty printer to maintain consistency with the surrounding code, since the current code is all over the place about whether it uses `self.s.…()` or `self.…()` for invoking methods of `rustc_ast_pretty::pp::Printer`. This PR standardizes on `self.…()` — relying on the `Deref` and `DerefMut` impls introduced by [rust-lang#62532](rust-lang@cab4532).
…crum Remove unneeded access to pretty printer's `s` field in favor of deref I found it taxing in some of my recent PRs touching the pretty printer to maintain consistency with the surrounding code, since the current code is all over the place about whether it uses `self.s.…()` or `self.…()` for invoking methods of `rustc_ast_pretty::pp::Printer`. This PR standardizes on `self.…()` — relying on the `Deref` and `DerefMut` impls introduced by [rust-lang#62532](rust-lang@cab4532).
…crum Remove unneeded access to pretty printer's `s` field in favor of deref I found it taxing in some of my recent PRs touching the pretty printer to maintain consistency with the surrounding code, since the current code is all over the place about whether it uses `self.s.…()` or `self.…()` for invoking methods of `rustc_ast_pretty::pp::Printer`. This PR standardizes on `self.…()` — relying on the `Deref` and `DerefMut` impls introduced by [rust-lang#62532](rust-lang@cab4532).
All of these changes should be functionally equivalent to previous code.
Each commit mostly stands alone and this PR is easiest to review by-commit.