fix(rust): use unix + wasi cfg instead of not windows for fd

This commit is contained in:
Liam Rosenfeld 2024-04-23 10:13:38 -04:00 committed by GitHub
parent af695f3c0a
commit 0f125e2d09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(not(feature = "bindgen"))]
include!("./bindings.rs");
#[cfg(not(windows))]
#[cfg(any(unix, target_os = "wasi"))]
extern "C" {
pub(crate) fn _ts_dup(fd: std::os::raw::c_int) -> std::os::raw::c_int;
}

View file

@ -3,7 +3,7 @@
pub mod ffi;
mod util;
#[cfg(not(windows))]
#[cfg(any(unix, target_os = "wasi"))]
use std::os::fd::AsRawFd;
#[cfg(windows)]
use std::os::windows::io::AsRawHandle;
@ -533,10 +533,10 @@ impl Parser {
#[doc(alias = "ts_parser_print_dot_graphs")]
pub fn print_dot_graphs(
&mut self,
#[cfg(not(windows))] file: &impl AsRawFd,
#[cfg(any(unix, target_os = "wasi"))] file: &impl AsRawFd,
#[cfg(windows)] file: &impl AsRawHandle,
) {
#[cfg(not(windows))]
#[cfg(any(unix, target_os = "wasi"))]
{
let fd = file.as_raw_fd();
unsafe {
@ -942,10 +942,10 @@ impl Tree {
#[doc(alias = "ts_tree_print_dot_graph")]
pub fn print_dot_graph(
&self,
#[cfg(not(windows))] file: &impl AsRawFd,
#[cfg(any(unix, target_os = "wasi"))] file: &impl AsRawFd,
#[cfg(windows)] file: &impl AsRawHandle,
) {
#[cfg(not(windows))]
#[cfg(any(unix, target_os = "wasi"))]
{
let fd = file.as_raw_fd();
unsafe { ffi::ts_tree_print_dot_graph(self.0.as_ptr(), fd) }