Skip to content

Commit

Permalink
fix(tvix/nix-compat): Feature flag code only used in async
Browse files Browse the repository at this point in the history
When only the wire feature was enabled two methods were unused and so
would faild `cargo check --no-default-features --features wire`.

This feature flags those two methods on async feature since that is the
only place they are used.

Change-Id: I6ec18a670e3c6e3ecee8d1417c99f1a5084e0ae7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12346
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Brian Olsen <me@griff.name>
Tested-by: BuildkiteCI
griff authored and clbot committed Aug 25, 2024
1 parent 7b37ff8 commit 402bde1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nix-compat/src/wire/bytes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#[cfg(feature = "async")]
use std::mem::MaybeUninit;
use std::{
io::{Error, ErrorKind},
mem::MaybeUninit,
ops::RangeInclusive,
};
use tokio::io::{self, AsyncReadExt, AsyncWriteExt, ReadBuf};
#[cfg(feature = "async")]
use tokio::io::ReadBuf;
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};

pub(crate) mod reader;
pub use reader::BytesReader;
@@ -79,6 +82,7 @@ where
Ok(buf)
}

#[cfg(feature = "async")]
pub(crate) async fn read_bytes_buf<'a, const N: usize, R>(
reader: &mut R,
buf: &'a mut [MaybeUninit<u8>; N],
@@ -132,6 +136,7 @@ where
}

/// SAFETY: The bytes have to actually be initialized.
#[cfg(feature = "async")]
unsafe fn assume_init_bytes(slice: &[MaybeUninit<u8>]) -> &[u8] {
&*(slice as *const [MaybeUninit<u8>] as *const [u8])
}

0 comments on commit 402bde1

Please sign in to comment.