Skip to content

Commit ea991bc

Browse files
committed
Wrap QueryDescription into a macro.
1 parent 9a4d339 commit ea991bc

File tree

3 files changed

+18
-33
lines changed

3 files changed

+18
-33
lines changed

compiler/rustc_macros/src/query.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ fn add_query_description_impl(
363363
impls: &mut proc_macro2::TokenStream,
364364
) {
365365
let name = &query.name;
366-
let arg = &query.arg;
367366
let key = &query.key.0;
368367

369368
// Find out if we should cache the query on disk
@@ -435,7 +434,7 @@ fn add_query_description_impl(
435434
#[allow(unused_variables)]
436435
fn describe(
437436
tcx: QueryCtxt<'tcx>,
438-
key: #arg,
437+
key: Self::Key,
439438
) -> Cow<'static, str> {
440439
let (#tcx, #key) = (*tcx, key);
441440
::rustc_middle::ty::print::with_no_trimmed_paths(|| format!(#desc).into())
@@ -544,7 +543,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
544543
$($macro)*(#cached_queries);
545544
}
546545
}
547-
548-
#query_description_stream
546+
macro_rules! rustc_query_description {
547+
() => { #query_description_stream }
548+
}
549549
})
550550
}

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +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-
use std::borrow::Cow;
18-
19-
fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
20-
if def_id.is_top_level_module() {
21-
"top-level module".to_string()
22-
} else {
23-
format!("module `{}`", tcx.def_path_str(def_id.to_def_id()))
24-
}
25-
}
26-
271
// Each of these queries corresponds to a function pointer field in the
282
// `Providers` struct for requesting a value of that type, and a method
293
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
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;
20+
use std::borrow::Cow;
2021

2122
#[derive(Copy, Clone)]
2223
pub struct QueryCtxt<'tcx> {
@@ -810,3 +811,13 @@ macro_rules! define_provider_struct {
810811
}
811812
};
812813
}
814+
815+
fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
816+
if def_id.is_top_level_module() {
817+
"top-level module".to_string()
818+
} else {
819+
format!("module `{}`", tcx.def_path_str(def_id.to_def_id()))
820+
}
821+
}
822+
823+
rustc_query_description! {}

0 commit comments

Comments
 (0)