]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | // run-pass |
2 | ||
3 | #![allow(incomplete_features)] | |
4 | #![feature(const_trait_impl)] | |
cdc7bbd5 | 5 | #![feature(const_fn_trait_bound)] |
74b04a01 XL |
6 | |
7 | use std::marker::PhantomData; | |
8 | ||
9 | struct S<T>(PhantomData<T>); | |
10 | ||
11 | impl<T> Copy for S<T> {} | |
12 | impl<T> Clone for S<T> { | |
13 | fn clone(&self) -> Self { | |
14 | S(PhantomData) | |
15 | } | |
16 | } | |
17 | ||
18 | impl<T> const std::ops::Add for S<T> { | |
19 | type Output = Self; | |
20 | ||
21 | fn add(self, _: Self) -> Self { | |
22 | S(std::marker::PhantomData) | |
23 | } | |
24 | } | |
25 | ||
26 | const fn twice<T: std::ops::Add>(arg: S<T>) -> S<T> { | |
27 | arg + arg | |
28 | } | |
29 | ||
30 | fn main() { | |
31 | let _ = twice(S(PhantomData::<i32>)); | |
32 | } |