v0: replace skip_*
methods with print_*
methods in a "skip printing" mode.
#53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My motivation for this change is that I wanted to implement structural constant value demangling (for rust-lang/rust#87194) and having to implement both
skip_const
andprint_const
for the new constant values seemed redundant, and also potentially risky (i.e. the two could go out of sync).FWIW, the C demangler I wrote for
libiberty
just doesn't have this problem, as it took the "skip printing" route from the start, and I believe other implementations do something similar as well.While the
print_*
methods may be less efficient when theout
field isNone
, than the oldskip_*
implementation, I don't think the performance difference warrants dealing with the maintenance burden of duplication.Worst case, if performance does become a concern, we can make
Printer
generic over a type that provides theOption<&mut fmt::Formatter>
through a method, which could let LLVM optimizeprint_*
methods to be more or less the same as the oldskip_*
methods (forPrinter<SkipFmt>
).