Skip to content

Commit 160e630

Browse files
Add passing test for Add on generic struct
1 parent 9a36824 commit 160e630

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// run-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(const_trait_impl)]
5+
#![feature(const_fn)]
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+
}

0 commit comments

Comments
 (0)