This post is a “public service announcement” for people working on the guts of rustc. I wish I had known about this a year ago, so I hope this post can make this feature more widely known.
Debugging layouts recently became a lot easier:
#![feature(rustc_attrs)]
#[rustc_layout(debug)]
type T = (u8, u16);
Interesting. My first suspicion would be that this call fails, i.e., that the type does not yet have a layout when the attribute gets processed. @eddyb might be able to confirm or reject that hypothesis.
That's not really a thing nowadays, you can't observe something like that without it being unsound for the query system and incremental - what would happen is that the necessary queries would be triggered and the type computed on-demand (this is similar to CTFE triggering type-checking, borrow-checking and only then running the MIR through miri).
It works with this tweak, which means @jschievink is right:
#[rustc_layout(debug)]
type X = T;
type T = impl Generator<u8>;
This is somewhat surprising to me, as I expected impl Trait to be allowed anywhere inside the RHS of a type alias, but apparently the feature is limited to type Foo = impl Bar;.
I find it somewhat confusing to get entirely different AST nodes for very similar surface syntax -- naively I would have expected that TyAlias then has two kind of "child nodes", one for normal aliases and one for impl. But well, I probably should just have read the docs.