]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs
Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / generic-bound.rs
1 // run-pass
2
3 #![feature(const_trait_impl)]
4 #![feature(const_fn_trait_bound)]
5
6 use std::marker::PhantomData;
7
8 struct S<T>(PhantomData<T>);
9
10 impl<T> Copy for S<T> {}
11 impl<T> Clone for S<T> {
12     fn clone(&self) -> Self {
13         S(PhantomData)
14     }
15 }
16
17 impl<T> const std::ops::Add for S<T> {
18     type Output = Self;
19
20     fn add(self, _: Self) -> Self {
21         S(std::marker::PhantomData)
22     }
23 }
24
25 const fn twice<T: std::ops::Add>(arg: S<T>) -> S<T> {
26     arg + arg
27 }
28
29 fn main() {
30     let _ = twice(S(PhantomData::<i32>));
31 }