]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs
Rollup merge of #106716 - c410-f3r:rfc-2397-1, r=davidtwco
[rust.git] / tests / ui / type-alias-impl-trait / imply_bounds_from_bounds_param.rs
1 #![feature(type_alias_impl_trait)]
2
3 trait Callable {
4     type Output;
5     fn call(x: Self) -> Self::Output;
6 }
7
8 trait PlusOne {
9     fn plus_one(&mut self);
10 }
11
12 impl<'a> PlusOne for &'a mut i32 {
13     fn plus_one(&mut self) {
14         **self += 1;
15     }
16 }
17
18 impl<T: PlusOne> Callable for T {
19     type Output = impl PlusOne;
20     fn call(t: T) -> Self::Output { t }
21 }
22
23 fn test<'a>(y: &'a mut i32) -> impl PlusOne {
24     <&'a mut i32 as Callable>::call(y)
25     //~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds
26 }
27
28 fn main() {
29     let mut z = 42;
30     let mut thing = test(&mut z);
31     let mut thing2 = test(&mut z);
32     thing.plus_one();
33     assert_eq!(z, 43);
34     thing2.plus_one();
35     assert_eq!(z, 44);
36     thing.plus_one();
37     assert_eq!(z, 45);
38 }