fix(std): Rename os_str_bytes to encoded_bytes
This commit is contained in:
parent
9aee1de612
commit
30292bb68e
16 changed files with 87 additions and 87 deletions
|
|
@ -24,7 +24,7 @@ pub fn bytes_to_os_str<'tcx>(bytes: &[u8]) -> InterpResult<'tcx, &OsStr> {
|
|||
}
|
||||
#[cfg(not(unix))]
|
||||
pub fn bytes_to_os_str<'tcx>(bytes: &[u8]) -> InterpResult<'tcx, &OsStr> {
|
||||
// We cannot use `from_os_str_bytes_unchecked` here since we can't trust `bytes`.
|
||||
// We cannot use `from_encoded_bytes_unchecked` here since we can't trust `bytes`.
|
||||
let s = std::str::from_utf8(bytes)
|
||||
.map_err(|_| err_unsup_format!("{:?} is not a valid utf-8 string", bytes))?;
|
||||
Ok(OsStr::new(s))
|
||||
|
|
@ -83,7 +83,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
ptr: Pointer<Option<Provenance>>,
|
||||
size: u64,
|
||||
) -> InterpResult<'tcx, (bool, u64)> {
|
||||
let bytes = os_str.as_os_str_bytes();
|
||||
let bytes = os_str.as_encoded_bytes();
|
||||
self.eval_context_mut().write_c_str(bytes, ptr, size)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1344,7 +1344,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
|
||||
let mut name = dir_entry.file_name(); // not a Path as there are no separators!
|
||||
name.push("\0"); // Add a NUL terminator
|
||||
let name_bytes = name.as_os_str_bytes();
|
||||
let name_bytes = name.as_encoded_bytes();
|
||||
let name_len = u64::try_from(name_bytes.len()).unwrap();
|
||||
|
||||
let dirent64_layout = this.libc_ty_layout("dirent64");
|
||||
|
|
@ -1698,7 +1698,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
Cow::Borrowed(resolved.as_ref()),
|
||||
crate::shims::os_str::PathConversion::HostToTarget,
|
||||
);
|
||||
let mut path_bytes = resolved.as_os_str_bytes();
|
||||
let mut path_bytes = resolved.as_encoded_bytes();
|
||||
let bufsize: usize = bufsize.try_into().unwrap();
|
||||
if path_bytes.len() > bufsize {
|
||||
path_bytes = &path_bytes[..bufsize]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use super::miri_extern;
|
|||
pub fn host_to_target_path(path: OsString) -> PathBuf {
|
||||
use std::ffi::{CStr, CString};
|
||||
|
||||
// Once into_os_str_bytes is stable we can use it here.
|
||||
// Once into_encoded_bytes is stable we can use it here.
|
||||
// (Unstable features would need feature flags in each test...)
|
||||
let path = CString::new(path.into_string().unwrap()).unwrap();
|
||||
let mut out = Vec::with_capacity(1024);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue