Skip to content
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

Fix double space in pretty printed TryBlock #92412

Merged
merged 1 commit into from
Jan 1, 2022
Merged

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Dec 29, 2021

Follow-up to #92238 fixing one of the FIXMEs.

macro_rules! repro {
    ($expr:expr) => {
        stringify!($expr)
    };
}

fn main() {
    println!("{}", repro!(try {}));
}

Before: try  {}
After: try {}

The head helper already appends a space:

fn head<S: Into<Cow<'static, str>>>(&mut self, w: S) {
let w = w.into();
// Outer-box is consistent.
self.cbox(INDENT_UNIT);
// Head-box is inconsistent.
self.ibox(w.len() + 1);
// Keyword that starts the head.
if !w.is_empty() {
self.word_nbsp(w);
}
}

so doing head followed by space resulted in a double space:

self.head("try");
self.space();

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 29, 2021
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 29, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 1, 2022

📌 Commit 2f25a4a has been approved by Mark-Simulacrum

@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 Jan 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 1, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#88310 (Lock bootstrap (x.py) build directory)
 - rust-lang#92097 (Implement split_at_spare_mut without Deref to a slice so that the spare slice is valid)
 - rust-lang#92412 (Fix double space in pretty printed TryBlock)
 - rust-lang#92420 (Fix whitespace in pretty printed PatKind::Range)
 - rust-lang#92457 (Sync rustc_codegen_gcc)
 - rust-lang#92460 ([rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape)
 - rust-lang#92469 (Make tidy check for magic numbers that spell things)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 682b4cb into rust-lang:master Jan 1, 2022
@rustbot rustbot added this to the 1.59.0 milestone Jan 1, 2022
@dtolnay dtolnay deleted the tryspace branch January 31, 2022 17:54
@dtolnay dtolnay added the A-pretty Area: Pretty printing (including `-Z unpretty`) label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants