diff options
| author | Jhonny Bill Mena <jhonnybillm@gmail.com> | 2022-09-07 09:36:08 -0400 |
|---|---|---|
| committer | Jhonny Bill Mena <jhonnybillm@gmail.com> | 2022-09-21 11:39:52 -0400 |
| commit | 5b8152807cae152d5c7cfb40615e5a817a6cf750 (patch) | |
| tree | 4550b129bfedd6ac5b9535f8d889fb0174fff56f /compiler/rustc_errors/src | |
| parent | b79b7d8b4e0f2b112142a9ce1fea335f321a6558 (diff) | |
| download | rust-5b8152807cae152d5c7cfb40615e5a817a6cf750.tar.gz rust-5b8152807cae152d5c7cfb40615e5a817a6cf750.zip | |
UPDATE - move SessionDiagnostic from rustc_session to rustc_errors
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_builder.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 7e29dc207ac..71e21373d0d 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -13,6 +13,15 @@ use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::thread::panicking; +/// Trait implemented by error types. This should not be implemented manually. Instead, use +/// `#[derive(SessionDiagnostic)]` -- see [rustc_macros::SessionDiagnostic]. +#[rustc_diagnostic_item = "SessionDiagnostic"] +pub trait SessionDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> { + /// Write out as a diagnostic out of `Handler`. + #[must_use] + fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, T>; +} + /// Used for emitting structured error messages and other diagnostic information. /// /// If there is some state in a downstream crate you would like to diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 6f969bfcc53..3549d3c4999 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -60,6 +60,7 @@ mod snippet; mod styled_buffer; pub mod translation; +pub use diagnostic_builder::SessionDiagnostic; pub use snippet::Style; pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorGuaranteed>>; |
