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
This commit is contained in:
Dylan DPC 2022-06-14 10:35:32 +02:00 committed by GitHub
commit e565541824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
}