]> git.lizzy.rs Git - rust.git/blob - tests/ui/trait-bounds/impl-derived-implicit-sized-bound.rs
Rollup merge of #106813 - oli-obk:sess_cleanup, r=GuillaumeGomez,petrochenkov
[rust.git] / tests / ui / trait-bounds / impl-derived-implicit-sized-bound.rs
1 struct Victim<'a, T: Perpetrator + ?Sized>
2 where
3   Self: Sized
4 {
5   value: u8,
6   perp: &'a T,
7 }
8
9 trait VictimTrait {
10   type Ret;
11   fn get(self) -> Self::Ret;
12 }
13
14 // Actual fix is here
15 impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
16   type Ret = u8;
17   fn get(self) -> Self::Ret {
18     self.value
19   }
20 }
21
22 trait Perpetrator {
23   fn getter<'a>(&'a self) -> Victim<'a, Self> {
24     Victim {
25       value: 0,
26       perp: self,
27     }
28   }
29
30   fn trigger(&self) {
31     self.getter().get();
32     //~^ ERROR the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
33   }
34 }
35
36 fn main() {}