From 5b8152807cae152d5c7cfb40615e5a817a6cf750 Mon Sep 17 00:00:00 2001 From: Jhonny Bill Mena Date: Wed, 7 Sep 2022 09:36:08 -0400 Subject: UPDATE - move SessionDiagnostic from rustc_session to rustc_errors --- compiler/rustc_errors/src/diagnostic_builder.rs | 9 +++++++++ compiler/rustc_errors/src/lib.rs | 1 + 2 files changed, 10 insertions(+) (limited to 'compiler/rustc_errors') 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>; -- cgit 1.4.1-3-g733a5