-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsGATs-triagedIssues using the `generic_associated_types` feature that have been triagedIssues using the `generic_associated_types` feature that have been triaged
Description
I tried this code:
#![feature(generic_associated_types)]
trait Trait {
type Assoc<'a>;
}
fn f<T: Trait>(_: T, _: impl Fn(T::Assoc<'_>)) {}
struct Type;
impl Trait for Type {
type Assoc<'a> = ();
}
fn main() {
f(Type, |_|());
}
I expected to see this happen: compiles with no errors.
Instead, this happened:
error[E0631]: type mismatch in closure arguments
--> src/main.rs:16:5
|
16 | f(Type, |_|());
| ^ ----- found signature of `fn(()) -> _`
| |
| expected signature of `for<'r> fn(<Type as Trait>::Assoc<'r>) -> _`
|
note: required by a bound in `f`
--> src/main.rs:7:30
|
7 | fn f<T: Trait>(_: T, _: impl Fn(T::Assoc<'_>)) {}
| ^^^^^^^^^^^^^^^^ required by this bound in `f`
The error seems to suggest that rustc can't figure out that the associated type is ()
which should satisfy the bound in f
.
Meta
1.56.0-nightly ( 5eacec9 )
This could be related to #85921, but unlike that issue this one does not seem to be fixed on latest nightly.
ollpu and hlb8122
Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsGATs-triagedIssues using the `generic_associated_types` feature that have been triagedIssues using the `generic_associated_types` feature that have been triaged