-
Notifications
You must be signed in to change notification settings - Fork 889
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
[unstable option] blank_lines_upper_bound #3381
Comments
May I ask why the default is 1? That's basically the only thing where I disagree with the standard style. I'd love to avoid having a My reasoning: more space between items is a useful visual separator. Rust files tend to get fairly long and often contain many different kinds of items. Compare that to some other languages, where there is usually just one class per file, for example. So in Rust files I often have "blocks" of items that somehow belong together. Maybe it's something like: struct A;
impl A {
}
impl Display for A {
}
struct B;
impl B {
}
impl Display for B {
} I think it should be pretty clear that some items belong closer together than others (specifically: all the So I'd like to propose increasing the default value to 3 or even 5. I think rustfmt shouldn't really be getting in the way of the programmer in this case. But maybe people have strong opinions against large separators. I tried searching for previous discussions about this, but I found nothing. So please let me know either way! |
I would also like to voice my support for stabilizing this option. I personally use single lines between "paragraphs" in blocks of code, two lines between related functions and structs, and three lines between unrelated sections of source. This feature requiring nightly is rather frustrating |
why is it nightly? I think it makes sense to be able to set it to |
The discussion here seems like we will not change the default, unfortunately. So we could go ahead and stabilize this option. Only these conditions left:
|
Where does this leave us now? Doesn't look like there are bugs open about the option other than this. The other two points seem a bit subjective; a rust n00b like me certainly can't weigh in there, but I agree with the others that having this option in stable would be very nice. |
As a reminder, issues for tracking stabilization of rustfmt configuration options are not intended to be used for debating default formatting behavior set by the Style Guide that governs rustfmt's default behavior. Additionally, the discussion around this particular aspect of the default behavior in the Style Guide is closed, so additional comments about the default, particularly here within the rustfmt repository, are not particularly productive. As far as actually stabilizing a configuration option, the process and requirements are defined here. While I appreciate that folks are eager to have the option available on stable, that really isn't the driver/determination of stabilization. Rust takes stability very seriously, and the formatting guarantee for rustfmt imposes additional constraints on the development of rustfmt and stabilization of features. We won't stabilize any option unless and until those criteria have all been easily cleared and we're sufficiently confident in the implementation and that it won't cause any buggy or unexpected formatting behavior anywhere, regardless of how long the option has existed in unstable or how many users are interested in stabilization. I know it can be frustrating/annoying for options to not be available on stable, but premature stabilization is absolutely unacceptable and why we always err on the side of caution and taking longer.
|
I'm not sure how real usage is quantified typically, but for what it's worth, the feature is working well for us in a number of projects, and it is the main reason why these projects rely on the 2.0 RC branch. |
For now, this has to use the nightly version of Cargo/rustfmt, because I really want to preserve the multiple newlines between sections of code, and that requires the `blank_lines_upper_bound` configuration option in `.rustfmt.toml`. See rust-lang/rustfmt#3381 forthe bug tracking the stabilization of this configuration option.
For now, this has to use the nightly version of Cargo/rustfmt, because I really want to preserve the multiple newlines between sections of code, and that requires the `blank_lines_upper_bound` configuration option in `.rustfmt.toml`. See rust-lang/rustfmt#3381 for the bug tracking the stabilization of this configuration option.
Can't comment on that.
I don't know about being well tested in unit tests, but real world usage is definitely present. Search for
The only one that's referenced is #4082, which appears to be a wontfix. |
Dear all, I would really like to understand which option would allow me to have an explicit blank line between a fn signature and its body ❓ Asking since initially I hoped this option would allow it. I really want this (and used it in other languages) for the cases where the function signature is long or complex enough to need a blank line between it and its body to improve readability. For example:
Testing using the nightly toolchain (by running fn main() {
println!("Hello, world!");
} and running fn main() {
println!("Hello, world!");
} Thanks. |
@dxps I don't think that's possible. EDIT: for reference, [clang-format calls this EDIT2: I deleted my previous comment arguing that the default should be changed, after getting used to |
@marcospb19 Appreciate the quick feedback! 🙏 |
It's there any plans on passing that as stable ? |
What is so difficult in making this option stable? It has been years. |
Tracking issue for unstable option: blank_lines_upper_bound
The text was updated successfully, but these errors were encountered: