Skip to content

std feature of rand_core changes API #738

Description

@Nemo157

Specifically if you are calling rand_core::Error::with_cause with something that doesn't implement std::error::Error (because you don't directly rely on std) then another dependency activates the rand_core/std feature you will get a compilation error.

Simplest way to see this is to use rand as the library that is built on rand_core without the std feature, then activate the std feature in an empty library that depends on both:

[dependencies]
rand = { version = "0.6.5", default-features = false }
rand_core = { version = "0.4.0", default-features = false, features = ["std"] }

This will fail to build with the error:

error[E0277]: the trait bound `error::TimerError: std::error::Error` is not satisfied
  --> /home/wim/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_jitter-0.1.3/src/error.rs:62:9
   |
62 |         Error::with_cause(ErrorKind::Unavailable,
   |         ^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `error::TimerError`
   |
   = note: required because of the requirements on the impl of `core::convert::From<error::TimerError>` for `alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'static)>`
   = note: required because of the requirements on the impl of `core::convert::Into<alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'static)>>` for `error::TimerError`
   = note: required by `rand_core::Error::with_cause`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions