ra_ap_rustc_index/
lib.rs

1// tidy-alphabetical-start
2#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
3#![cfg_attr(feature = "nightly", allow(internal_features))]
4#![cfg_attr(feature = "nightly", feature(extend_one, step_trait, test))]
5#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
6#![warn(unreachable_pub)]
7// tidy-alphabetical-end
8
9pub mod bit_set;
10#[cfg(feature = "nightly")]
11pub mod interval;
12
13mod idx;
14mod slice;
15mod vec;
16
17pub use idx::Idx;
18pub use rustc_index_macros::newtype_index;
19pub use slice::IndexSlice;
20#[doc(no_inline)]
21pub use vec::IndexVec;
22
23/// Type size assertion. The first argument is a type and the second argument is its expected size.
24///
25/// <div class="warning">
26///
27/// Emitting hard errors from size assertions like this is generally not
28/// recommended, especially in libraries, because they can cause build failures if the layout
29/// algorithm or dependencies change. Here in rustc we control the toolchain and layout algorithm,
30/// so the former is not a problem. For the latter we have a lockfile as rustc is an application and
31/// precompiled library.
32///
33/// Short version: Don't copy this macro into your own code. Use a `#[test]` instead.
34///
35/// </div>
36#[macro_export]
37#[cfg(not(feature = "rustc_randomized_layouts"))]
38macro_rules! static_assert_size {
39    ($ty:ty, $size:expr) => {
40        const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
41    };
42}
43
44#[macro_export]
45#[cfg(feature = "rustc_randomized_layouts")]
46macro_rules! static_assert_size {
47    ($ty:ty, $size:expr) => {
48        // no effect other than using the statements.
49        // struct sizes are not deterministic under randomized layouts
50        const _: (usize, usize) = ($size, ::std::mem::size_of::<$ty>());
51    };
52}