Skip to content

Wrong infered type when an additional constrain added #64681

@kurnevsky

Description

@kurnevsky

In the function f I have to specify bool explicitly while f differs from g in constrains only:

use rand::Rng;
use rand::distributions::{Distribution, Standard};

fn f<S, R>(rng: &mut R) -> bool
where
    R: Rng,
    Standard: Distribution<S>,
{
    rng.gen::<bool>()
}

fn g<R>(rng: &mut R) -> bool
where
    R: Rng
{
    rng.gen()
}

Playground

Not sure if it's an actual bug but it looks like the type inference should work the same way in both cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceA-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions