Repository: rust-lang/rust
File: compiler/rustc_middle/src/query/plumbing.rs (Rust)

Code before:
    pub fn ensure_done(self) -> TyCtxtEnsureDone<'tcx> {
        TyCtxtEnsureDone { tcx: self }
    }

    /// Returns a transparent wrapper for `TyCtxt` which uses
    /// `span` as the location of queries performed through it.
    #[inline(always)]
    pub fn at(self, span: Span) -> TyCtxtAt<'tcx> {
        TyCtxtAt { tcx: self, span }
    }

    pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool {
        (self.query_system.fns.try_mark_green)(self, dep_node)
    }
}

macro_rules! query_helper_param_ty {
    (DefId) => { impl $crate::query::IntoQueryParam<DefId> };
    (LocalDefId) => { impl $crate::query::IntoQueryParam<LocalDefId> };
    ($K:ty) => { $K };
}

// Expands to `$then` if the `arena_cache` modifier is present, `$else` otherwise.
macro_rules! if_arena_cache {
    ([] $_then:tt $else:tt) => { $else };
    ([(arena_cache) $($modifiers:tt)*] $then:tt $_else:tt) => { $then };
    ([$other:tt $($modifiers:tt)*] $then:tt $else:tt) => {
        if_arena_cache!([$($modifiers)*] $then $else)
    };
}

// Expands to `$then` if the `separate_provide_extern` modifier is present, `$else` otherwise.
macro_rules! if_separate_provide_extern {
    ([] $_then:tt $else:tt) => { $else };
    ([(separate_provide_extern) $($modifiers:tt)*] $then:tt $_else:tt) => { $then };
    ([$other:tt $($modifiers:tt)*] $then:tt $else:tt) => {
        if_separate_provide_extern!([$($modifiers)*] $then $else)
    };
}

// Expands to `$then` if the `return_result_from_ensure_ok` modifier is present, `$else` otherwise.
macro_rules! if_return_result_from_ensure_ok {
    ([] $_then:tt $else:tt) => { $else };
    ([(return_result_from_ensure_ok) $($modifiers:tt)*] $then:tt $_else:tt) => { $then };
    ([$other:tt $($modifiers:tt)*] $then:tt $else:tt) => {
        if_return_result_from_ensure_ok!([$($modifiers)*] $then $else)
    };
}

macro_rules! define_callbacks {
    (

Review comment (suggestion):
Nit/suggestion: Elsewhere I have used `$yes:tt` and `$no:tt` for this purpose, which I find a little nicer than `$then:tt` and `$else:tt`.

Code after:
    pub fn ensure_done(self) -> TyCtxtEnsureDone<'tcx> {
        TyCtxtEnsureDone { tcx: self }
    }

    /// Returns a transparent wrapper for `TyCtxt` which uses
    /// `span` as the location of queries performed through it.
    #[inline(always)]
    pub fn at(self, span: Span) -> TyCtxtAt<'tcx> {
        TyCtxtAt { tcx: self, span }
    }

    pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool {
        (self.query_system.fns.try_mark_green)(self, dep_node)
    }
}

macro_rules! query_helper_param_ty {
    (DefId) => { impl $crate::query::IntoQueryParam<DefId> };
    (LocalDefId) => { impl $crate::query::IntoQueryParam<LocalDefId> };
    ($K:ty) => { $K };
}

// Expands to `$yes` if the `arena_cache` modifier is present, `$no` otherwise.
macro_rules! if_arena_cache {
    ([] $then:tt $no:tt) => { $no };
    ([(arena_cache) $($modifiers:tt)*] $yes:tt $no:tt) => { $yes };
    ([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => {
        if_arena_cache!([$($modifiers)*] $yes $no)
    };
}

// Expands to `$yes` if the `separate_provide_extern` modifier is present, `$no` otherwise.
macro_rules! if_separate_provide_extern {
    ([] $then:tt $no:tt) => { $no };
    ([(separate_provide_extern) $($modifiers:tt)*] $yes:tt $no:tt) => { $yes };
    ([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => {
        if_separate_provide_extern!([$($modifiers)*] $yes $no)
    };
}

// Expands to `$yes` if the `return_result_from_ensure_ok` modifier is present, `$no` otherwise.
macro_rules! if_return_result_from_ensure_ok {
    ([] $then:tt $no:tt) => { $no };
    ([(return_result_from_ensure_ok) $($modifiers:tt)*] $yes:tt $no:tt) => { $yes };
    ([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => {
        if_return_result_from_ensure_ok!([$($modifiers)*] $yes $no)
    };
}

macro_rules! define_callbacks {
    (