]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs
Rollup merge of #99244 - gthb:doc-improve-iterator-scan, r=m-ou-se
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / trait-where-clause-const.rs
1 // Like trait-where-clause.rs, but we are calling from a const context.
2 // Checking the validity of traits' where clauses happen at a later stage.
3 // (`rustc_const_eval` instead of `rustc_hir_analysis`) Therefore one file as a
4 // test is not enough.
5 #![feature(const_trait_impl)]
6
7 #[const_trait]
8 trait Bar {}
9
10 #[const_trait]
11 trait Foo {
12     fn a();
13     fn b() where Self: ~const Bar;
14     fn c<T: ~const Bar>();
15 }
16
17 const fn test1<T: ~const Foo + Bar>() {
18     T::a();
19     T::b();
20     //~^ ERROR the trait bound
21     T::c::<T>();
22     //~^ ERROR the trait bound
23 }
24
25 const fn test2<T: ~const Foo + ~const Bar>() {
26     T::a();
27     T::b();
28     T::c::<T>();
29 }
30
31 fn main() {}