diff options
| author | DrMeepster <19316085+DrMeepster@users.noreply.github.com> | 2022-05-31 18:25:06 -0700 |
|---|---|---|
| committer | DrMeepster <19316085+DrMeepster@users.noreply.github.com> | 2022-06-11 16:52:59 -0700 |
| commit | 940e0b376510d68e7ce4a8eb30e33517692d83b1 (patch) | |
| tree | 8b0fa0df4461090411092341b0650741a61a4dde | |
| parent | 09d52bc5d4260bac8b9a2ea8ac7a07c5c72906f1 (diff) | |
| download | rust-940e0b376510d68e7ce4a8eb30e33517692d83b1.tar.gz rust-940e0b376510d68e7ce4a8eb30e33517692d83b1.zip | |
fix compat_fn option method on miri
| -rw-r--r-- | library/std/src/sys/windows/compat.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/library/std/src/sys/windows/compat.rs b/library/std/src/sys/windows/compat.rs index c55df042003..424a0892b42 100644 --- a/library/std/src/sys/windows/compat.rs +++ b/library/std/src/sys/windows/compat.rs @@ -103,20 +103,21 @@ macro_rules! compat_fn { #[allow(dead_code)] pub fn option() -> Option<F> { - unsafe { PTR } + unsafe { + if cfg!(miri) { + // Miri does not run `init`, so we just call `get_f` each time. + get_f() + } else { + PTR + } + } } #[allow(dead_code)] pub unsafe fn call($($argname: $argtype),*) -> $rettype { - if let Some(ptr) = PTR { + if let Some(ptr) = option() { return ptr($($argname),*); } - if cfg!(miri) { - // Miri does not run `init`, so we just call `get_f` each time. - if let Some(ptr) = get_f() { - return ptr($($argname),*); - } - } $fallback_body } } |
