Skip to content

Commit db49339

Browse files
committed
Auto merge of #1255 - RalfJung:os_str_bytes, r=RalfJung
fix conditional compilation condition for os_str <-> bytes conversion Turns out that condition was wrong and these functions never got compiled... Cc @christianpoveda
2 parents aaa16a5 + 2f37177 commit db49339

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/helpers.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
463463
'tcx: 'a,
464464
'mir: 'a,
465465
{
466-
#[cfg(target_os = "unix")]
466+
#[cfg(unix)]
467467
fn bytes_to_os_str<'tcx, 'a>(bytes: &'a [u8]) -> InterpResult<'tcx, &'a OsStr> {
468-
Ok(std::os::unix::ffi::OsStringExt::from_bytes(bytes))
468+
Ok(std::os::unix::ffi::OsStrExt::from_bytes(bytes))
469469
}
470-
#[cfg(not(target_os = "unix"))]
470+
#[cfg(not(unix))]
471471
fn bytes_to_os_str<'tcx, 'a>(bytes: &'a [u8]) -> InterpResult<'tcx, &'a OsStr> {
472472
let s = std::str::from_utf8(bytes)
473473
.map_err(|_| err_unsup_format!("{:?} is not a valid utf-8 string", bytes))?;
@@ -490,11 +490,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
490490
scalar: Scalar<Tag>,
491491
size: u64,
492492
) -> InterpResult<'tcx, (bool, u64)> {
493-
#[cfg(target_os = "unix")]
493+
#[cfg(unix)]
494494
fn os_str_to_bytes<'tcx, 'a>(os_str: &'a OsStr) -> InterpResult<'tcx, &'a [u8]> {
495-
std::os::unix::ffi::OsStringExt::into_bytes(os_str)
495+
Ok(std::os::unix::ffi::OsStrExt::as_bytes(os_str))
496496
}
497-
#[cfg(not(target_os = "unix"))]
497+
#[cfg(not(unix))]
498498
fn os_str_to_bytes<'tcx, 'a>(os_str: &'a OsStr) -> InterpResult<'tcx, &'a [u8]> {
499499
// On non-unix platforms the best we can do to transform bytes from/to OS strings is to do the
500500
// intermediate transformation into strings. Which invalidates non-utf8 paths that are actually

0 commit comments

Comments
 (0)