Skip to content

Able to use the turbofish syntax with impl trait for methods #50950

Closed
@Thinkofname

Description

@Thinkofname

In some cases it seems like you are able to use the turbofish syntax with impl Trait

use std::any::Any;
pub struct EventHandler {
}

impl EventHandler
{
    pub fn handle_event<T: Any>(&mut self, _efunc: impl FnMut(T)) {}
}

struct TestEvent(i32);

fn main() {
    let mut evt = EventHandler {};
    evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
    });
}

playground: http://play.rust-lang.org/?gist=62b8c9d317dd6f149354555ca42d45b3&version=stable&mode=debug

This should fail with error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.

Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.P-highHigh priorityT-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