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

Closed
carado opened this issue Jun 16, 2019 · 2 comments
Closed
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@carado
Copy link

carado 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
@jonas-schievink jonas-schievink added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 16, 2019
@carado
Copy link
Author

carado commented Sep 13, 2019

This bug no longer occurs.
(I just checked with rustc 1.39.0-nightly (0b36e9d 2019-09-09))

@carado carado closed this as completed Sep 13, 2019
@jonas-schievink
Copy link
Contributor

Probably fixed by #62221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants