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

Code before:
    /// The query and related span that uses the cycle.
    pub usage: Option<(Span, QueryStackFrame<I>)>,
    pub cycle: Vec<QueryInfo<I>>,
}

impl<'tcx> CycleError<QueryStackDeferred<'tcx>> {
    pub fn lift(&self) -> CycleError<QueryStackFrameExtra> {
        CycleError {
            usage: self.usage.as_ref().map(|(span, frame)| (*span, frame.lift())),
            cycle: self.cycle.iter().map(|info| info.lift()).collect(),
        }
    }
}

#[derive(Debug)]
pub enum QueryMode {
    Get,
    Ensure { check_cache: bool },
}

/// Stores function pointers and other metadata for a particular query.
pub struct QueryVTable<'tcx, C: QueryCache> {
    pub name: &'static str,
    /// True if this query has the `anon` modifier.
    pub anon: bool,
    /// True if this query has the `eval_always` modifier.
    pub eval_always: bool,
    /// True if this query has the `depth_limit` modifier.
    pub depth_limit: bool,
    /// True if this query has the `feedable` modifier.
    pub feedable: bool,

    pub dep_kind: DepKind,
    /// How this query deals with query cycle errors.
    pub cycle_error_handling: CycleErrorHandling,
    // Offset of this query's state field in the QueryStates struct
    pub query_state: usize,
    // Offset of this query's cache field in the QueryCaches struct
    pub query_cache: usize,
    pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,

    /// Function pointer that calls `tcx.$query(key)` for this query and
    /// discards the returned value.
    ///
    /// This is a weird thing to be doing, and probably not what you want.
    /// It is used for loading query results from disk-cache in some cases.
    pub call_query_method_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key),

    /// Function pointer that actually calls this query's provider.
    /// Also performs some associated secondary tasks; see the macro-defined
    /// implementation in `mod invoke_provider_fn` for more details.

Review comment (suggestion):
Nit/suggestion: Consider putting a newline before `anon` so that the boolean modifiers form a single block.

Code after:
    /// The query and related span that uses the cycle.
    pub usage: Option<(Span, QueryStackFrame<I>)>,
    pub cycle: Vec<QueryInfo<I>>,
}

impl<'tcx> CycleError<QueryStackDeferred<'tcx>> {
    pub fn lift(&self) -> CycleError<QueryStackFrameExtra> {
        CycleError {
            usage: self.usage.as_ref().map(|(span, frame)| (*span, frame.lift())),
            cycle: self.cycle.iter().map(|info| info.lift()).collect(),
        }
    }
}

#[derive(Debug)]
pub enum QueryMode {
    Get,
    Ensure { check_cache: bool },
}

/// Stores function pointers and other metadata for a particular query.
pub struct QueryVTable<'tcx, C: QueryCache> {
    pub name: &'static str,

    /// True if this query has the `anon` modifier.
    pub anon: bool,
    /// True if this query has the `eval_always` modifier.
    pub eval_always: bool,
    /// True if this query has the `depth_limit` modifier.
    pub depth_limit: bool,
    /// True if this query has the `feedable` modifier.
    pub feedable: bool,

    pub dep_kind: DepKind,
    /// How this query deals with query cycle errors.
    pub cycle_error_handling: CycleErrorHandling,
    // Offset of this query's state field in the QueryStates struct
    pub query_state: usize,
    // Offset of this query's cache field in the QueryCaches struct
    pub query_cache: usize,
    pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,

    /// Function pointer that calls `tcx.$query(key)` for this query and
    /// discards the returned value.
    ///
    /// This is a weird thing to be doing, and probably not what you want.
    /// It is used for loading query results from disk-cache in some cases.
    pub call_query_method_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key),

    /// Function pointer that actually calls this query's provider.
    /// Also performs some associated secondary tasks; see the macro-defined