Skip to content

Error extending Fn trait then using it as a trait object: the value of the associated type `Output must be specified #24010

Closed
@carllerche

Description

@carllerche
trait Foo: Fn(i32) + Send { }
impl<T:?Sized + Fn(i32) + Send> Foo for T { }

fn wants_foo(t: Box<Foo>) {
}

fn main() {
  let f = Box::new(|x| println!("{}", x));
  wants_foo(f);
}

Output:

<anon>:9:13: 9:14 error: the value of the associated type `Output` (from the trait `core::ops::FnOnce`) must be specified [E0191]
<anon>:9   wants_foo(f);
                     ^

cc @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-trait-systemArea: Trait systemC-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