From 406cbf1a39c99ef7b7f329a44f1d1c7af7a8ecda Mon Sep 17 00:00:00 2001 From: Donato Sciarra Date: Fri, 12 Oct 2018 00:34:26 +0200 Subject: Support underscore as constant name Issue: 54912 --- src/libsyntax/feature_gate.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libsyntax/feature_gate.rs') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index b86b92fb29e..84122688c83 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -499,6 +499,9 @@ declare_features! ( // #[cfg_attr(predicate, multiple, attributes, here)] (active, cfg_attr_multi, "1.31.0", Some(54881), None), + + // Allows `const _: TYPE = VALUE` + (active, underscore_const_names, "1.31.0", Some(54912), None), ); declare_features! ( @@ -1583,6 +1586,13 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } + ast::ItemKind::Const(_,_) => { + if i.ident.name == "_" { + gate_feature_post!(&self, underscore_const_names, i.span, + "naming constants with `_` is unstable"); + } + } + ast::ItemKind::ForeignMod(ref foreign_module) => { self.check_abi(foreign_module.abi, i.span); } -- cgit 1.4.1-3-g733a5