forked from rust-lang/rustfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rustfmt): fix struct field formatting with doc comments present (r…
…ust-lang#5217) * fix(rustfmt): fix struct field formatting with doc comments present Fixes rust-lang#5215 * fix review feedbacks * add unit test without doc comment * move tests to a seperate file * add additional test cases * reintroduce a newline at the of test/souce/structs.rs
- Loading branch information
Showing
3 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// #5215 | ||
struct MyTuple( | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ u32, | ||
/// Doc Comments | ||
// TODO note | ||
u64, | ||
); | ||
|
||
struct MyTuple( | ||
#[cfg(unix)] // some comment | ||
u64, | ||
#[cfg(not(unix))] /*block comment */ | ||
u32, | ||
); | ||
|
||
struct MyTuple( | ||
#[cfg(unix)] | ||
// some comment | ||
u64, | ||
#[cfg(not(unix))] | ||
/*block comment */ | ||
u32, | ||
); | ||
|
||
struct MyTuple( | ||
#[cfg(unix)] // some comment | ||
pub u64, | ||
#[cfg(not(unix))] /*block comment */ | ||
pub(crate) u32, | ||
); | ||
|
||
struct MyTuple( | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
pub u32, | ||
/// Doc Comments | ||
// TODO note | ||
pub(crate) u64, | ||
); | ||
|
||
struct MyStruct { | ||
#[cfg(unix)] // some comment | ||
a: u64, | ||
#[cfg(not(unix))] /*block comment */ | ||
b: u32, | ||
} | ||
|
||
struct MyStruct { | ||
#[cfg(unix)] // some comment | ||
pub a: u64, | ||
#[cfg(not(unix))] /*block comment */ | ||
pub(crate) b: u32, | ||
} | ||
|
||
struct MyStruct { | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
a: u32, | ||
/// Doc Comments | ||
// TODO note | ||
b: u64, | ||
} | ||
|
||
struct MyStruct { | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
pub a: u32, | ||
/// Doc Comments | ||
// TODO note | ||
pub(crate) b: u64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// #5215 | ||
struct MyTuple( | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
u32, | ||
/// Doc Comments | ||
// TODO note | ||
u64, | ||
); | ||
|
||
struct MyTuple( | ||
#[cfg(unix)] // some comment | ||
u64, | ||
#[cfg(not(unix))] /*block comment */ u32, | ||
); | ||
|
||
struct MyTuple( | ||
#[cfg(unix)] | ||
// some comment | ||
u64, | ||
#[cfg(not(unix))] | ||
/*block comment */ | ||
u32, | ||
); | ||
|
||
struct MyTuple( | ||
#[cfg(unix)] // some comment | ||
pub u64, | ||
#[cfg(not(unix))] /*block comment */ pub(crate) u32, | ||
); | ||
|
||
struct MyTuple( | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
pub u32, | ||
/// Doc Comments | ||
// TODO note | ||
pub(crate) u64, | ||
); | ||
|
||
struct MyStruct { | ||
#[cfg(unix)] // some comment | ||
a: u64, | ||
#[cfg(not(unix))] /*block comment */ b: u32, | ||
} | ||
|
||
struct MyStruct { | ||
#[cfg(unix)] // some comment | ||
pub a: u64, | ||
#[cfg(not(unix))] /*block comment */ pub(crate) b: u32, | ||
} | ||
|
||
struct MyStruct { | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
a: u32, | ||
/// Doc Comments | ||
// TODO note | ||
b: u64, | ||
} | ||
|
||
struct MyStruct { | ||
/// Doc Comments | ||
/* TODO note to add more to Doc Comments */ | ||
pub a: u32, | ||
/// Doc Comments | ||
// TODO note | ||
pub(crate) b: u64, | ||
} |