diff options
| author | bors <bors@rust-lang.org> | 2019-06-16 20:33:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-16 20:33:55 +0000 |
| commit | 4edff843dd219cf19a5fede6c78c7ce95402e1f5 (patch) | |
| tree | 8b249bd7f2e9c9743684019f07ab792a7846afa5 /src/librustc_data_structures | |
| parent | 799cf3f603b5809a68853efcd779671cb8e046c4 (diff) | |
| parent | e62c9d7917052db098c6f27314f4daa5b9513387 (diff) | |
| download | rust-4edff843dd219cf19a5fede6c78c7ce95402e1f5.tar.gz rust-4edff843dd219cf19a5fede6c78c7ce95402e1f5.zip | |
Auto merge of #61347 - Centril:stabilize-underscore_const_names, r=petrochenkov
Stabilize underscore_const_names in 1.37.0
You are now permitted to write:
```rust
const _: $type_expression = $term_expression;
```
That is, we change the [grammar of items](https://github.com/rust-lang-nursery/wg-grammar/blob/9d1984d7ae8d6576f943566539a31a5800644c57/grammar/item.lyg#L3-L42), as written in [the *`.lyg`* notation](https://github.com/rust-lang/gll/tree/263bf161dad903e67aa65fc591ced3cab18afa2a#grammar), from:
```java
Item = attrs:OuterAttr* vis:Vis? kind:ItemKind;
ItemKind =
| ...
| Const:{ "const" name:IDENT ":" ty:Type "=" value:Expr ";" }
| ...
;
```
into:
```java
Item = attrs:OuterAttr* vis:Vis? kind:ItemKind;
ItemKind =
| ...
| Const:{ "const" name:IdentOrUnderscore ":" ty:Type "=" value:Expr ";" }
| ...
;
IdentOrUnderscore =
| Named:IDENT
| NoName:"_"
;
```
r? @petrochenkov
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/macros.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/librustc_data_structures/macros.rs b/src/librustc_data_structures/macros.rs index b851263aaf9..6e7a8e98853 100644 --- a/src/librustc_data_structures/macros.rs +++ b/src/librustc_data_structures/macros.rs @@ -1,6 +1,7 @@ /// A simple static assertion macro. #[macro_export] -#[allow_internal_unstable(type_ascription, underscore_const_names)] +#[cfg_attr(bootstrap, allow_internal_unstable(type_ascription, underscore_const_names))] +#[cfg_attr(not(bootstrap), allow_internal_unstable(type_ascription))] macro_rules! static_assert { ($test:expr) => { // Use the bool to access an array such that if the bool is false, the access @@ -12,7 +13,7 @@ macro_rules! static_assert { /// Type size assertion. The first argument is a type and the second argument is its expected size. #[macro_export] -#[allow_internal_unstable(underscore_const_names)] +#[cfg_attr(bootstrap, allow_internal_unstable(underscore_const_names))] macro_rules! static_assert_size { ($ty:ty, $size:expr) => { const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()]; |
