diff options
| author | Sean Patrick Santos <SeanPatrickSantos@gmail.com> | 2015-03-26 13:06:26 -0600 |
|---|---|---|
| committer | Sean Patrick Santos <SeanPatrickSantos@gmail.com> | 2015-04-23 21:02:29 -0600 |
| commit | b1db4ec3d0a96a1e83d74fbc7f99dc3be054f4d8 (patch) | |
| tree | b716e5a1dace81b0758069179b2fbd3e283f37db /src/libsyntax | |
| parent | 29eb550ee6a9fd6961bb00e2680a5735aab95de1 (diff) | |
| download | rust-b1db4ec3d0a96a1e83d74fbc7f99dc3be054f4d8.tar.gz rust-b1db4ec3d0a96a1e83d74fbc7f99dc3be054f4d8.zip | |
Feature-gate associated constants.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d0975c76e93..495bbd412ab 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -155,6 +155,10 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // Allows use of unary negate on unsigned integers, e.g. -e for e: u8 ("negate_unsigned", "1.0.0", Active), + + // Allows the definition of associated constants in `trait` or `impl` + // blocks. + ("associated_consts", "1.0.0", Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -659,6 +663,30 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } visit::walk_fn(self, fn_kind, fn_decl, block, span); } + + fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) { + match ti.node { + ast::ConstTraitItem(..) => { + self.gate_feature("associated_consts", + ti.span, + "associated constants are experimental") + } + _ => {} + } + visit::walk_trait_item(self, ti); + } + + fn visit_impl_item(&mut self, ii: &'v ast::ImplItem) { + match ii.node { + ast::ConstImplItem(..) => { + self.gate_feature("associated_consts", + ii.span, + "associated constants are experimental") + } + _ => {} + } + visit::walk_impl_item(self, ii); + } } fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, |
