Skip to content

Commit ab8a947

Browse files
committed
Move static_assert! into librustc_data_structures.
This means it can be used by more crates.
1 parent 5a2ca1a commit ab8a947

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/librustc/macros.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ macro_rules! span_bug {
6262
})
6363
}
6464

65-
#[macro_export]
66-
macro_rules! static_assert {
67-
($name:ident: $test:expr) => {
68-
// Use the bool to access an array such that if the bool is false, the access
69-
// is out-of-bounds.
70-
#[allow(dead_code)]
71-
static $name: () = [()][!$test as usize];
72-
}
73-
}
74-
7565
#[macro_export]
7666
macro_rules! __impl_stable_hash_field {
7767
($field:ident, $ctx:expr, $hasher:expr) => ($field.hash_stable($ctx, $hasher));

src/librustc_data_structures/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ extern crate rustc_cratesio_shim;
5757

5858
pub use rustc_serialize::hex::ToHex;
5959

60+
pub mod macros;
6061
pub mod svh;
6162
pub mod base_n;
6263
pub mod bit_set;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 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+
/// A simple static assertion macro. The first argument should be a unique
12+
/// ALL_CAPS identifier that describes the condition.
13+
#[macro_export]
14+
macro_rules! static_assert {
15+
($name:ident: $test:expr) => {
16+
// Use the bool to access an array such that if the bool is false, the access
17+
// is out-of-bounds.
18+
#[allow(dead_code)]
19+
static $name: () = [()][!$test as usize];
20+
}
21+
}

0 commit comments

Comments
 (0)