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

Make Fn* types work with some generic methods #37

Closed
LukasKalbertodt opened this issue Oct 6, 2018 · 1 comment · Fixed by #80
Closed

Make Fn* types work with some generic methods #37

LukasKalbertodt opened this issue Oct 6, 2018 · 1 comment · Fixed by #80

Comments

@LukasKalbertodt
Copy link
Member

Currently, this:

#[auto_impl(Fn)]
trait Greeter {
    fn greet<T: Display>(&self, name: T);
}

Generates this:

impl<U: ::std::ops::Fn(T)> Greeter for U {
    fn greet<T: Display>(&self, name: T) {
        ({ self })(name)
    }
}

This doesn't compile as T is only declared on the method but already used in the impl header. We could make this specific thing work by moving T: Display to the impl header.

But it's questionable whether we should support generic functions at all. impl Trait in argument position could be complicated. We would have to transform impl Trait generics into standard generics. If we would only support standard generics, that would... be kinda sad.

Since we never claimed to support generics for Fn* types, I won't classify this as bug. But it would be nice to support in the future.

@KodrAus
Copy link
Member

KodrAus commented Oct 15, 2018

Could we use a similar technique to finding a reasonable name for generic types that we do with find_suitable_param_names?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants