]> git.proxmox.com Git - rustc.git/blob - src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / rfc-2632-const-trait-impl / trait-where-clause-run.rs
1 // run-pass
2
3 #![feature(const_trait_impl)]
4
5 trait Bar {
6 fn bar() -> u8;
7 }
8
9 #[const_trait]
10 trait Foo {
11 fn foo() -> u8 where Self: ~const Bar {
12 <Self as Bar>::bar() * 6
13 }
14 }
15
16 struct NonConst;
17 struct Const;
18
19 impl Bar for NonConst {
20 fn bar() -> u8 {
21 3
22 }
23 }
24
25 impl Foo for NonConst {}
26
27 impl const Bar for Const {
28 fn bar() -> u8 {
29 4
30 }
31 }
32
33 impl const Foo for Const {}
34
35 fn main() {
36 const ANS1: u8 = Const::foo();
37 let ans2 = NonConst::foo();
38
39 assert_eq!(ANS1 + ans2, 42);
40 }