Skip to content

Strangly [E0275]: overflow evaluating the requirement #165413

Open

Description

@A4-Tacks

Code

fn foo() {
    rand::RngExt::random(&mut rand::rng())%50i32;
}

Current output

error[E0275]: overflow evaluating the requirement `StandardUniform: rand::distr::Distribution<_>`
  --> src/lib.rs:2:5
   |
 2 |     rand::RngExt::random(&mut rand::rng())%50i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: required by a bound in `rand::RngExt::random`
  --> /home/lrne/.cargo/registry/src/rsproxy.cn-e3de039b2554c837/rand-0.10.3/src/rng.rs:95:26
   |
56 | pub trait RngExt: Rng {
...
93 |     fn random<T>(&mut self) -> T
94 |     where
95 |         StandardUniform: Distribution<T>,
   |                          ^^^^^^^^^^^^^^^ required by this bound in `RngExt::random`

Desired output

Some types, generics, bounds diagnostics...

Rationale and extra context

rand = "0.10.3"

Other cases

fn foo() {
    rand::RngExt::random::<i32>(&mut rand::rng())%50i32;
}

Rust Version

rustc 1.101.0-nightly (7df81381d 2026-10-14)
binary: rustc
commit-hash: 7df81381d027710708209f36b98d11b1c88f8d2e
commit-date: 2026-10-14
host: aarch64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.3

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Nov 3, 2026
  2. added
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)
    on Nov 4, 2026
  3. adwinwhite commented on Nov 4, 2026

    @adwinwhite
    Contributor

    self contained:

    trait Distribution<T> {}
    impl Distribution<()> for u32 {}
    impl<A, B> Distribution<(A, B)> for u32
    where
        u32: Distribution<A>,
        u32: Distribution<B>,
    {
    }
    
    fn require<T>() where u32: Distribution<T> {}
    
    fn main() {
        require();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions