Rollup merge of #151445 - Zalathar:arenas-default, r=mati865
Derive `Default` for `QueryArenas` There's no need to manually implement Default for this struct, because the fields are all `TypeArena<_>` or `()`, which both implement Default already. This lets us avoid one occurrence of the `query_if_arena!` macro.
This commit is contained in:
commit
f87b84ce3d
1 changed files with 11 additions and 15 deletions
|
|
@ -342,22 +342,18 @@ macro_rules! define_callbacks {
|
|||
})*
|
||||
}
|
||||
|
||||
/// Holds per-query arenas for queries with the `arena_cache` modifier.
|
||||
#[derive(Default)]
|
||||
pub struct QueryArenas<'tcx> {
|
||||
$($(#[$attr])* pub $name: query_if_arena!([$($modifiers)*]
|
||||
(TypedArena<<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Allocated>)
|
||||
()
|
||||
),)*
|
||||
}
|
||||
|
||||
impl Default for QueryArenas<'_> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
$($name: query_if_arena!([$($modifiers)*]
|
||||
(Default::default())
|
||||
()
|
||||
),)*
|
||||
}
|
||||
}
|
||||
$(
|
||||
$(#[$attr])*
|
||||
pub $name: query_if_arena!([$($modifiers)*]
|
||||
// Use the `ArenaCached` helper trait to determine the arena's value type.
|
||||
(TypedArena<<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Allocated>)
|
||||
// No arena for this query, so the field type is `()`.
|
||||
()
|
||||
),
|
||||
)*
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue