]> git.lizzy.rs Git - rust.git/blob - tests/ui/generic-associated-types/issue-90729.rs
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / ui / generic-associated-types / issue-90729.rs
1 // check-pass
2
3 use std::marker::PhantomData;
4
5 pub trait Type {
6     type Ref<'a>;
7 }
8
9 pub trait AsBytes {}
10
11 impl AsBytes for &str {}
12
13 pub struct Utf8;
14
15 impl Type for Utf8 {
16     type Ref<'a> = &'a str;
17 }
18
19 pub struct Bytes<T: Type> {
20     _marker: PhantomData<T>,
21 }
22
23 impl<T: Type> Bytes<T>
24 where
25     for<'a> T::Ref<'a>: AsBytes,
26 {
27     pub fn new() -> Self {
28         Self {
29             _marker: PhantomData,
30         }
31     }
32 }
33
34 fn main() {
35     let _b = Bytes::<Utf8>::new();
36 }