Skip to content

Commit

Permalink
Rollup merge of #65176 - nnethercote:rm-query-macros, r=michaelwoerister
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Centril committed Oct 8, 2019
2 parents dba40d8 + 9267d9f commit 8c2e726
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
45 changes: 13 additions & 32 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,37 +1134,6 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
return false
}

macro_rules! def_id {
() => {
if let Some(def_id) = dep_node.extract_def_id(tcx) {
def_id
} else {
// Return from the whole function.
return false
}
}
};

macro_rules! krate {
() => { (def_id!()).krate }
};

macro_rules! force_ex {
($tcx:expr, $query:ident, $key:expr) => {
{
$tcx.force_query::<crate::ty::query::queries::$query<'_>>(
$key,
DUMMY_SP,
*dep_node
);
}
}
};

macro_rules! force {
($query:ident, $key:expr) => { force_ex!(tcx, $query, $key) }
};

rustc_dep_node_force!([dep_node, tcx]
// These are inputs that are expected to be pre-allocated and that
// should therefore always be red or green already.
Expand All @@ -1183,7 +1152,19 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
bug!("force_from_dep_node: encountered {:?}", dep_node)
}

DepKind::Analysis => { force!(analysis, krate!()); }
DepKind::Analysis => {
let def_id = if let Some(def_id) = dep_node.extract_def_id(tcx) {
def_id
} else {
// Return from the whole function.
return false
};
tcx.force_query::<crate::ty::query::queries::analysis<'_>>(
def_id.krate,
DUMMY_SP,
*dep_node
);
}
);

true
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,11 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
dep_node_force_stream.extend(quote! {
DepKind::#name => {
if let Some(key) = RecoverKey::recover($tcx, $dep_node) {
force_ex!($tcx, #name, key);
$tcx.force_query::<crate::ty::query::queries::#name<'_>>(
key,
DUMMY_SP,
*$dep_node
);
} else {
return false;
}
Expand Down

0 comments on commit 8c2e726

Please sign in to comment.