use pin_project::{pin_project, project}; trait Bar { type Y; } struct Example(A); impl Bar for Example { type Y = Option; } #[pin_project] struct Foo { _x: as Bar>::Y, } #[project] impl Foo {}