Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Build errors for uptime on OpenBSD #9157

@lcheylus

Description

@lcheylus

On OpenBSD current/amd64 with Rust 1.90.0, there are some errors when trying to build uptime tool.

$ uname -a
OpenBSD openbsd-dev.home.lan 7.8 GENERIC.MP#76 amd64

$ rustc -vV
rustc 1.90.0 (1159e78c4 2025-09-14) (built from a source tarball)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-openbsd
release: 1.90.0
LLVM version: 19.1.7

$ cargo build -v --no-default-features --features uptime
(...)
error[E0308]: mismatched types
  --> src/uucore/src/lib/features/uptime.rs:78:13
   |
78 |         Err(UptimeError::SystemUptime)
   |         --- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn UError>`, found `UptimeError`
   |         |
   |         arguments to this enum variant are incorrect
   |
   = note: expected struct `Box<dyn UError>`
                found enum `UptimeError`
   = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
help: the type constructed contains `UptimeError` due to the type of the argument passed
  --> src/uucore/src/lib/features/uptime.rs:78:9
   |
78 |         Err(UptimeError::SystemUptime)
   |         ^^^^-------------------------^
   |             |
   |             this argument influences the type of `Err`
note: tuple variant defined here
  --> /usr/obj/ports/rust-1.90.0/rustc-1.90.0-src/library/core/src/result.rs:557:5
help: store this in the heap by calling `Box::new`
   |
78 |         Err(Box::new(UptimeError::SystemUptime))
   |             +++++++++                         +

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/uptime.rs:219:9
    |
218 |     let entries = match parse_from_path(file) {
    |                         --------------------- this expression has type `Result<Vec<UtmpEntry>, utmp_classic::ParseError>`
219 |         Some(e) => e,
    |         ^^^^^^^ expected `Result<Vec<UtmpEntry>, ParseError>`, found `Option<_>`
    |
    = note: expected enum `Result<Vec<UtmpEntry>, utmp_classic::ParseError>`
               found enum `Option<_>`

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/uptime.rs:220:9
    |
218 |     let entries = match parse_from_path(file) {
    |                         --------------------- this expression has type `Result<Vec<UtmpEntry>, utmp_classic::ParseError>`
219 |         Some(e) => e,
220 |         None => return 0,
    |         ^^^^ expected `Result<Vec<UtmpEntry>, ParseError>`, found `Option<_>`
    |
    = note: expected enum `Result<Vec<UtmpEntry>, utmp_classic::ParseError>`
               found enum `Option<_>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `uucore` (lib) due to 3 previous errors

I have a fix for these errors and also for tests for uptime on OpenBSD. I will propose a PR ASAP.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions