PSA: unstable type alias impl trait feature breakage incoming

97 points oli-obk 24 comments

We are about to land a major change in how the unstable TAITs (type alias impl trait) works from the user perspective: https://github.com/rust-lang/rust/pull/128440

This change will break every user of the feature, but it also becomes much simpler to use.

no more restructuring your code to use helper modules or moving functions around to avoid cycle errors.

the new rules are quite simple: by default, TAITs are opaque, meaning you cannot create them from a concrete type. the functions that you actually want to create TAIT values out of values of other types need a #[define_opaque(NameOfATypeAlias)] attribute.

Note that in contrast to previously, only functions and methods can define opaques, statics, closures, and consts cannot. you can however create a const fn that defines an opaque and call it from a static. closures of functions with the attribute can also define the TAITs