Skip to content

Commit aecb5a7

Browse files
committed
Fix emulation
1 parent 42f7d55 commit aecb5a7

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/shims/unix/fs.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ impl FileDescription for FileHandle {
6666
// Correctness of this emulation relies on sequential nature of Miri execution.
6767
#[cfg(not(unix))]
6868
{
69-
use io::{Seek, SeekFrom};
70-
let cursor_pos = self.file.stream_position()?;
71-
self.file.seek(SeekFrom::Start(offset))?;
72-
let n = self.file.read(bytes)?;
73-
self.file.seek(SeekFrom::Start(cursor_pos))?;
74-
Ok(n)
69+
let f = || {
70+
use io::{Seek, SeekFrom};
71+
let cursor_pos = self.file.stream_position()?;
72+
self.file.seek(SeekFrom::Start(offset))?;
73+
let n = self.file.read(bytes)?;
74+
self.file.seek(SeekFrom::Start(cursor_pos))?;
75+
Ok(n)
76+
};
77+
Ok(f())
7578
}
7679
}
7780

@@ -93,12 +96,15 @@ impl FileDescription for FileHandle {
9396
// Correctness of this emulation relies on sequential nature of Miri execution.
9497
#[cfg(not(unix))]
9598
{
96-
use io::{Seek, SeekFrom};
97-
let cursor_pos = self.file.stream_position()?;
98-
self.file.seek(SeekFrom::Start(offset))?;
99-
let n = self.file.write(bytes)?;
100-
self.file.seek(SeekFrom::Start(cursor_pos))?;
101-
Ok(n)
99+
let f = || {
100+
use io::{Seek, SeekFrom};
101+
let cursor_pos = self.file.stream_position()?;
102+
self.file.seek(SeekFrom::Start(offset))?;
103+
let n = self.file.write(bytes)?;
104+
self.file.seek(SeekFrom::Start(cursor_pos))?;
105+
Ok(n)
106+
};
107+
Ok(f())
102108
}
103109
}
104110

0 commit comments

Comments
 (0)