errors: introduce DiagnosticMessage

Introduce a `DiagnosticMessage` type that will enable diagnostic
messages to be simple strings or Fluent identifiers.
`DiagnosticMessage` is now used in the implementation of the standard
`DiagnosticBuilder` APIs.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood
2022-03-23 07:34:20 +00:00
parent a22cf2af05
commit 8c684563a5
10 changed files with 79 additions and 43 deletions

View File

@@ -145,7 +145,7 @@ pub struct CodeSuggestion {
/// ]
/// ```
pub substitutions: Vec<Substitution>,
pub msg: String,
pub msg: DiagnosticMessage,
/// Visual representation of this suggestion.
pub style: SuggestionStyle,
/// Whether or not the suggestion is approximate
@@ -400,7 +400,9 @@ impl fmt::Display for ExplicitBug {
impl error::Error for ExplicitBug {}
pub use diagnostic::{Diagnostic, DiagnosticId, DiagnosticStyledString, SubDiagnostic};
pub use diagnostic::{
Diagnostic, DiagnosticId, DiagnosticMessage, DiagnosticStyledString, SubDiagnostic,
};
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee};
use std::backtrace::Backtrace;