mirror of
https://github.com/trussed-dev/littlefs2.git
synced 2026-06-20 04:16:32 -07:00
Add short-enum bindgen regression
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user