Skip to content

macOS: cannot subtract Instants (mach_timebase_info not implemented) #1288

@RalfJung

Description

@RalfJung

On macOS, we cannot subtract one Instant from another:

error: unsupported operation: can't call foreign function: mach_timebase_info
   --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/time.rs:239:13
    |
239 |             mach_timebase_info(&mut info);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: mach_timebase_info
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
    = note: inside call to `std::sys::unix::time::inner::info` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/time.rs:156:24
    = note: inside call to `std::sys::unix::time::inner::Instant::checked_sub_instant` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/time.rs:263:9
note: inside call to `std::time::Instant::duration_since` at tests/run-pass/time.rs:25:20
   --> tests/run-pass/time.rs:25:20
    |
25  |         let diff = now2.duration_since(now1);
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: inside call to `main` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:34

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macArea: Affects only macOS targetsA-shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementE-good-first-issueA good way to start contributing, mentoring is available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions