Skip to content

Commit 8b89c7e

Browse files
committed
Use panicking coversions instead of as
1 parent 186d59a commit 8b89c7e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/shims/posix/fs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,13 +1372,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
13721372
match result {
13731373
Ok(resolved) => {
13741374
let mut path_bytes = this.os_str_to_bytes(resolved.as_ref())?;
1375-
if path_bytes.len() > bufsize as usize {
1376-
path_bytes = &path_bytes[..(bufsize as usize)]
1375+
let bufsize: usize = bufsize.try_into().unwrap();
1376+
if path_bytes.len() > bufsize {
1377+
path_bytes = &path_bytes[..bufsize]
13771378
}
13781379
// 'readlink' truncates the resolved path if
13791380
// the provided buffer is not large enough
13801381
this.memory.write_bytes(buf, path_bytes.iter().copied())?;
1381-
Ok(path_bytes.len() as i64)
1382+
Ok(path_bytes.len().try_into().unwrap())
13821383
}
13831384
Err(e) => {
13841385
this.set_last_error_from_io_error(e)?;

0 commit comments

Comments
 (0)