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