fix compat_fn option method on miri
This commit is contained in:
parent
09d52bc5d4
commit
940e0b3765
@ -103,20 +103,21 @@ pub mod $symbol {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn option() -> Option<F> {
|
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)]
|
#[allow(dead_code)]
|
||||||
pub unsafe fn call($($argname: $argtype),*) -> $rettype {
|
pub unsafe fn call($($argname: $argtype),*) -> $rettype {
|
||||||
if let Some(ptr) = PTR {
|
if let Some(ptr) = option() {
|
||||||
return ptr($($argname),*);
|
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
|
$fallback_body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user