Skip to content

Cannot mix impl Trait and explicit generic arguments #71869

Closed
@glandium

Description

@glandium

I tried this code:

trait Foo {}

impl Foo for usize {}

fn bar<T: Foo>(_t: impl Foo) -> T {
    unimplemented!();
}

fn main() {
    bar::<usize>(42);
}

I expected this would give the explicit return value.

Instead, this happened:

error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
  --> src/main.rs:10:11
   |
10 |     bar::<usize>(42);
   |           ^^^^^ explicit generic argument not allowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions