-
Notifications
You must be signed in to change notification settings - Fork 888
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
Is blank_lines_lower_bound correct? #2954
Comments
The option appears to be completely broken, as in, it just inserts N blank lines between each line that contains source code, although not always: #[cfg(test)]
mod tests { } becomes #[cfg(test)]
mod tests {} and for i in 0..10 {
let x = i;
let y = i;
} becomes for i in 0..10 {
let x = i;
let y = i;
} |
Expected behaviour is that it should newlines between module-scoped items (even if they appear inside functions), but not between statements/expressions. |
I agree with the issue poster. The current functionality does not seem very useful. What I would like it to do is to separate type declarations, impl blocks, functions etc from each other. But not inserting a newline between two use std::io;
use std::net;
/// A module doing foo
mod foomodule;
#[cfg(windows)]
pub const CONST_NUMBER: u8 = 3;
pub static STATIC_NUMBER: u8 = 5;
fn function() {}
struct MyStruct;
impl MyStruct {} Into: use std::io;
use std::net;
/// A module doing foo
mod foomodule;
#[cfg(windows)]
pub const CONST_NUMBER: u8 = 3;
pub static STATIC_NUMBER: u8 = 5;
fn function() {}
struct MyStruct;
impl MyStruct {} |
The blank_lines_lower_bound documentation says:
Then the example shows that by setting it to
1
:is formatted into
which is how
rustfmt
behaves. However, I am not sure this is correct because aren't thoseprintln!
are statements? Not all statements are items, e.g. let-decl are not items IIUC (and for let this option produces the same behavior). I think it would be much more useful to output:That is, it would be much more useful for this to control the spacing between items that are not statements. I don't know how useful it would be to also be able to control the spacing between statements (independently of whether they are items or not), but if someone needs that it could be added as a different option.
The text was updated successfully, but these errors were encountered: