What's the proper name for `impl Trait` types?

I wrote a wiki page about impl Trait, but I want to make sure that I use the right terminology. So I did some digging, and this is what I found out:

  • The first RFC allows impl Trait only in return position, so it calls it an abstract return type.

  • The second RFC, which expands impl Trait syntax to function arguments, just refers to it as "impl Trait". The book does the same.

    I don't particularly like this name, because it describes the syntax but not the purpose of the feature. Furthermore, to incorporate it in an English sentence, you have to resort to phrases like "the impl Trait syntax" or "the impl Trait feature".

  • The compiler calls it an opaque type (see playground), as does the Guide to Rustc Development.

Therefore I'm inclined to use the name "opaque type". The problem is that "opaque" is an overloaded term: Extern types are also called opaque, and even structs that don't expose implementation details are sometimes called opaque, e.g. here and here.

I'd like to have a name for this that is both descriptive and unambiguous, and is used by all the official documentation as well as the compiler. I believe that such a name doesn't exist (yet). I'd like to hear your opinions, if you agree that this is a problem, and how it could be addressed!

1 Like

Before someone else suggests it, I'd like to mention that "existential type" is sometimes used for this, but on more thorough inspection (as has been done in past discussions) that term turns out to be either misleading or simply incorrect. One of the simpler reasons is that dyn Trait is also sort of an existential.

I'm personally not aware of a better option than "opaque type", and simply discouraging using that term for extern types seems feasible to me.

1 Like

That sounds reasonable. It means that the standard library should be updated to rephrase parts that are currently ambiguous.

Just to note, the "terms" of RPIT (Return Position Impl Trait) and APIT (Argument Position Impl Trait) are fairly common in discussions that need to distinguish between the two, and TAIT (Type Alias (position) Impl Trait) is in the nightly pipeline.

1 Like

Maybe the wiki should have a glossary... :slightly_smiling_face:

It does, but I'm not sure how that helps in this case.