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

Code before:

        /// Holds per-query arenas for queries with the `arena_cache` modifier.
        #[derive(Default)]
        pub struct QueryArenas<'tcx> {
            $(
                $(#[$attr])*
                pub $name: if_arena_cache!(
                    [$($modifiers)*]
                    (TypedArena<<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Allocated>)
                    ()
                ),
            )*
        }

        #[derive(Default)]
        pub struct QueryCaches<'tcx> {
            $(
                $(#[$attr])* pub $name: $name::Storage<'tcx>,
            )*
        }

        impl<'tcx> $crate::query::TyCtxtEnsureOk<'tcx> {
            $(
                $(#[$attr])*
                #[inline(always)]
                pub fn $name(
                    self,
                    key: query_helper_param_ty!($($K)*),
                ) -> if_return_result_from_ensure_ok!(
                    [$($modifiers)*]
                    (Result<(), ErrorGuaranteed>)
                    ()
                ) {
                    if_return_result_from_ensure_ok!(
                        [$($modifiers)*]
                        (crate::query::inner::query_ensure_error_guaranteed(
                            self.tcx,
                            self.tcx.query_system.fns.engine.$name,
                            &self.tcx.query_system.caches.$name,
                            $crate::query::IntoQueryParam::into_query_param(key),
                            false,
                        ))
                        (crate::query::inner::query_ensure(
                            self.tcx,
                            self.tcx.query_system.fns.engine.$name,
                            &self.tcx.query_system.caches.$name,
                            $crate::query::IntoQueryParam::into_query_param(key),
                            false,
                        ))
                    )
                }

Review comment (suggestion):
Nit: I was going to suggest putting the attributes (query doc comments) on their own line, but maybe we should just get rid of them instead.

I don't think it provides much value to have them on every single for-each-query struct, and we currently aren't doing so consistently anyway.

Code after:
                            "` that is too large"
                        ));
                    }
                };
            }
        )*

        /// Holds per-query arenas for queries with the `arena_cache` modifier.
        #[derive(Default)]
        pub struct QueryArenas<'tcx> {
            $(
                pub $name: if_arena_cache!(
                    [$($modifiers)*]
                    // Use the `ArenaCached` helper trait to determine the arena's value type.
                    (TypedArena<<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Allocated>)
                    // No arena for this query, so the field type is `()`.
                    ()
                ),
            )*
        }

        #[derive(Default)]
        pub struct QueryCaches<'tcx> {
            $(
                pub $name: $name::Storage<'tcx>,
            )*
        }

        impl<'tcx> $crate::query::TyCtxtEnsureOk<'tcx> {
            $(
                $(#[$attr])*
                #[inline(always)]
                pub fn $name(
                    self,
                    key: query_helper_param_ty!($($K)*),
                ) -> if_return_result_from_ensure_ok!(
                    [$($modifiers)*]
                    (Result<(), ErrorGuaranteed>)
                    ()
                ) {
                    if_return_result_from_ensure_ok!(
                        [$($modifiers)*]
                        (crate::query::inner::query_ensure_error_guaranteed)
                        (crate::query::inner::query_ensure)
                    )(
                        self.tcx,
                        self.tcx.query_system.fns.engine.$name,
                        &self.tcx.query_system.caches.$name,
                        $crate::query::IntoQueryParam::into_query_param(key),
                        false,
                    )