Skip to content

Commit d737392

Browse files
committed
Auto-format Rust code
This should be checked in CI, really.
1 parent 50e0b3e commit d737392

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

src/alejandra/src/rules/inherit.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ pub(crate) fn rule(
5353
steps.push_back(crate::builder::Step::Whitespace);
5454
steps.push_back(crate::builder::Step::Comment(text));
5555
steps.push_back(crate::builder::Step::NewLine);
56-
// Only add padding if there are no `trivialities` (that is, there's no extra
57-
// `Newlines(_)` to be added) or if the first one is a comment (that is, it'll need
56+
// Only add padding if there are no `trivialities` (that is,
57+
// there's no extra `Newlines(_)` to be added)
58+
// or if the first one is a comment (that is, it'll need
5859
// to be indented to match the content).
5960
if matches!(
6061
child.trivialities.front(),
@@ -77,9 +78,10 @@ pub(crate) fn rule(
7778
match trivia {
7879
crate::children2::Trivia::Comment(text) => {
7980
steps.push_back(crate::builder::Step::Comment(text));
80-
// If the next `trivia` is a newline, don't add newlines and padding at the
81-
// end of this iteration, as it will lead to a new blank line in the
82-
// output.
81+
// If the next `trivia` is a newline, don't add newlines
82+
// and padding at the
83+
// end of this iteration, as it will lead to a new blank
84+
// line in the output.
8385
if matches!(
8486
trivia_iter.peek(),
8587
Some(crate::children2::Trivia::Newlines(_))

src/alejandra/tests/fmt.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use pretty_assertions::assert_eq;
21
use std::io::Write;
32

3+
use pretty_assertions::assert_eq;
4+
45
#[test]
56
fn cases() {
67
let should_update = std::env::var("UPDATE").is_ok();
@@ -27,6 +28,10 @@ fn cases() {
2728

2829
let content_out = std::fs::read_to_string(path_out.clone()).unwrap();
2930

30-
assert_eq!(content_out, content_got, "Test case `{case}` failed; see `src/alejandra/tests/cases/{case}/`");
31+
assert_eq!(
32+
content_out, content_got,
33+
"Test case `{case}` failed; see \
34+
`src/alejandra/tests/cases/{case}/`"
35+
);
3136
}
3237
}

src/alejandra_cli/src/cli.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct CLIArgs {
5151

5252
#[derive(Clone)]
5353
struct FormattedPath {
54-
pub path: String,
54+
pub path: String,
5555
pub status: alejandra::format::Status,
5656
}
5757

@@ -147,12 +147,12 @@ pub fn main() -> std::io::Result<()> {
147147
let formatted_paths = match &include[..] {
148148
&[] | &["-"] => {
149149
vec![crate::cli::format_stdin(verbosity)]
150-
},
150+
}
151151
include => {
152152
let paths = crate::find::nix_files(include, &args.exclude);
153153

154154
crate::cli::format_paths(paths, in_place, verbosity, threads)
155-
},
155+
}
156156
};
157157

158158
let errors = formatted_paths
@@ -183,11 +183,9 @@ pub fn main() -> std::io::Result<()> {
183183

184184
let changed = formatted_paths
185185
.iter()
186-
.filter(|formatted_path| {
187-
match formatted_path.status {
188-
alejandra::format::Status::Changed(changed) => changed,
189-
_ => false,
190-
}
186+
.filter(|formatted_path| match formatted_path.status {
187+
alejandra::format::Status::Changed(changed) => changed,
188+
_ => false,
191189
})
192190
.count();
193191

0 commit comments

Comments
 (0)