#![allow(clippy::used_underscore_binding)] use serde::{Deserialize, Serialize}; #[test] fn test_self() { pub trait Trait { type Assoc; } #[derive(Deserialize, Serialize)] pub struct Generics> where Self: Trait, ::Assoc: Sized, { _f: T, } impl> Trait for Generics { type Assoc = Self; } #[derive(Deserialize, Serialize)] pub struct Struct { _f1: Box, _f2: Box<::Assoc>, _f4: [(); Self::ASSOC], _f5: [(); Self::assoc()], } impl Struct { const ASSOC: usize = 1; const fn assoc() -> usize { 0 } } impl Trait for Struct { type Assoc = Self; } #[derive(Deserialize, Serialize)] struct Tuple( Box, Box<::Assoc>, [(); Self::ASSOC], [(); Self::assoc()], ); impl Tuple { const ASSOC: usize = 1; const fn assoc() -> usize { 0 } } impl Trait for Tuple { type Assoc = Self; } #[derive(Deserialize, Serialize)] enum Enum { Struct { _f1: Box, _f2: Box<::Assoc>, _f4: [(); Self::ASSOC], _f5: [(); Self::assoc()], }, Tuple( Box, Box<::Assoc>, [(); Self::ASSOC], [(); Self::assoc()], ), } impl Enum { const ASSOC: usize = 1; const fn assoc() -> usize { 0 } } impl Trait for Enum { type Assoc = Self; } }