]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / rfc-2632-const-trait-impl / generic-bound.rs
CommitLineData
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
7use std::marker::PhantomData;
8
9struct S<T>(PhantomData<T>);
10
11impl<T> Copy for S<T> {}
12impl<T> Clone for S<T> {
13 fn clone(&self) -> Self {
14 S(PhantomData)
15 }
16}
17
18impl<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
26const fn twice<T: std::ops::Add>(arg: S<T>) -> S<T> {
27 arg + arg
28}
29
30fn main() {
31 let _ = twice(S(PhantomData::<i32>));
32}