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 TrailingWhitespace when using line breaks in macros arguments #3768

Merged
merged 4 commits into from
Sep 4, 2019

Conversation

rchaser53
Copy link
Contributor

fix #2916

@@ -41,6 +42,7 @@ pub(crate) struct RewriteContext<'a> {
pub(crate) macro_rewrite_failure: RefCell<bool>,
pub(crate) report: FormatReport,
pub(crate) skip_context: SkipContext,
pub(crate) skipped_range: Rc<RefCell<Vec<(usize, usize)>>>,
Copy link
Contributor Author

@rchaser53 rchaser53 Sep 1, 2019

Choose a reason for hiding this comment

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

This is an important point in this PR. I want to use skipped_range in RewriteContext. It's used to resolve #3717. I think the skipped_range should include the failed format span or skipped span.

This is also related with #3761. The case #3761 is a case the edge of the span has white space. It's easy to resolve. Just trim the white space. But I think no way to avoid TrailingWhitespace error now in a case the failed format span has newline now.

// case like #3761. just trim the white space.
let snippet = "     let a = 1;"; 

// case like this PR. no way to avoid TrailingWhitespace error now
a_macro!(name<Param1, Param2>, 
);

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! I think the idea in the PR is really good. Before merging, however, we need to fix some issues.

src/macros.rs Outdated Show resolved Hide resolved
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.

internal error: left behind trailing whitespace
2 participants