Skip to content

Commit 143ca0b

Browse files
Rollup merge of #152779 - nnethercote:clarify-aspects-of-query-macros, r=Zalathar
Clarify aspects of query macros Various clarity and consistency improvements to query macros. r? @Zalathar
2 parents 1500f0f + bc1b6b8 commit 143ca0b

3 files changed

Lines changed: 246 additions & 236 deletions

File tree

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,12 @@ impl StableOrd for WorkProductId {
324324
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
325325
}
326326

327+
// Note: `$K` and `$V` are unused but present so this can be called by `rustc_with_all_queries`.
327328
macro_rules! define_dep_nodes {
328329
(
329330
$(
330331
$(#[$attr:meta])*
331-
[$($modifiers:tt)*] fn $variant:ident($($K:tt)*) -> $V:ty,
332+
[$($modifiers:tt)*] fn $variant:ident($K:ty) -> $V:ty,
332333
)*
333334
) => {
334335

@@ -382,20 +383,20 @@ macro_rules! define_dep_nodes {
382383
}
383384

384385
// Create various data structures for each query, and also for a few things
385-
// that aren't queries.
386+
// that aren't queries. The key and return types aren't used, hence the use of `()`.
386387
rustc_with_all_queries!(define_dep_nodes![
387388
/// We use this for most things when incr. comp. is turned off.
388-
[] fn Null() -> (),
389+
[] fn Null(()) -> (),
389390
/// We use this to create a forever-red node.
390-
[] fn Red() -> (),
391+
[] fn Red(()) -> (),
391392
/// We use this to create a side effect node.
392-
[] fn SideEffect() -> (),
393+
[] fn SideEffect(()) -> (),
393394
/// We use this to create the anon node with zero dependencies.
394-
[] fn AnonZeroDeps() -> (),
395-
[] fn TraitSelect() -> (),
396-
[] fn CompileCodegenUnit() -> (),
397-
[] fn CompileMonoItem() -> (),
398-
[] fn Metadata() -> (),
395+
[] fn AnonZeroDeps(()) -> (),
396+
[] fn TraitSelect(()) -> (),
397+
[] fn CompileCodegenUnit(()) -> (),
398+
[] fn CompileMonoItem(()) -> (),
399+
[] fn Metadata(()) -> (),
399400
]);
400401

401402
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.

0 commit comments

Comments
 (0)