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

Rustfmt fails in rustfmt_skip-blocks with line exceeded maximum length #1298

Closed
MackieLoeffel opened this issue Feb 6, 2017 · 4 comments
Closed

Comments

@MackieLoeffel
Copy link

If I try to format the following code:

#[cfg_attr(rustfmt, rustfmt_skip)]
fn test() {
    let a = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25];
}

Rustfmt fails with the following error:
Rustfmt failed at stdin:3: line exceeded maximum length (maximum: 100, found: 108) (sorry)

I would expect, that rustfmt doesn't complain about lines, which it shouldn't format in the first place.

@nrc
Copy link
Member

nrc commented Feb 6, 2017

This is expected behaviour - the logic is that even where Rustfmt does not format, the user is still interested to know if their formatting satisfies the constraints they have given Rustfmt.

We should probably have a command line flag or config option to change this bahaviour.

@MackieLoeffel
Copy link
Author

Ok, your argument makes sense. A config option or command line flag for changing this behavior would probably be nice, but I can live with the current behavior.

And by the way: Thanks for creating such an awesome tool. I really enjoy using it. 👍

@MackieLoeffel
Copy link
Author

Maybe an additional attribute would be the best solution, something like:
#[cfg_attr(rustfmt, rustfmt_skip_dont_check)]

This would give the developer finer grained control over which parts should be checked, whether they satisfy the constraints.

@mjhanninen
Copy link

I would vote for an additional attribute giving finer control. I can easily imagine a scenario in which you have a painstakingly handcrafted source layout that you want to maintain manually in which case you would want to be informed about style violations. However, right now I'm getting bogus warnings for raw string literals (in my case big regular expressions) that just force the too long lines on me. When you really cannot split the line the warnings are unhelpful and worsens the signal-to-noise ratio.

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

No branches or pull requests

3 participants