Closed
Description
trait LifetimeToType<'a> {
type Out;
}
impl<'a> LifetimeToType<'a> for () {
type Out = &'a ();
}
fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out {
val
}
fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { }
fn main() {
assert_fn(id);
}
fails with
test.rs:16:5: 16:14 error: type mismatch resolving `for<'a> <fn(&'a ()) -> <() as LifetimeToType<'a>>::Out {id} as core::ops::FnOnce<(&'a (),)>>::Output == <() as LifetimeToType<'a>>::Out`:
expected &-ptr,
found associated type [E0271]
test.rs:16 assert_fn(id);
^~~~~~~~~
test.rs:16:5: 16:14 help: run `rustc --explain E0271` to see a detailed explanation
test.rs:16:5: 16:14 note: required by `assert_fn`
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Lifetimes / regionsCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.