Skip to content

Commit 8e5d613

Browse files
committed
Wrap QueryDescription into a macro.
1 parent cdc0b19 commit 8e5d613

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

compiler/rustc_macros/src/query.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ fn add_query_description_impl(
344344
impls: &mut proc_macro2::TokenStream,
345345
) {
346346
let name = &query.name;
347-
let arg = &query.arg;
348347
let key = &query.key.0;
349348

350349
// Find out if we should cache the query on disk
@@ -414,7 +413,7 @@ fn add_query_description_impl(
414413

415414
let desc = quote! {
416415
#[allow(unused_variables)]
417-
fn describe(tcx: QueryCtxt<'tcx>, key: #arg) -> String {
416+
fn describe(tcx: QueryCtxt<'tcx>, key: Self::Key) -> String {
418417
let (#tcx, #key) = (*tcx, key);
419418
::rustc_middle::ty::print::with_no_trimmed_paths(|| format!(#desc).into())
420419
}
@@ -520,7 +519,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
520519
$($macro)*(#cached_queries);
521520
}
522521
}
523-
524-
#query_description_stream
522+
macro_rules! rustc_query_description {
523+
() => { #query_description_stream }
524+
}
525525
})
526526
}

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
use crate::dep_graph::SerializedDepNodeIndex;
2-
use crate::mir::interpret::{GlobalId, LitToConstInput};
3-
use crate::traits;
4-
use crate::traits::query::{
5-
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
6-
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
7-
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
8-
};
9-
use crate::ty::query::queries;
10-
use crate::ty::query::QueryCtxt;
11-
use crate::ty::subst::{GenericArg, SubstsRef};
12-
use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
13-
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
14-
use rustc_query_system::query::QueryDescription;
15-
16-
use rustc_span::symbol::Symbol;
17-
18-
fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
19-
if def_id.is_top_level_module() {
20-
"top-level module".to_string()
21-
} else {
22-
format!("module `{}`", tcx.def_path_str(def_id.to_def_id()))
23-
}
24-
}
25-
261
// Each of these queries corresponds to a function pointer field in the
272
// `Providers` struct for requesting a value of that type, and a method
283
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way

compiler/rustc_middle/src/ty/query/plumbing.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
//! manage the caches, and so forth.
44
55
use crate::dep_graph::{self, DepKind, DepNode, DepNodeExt, DepNodeIndex, SerializedDepNodeIndex};
6-
use crate::ty::query::{on_disk_cache, Queries, Query};
6+
use crate::ty::query::{on_disk_cache, queries, Queries, Query};
77
use crate::ty::tls::{self, ImplicitCtxt};
88
use crate::ty::{self, TyCtxt};
99
use rustc_query_system::dep_graph::HasDepContext;
10-
use rustc_query_system::query::QueryContext;
1110
use rustc_query_system::query::{CycleError, QueryJobId, QueryJobInfo};
11+
use rustc_query_system::query::{QueryContext, QueryDescription};
1212

1313
use rustc_data_structures::fx::FxHashMap;
1414
use rustc_data_structures::sync::Lock;
1515
use rustc_data_structures::thin_vec::ThinVec;
1616
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, Handler, Level};
1717
use rustc_serialize::opaque;
18-
use rustc_span::def_id::DefId;
18+
use rustc_span::def_id::{DefId, LocalDefId};
1919
use rustc_span::Span;
2020

2121
#[derive(Copy, Clone)]
@@ -797,3 +797,13 @@ macro_rules! define_provider_struct {
797797
}
798798
};
799799
}
800+
801+
fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
802+
if def_id.is_top_level_module() {
803+
"top-level module".to_string()
804+
} else {
805+
format!("module `{}`", tcx.def_path_str(def_id.to_def_id()))
806+
}
807+
}
808+
809+
rustc_query_description! {}

0 commit comments

Comments
 (0)