Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to return an impl Fn/FnMut/FnOnce that takes a concrete associated type #61903

Open
carado opened this issue Jun 16, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@carado
Copy link

commented Jun 16, 2019

A blank project with the following main.rs:

trait Trait {
	type Associated;
}

struct Struct;

impl Trait for Struct {
	type Associated = u8;
}

fn f() -> impl Fn(<Struct as Trait>::Associated) {
	// All of the following produce more or less the same error:
	//loop {}
	//unimplemented!()
	//panic!()
	//|_: <Struct as Trait>::Associated| {}
	//|_: u8| {}
	|_| {}
}

fn main() {}

Produces the following error:

    Checking rust9 v0.1.0 (/home/carado/tmp/rust9)
error[E0631]: type mismatch in closure arguments
  --> src/main.rs:11:11
   |
11 | fn f() -> impl Fn(<Struct as Trait>::Associated) {
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn(<Struct as Trait>::Associated) -> _`
...
18 |     |_| {}
   |     --- found signature of `fn(u8) -> _`
   |
   = note: the return type of a function must have a statically known size

error: aborting due to previous error

error: Could not compile `rust9`.

To learn more, run the command again with --verbose.

@carado carado changed the title Unable to return a Fn/FnMut/FnOnce that takes an concrete associated type Unable to return an impl Fn/FnMut/FnOnce that takes an concrete associated type Jun 16, 2019

@carado carado changed the title Unable to return an impl Fn/FnMut/FnOnce that takes an concrete associated type Unable to return an impl Fn/FnMut/FnOnce that takes a concrete associated type Jun 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.