]>
Commit | Line | Data |
---|---|---|
3dfed10e | 1 | An unstable feature in `const` contexts was used. |
60c5eb7d XL |
2 | |
3 | Erroneous code example: | |
4 | ||
5 | ```compile_fail,E0723 | |
6 | trait T {} | |
7 | ||
8 | impl T for () {} | |
9 | ||
10 | const fn foo() -> impl T { // error: `impl Trait` in const fn is unstable | |
11 | () | |
12 | } | |
13 | ``` | |
14 | ||
15 | To enable this feature on a nightly version of rustc, add the `const_fn` | |
16 | feature flag: | |
17 | ||
18 | ``` | |
19 | #![feature(const_fn)] | |
20 | ||
21 | trait T {} | |
22 | ||
23 | impl T for () {} | |
24 | ||
25 | const fn foo() -> impl T { | |
26 | () | |
27 | } | |
28 | ``` |