1
Fork 0

add min_const_generics feature gate

This commit is contained in:
Bastian Kauschke 2020-08-05 18:27:54 +02:00
parent ec9d5241f7
commit 375bccb8b3
6 changed files with 21 additions and 5 deletions

View file

@ -776,7 +776,13 @@ fn validate_generic_param_order<'a>(
span,
&format!(
"reorder the parameters: lifetimes, then types{}",
if sess.features_untracked().const_generics { ", then consts" } else { "" },
if sess.features_untracked().const_generics
|| sess.features_untracked().min_const_generics
{
", then consts"
} else {
""
},
),
ordered_params.clone(),
Applicability::MachineApplicable,

View file

@ -526,12 +526,13 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
fn visit_generic_param(&mut self, param: &'a GenericParam) {
if let GenericParamKind::Const { .. } = param.kind {
gate_feature_post!(
gate_feature_fn!(
&self,
const_generics,
|x: &Features| x.const_generics || x.min_const_generics,
param.ident.span,
sym::const_generics,
"const generics are unstable"
)
);
}
visit::walk_generic_param(self, param)
}

View file

@ -579,6 +579,9 @@ declare_features! (
/// Alloc calling `transmute` in const fn
(active, const_fn_transmute, "1.46.0", Some(53605), None),
/// The smallest useful subset of `const_generics`.
(active, min_const_generics, "1.46.0", None, None),
// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------

View file

@ -1380,7 +1380,9 @@ impl<'tcx> TyCtxt<'tcx> {
/// we still evaluate them eagerly.
#[inline]
pub fn lazy_normalization(self) -> bool {
self.features().const_generics || self.features().lazy_normalization_consts
let features = self.features();
// Note: We do not enable lazy normalization for `features.min_const_generics`.
features.const_generics || features.lazy_normalization_consts
}
#[inline]

View file

@ -672,6 +672,7 @@ symbols! {
min_align_of,
min_align_of_val,
min_const_fn,
min_const_generics,
min_const_unsafe_fn,
min_specialization,
minnumf32,

View file

@ -1238,6 +1238,9 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
// HACK(eddyb) this provides the correct generics when
// `feature(const_generics)` is enabled, so that const expressions
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
//
// Note that we do not supply the parent generics when using
// `feature(min_const_generics)`.
Some(parent_def_id.to_def_id())
} else {
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));