-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
GAT: unconstrained lifetime in output when using GAT in fn type #77905
Comments
I don't think this is a bug. The following compiles:
|
@b-naber With your modifications fn somefn_gat<'a, T: Foo>(f: fn(T::In<'a>) -> T::In<'a>) {
} |
Unfortunately, this code isn't equivalent. With your proposed variant, Comparing two playgrounds (without GAT, to not run into the issue described in the original post of this issue): https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=18e76ca1267c0d8f9ee00b1c30475d4c |
I don't really understand how you want to call |
This isn't specific to GATs. trait Foo<'a> {
type In;
}
struct Simple<'a>(std::marker::PhantomData<&'a u32>);
fn somefn_simple(f: for<'a> fn(Simple<'a>) -> Simple<'a>) {
// compiles.
}
fn somefn_gat<T: for<'r> Foo<'r>>(f: for<'a> fn(<T as Foo<'a>>::In) -> <T as Foo<'a>>::In) {
// errors.
}
fn main() {} This is intended as |
I agree this is not a bug. The error message could use work. The key point is that the lifetime |
I would expect
somefn_gat
to build just likesomefn_simple
does, however it currently results in this error:rustc --version --verbose
:Click here for playground
The text was updated successfully, but these errors were encountered: