Skip to content

Add --check to cargo fmt run in CI #4533

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

Merged
merged 2 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions ci/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture
command -v rustfmt
rustfmt -V

# Run once to cover everything that isn't in `src/`
cargo fmt

# Save a list of all source files
tmpfile="file-list~" # trailing tilde for gitignore
find src -name '*.rs' > "$tmpfile"
Expand Down Expand Up @@ -61,7 +58,7 @@ rm "$tmpfile"

# Run once from workspace root to get everything that wasn't handled as an
# individual file.
cargo fmt
cargo fmt "$check"

# Ensure that `sort` output is not locale-dependent
export LC_ALL=C
Expand Down
3 changes: 2 additions & 1 deletion ctest-next/src/ffi_items.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::ops::Deref;

use syn::{punctuated::Punctuated, visit::Visit};
use syn::punctuated::Punctuated;
use syn::visit::Visit;

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

Expand Down
17 changes: 7 additions & 10 deletions ctest-next/src/generator.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use std::{
env,
fs::File,
io::Write,
path::{Path, PathBuf},
};
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};

use askama::Template;
use syn::visit::Visit;
use thiserror::Error;

use crate::ffi_items::FfiItems;
use crate::template::{CTestTemplate, RustTestTemplate};
use crate::{
expand,
ffi_items::FfiItems,
template::{CTestTemplate, RustTestTemplate},
Const, Field, MapInput, Parameter, Result, Static, Struct, Type, VolatileItemKind,
expand, Const, Field, MapInput, Parameter, Result, Static, Struct, Type, VolatileItemKind,
};

/// A function that takes a mappable input and returns its mapping as Some, otherwise
Expand Down
5 changes: 4 additions & 1 deletion ctest-next/src/macro_expansion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{env, fs::canonicalize, path::Path, process::Command};
use std::env;
use std::fs::canonicalize;
use std::path::Path;
use std::process::Command;

use crate::Result;

Expand Down
3 changes: 2 additions & 1 deletion ctest-next/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::{Result, TestGenerator};
use std::env;
use std::fs::{canonicalize, File};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;

use crate::{Result, TestGenerator};

/// Generate all tests for the given crate and output the Rust side to a file.
#[doc(hidden)]
pub fn generate_test(
Expand Down
8 changes: 4 additions & 4 deletions ctest-next/src/template.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use askama::Template;
use quote::ToTokens;

use crate::{
ffi_items::FfiItems, generator::GenerationError, translator::Translator, MapInput, Result,
TestGenerator,
};
use crate::ffi_items::FfiItems;
use crate::generator::GenerationError;
use crate::translator::Translator;
use crate::{MapInput, Result, TestGenerator};

/// Represents the Rust side of the generated testing suite.
#[derive(Template, Clone)]
Expand Down
6 changes: 4 additions & 2 deletions ctest-next/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{ffi_items::FfiItems, translator::Translator, Result, TranslationError};

use syn::visit::Visit;

use crate::ffi_items::FfiItems;
use crate::translator::Translator;
use crate::{Result, TranslationError};

const ALL_ITEMS: &str = r#"
use std::os::raw::c_void;

Expand Down
3 changes: 2 additions & 1 deletion ctest-next/src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//!
//! Simple to semi complex types are supported only.

use std::{fmt, ops::Deref};
use std::fmt;
use std::ops::Deref;

use proc_macro2::Span;
use quote::ToTokens;
Expand Down
9 changes: 3 additions & 6 deletions ctest-next/tests/basic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use std::{
env, fs,
path::{Path, PathBuf},
};

use pretty_assertions::assert_eq;
use std::path::{Path, PathBuf};
use std::{env, fs};

use ctest_next::{Result, TestGenerator, __compile_test, __run_test, generate_test};
use pretty_assertions::assert_eq;

// Headers are found relevative to the include directory, all files are generated
// relative to the output directory.
Expand Down
3 changes: 1 addition & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2849,8 +2849,7 @@ fn test_freebsd(target: &str) {
"splice" if Some(14) > freebsd_ver => true,

// Those are introduced in FreeBSD 15.
"xktls_session_onedir" | "xktls_session"
if Some(15) > freebsd_ver => true,
"xktls_session_onedir" | "xktls_session" if Some(15) > freebsd_ver => true,

_ => false,
}
Expand Down
7 changes: 5 additions & 2 deletions src/unix/linux_like/linux/musl/b64/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ s! {
}

pub const MADV_SOFT_OFFLINE: c_int = 101;
#[deprecated(since = "0.2.175", note = "Linux does not define MAP_32BIT on any architectures \
other than x86 and x86_64, this constant will be removed in the future")]
#[deprecated(
since = "0.2.175",
note = "Linux does not define MAP_32BIT on any architectures \
other than x86 and x86_64, this constant will be removed in the future"
)]
pub const MAP_32BIT: c_int = 0x0040;
pub const O_APPEND: c_int = 1024;
pub const O_DIRECT: c_int = 0x20000;
Expand Down
Loading