fix(rust): use core crates for no_std
also add `no_std` build to CI
This commit is contained in:
parent
acc9cafc7c
commit
ed69a74463
3 changed files with 14 additions and 3 deletions
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
|
|
@ -195,6 +195,13 @@ jobs:
|
|||
npm run build
|
||||
npm run build:debug
|
||||
|
||||
- name: Check no_std builds
|
||||
if: ${{ !matrix.no-run && inputs.run-test }}
|
||||
shell: bash
|
||||
run: |
|
||||
cd lib
|
||||
$BUILD_CMD check --no-default-features
|
||||
|
||||
- name: Build target
|
||||
run: $BUILD_CMD build --release --target=${{ matrix.target }} --features=${{ matrix.features }}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(feature = "std")]
|
||||
extern "C" {
|
||||
pub(crate) fn _ts_dup(handle: *mut std::os::raw::c_void) -> std::os::raw::c_int;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1222,7 +1222,7 @@ impl Parser {
|
|||
len: u32,
|
||||
code_point: *mut i32,
|
||||
) -> u32 {
|
||||
let (c, len) = D::decode(std::slice::from_raw_parts(data, len as usize));
|
||||
let (c, len) = D::decode(core::slice::from_raw_parts(data, len as usize));
|
||||
if let Some(code_point) = code_point.as_mut() {
|
||||
*code_point = c;
|
||||
}
|
||||
|
|
@ -1422,7 +1422,7 @@ impl Parser {
|
|||
if let Some(flag) = flag {
|
||||
ffi::ts_parser_set_cancellation_flag(
|
||||
self.0.as_ptr(),
|
||||
std::ptr::from_ref::<AtomicUsize>(flag).cast::<usize>(),
|
||||
core::ptr::from_ref::<AtomicUsize>(flag).cast::<usize>(),
|
||||
);
|
||||
} else {
|
||||
ffi::ts_parser_set_cancellation_flag(self.0.as_ptr(), ptr::null());
|
||||
|
|
@ -1432,7 +1432,10 @@ impl Parser {
|
|||
|
||||
impl Drop for Parser {
|
||||
fn drop(&mut self) {
|
||||
self.stop_printing_dot_graphs();
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
self.stop_printing_dot_graphs();
|
||||
}
|
||||
self.set_logger(None);
|
||||
unsafe { ffi::ts_parser_delete(self.0.as_ptr()) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue