Stabilize const_impl_trait as well

This commit is contained in:
Eric Holk 2022-02-11 18:04:44 -08:00
parent 801be21d11
commit 8700b45b67
9 changed files with 5 additions and 58 deletions

View File

@ -356,7 +356,6 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
match *ty.kind() {
ty::Ref(_, _, hir::Mutability::Mut) => self.check_op(ops::ty::MutRef(kind)),
ty::Opaque(..) => self.check_op(ops::ty::ImplTrait),
_ => {}
}
}

View File

@ -795,25 +795,4 @@ pub mod ty {
)
}
}
#[derive(Debug)]
pub struct ImplTrait;
impl<'tcx> NonConstOp<'tcx> for ImplTrait {
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
Status::Unstable(sym::const_impl_trait)
}
fn build_error(
&self,
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_impl_trait,
span,
&format!("`impl Trait` is not allowed in {}s", ccx.const_kind()),
)
}
}
}

View File

@ -100,6 +100,8 @@ declare_features! (
(accepted, const_generics_defaults, "1.59.0", Some(44580), None),
/// Allows the use of `if` and `match` in constants.
(accepted, const_if_match, "1.46.0", Some(49146), None),
/// Allows argument and return position `impl Trait` in a `const fn`.
(accepted, const_impl_trait, "1.60.0", Some(77463), None),
/// Allows indexing into constant arrays.
(accepted, const_indexing, "1.26.0", Some(29947), None),
/// Allows let bindings, assignments and destructuring in `const` functions and constants.

View File

@ -340,8 +340,6 @@ declare_features! (
(active, const_fn_floating_point_arithmetic, "1.48.0", Some(57241), None),
/// Allows `for _ in _` loops in const contexts.
(active, const_for, "1.56.0", Some(87575), None),
/// Allows argument and return position `impl Trait` in a `const fn`.
(active, const_impl_trait, "1.48.0", Some(77463), None),
/// Allows using `&mut` in constant functions.
(active, const_mut_refs, "1.41.0", Some(57349), None),
/// Be more precise when looking for live drops in a const context.

View File

@ -160,7 +160,7 @@
#![feature(const_fn_floating_point_arithmetic)]
#![cfg_attr(bootstrap, feature(const_fn_fn_ptr_basics))]
#![cfg_attr(bootstrap, feature(const_fn_trait_bound))]
#![feature(const_impl_trait)]
#![cfg_attr(bootstrap, feature(const_impl_trait))]
#![feature(const_mut_refs)]
#![feature(const_precise_live_drops)]
#![feature(const_refs_to_cell)]

View File

@ -1,10 +0,0 @@
// gate-test-const_impl_trait
struct AlanTuring<T>(T);
const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { //~ `impl Trait`
AlanTuring(0)
}
const fn no_rpit() -> impl std::fmt::Debug {} //~ `impl Trait`
fn main() {}

View File

@ -1,21 +0,0 @@
error[E0658]: `impl Trait` is not allowed in constant functions
--> $DIR/min_const_fn_impl_trait.rs:4:24
|
LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #77463 <https://github.com/rust-lang/rust/issues/77463> for more information
= help: add `#![feature(const_impl_trait)]` to the crate attributes to enable
error[E0658]: `impl Trait` is not allowed in constant functions
--> $DIR/min_const_fn_impl_trait.rs:8:23
|
LL | const fn no_rpit() -> impl std::fmt::Debug {}
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #77463 <https://github.com/rust-lang/rust/issues/77463> for more information
= help: add `#![feature(const_impl_trait)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,4 +1,4 @@
#![feature(const_impl_trait, rustc_attrs)]
#![feature(rustc_attrs)]
#![feature(type_alias_impl_trait)]
type Foo = impl Fn() -> usize;

View File

@ -1,4 +1,4 @@
#![feature(const_impl_trait, generators, generator_trait, rustc_attrs)]
#![feature(generators, generator_trait, rustc_attrs)]
#![feature(type_alias_impl_trait)]
use std::ops::Generator;