From b5a5556dd4807ee97cb51ab395d5dbfc858152dd Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 28 Sep 2017 15:56:28 -0300 Subject: Generate DepNodeIndexNew using newtype_index macro --- src/librustc_data_structures/indexed_vec.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/librustc_data_structures') diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 82882f94440..ce2468fb9f1 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -49,6 +49,13 @@ macro_rules! newtype_index { RustcEncodable, RustcDecodable)] pub struct $name(u32); + impl $name { + // HACK use for constants + pub const fn const_new(x: u32) -> Self { + $name(x) + } + } + impl Idx for $name { fn new(value: usize) -> Self { assert!(value < (::std::u32::MAX) as usize); -- cgit 1.4.1-3-g733a5