-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Don't print newlines in APITs #111929
Don't print newlines in APITs #111929
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
// HACK: pprust breaks strigns with newlines when the type | ||
// gets too long. We don't want these to show up in compiler | ||
// output or built artifacts, so replace them here... | ||
// Perhaps we should instead format APITs more robustly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this in pprust instead? I don't know why we'd want it to add the newline ... if it's just for -Zunpretty=expanded that doesn't seem worth adding hacks for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This newline is not impl Trait
specifically. This is just the regular line breaking that pprust does for code that is too long:
rust/compiler/rustc_ast_pretty/src/pp.rs
Lines 417 to 435 in 096309e
fn print_break(&mut self, token: BreakToken, size: isize) { | |
let fits = match self.get_top() { | |
PrintFrame::Fits => true, | |
PrintFrame::Broken { breaks: Breaks::Consistent, .. } => false, | |
PrintFrame::Broken { breaks: Breaks::Inconsistent, .. } => size <= self.space, | |
}; | |
if fits { | |
self.pending_indentation += token.blank_space; | |
self.space -= token.blank_space; | |
} else { | |
if let Some(pre_break) = token.pre_break { | |
self.out.push(pre_break); | |
} | |
self.out.push('\n'); | |
let indent = self.indent as isize + token.offset; | |
self.pending_indentation = indent; | |
self.space = cmp::max(MARGIN - indent, MIN_SPACE); | |
} | |
} |
I don't think we should remove pprust's ability to break lines, and I don't think it's worth it to introduce extra configurables (like breaking only with spaces). I'd rather have the hack be as localized as possible, or else rewrite this formatting code to no longer rely on pprust at all.
7fe841f
to
4692375
Compare
@bors r+ rollup |
…=wesleywiser Don't print newlines in APITs This is kind of a hack, but it gets the job done because the only "special" formatting that (afaict) `rustc_ast_pretty` does is break with newlines sometimes. Fixes rust-lang/measureme#207
…mpiler-errors Rollup of 7 pull requests Successful merges: - rust-lang#107522 (Add Median of Medians fallback to introselect) - rust-lang#111152 (update `pulldown-cmark` to `0.9.3`) - rust-lang#111757 (Consider lint check attributes on match arms) - rust-lang#111831 (Always capture slice when pattern requires checking the length) - rust-lang#111929 (Don't print newlines in APITs) - rust-lang#111945 (Migrate GUI colors test to original CSS color format) - rust-lang#111950 (Remove ExpnKind::Inlined.) r? `@ghost` `@rustbot` modify labels: rollup
This is kind of a hack, but it gets the job done because the only "special" formatting that (afaict)
rustc_ast_pretty
does is break with newlines sometimes.Fixes rust-lang/measureme#207