Question about RTN MVP

Hey folks

I've seen the new blog post about RTN, there you can read:

Currently, RTN is only allowed for trait associated functions and methods with lifetime generics (not const or type generics) that use:

async fn in traits (AFIT) or
return-position impl Trait in traits (RPITIT) where the impl Trait is the outermost return type, i.e. -> impl Trait, but not -> Box<impl Trait>.

These restrictions are described in further detail in RFC 3654.

I understand the point in the RFC why you can only use it currently with AFIT and RPITIT but I cannot find any real explaination why RTN cannot be used with functions/methods that have const or type generics. The RFC says at least:

The method named in an RTN type may have generic parameters (e.g., fn widgets<'a>(&'a self) has a lifetime parameter 'a). Because RTN locations are limited to where-clauses and trait bounds in this RFC, these parameters can always be captured in a for to form a higher-ranked trait bound.

So is the generic lifetime only support here a design decision to make sure that RTNs - always - work with HRTBs or are there any other reasons for this restriction?

Regards
keks

PS: I ask this just out of curiosity because I want to understand it. :slight_smile:

Ok, I think I might understand it now. It seems as if generic parameters on a function have to desugar always to a higher-ranked generic on a RTN bound and as this is not yet possible for types you can only use functions with generic lifetimes for now.

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.