summaryrefslogtreecommitdiffstats
path: root/src/test/ui/generic-associated-types/issue-90729.rs
blob: 98295cce8d587fa1b4c9c7096a6ca76e9ff23d16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// check-pass

#![feature(generic_associated_types)]

use std::marker::PhantomData;

pub trait Type {
    type Ref<'a>;
}

pub trait AsBytes {}

impl AsBytes for &str {}

pub struct Utf8;

impl Type for Utf8 {
    type Ref<'a> = &'a str;
}

pub struct Bytes<T: Type> {
    _marker: PhantomData<T>,
}

impl<T: Type> Bytes<T>
where
    for<'a> T::Ref<'a>: AsBytes,
{
    pub fn new() -> Self {
        Self {
            _marker: PhantomData,
        }
    }
}

fn main() {
    let _b = Bytes::<Utf8>::new();
}