“return type cannot contain a projection or Self” when not using Self

Hi! I’m looking for help regarding the error message “async fn return type cannot contain a projection or Self that references lifetimes from a parent scope”. AFAICT from searching the forum there is only one other mention of this error message (“How to wrap async stream (for a library)?”), but in that thread, the solution is to change an occurrence of Self to the underlying type. In my case, I get this error on a free function, there is no Self involved, and I’m not sure what to do about it. Does anyone have any ideas?

trait MyTrait<'a> {
	type Output;

async fn my_function<'a, T: MyTrait<'a>>(input: T) -> T::Output {

Rust playground


This is compiler bug #53613. A workaround is to spell out T::Output as <T as MyTrait<'a>>::Output.

Playground link

Fantastic, thank you! I knew it was a compiler bug, I just didn’t know how to work around it in this particular situation.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.