rustc_arena: macros 2.0
This commit is contained in:
parent
bf24e6ba00
commit
71db7cc0b4
1 changed files with 79 additions and 81 deletions
|
@ -15,6 +15,8 @@
|
||||||
#![feature(new_uninit)]
|
#![feature(new_uninit)]
|
||||||
#![feature(maybe_uninit_slice)]
|
#![feature(maybe_uninit_slice)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
|
#![feature(decl_macro)]
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
#![cfg_attr(test, feature(test))]
|
#![cfg_attr(test, feature(test))]
|
||||||
|
|
||||||
use rustc_data_structures::sync;
|
use rustc_data_structures::sync;
|
||||||
|
@ -608,35 +610,32 @@ impl DropArena {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
pub macro arena_for_type {
|
||||||
macro_rules! arena_for_type {
|
|
||||||
([][$ty:ty]) => {
|
([][$ty:ty]) => {
|
||||||
$crate::TypedArena<$ty>
|
$crate::TypedArena<$ty>
|
||||||
};
|
},
|
||||||
([few $(, $attrs:ident)*][$ty:ty]) => {
|
([few $(, $attrs:ident)*][$ty:ty]) => {
|
||||||
::std::marker::PhantomData<$ty>
|
::std::marker::PhantomData<$ty>
|
||||||
};
|
},
|
||||||
([$ignore:ident $(, $attrs:ident)*]$args:tt) => {
|
([$ignore:ident $(, $attrs:ident)*]$args:tt) => {
|
||||||
$crate::arena_for_type!([$($attrs),*]$args)
|
$crate::arena_for_type!([$($attrs),*]$args)
|
||||||
};
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
pub macro which_arena_for_type {
|
||||||
macro_rules! which_arena_for_type {
|
|
||||||
([][$arena:expr]) => {
|
([][$arena:expr]) => {
|
||||||
::std::option::Option::Some($arena)
|
::std::option::Option::Some($arena)
|
||||||
};
|
},
|
||||||
([few$(, $attrs:ident)*][$arena:expr]) => {
|
([few$(, $attrs:ident)*][$arena:expr]) => {
|
||||||
::std::option::Option::None
|
::std::option::Option::None
|
||||||
};
|
},
|
||||||
([$ignore:ident$(, $attrs:ident)*]$args:tt) => {
|
([$ignore:ident$(, $attrs:ident)*]$args:tt) => {
|
||||||
$crate::which_arena_for_type!([$($attrs),*]$args)
|
$crate::which_arena_for_type!([$($attrs),*]$args)
|
||||||
};
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[rustc_macro_transparency = "semitransparent"]
|
||||||
macro_rules! declare_arena {
|
pub macro declare_arena([], [$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) {
|
||||||
([], [$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => {
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Arena<$tcx> {
|
pub struct Arena<$tcx> {
|
||||||
pub dropless: $crate::DroplessArena,
|
pub dropless: $crate::DroplessArena,
|
||||||
|
@ -720,7 +719,6 @@ macro_rules! declare_arena {
|
||||||
T::allocate_from_iter(self, iter)
|
T::allocate_from_iter(self, iter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue