diff options
| author | Matthew Kelly <matthew.kelly2@gmail.com> | 2022-09-26 19:59:52 -0400 |
|---|---|---|
| committer | Matthew Kelly <matthew.kelly2@gmail.com> | 2022-09-26 19:59:52 -0400 |
| commit | 24aab524cbafec7ff8c7cd54ba4f6fb18216c623 (patch) | |
| tree | b0fd92c686ed3fe2b3a5a010c0dc32a6a54d3ea1 /compiler/rustc_query_system/src/error.rs | |
| parent | eda2a401457ba645a32bdc5b9e7e90214e3e4e24 (diff) | |
| parent | 8b705839cd656d202e920efa8769cbe43a5ee269 (diff) | |
Merge remote-tracking branch 'origin/master' into mpk/add-long-error-message-for-E0311
Diffstat (limited to 'compiler/rustc_query_system/src/error.rs')
| -rw-r--r-- | compiler/rustc_query_system/src/error.rs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/compiler/rustc_query_system/src/error.rs b/compiler/rustc_query_system/src/error.rs new file mode 100644 index 00000000000..8602a4cf5ae --- /dev/null +++ b/compiler/rustc_query_system/src/error.rs @@ -0,0 +1,97 @@ +use rustc_errors::AddToDiagnostic; +use rustc_macros::{Diagnostic, Subdiagnostic}; +use rustc_session::Limit; +use rustc_span::{Span, Symbol}; + +pub struct CycleStack { + pub span: Span, + pub desc: String, +} + +impl AddToDiagnostic for CycleStack { + fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) { + diag.span_note(self.span, &format!("...which requires {}...", self.desc)); + } +} + +#[derive(Copy, Clone)] +pub enum HandleCycleError { + Error, + Fatal, + DelayBug, +} + +#[derive(Subdiagnostic)] +pub enum StackCount { + #[note(query_system::cycle_stack_single)] + Single, + #[note(query_system::cycle_stack_multiple)] + Multiple, +} + +#[derive(Subdiagnostic)] +pub enum Alias { + #[note(query_system::cycle_recursive_ty_alias)] + #[help(query_system::cycle_recursive_ty_alias_help1)] + #[help(query_system::cycle_recursive_ty_alias_help2)] + Ty, + #[note(query_system::cycle_recursive_trait_alias)] + Trait, +} + +#[derive(Subdiagnostic)] +#[note(query_system::cycle_usage)] +pub struct CycleUsage { + #[primary_span] + pub span: Span, + pub usage: String, +} + +#[derive(Diagnostic)] +#[diag(query_system::cycle, code = "E0391")] +pub struct Cycle { + #[primary_span] + pub span: Span, + pub stack_bottom: String, + #[subdiagnostic] + pub cycle_stack: Vec<CycleStack>, + #[subdiagnostic] + pub stack_count: StackCount, + #[subdiagnostic] + pub alias: Option<Alias>, + #[subdiagnostic] + pub cycle_usage: Option<CycleUsage>, +} + +#[derive(Diagnostic)] +#[diag(query_system::reentrant)] +pub struct Reentrant; + +#[derive(Diagnostic)] +#[diag(query_system::increment_compilation)] +#[help] +#[note(query_system::increment_compilation_note1)] +#[note(query_system::increment_compilation_note2)] +pub struct IncrementCompilation { + pub run_cmd: String, + pub dep_node: String, +} + +#[derive(Diagnostic)] +#[help] +#[diag(query_system::query_overflow)] +pub struct QueryOverflow { + #[primary_span] + pub span: Option<Span>, + #[subdiagnostic] + pub layout_of_depth: Option<LayoutOfDepth>, + pub suggested_limit: Limit, + pub crate_name: Symbol, +} + +#[derive(Subdiagnostic)] +#[note(query_system::layout_of_depth)] +pub struct LayoutOfDepth { + pub desc: String, + pub depth: usize, +} |
