Skip to content

Commit 8d83521

Browse files
varkoryodaldevoid
andcommitted
Add const_generics feature flag
Co-Authored-By: Gabriel Smith <[email protected]>
1 parent 751dcdf commit 8d83521

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use AttributeType::*;
1616
use AttributeGate::*;
1717

18-
use crate::ast::{self, NodeId, PatKind, RangeEnd};
18+
use crate::ast::{self, NodeId, GenericParam, GenericParamKind, PatKind, RangeEnd};
1919
use crate::attr;
2020
use crate::early_buffered_lints::BufferedEarlyLintId;
2121
use crate::source_map::Spanned;
@@ -462,6 +462,9 @@ declare_features! (
462462
// Re-Rebalance coherence
463463
(active, re_rebalance_coherence, "1.32.0", Some(55437), None),
464464

465+
// Const generic types.
466+
(active, const_generics, "1.34.0", Some(44580), None),
467+
465468
// #[optimize(X)]
466469
(active, optimize_attribute, "1.34.0", Some(54882), None),
467470

@@ -1899,6 +1902,14 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
18991902
visit::walk_fn(self, fn_kind, fn_decl, span);
19001903
}
19011904

1905+
fn visit_generic_param(&mut self, param: &'a GenericParam) {
1906+
if let GenericParamKind::Const { .. } = param.kind {
1907+
gate_feature_post!(&self, const_generics, param.ident.span,
1908+
"const generics are unstable");
1909+
}
1910+
visit::walk_generic_param(self, param);
1911+
}
1912+
19021913
fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
19031914
match ti.node {
19041915
ast::TraitItemKind::Method(ref sig, ref block) => {
@@ -1984,7 +1995,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19841995
// Some features are known to be incomplete and using them is likely to have
19851996
// unanticipated results, such as compiler crashes. We warn the user about these
19861997
// to alert them.
1987-
let incomplete_features = ["generic_associated_types"];
1998+
let incomplete_features = ["generic_associated_types", "const_generics"];
19881999

19892000
let mut features = Features::new();
19902001
let mut edition_enabled_features = FxHashMap::default();

0 commit comments

Comments
 (0)