Add short-enum bindgen regression

This commit is contained in:
Niklas Dusenlund
2026-06-10 13:53:11 +02:00
parent 4f1a5949a0
commit cc3f928543
2 changed files with 13 additions and 3 deletions
+7
View File
@@ -60,6 +60,13 @@ jobs:
cargo test --workspace --release &&
cargo test --workspace --features unstable-littlefs-patched
- name: Check bindgen short enums
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: cargo check --package littlefs2 --all-targets
env:
BINDGEN_EXTRA_CLANG_ARGS: -fshort-enums
CARGO_TARGET_DIR: target/bindgen-short-enums
- name: Check documentation
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --workspace
+6 -3
View File
@@ -23,13 +23,16 @@ use crate::{
DISK_VERSION,
};
fn error_code_from<T>(result: Result<T>) -> ll::lfs_error {
// This conversion is only useless when bindgen emits `lfs_error` as `c_int`.
// With `-fshort-enums`, bindgen emits a narrower type that must be widened.
#[allow(clippy::useless_conversion)]
fn error_code_from<T>(result: Result<T>) -> c_int {
result
.map(|_| ll::lfs_error_LFS_ERR_OK)
.map(|_| ll::lfs_error_LFS_ERR_OK.into())
.unwrap_or_else(From::from)
}
fn result_from<T>(return_value: T, error_code: ll::lfs_error) -> Result<T> {
fn result_from<T>(return_value: T, error_code: c_int) -> Result<T> {
if let Some(error) = Error::new(error_code) {
Err(error)
} else {