Skip to content

Commit b0455e9

Browse files
authored
Rollup merge of #101635 - jyn514:queries-new-derived, r=cjgillot
Move `Queries::new` out of the macro Split out from #101178 to make sure it's not contributing to the perf impact. r? `@cjgillot`
2 parents 6afbe3e + d2c53ca commit b0455e9

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,
@@ -499,9 +499,28 @@ macro_rules! define_queries {
499499
}
500500
}
501501

502+
use crate::{ExternProviders, OnDiskCache, Providers};
503+
504+
impl<'tcx> Queries<'tcx> {
505+
pub fn new(
506+
local_providers: Providers,
507+
extern_providers: ExternProviders,
508+
on_disk_cache: Option<OnDiskCache<'tcx>>,
509+
) -> Self {
510+
Queries {
511+
local_providers: Box::new(local_providers),
512+
extern_providers: Box::new(extern_providers),
513+
on_disk_cache,
514+
jobs: AtomicU64::new(1),
515+
..Queries::default()
516+
}
517+
}
518+
}
519+
502520
macro_rules! define_queries_struct {
503521
(
504522
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
523+
#[derive(Default)]
505524
pub struct Queries<'tcx> {
506525
local_providers: Box<Providers>,
507526
extern_providers: Box<ExternProviders>,
@@ -514,20 +533,6 @@ macro_rules! define_queries_struct {
514533
}
515534

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

0 commit comments

Comments
 (0)