Skip to content

Commit d2c53ca

Browse files
committed
Move Queries::new out of the macro
1 parent 699bfa8 commit d2c53ca

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

compiler/rustc_data_structures/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cfg_if! {
4848
/// the native atomic types.
4949
/// You should use this type through the `AtomicU64`, `AtomicUsize`, etc, type aliases
5050
/// as it's not intended to be used separately.
51-
#[derive(Debug)]
51+
#[derive(Debug, Default)]
5252
pub struct Atomic<T: Copy>(Cell<T>);
5353

5454
impl<T: Copy> Atomic<T> {

compiler/rustc_query_impl/src/plumbing.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::keys::Key;
66
use crate::{on_disk_cache, Queries};
77
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
8-
use rustc_data_structures::sync::Lock;
8+
use rustc_data_structures::sync::{AtomicU64, Lock};
99
use rustc_errors::{Diagnostic, Handler};
1010
use rustc_middle::dep_graph::{
1111
self, DepKind, DepKindStruct, DepNode, DepNodeIndex, SerializedDepNodeIndex,
@@ -501,9 +501,28 @@ macro_rules! define_queries {
501501
}
502502
}
503503

504+
use crate::{ExternProviders, OnDiskCache, Providers};
505+
506+
impl<'tcx> Queries<'tcx> {
507+
pub fn new(
508+
local_providers: Providers,
509+
extern_providers: ExternProviders,
510+
on_disk_cache: Option<OnDiskCache<'tcx>>,
511+
) -> Self {
512+
Queries {
513+
local_providers: Box::new(local_providers),
514+
extern_providers: Box::new(extern_providers),
515+
on_disk_cache,
516+
jobs: AtomicU64::new(1),
517+
..Queries::default()
518+
}
519+
}
520+
}
521+
504522
macro_rules! define_queries_struct {
505523
(
506524
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
525+
#[derive(Default)]
507526
pub struct Queries<'tcx> {
508527
local_providers: Box<Providers>,
509528
extern_providers: Box<ExternProviders>,
@@ -516,20 +535,6 @@ macro_rules! define_queries_struct {
516535
}
517536

518537
impl<'tcx> Queries<'tcx> {
519-
pub fn new(
520-
local_providers: Providers,
521-
extern_providers: ExternProviders,
522-
on_disk_cache: Option<OnDiskCache<'tcx>>,
523-
) -> Self {
524-
Queries {
525-
local_providers: Box::new(local_providers),
526-
extern_providers: Box::new(extern_providers),
527-
on_disk_cache,
528-
jobs: AtomicU64::new(1),
529-
$($name: Default::default()),*
530-
}
531-
}
532-
533538
pub(crate) fn try_collect_active_jobs(
534539
&'tcx self,
535540
tcx: TyCtxt<'tcx>,

0 commit comments

Comments
 (0)