From c8a9300d8e263cf3f37a7d6736a0167d085b19cd Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 15 Nov 2018 16:16:34 +0100 Subject: [PATCH 1/2] Fix stability hole with `static _` --- src/libsyntax/feature_gate.rs | 1 + .../ui/underscore_const_names_feature_gate.rs | 14 ++++++++++++++ ...underscore_const_names_feature_gate.stderr | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/test/ui/underscore_const_names_feature_gate.rs create mode 100644 src/test/ui/underscore_const_names_feature_gate.stderr diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 55652c481bd3f..a7c97feee498d 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1583,6 +1583,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } + ast::ItemKind::Static(..) | ast::ItemKind::Const(_,_) => { if i.ident.name == "_" { gate_feature_post!(&self, underscore_const_names, i.span, diff --git a/src/test/ui/underscore_const_names_feature_gate.rs b/src/test/ui/underscore_const_names_feature_gate.rs new file mode 100644 index 0000000000000..b2174036dede0 --- /dev/null +++ b/src/test/ui/underscore_const_names_feature_gate.rs @@ -0,0 +1,14 @@ +// Copyright 2012-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const _: () = (); //~ ERROR is unstable +static _: () = (); //~ ERROR is unstable + +fn main() {} diff --git a/src/test/ui/underscore_const_names_feature_gate.stderr b/src/test/ui/underscore_const_names_feature_gate.stderr new file mode 100644 index 0000000000000..4cce252bcaed7 --- /dev/null +++ b/src/test/ui/underscore_const_names_feature_gate.stderr @@ -0,0 +1,19 @@ +error[E0658]: naming constants with `_` is unstable (see issue #54912) + --> $DIR/underscore_const_names_feature_gate.rs:11:1 + | +LL | const _: () = (); + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(underscore_const_names)] to the crate attributes to enable + +error[E0658]: naming constants with `_` is unstable (see issue #54912) + --> $DIR/underscore_const_names_feature_gate.rs:12:1 + | +LL | static _: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(underscore_const_names)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. From 9b8791179f116af912806ff79d101131d412df87 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 16 Nov 2018 09:04:35 +0100 Subject: [PATCH 2/2] Update stderr file --- src/test/ui/underscore_const_names_feature_gate.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/underscore_const_names_feature_gate.stderr b/src/test/ui/underscore_const_names_feature_gate.stderr index 4cce252bcaed7..c97b3f8d4d3cd 100644 --- a/src/test/ui/underscore_const_names_feature_gate.stderr +++ b/src/test/ui/underscore_const_names_feature_gate.stderr @@ -1,7 +1,7 @@ error[E0658]: naming constants with `_` is unstable (see issue #54912) --> $DIR/underscore_const_names_feature_gate.rs:11:1 | -LL | const _: () = (); +LL | const _: () = (); //~ ERROR is unstable | ^^^^^^^^^^^^^^^^^ | = help: add #![feature(underscore_const_names)] to the crate attributes to enable @@ -9,7 +9,7 @@ LL | const _: () = (); error[E0658]: naming constants with `_` is unstable (see issue #54912) --> $DIR/underscore_const_names_feature_gate.rs:12:1 | -LL | static _: () = (); +LL | static _: () = (); //~ ERROR is unstable | ^^^^^^^^^^^^^^^^^^ | = help: add #![feature(underscore_const_names)] to the crate attributes to enable