Skip to content

Commit 557af5b

Browse files
authoredMay 21, 2019
Rollup merge of #60998 - RalfJung:static_assert, r=Centril
static_assert: make use of anonymous constants
2 parents 36680df + a2168b0 commit 557af5b

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed
 

‎src/librustc_data_structures/macros.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
/// A simple static assertion macro. The first argument should be a unique
2-
/// ALL_CAPS identifier that describes the condition.
1+
/// A simple static assertion macro.
32
#[macro_export]
4-
#[allow_internal_unstable(type_ascription)]
3+
#[allow_internal_unstable(type_ascription, underscore_const_names)]
54
macro_rules! static_assert {
6-
($name:ident: $test:expr) => {
5+
($test:expr) => {
76
// Use the bool to access an array such that if the bool is false, the access
87
// is out-of-bounds.
98
#[allow(dead_code)]
10-
static $name: () = [()][!($test: bool) as usize];
9+
const _: () = [()][!($test: bool) as usize];
1110
}
1211
}
1312

‎src/librustc_mir/transform/qualify_consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,14 @@ impl Qualif for IsNotImplicitlyPromotable {
544544
// Ensure the `IDX` values are sequential (`0..QUALIF_COUNT`).
545545
macro_rules! static_assert_seq_qualifs {
546546
($i:expr => $first:ident $(, $rest:ident)*) => {
547-
static_assert!(SEQ_QUALIFS: {
547+
static_assert!({
548548
static_assert_seq_qualifs!($i + 1 => $($rest),*);
549549

550550
$first::IDX == $i
551551
});
552552
};
553553
($i:expr =>) => {
554-
static_assert!(SEQ_QUALIFS: QUALIF_COUNT == $i);
554+
static_assert!(QUALIF_COUNT == $i);
555555
};
556556
}
557557
static_assert_seq_qualifs!(

0 commit comments

Comments
 (0)
Please sign in to comment.