diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-14 10:35:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-14 10:35:32 +0200 |
| commit | e5655418244cac9b3be0ef1b83aab1f8b00fe548 (patch) | |
| tree | 9bd731ad633dd071eec984426acb6e1876446b60 /library/std/src/sys | |
| parent | d8333a7b59c7b1308955bbd5a37ceabf86ec7dea (diff) | |
| parent | 5470a389214381917ff7215c5fe700e9045fb838 (diff) | |
| download | rust-e5655418244cac9b3be0ef1b83aab1f8b00fe548.tar.gz rust-e5655418244cac9b3be0ef1b83aab1f8b00fe548.zip | |
Rollup merge of #98042 - DrMeepster:winfred_std_changes, r=ChrisDenton
Fix compat_fn option method on miri This change is required to make `WaitOnAddress` work with rust-lang/miri#2231
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/windows/compat.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/library/std/src/sys/windows/compat.rs b/library/std/src/sys/windows/compat.rs index c55df042003..ded97bb7eaa 100644 --- a/library/std/src/sys/windows/compat.rs +++ b/library/std/src/sys/windows/compat.rs @@ -102,21 +102,23 @@ macro_rules! compat_fn { } #[allow(dead_code)] + #[inline(always)] 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 } } |
