blob: ae21a9134a41662ced017662cb09323902481db4 (
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
|
#![feature(type_alias_impl_trait)]
trait Callable {
type Output;
fn call(x: Self) -> Self::Output;
}
trait PlusOne {
fn plus_one(&mut self);
}
impl<'a> PlusOne for &'a mut i32 {
fn plus_one(&mut self) {
**self += 1;
}
}
impl<T: PlusOne> Callable for T {
type Output = impl PlusOne;
fn call(t: T) -> Self::Output { t }
}
fn test<'a>(y: &'a mut i32) -> impl PlusOne {
<&'a mut i32 as Callable>::call(y)
//~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds
}
fn main() {
let mut z = 42;
let mut thing = test(&mut z);
let mut thing2 = test(&mut z);
thing.plus_one();
assert_eq!(z, 43);
thing2.plus_one();
assert_eq!(z, 44);
thing.plus_one();
assert_eq!(z, 45);
}
|