Add #![feature(const_fn_impl)]
This commit is contained in:
parent
a1dfd2490a
commit
e1d76818b2
3 changed files with 15 additions and 2 deletions
|
@ -596,6 +596,9 @@ declare_features! (
|
||||||
/// Allows rustc to inject a default alloc_error_handler
|
/// Allows rustc to inject a default alloc_error_handler
|
||||||
(active, default_alloc_error_handler, "1.48.0", Some(66741), None),
|
(active, default_alloc_error_handler, "1.48.0", Some(66741), None),
|
||||||
|
|
||||||
|
/// Allows argument and return position `impl Trait` in a `const fn`.
|
||||||
|
(active, const_fn_impl_trait, "1.48.0", Some(77463), None),
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// feature-group-end: actual feature gates
|
// feature-group-end: actual feature gates
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
|
@ -559,11 +559,20 @@ pub mod ty {
|
||||||
pub struct ImplTrait;
|
pub struct ImplTrait;
|
||||||
impl NonConstOp for ImplTrait {
|
impl NonConstOp for ImplTrait {
|
||||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||||
mcf_status_in_item(ccx)
|
if ccx.const_kind() != hir::ConstContext::ConstFn {
|
||||||
|
Status::Allowed
|
||||||
|
} else {
|
||||||
|
Status::Unstable(sym::const_fn_impl_trait)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
mcf_build_error(ccx, span, "`impl Trait` in const fn is unstable")
|
feature_err(
|
||||||
|
&ccx.tcx.sess.parse_sess,
|
||||||
|
sym::const_fn_impl_trait,
|
||||||
|
span,
|
||||||
|
&format!("`impl Trait` is not allowed in {}s", ccx.const_kind()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,7 @@ symbols! {
|
||||||
const_fn,
|
const_fn,
|
||||||
const_fn_floating_point_arithmetic,
|
const_fn_floating_point_arithmetic,
|
||||||
const_fn_fn_ptr_basics,
|
const_fn_fn_ptr_basics,
|
||||||
|
const_fn_impl_trait,
|
||||||
const_fn_transmute,
|
const_fn_transmute,
|
||||||
const_fn_union,
|
const_fn_union,
|
||||||
const_generics,
|
const_generics,
|
||||||
|
|
Loading…
Add table
Reference in a new issue