Skip to content

Commit 046e054

Browse files
committed
Auto merge of #55983 - oli-obk:static_, r=Mark-Simulacrum
Fix stability hole with `static _` The `underscore_const_names` only gated const items with `_` as the name. `static _: () = ();` works on beta without feature gates right now, this PR fixes that.
2 parents 31fa301 + 9b87911 commit 046e054

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/libsyntax/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15831583
}
15841584
}
15851585

1586+
ast::ItemKind::Static(..) |
15861587
ast::ItemKind::Const(_,_) => {
15871588
if i.ident.name == "_" {
15881589
gate_feature_post!(&self, underscore_const_names, i.span,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2012-2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
const _: () = (); //~ ERROR is unstable
12+
static _: () = (); //~ ERROR is unstable
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0658]: naming constants with `_` is unstable (see issue #54912)
2+
--> $DIR/underscore_const_names_feature_gate.rs:11:1
3+
|
4+
LL | const _: () = (); //~ ERROR is unstable
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add #![feature(underscore_const_names)] to the crate attributes to enable
8+
9+
error[E0658]: naming constants with `_` is unstable (see issue #54912)
10+
--> $DIR/underscore_const_names_feature_gate.rs:12:1
11+
|
12+
LL | static _: () = (); //~ ERROR is unstable
13+
| ^^^^^^^^^^^^^^^^^^
14+
|
15+
= help: add #![feature(underscore_const_names)] to the crate attributes to enable
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)