Open
Description
#![feature(generic_associated_types)]
trait Foo {
type In<'a>;
}
struct Simple<'a>(std::marker::PhantomData<&'a u32>);
fn somefn_simple(f: for<'a> fn(Simple<'a>) -> Simple<'a>) {
// compiles.
}
fn somefn_gat<T: Foo>(f: for<'a> fn(T::In<'a>) -> T::In<'a>) {
// errors.
}
fn main() {}
I would expect somefn_gat
to build just like somefn_simple
does, however it currently results in this error:
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1:12
|
1 | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types
--> src/main.rs:13:51
|
13 | fn somefn_gat<T: Foo>(f: for<'a> fn(T::In<'a>) -> T::In<'a>) {
| ^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0581`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
rustc --version --verbose
:
rustc 1.48.0-nightly (ef663a8a4 2020-09-30)