17e2e9c0cSopenharmony_ci#![allow(clippy::used_underscore_binding)] 27e2e9c0cSopenharmony_ci 37e2e9c0cSopenharmony_ciuse serde_derive::{Deserialize, Serialize}; 47e2e9c0cSopenharmony_ci 57e2e9c0cSopenharmony_ci#[test] 67e2e9c0cSopenharmony_cifn test_self() { 77e2e9c0cSopenharmony_ci pub trait Trait { 87e2e9c0cSopenharmony_ci type Assoc; 97e2e9c0cSopenharmony_ci } 107e2e9c0cSopenharmony_ci 117e2e9c0cSopenharmony_ci #[derive(Deserialize, Serialize)] 127e2e9c0cSopenharmony_ci pub struct Generics<T: Trait<Assoc = Self>> 137e2e9c0cSopenharmony_ci where 147e2e9c0cSopenharmony_ci Self: Trait<Assoc = Self>, 157e2e9c0cSopenharmony_ci <Self as Trait>::Assoc: Sized, 167e2e9c0cSopenharmony_ci { 177e2e9c0cSopenharmony_ci _f: T, 187e2e9c0cSopenharmony_ci } 197e2e9c0cSopenharmony_ci 207e2e9c0cSopenharmony_ci impl<T: Trait<Assoc = Self>> Trait for Generics<T> { 217e2e9c0cSopenharmony_ci type Assoc = Self; 227e2e9c0cSopenharmony_ci } 237e2e9c0cSopenharmony_ci 247e2e9c0cSopenharmony_ci #[derive(Deserialize, Serialize)] 257e2e9c0cSopenharmony_ci pub struct Struct { 267e2e9c0cSopenharmony_ci _f1: Box<Self>, 277e2e9c0cSopenharmony_ci _f2: Box<<Self as Trait>::Assoc>, 287e2e9c0cSopenharmony_ci _f4: [(); Self::ASSOC], 297e2e9c0cSopenharmony_ci _f5: [(); Self::assoc()], 307e2e9c0cSopenharmony_ci } 317e2e9c0cSopenharmony_ci 327e2e9c0cSopenharmony_ci impl Struct { 337e2e9c0cSopenharmony_ci const ASSOC: usize = 1; 347e2e9c0cSopenharmony_ci const fn assoc() -> usize { 357e2e9c0cSopenharmony_ci 0 367e2e9c0cSopenharmony_ci } 377e2e9c0cSopenharmony_ci } 387e2e9c0cSopenharmony_ci 397e2e9c0cSopenharmony_ci impl Trait for Struct { 407e2e9c0cSopenharmony_ci type Assoc = Self; 417e2e9c0cSopenharmony_ci } 427e2e9c0cSopenharmony_ci 437e2e9c0cSopenharmony_ci #[derive(Deserialize, Serialize)] 447e2e9c0cSopenharmony_ci struct Tuple( 457e2e9c0cSopenharmony_ci Box<Self>, 467e2e9c0cSopenharmony_ci Box<<Self as Trait>::Assoc>, 477e2e9c0cSopenharmony_ci [(); Self::ASSOC], 487e2e9c0cSopenharmony_ci [(); Self::assoc()], 497e2e9c0cSopenharmony_ci ); 507e2e9c0cSopenharmony_ci 517e2e9c0cSopenharmony_ci impl Tuple { 527e2e9c0cSopenharmony_ci const ASSOC: usize = 1; 537e2e9c0cSopenharmony_ci const fn assoc() -> usize { 547e2e9c0cSopenharmony_ci 0 557e2e9c0cSopenharmony_ci } 567e2e9c0cSopenharmony_ci } 577e2e9c0cSopenharmony_ci 587e2e9c0cSopenharmony_ci impl Trait for Tuple { 597e2e9c0cSopenharmony_ci type Assoc = Self; 607e2e9c0cSopenharmony_ci } 617e2e9c0cSopenharmony_ci 627e2e9c0cSopenharmony_ci #[derive(Deserialize, Serialize)] 637e2e9c0cSopenharmony_ci enum Enum { 647e2e9c0cSopenharmony_ci Struct { 657e2e9c0cSopenharmony_ci _f1: Box<Self>, 667e2e9c0cSopenharmony_ci _f2: Box<<Self as Trait>::Assoc>, 677e2e9c0cSopenharmony_ci _f4: [(); Self::ASSOC], 687e2e9c0cSopenharmony_ci _f5: [(); Self::assoc()], 697e2e9c0cSopenharmony_ci }, 707e2e9c0cSopenharmony_ci Tuple( 717e2e9c0cSopenharmony_ci Box<Self>, 727e2e9c0cSopenharmony_ci Box<<Self as Trait>::Assoc>, 737e2e9c0cSopenharmony_ci [(); Self::ASSOC], 747e2e9c0cSopenharmony_ci [(); Self::assoc()], 757e2e9c0cSopenharmony_ci ), 767e2e9c0cSopenharmony_ci } 777e2e9c0cSopenharmony_ci 787e2e9c0cSopenharmony_ci impl Enum { 797e2e9c0cSopenharmony_ci const ASSOC: usize = 1; 807e2e9c0cSopenharmony_ci const fn assoc() -> usize { 817e2e9c0cSopenharmony_ci 0 827e2e9c0cSopenharmony_ci } 837e2e9c0cSopenharmony_ci } 847e2e9c0cSopenharmony_ci 857e2e9c0cSopenharmony_ci impl Trait for Enum { 867e2e9c0cSopenharmony_ci type Assoc = Self; 877e2e9c0cSopenharmony_ci } 887e2e9c0cSopenharmony_ci} 89