]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs
Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`.
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / const-default-method-bodies.rs
1 #![feature(const_trait_impl)]
2 #![feature(const_fn_trait_bound)] // FIXME is this needed?
3
4 trait ConstDefaultFn: Sized {
5     fn b(self);
6
7     #[default_method_body_is_const]
8     fn a(self) {
9         self.b();
10     }
11 }
12
13 struct NonConstImpl;
14 struct ConstImpl;
15
16 impl ConstDefaultFn for NonConstImpl {
17     fn b(self) {}
18 }
19
20 impl const ConstDefaultFn for ConstImpl {
21     fn b(self) {}
22 }
23
24 const fn test() {
25     NonConstImpl.a();
26     //~^ ERROR calls in constant functions are limited to constant functions, tuple structs and tuple variants
27     ConstImpl.a();
28 }
29
30 fn main() {}