test_self.rs
This file
Path
test_suite/tests/test_self.rs
88 lines · 1.7 KiB · Rust
Last changed by
Allow more dead codeOli Schererbefore adoptionc85e424
History of this fileTake it
The walk stopped after 200 commits: lines older than 3761854 point at it.
Allow more dead codeOli Schererbefore adoptionc85e424
line 1why, one step back1#![allow(clippy::used_underscore_binding, dead_code)]Merge pull request #2745 from dtolnay/docsrsDavid Tolnaybefore adoption3761854
lines 2–43why, one step back23use serde_derive::{Deserialize, Serialize};45#[test]6fn test_self() {7 pub trait Trait {8 type Assoc;9 }1011 #[derive(Deserialize, Serialize)]12 pub struct Generics<T: Trait<Assoc = Self>>13 where14 Self: Trait<Assoc = Self>,15 <Self as Trait>::Assoc: Sized,16 {17 _f: T,18 }1920 impl<T: Trait<Assoc = Self>> Trait for Generics<T> {21 type Assoc = Self;22 }2324 #[derive(Deserialize, Serialize)]25 pub struct Struct {26 _f1: Box<Self>,27 _f2: Box<<Self as Trait>::Assoc>,28 _f4: [(); Self::ASSOC],29 _f5: [(); Self::assoc()],30 }3132 impl Struct {33 const ASSOC: usize = 1;34 const fn assoc() -> usize {35 036 }37 }3839 impl Trait for Struct {40 type Assoc = Self;41 }4243 #[derive(Deserialize, Serialize)]Work around test suite dead code warnings in nightly-2024-07-07David Tolnaybefore adoption28a0922
line 44why, one step back44 pub struct Tuple(Merge pull request #2745 from dtolnay/docsrsDavid Tolnaybefore adoption3761854
lines 45–62why, one step back45 Box<Self>,46 Box<<Self as Trait>::Assoc>,47 [(); Self::ASSOC],48 [(); Self::assoc()],49 );5051 impl Tuple {52 const ASSOC: usize = 1;53 const fn assoc() -> usize {54 055 }56 }5758 impl Trait for Tuple {59 type Assoc = Self;60 }6162 #[derive(Deserialize, Serialize)]Work around test suite dead code warnings in nightly-2024-07-07David Tolnaybefore adoption28a0922
line 63why, one step back63 pub enum Enum {Merge pull request #2745 from dtolnay/docsrsDavid Tolnaybefore adoption3761854
lines 64–88why, one step back64 Struct {65 _f1: Box<Self>,66 _f2: Box<<Self as Trait>::Assoc>,67 _f4: [(); Self::ASSOC],68 _f5: [(); Self::assoc()],69 },70 Tuple(71 Box<Self>,72 Box<<Self as Trait>::Assoc>,73 [(); Self::ASSOC],74 [(); Self::assoc()],75 ),76 }7778 impl Enum {79 const ASSOC: usize = 1;80 const fn assoc() -> usize {81 082 }83 }8485 impl Trait for Enum {86 type Assoc = Self;87 }88}