Skip to main content

rustc_query_impl/
error.rs

1use rustc_hir::limit::Limit;
2use rustc_macros::{Diagnostic, Subdiagnostic};
3use rustc_span::{Span, Symbol};
4
5#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for QueryOverflow
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    QueryOverflow {
                        span: __binding_0,
                        note: __binding_1,
                        suggested_limit: __binding_2,
                        crate_name: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("queries overflow the depth limit!")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)")));
                        ;
                        diag.arg("suggested_limit", __binding_2);
                        diag.arg("crate_name", __binding_3);
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
6#[help(
7    "consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
8)]
9#[diag("queries overflow the depth limit!")]
10pub(crate) struct QueryOverflow {
11    #[primary_span]
12    pub span: Span,
13    #[subdiagnostic]
14    pub note: QueryOverflowNote,
15    pub suggested_limit: Limit,
16    pub crate_name: Symbol,
17}
18
19#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for QueryOverflowNote {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    QueryOverflowNote { desc: __binding_0, depth: __binding_1 }
                        => {
                        diag.store_args();
                        diag.arg("desc", __binding_0);
                        diag.arg("depth", __binding_1);
                        let __message =
                            diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("query depth increased by {$depth} when {$desc}")));
                        diag.note(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
20#[note("query depth increased by {$depth} when {$desc}")]
21pub(crate) struct QueryOverflowNote {
22    pub desc: String,
23    pub depth: usize,
24}