Skip to content

Create a size-limited fmt::Formatter outside of v0 for full limiting. - #50

Merged
alexcrichton merged 2 commits into
rust-lang:mainfrom
eddyb:full-size-limiting
Jul 20, 2021
Merged

alexcrichton merged 2 commits into
rust-lang:mainfrom
eddyb:full-size-limiting

Conversation

@eddyb

@eddyb eddyb commented Jul 20, 2021

Copy link
Copy Markdown
Contributor

Previously, we were using the single fmt::Formatter created by the user, all the way deep into v0 - this is largely incorrect, as any formatting features (e.g. width padding) would be applied to all of the relevant leaves.

Also, because we didn't want to create a fmt::Formatter for every formatting operation, the size limiting was approximate, since only write_str calls would be affected by it.

This PR solves both of those issues by moving the size-limited fmt::Write sink out of v0, and uses it to create one fmt::Formatter that the whole v0 (or legacy) demangling output is passed through, with no way for the demangling logic to (accidentally) bypass the size-limiting at all.

The second commit is mostly stylistic, trying to enforce a pattern of "not using write! in demangling logic", and only using fmt::Trait::fmt(&value, self.out) - which I'm guessing we do want (for performance reasons?).

@alexcrichton
alexcrichton merged commit 59fa193 into rust-lang:main Jul 20, 2021
@alexcrichton

Copy link
Copy Markdown
Member

Seems reasonable to me!

@eddyb
eddyb deleted the full-size-limiting branch July 20, 2021 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants