mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
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.
This commit is contained in:
commit
046e054a99
@ -1583,6 +1583,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ast::ItemKind::Static(..) |
|
||||||
ast::ItemKind::Const(_,_) => {
|
ast::ItemKind::Const(_,_) => {
|
||||||
if i.ident.name == "_" {
|
if i.ident.name == "_" {
|
||||||
gate_feature_post!(&self, underscore_const_names, i.span,
|
gate_feature_post!(&self, underscore_const_names, i.span,
|
||||||
|
14
src/test/ui/underscore_const_names_feature_gate.rs
Normal file
14
src/test/ui/underscore_const_names_feature_gate.rs
Normal file
@ -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 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() {}
|
19
src/test/ui/underscore_const_names_feature_gate.stderr
Normal file
19
src/test/ui/underscore_const_names_feature_gate.stderr
Normal file
@ -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 _: () = (); //~ ERROR is unstable
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= 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 _: () = (); //~ ERROR is unstable
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= 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`.
|
Loading…
Reference in New Issue
Block a user