-
Notifications
You must be signed in to change notification settings - Fork 909
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
Cannot prohibit long code lines while allowing long doc lines #5477
Comments
Thanks for reaching out. As you correctly note we don't want to break URLs in comments #506. Here are a few other resolved URL issues that demonstrate scenarios where we used to incorrectly break links in comments (#3787, #4130, and #5095). You also correctly note #3863. is preventing rustfmt from formatting the code.
I don't think we could provide an option to allow comment width to exceed the max_width, but maybe we could provide a new config like |
Is there an expected way to handle this, out of curiosity? |
Apologies, I'm not sure what you mean by expected. Do you mean what's the process for opening up a PR? You can read the entire contributing guide, but the Configuration section should have all the details for adding a new configuration option. The relevant code that determines if the formatted code contains an error is in Lines 551 to 560 in a7801aa
The I think this is the best place to add some additional logic to determine if the doc comment line overflow is a hard error. |
At least that's how they are supposed to behave, though both options are still unstable and could have bugs that cause divergent behavior. My understanding is that the rational for including comments and lits together is that they have a massive overlap of reasons as to why they need to be long lines that can't readily be broken. I think this is a case where as things currently stand you may want to also utilize the I'm not necessarily opposed to considering a comment vs. non-comment type of check down the road, but I don't see that happening any time soon. |
I actually meant, how should a Rust developer follow the prescribed style here? How should they format the given comment? But the contributing information is useful too, thank you.
This was certainly not my experience with stable - removing either of those options caused both errors to disappear. Only both together catch them, and then they catch both. |
I have code that contains this:
The last line is 132 characters long. The code also contains this:
The
panic!()
line is 117 characters long.I would like to prohibit the overly long code line, because it can be fixed so that developers don't have to scroll the line to read it. This can be done with the following flags:
(Both are necessary.)
The good part is that these flags catch the line of code, which I can change to be formatted automatically. The bad part is that this flag also catches the URL in the comment, which I can't change to be formatted automatically.
To be honest, I'm not really sure what I'd expect, so here are some notes about it in no particular order:
Versions:
1.62
1.4.38-stable
1.62.1
The text was updated successfully, but these errors were encountered: