Skip to content

Integer type inference doesn't check trait implementations #15232

Closed
@sfackler

Description

@sfackler

Ideally something like this would work, but it currently doesn't:

trait Foo {}

impl Foo for i32 {}

struct Baz;

fn foo<F: Foo>(f: F) {}

fn main() {
    foo(10);
}
test.rs:11:5: 11:8 error: cannot determine the type of this integer; add a suffix to specify the type explicitly
test.rs:11     foo(10);
               ^~~
test.rs:11:5: 11:8 error: failed to find an implementation of trait Foo for int
test.rs:11     foo(10);
               ^~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions