Skip to content

fix internal error when using rustfmt::skip with newline on stmt #3785

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

Merged
merged 7 commits into from
Sep 15, 2019

Conversation

rchaser53
Copy link
Contributor

fix: #3717
This PR is to fix the bug reported by BartMassey. I will send the another PR to fix other case including 0xpr03's bug.

like below
```
macro_rules! shuffle_done {
    () => {
        // need to suppress not to remove indent
        #[cfg_attr(rustfmt, rustfmt_skip)]
        simd_shuffle32();
    };
}
```
Copy link
Contributor

@topecongiro topecongiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@rchaser53 IIUC, we only need the diffs in src/expr.rs to fix the issue. I am not sure why we need to update src/visitor.rs in ba9b1bf. Would you mind explaining why we need it?

@rchaser53
Copy link
Contributor Author

I misunderstood. We only need the diffs in src/expr.rs to fix the issue. Sorry!

Copy link
Contributor

@topecongiro topecongiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

src/expr.rs Outdated
context
.skipped_range
.borrow_mut()
.append(&mut visitor_context.skipped_range.borrow_mut().clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we can consume visitor_context and avoid cloneing here, though I assume that requires an additional refactoring.

Copy link
Contributor Author

@rchaser53 rchaser53 Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to delete the clone than to use replace_with? The following code can also be compiled and pass tests:

context
   .skipped_range
   .borrow_mut()
   .append(&mut visitor_context.skipped_range.borrow_mut());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just remove clone is better than using replace_with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this is much simpler than I first expected 😄 Thanks!

@topecongiro topecongiro merged commit 789a097 into rust-lang:master Sep 15, 2019
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.

Another "error[internal]: left behind trailing whitespace" bug
2 participants