Skip to main content

rustc_query_system/
error.rs

1use rustc_errors::codes::*;
2use rustc_hir::limit::Limit;
3use rustc_macros::{Diagnostic, Subdiagnostic};
4use rustc_span::{Span, Symbol};
5
6#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for CycleStack {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    CycleStack { span: __binding_0, desc: __binding_1 } => {
                        diag.store_args();
                        diag.arg("desc", __binding_1);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_stack_middle);
                        diag.span_note(__binding_0, __message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
7#[note(query_system_cycle_stack_middle)]
8pub(crate) struct CycleStack {
9    #[primary_span]
10    pub span: Span,
11    pub desc: String,
12}
13
14#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for StackCount {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    StackCount::Single => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_stack_single);
                        diag.note(__message);
                        diag.restore_args();
                    }
                    StackCount::Multiple => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_stack_multiple);
                        diag.note(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
15pub(crate) enum StackCount {
16    #[note(query_system_cycle_stack_single)]
17    Single,
18    #[note(query_system_cycle_stack_multiple)]
19    Multiple,
20}
21
22#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for Alias {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    Alias::Ty => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_recursive_ty_alias);
                        diag.note(__message);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_recursive_ty_alias_help1);
                        diag.help(__message);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_recursive_ty_alias_help2);
                        diag.help(__message);
                        diag.restore_args();
                    }
                    Alias::Trait => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_recursive_trait_alias);
                        diag.note(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
23pub(crate) enum Alias {
24    #[note(query_system_cycle_recursive_ty_alias)]
25    #[help(query_system_cycle_recursive_ty_alias_help1)]
26    #[help(query_system_cycle_recursive_ty_alias_help2)]
27    Ty,
28    #[note(query_system_cycle_recursive_trait_alias)]
29    Trait,
30}
31
32#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for CycleUsage {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    CycleUsage { span: __binding_0, usage: __binding_1 } => {
                        diag.store_args();
                        diag.arg("usage", __binding_1);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::query_system_cycle_usage);
                        diag.span_note(__binding_0, __message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
33#[note(query_system_cycle_usage)]
34pub(crate) struct CycleUsage {
35    #[primary_span]
36    pub span: Span,
37    pub usage: String,
38}
39
40#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Cycle 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 {
                    Cycle {
                        span: __binding_0,
                        stack_bottom: __binding_1,
                        cycle_stack: __binding_2,
                        stack_count: __binding_3,
                        alias: __binding_4,
                        cycle_usage: __binding_5,
                        note_span: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::query_system_cycle);
                        diag.code(E0391);
                        ;
                        diag.arg("stack_bottom", __binding_1);
                        diag.span(__binding_0);
                        for __binding_2 in __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag.subdiagnostic(__binding_3);
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        if let Some(__binding_5) = __binding_5 {
                            diag.subdiagnostic(__binding_5);
                        }
                        diag.note(crate::fluent_generated::_subdiag::note);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
41#[diag(query_system_cycle, code = E0391)]
42pub(crate) struct Cycle {
43    #[primary_span]
44    pub span: Span,
45    pub stack_bottom: String,
46    #[subdiagnostic]
47    pub cycle_stack: Vec<CycleStack>,
48    #[subdiagnostic]
49    pub stack_count: StackCount,
50    #[subdiagnostic]
51    pub alias: Option<Alias>,
52    #[subdiagnostic]
53    pub cycle_usage: Option<CycleUsage>,
54    #[note]
55    pub note_span: (),
56}
57
58#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Reentrant
            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 {
                    Reentrant => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::query_system_reentrant);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
59#[diag(query_system_reentrant)]
60pub(crate) struct Reentrant;
61
62#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IncrementCompilation 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 {
                    IncrementCompilation {
                        run_cmd: __binding_0, dep_node: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::query_system_increment_compilation);
                        diag.note(crate::fluent_generated::query_system_increment_compilation_note1);
                        diag.note(crate::fluent_generated::query_system_increment_compilation_note2);
                        diag.note(crate::fluent_generated::query_system_increment_compilation_note3);
                        diag.note(crate::fluent_generated::query_system_increment_compilation_note4);
                        ;
                        diag.arg("run_cmd", __binding_0);
                        diag.arg("dep_node", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
63#[diag(query_system_increment_compilation)]
64#[note(query_system_increment_compilation_note1)]
65#[note(query_system_increment_compilation_note2)]
66#[note(query_system_increment_compilation_note3)]
67#[note(query_system_increment_compilation_note4)]
68pub(crate) struct IncrementCompilation {
69    pub run_cmd: String,
70    pub dep_node: String,
71}
72
73#[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,
                                crate::fluent_generated::query_system_query_overflow);
                        diag.help(crate::fluent_generated::_subdiag::help);
                        ;
                        diag.arg("suggested_limit", __binding_2);
                        diag.arg("crate_name", __binding_3);
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
74#[help]
75#[diag(query_system_query_overflow)]
76pub struct QueryOverflow {
77    #[primary_span]
78    pub span: Span,
79    #[subdiagnostic]
80    pub note: QueryOverflowNote,
81    pub suggested_limit: Limit,
82    pub crate_name: Symbol,
83}
84
85#[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(crate::fluent_generated::query_system_overflow_note);
                        diag.note(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
86#[note(query_system_overflow_note)]
87pub struct QueryOverflowNote {
88    pub desc: String,
89    pub depth: usize,
90}