Skip to content

Commit e565541

Browse files
authored
Rollup merge of rust-lang#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
2 parents d8333a7 + 5470a38 commit e565541

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

library/std/src/sys/windows/compat.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,23 @@ macro_rules! compat_fn {
102102
}
103103

104104
#[allow(dead_code)]
105+
#[inline(always)]
105106
pub fn option() -> Option<F> {
106-
unsafe { PTR }
107+
unsafe {
108+
if cfg!(miri) {
109+
// Miri does not run `init`, so we just call `get_f` each time.
110+
get_f()
111+
} else {
112+
PTR
113+
}
114+
}
107115
}
108116

109117
#[allow(dead_code)]
110118
pub unsafe fn call($($argname: $argtype),*) -> $rettype {
111-
if let Some(ptr) = PTR {
119+
if let Some(ptr) = option() {
112120
return ptr($($argname),*);
113121
}
114-
if cfg!(miri) {
115-
// Miri does not run `init`, so we just call `get_f` each time.
116-
if let Some(ptr) = get_f() {
117-
return ptr($($argname),*);
118-
}
119-
}
120122
$fallback_body
121123
}
122124
}

0 commit comments

Comments
 (0)