Skip to content

Commit

Permalink
Use libcore's c_char if available
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 23, 2024
1 parent ef99848 commit 8f16379
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- rust: beta
- rust: stable
- rust: 1.60.0
- rust: 1.64.0
- rust: 1.70.0
- rust: 1.74.0
- name: Cargo on macOS
Expand Down Expand Up @@ -64,7 +65,7 @@ jobs:
shell: bash
- run: cargo run --manifest-path demo/Cargo.toml
- run: cargo test --workspace ${{steps.testsuite.outputs.exclude}}
if: matrix.rust != '1.60.0'
if: matrix.rust != '1.60.0' && matrix.rust != '1.64.0'
- run: cargo check --no-default-features --features alloc
env:
RUSTFLAGS: --cfg compile_error_if_std ${{env.RUSTFLAGS}}
Expand Down
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ fn main() {
rustc.version,
);
}

if rustc.minor < 64 {
// core::ffi::c_char
println!("cargo:rustc-cfg=no_core_ffi_c_char");
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/c_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ pub type c_char = c_char_definition::c_char;
#[cfg(all(test, feature = "std"))]
const _: self::c_char = 0 as std::os::raw::c_char;

#[cfg(not(no_core_ffi_c_char))]
mod c_char_definition {
pub use core::ffi::c_char;
}

#[cfg(no_core_ffi_c_char)]
#[allow(dead_code)]
mod c_char_definition {
// These are the targets on which c_char is unsigned.
Expand Down

0 comments on commit 8f16379

Please sign in to comment.