Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk

Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`
This commit is contained in:
bors 2020-10-07 19:59:52 +00:00
commit 4437b4b150
11 changed files with 34 additions and 31 deletions

View file

@ -3,12 +3,8 @@ An unstable feature in `const` contexts was used.
Erroneous code example:
```compile_fail,E0723
trait T {}
impl T for () {}
const fn foo() -> impl T { // error: `impl Trait` in const fn is unstable
()
const fn foo<T: Copy>(_: T) { // error!
// ...
}
```
@ -18,11 +14,7 @@ feature flag:
```
#![feature(const_fn)]
trait T {}
impl T for () {}
const fn foo() -> impl T {
()
const fn foo<T: Copy>(_: T) { // ok!
// ...
}
```