Skip to content

Commit f066ad0

Browse files
authored
Merge pull request #4533 from tgross35/enforce-fmt
Add `--check` to `cargo fmt` run in CI
2 parents b512c35 + 5b14b89 commit f066ad0

File tree

10 files changed

+30
-32
lines changed

10 files changed

+30
-32
lines changed

ci/style.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture
99
command -v rustfmt
1010
rustfmt -V
1111

12-
# Run once to cover everything that isn't in `src/`
13-
cargo fmt
14-
1512
# Save a list of all source files
1613
tmpfile="file-list~" # trailing tilde for gitignore
1714
find src -name '*.rs' > "$tmpfile"
@@ -61,7 +58,7 @@ rm "$tmpfile"
6158

6259
# Run once from workspace root to get everything that wasn't handled as an
6360
# individual file.
64-
cargo fmt
61+
cargo fmt "$check"
6562

6663
# Ensure that `sort` output is not locale-dependent
6764
export LC_ALL=C

ctest-next/src/ffi_items.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::Deref;
22

3-
use syn::{punctuated::Punctuated, visit::Visit};
3+
use syn::punctuated::Punctuated;
4+
use syn::visit::Visit;
45

56
use crate::{Abi, Const, Field, Fn, Parameter, Static, Struct, Type, Union};
67

ctest-next/src/generator.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
use std::{
2-
env,
3-
fs::File,
4-
io::Write,
5-
path::{Path, PathBuf},
6-
};
1+
use std::env;
2+
use std::fs::File;
3+
use std::io::Write;
4+
use std::path::{Path, PathBuf};
75

86
use askama::Template;
97
use syn::visit::Visit;
108
use thiserror::Error;
119

10+
use crate::ffi_items::FfiItems;
11+
use crate::template::{CTestTemplate, RustTestTemplate};
1212
use crate::{
13-
expand,
14-
ffi_items::FfiItems,
15-
template::{CTestTemplate, RustTestTemplate},
16-
Const, Field, MapInput, Parameter, Result, Static, Struct, Type, VolatileItemKind,
13+
expand, Const, Field, MapInput, Parameter, Result, Static, Struct, Type, VolatileItemKind,
1714
};
1815

1916
/// A function that takes a mappable input and returns its mapping as Some, otherwise

ctest-next/src/macro_expansion.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::{env, fs::canonicalize, path::Path, process::Command};
1+
use std::env;
2+
use std::fs::canonicalize;
3+
use std::path::Path;
4+
use std::process::Command;
25

36
use crate::Result;
47

ctest-next/src/runner.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use crate::{Result, TestGenerator};
21
use std::env;
32
use std::fs::{canonicalize, File};
43
use std::io::Write;
54
use std::path::{Path, PathBuf};
65
use std::process::Command;
76

7+
use crate::{Result, TestGenerator};
8+
89
/// Generate all tests for the given crate and output the Rust side to a file.
910
#[doc(hidden)]
1011
pub fn generate_test(

ctest-next/src/template.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use askama::Template;
22
use quote::ToTokens;
33

4-
use crate::{
5-
ffi_items::FfiItems, generator::GenerationError, translator::Translator, MapInput, Result,
6-
TestGenerator,
7-
};
4+
use crate::ffi_items::FfiItems;
5+
use crate::generator::GenerationError;
6+
use crate::translator::Translator;
7+
use crate::{MapInput, Result, TestGenerator};
88

99
/// Represents the Rust side of the generated testing suite.
1010
#[derive(Template, Clone)]

ctest-next/src/tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use crate::{ffi_items::FfiItems, translator::Translator, Result, TranslationError};
2-
31
use syn::visit::Visit;
42

3+
use crate::ffi_items::FfiItems;
4+
use crate::translator::Translator;
5+
use crate::{Result, TranslationError};
6+
57
const ALL_ITEMS: &str = r#"
68
use std::os::raw::c_void;
79

ctest-next/src/translator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//!
33
//! Simple to semi complex types are supported only.
44
5-
use std::{fmt, ops::Deref};
5+
use std::fmt;
6+
use std::ops::Deref;
67

78
use proc_macro2::Span;
89
use quote::ToTokens;

ctest-next/tests/basic.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
use std::{
2-
env, fs,
3-
path::{Path, PathBuf},
4-
};
5-
6-
use pretty_assertions::assert_eq;
1+
use std::path::{Path, PathBuf};
2+
use std::{env, fs};
73

84
use ctest_next::{Result, TestGenerator, __compile_test, __run_test, generate_test};
5+
use pretty_assertions::assert_eq;
96

107
// Headers are found relevative to the include directory, all files are generated
118
// relative to the output directory.

libc-test/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,8 +2849,7 @@ fn test_freebsd(target: &str) {
28492849
"splice" if Some(14) > freebsd_ver => true,
28502850

28512851
// Those are introduced in FreeBSD 15.
2852-
"xktls_session_onedir" | "xktls_session"
2853-
if Some(15) > freebsd_ver => true,
2852+
"xktls_session_onedir" | "xktls_session" if Some(15) > freebsd_ver => true,
28542853

28552854
_ => false,
28562855
}

0 commit comments

Comments
 (0)