Skip to content

Commit 8c2e726

Browse files
authored
Rollup merge of #65176 - nnethercote:rm-query-macros, r=michaelwoerister
Remove query-related macros The query system has a few macros that only have one or two call sites, and I find they hurt readability. This PR removes them. r? @michaelwoerister
2 parents dba40d8 + 9267d9f commit 8c2e726

File tree

2 files changed

+18
-33
lines changed

2 files changed

+18
-33
lines changed

src/librustc/ty/query/plumbing.rs

+13-32
Original file line numberDiff line numberDiff line change
@@ -1134,37 +1134,6 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
11341134
return false
11351135
}
11361136

1137-
macro_rules! def_id {
1138-
() => {
1139-
if let Some(def_id) = dep_node.extract_def_id(tcx) {
1140-
def_id
1141-
} else {
1142-
// Return from the whole function.
1143-
return false
1144-
}
1145-
}
1146-
};
1147-
1148-
macro_rules! krate {
1149-
() => { (def_id!()).krate }
1150-
};
1151-
1152-
macro_rules! force_ex {
1153-
($tcx:expr, $query:ident, $key:expr) => {
1154-
{
1155-
$tcx.force_query::<crate::ty::query::queries::$query<'_>>(
1156-
$key,
1157-
DUMMY_SP,
1158-
*dep_node
1159-
);
1160-
}
1161-
}
1162-
};
1163-
1164-
macro_rules! force {
1165-
($query:ident, $key:expr) => { force_ex!(tcx, $query, $key) }
1166-
};
1167-
11681137
rustc_dep_node_force!([dep_node, tcx]
11691138
// These are inputs that are expected to be pre-allocated and that
11701139
// should therefore always be red or green already.
@@ -1183,7 +1152,19 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
11831152
bug!("force_from_dep_node: encountered {:?}", dep_node)
11841153
}
11851154

1186-
DepKind::Analysis => { force!(analysis, krate!()); }
1155+
DepKind::Analysis => {
1156+
let def_id = if let Some(def_id) = dep_node.extract_def_id(tcx) {
1157+
def_id
1158+
} else {
1159+
// Return from the whole function.
1160+
return false
1161+
};
1162+
tcx.force_query::<crate::ty::query::queries::analysis<'_>>(
1163+
def_id.krate,
1164+
DUMMY_SP,
1165+
*dep_node
1166+
);
1167+
}
11871168
);
11881169

11891170
true

src/librustc_macros/src/query.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
495495
dep_node_force_stream.extend(quote! {
496496
DepKind::#name => {
497497
if let Some(key) = RecoverKey::recover($tcx, $dep_node) {
498-
force_ex!($tcx, #name, key);
498+
$tcx.force_query::<crate::ty::query::queries::#name<'_>>(
499+
key,
500+
DUMMY_SP,
501+
*$dep_node
502+
);
499503
} else {
500504
return false;
501505
}

0 commit comments

Comments
 (0)