diff options
author | Haibo Huang <hhb@google.com> | 2020-11-30 18:18:40 -0800 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2020-11-30 18:18:40 -0800 |
commit | f8e9299b324cf4963862af1bef8ba4b137923fc5 (patch) | |
tree | 291f85450ee9cb3667a166c313c51e87bf5647eb /src/diagnostic.rs | |
parent | 38004163c2ed653e75215220d1d22d4d4994abed (diff) | |
download | codespan-reporting-f8e9299b324cf4963862af1bef8ba4b137923fc5.tar.gz |
Upgrade rust/crates/codespan-reporting to 0.11.0
Test: make
Change-Id: Ic52ba5f9bbf0ad9dd0cb7293bcc451623c2d3e82
Diffstat (limited to 'src/diagnostic.rs')
-rw-r--r-- | src/diagnostic.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/diagnostic.rs b/src/diagnostic.rs index 559c899..7dddcec 100644 --- a/src/diagnostic.rs +++ b/src/diagnostic.rs @@ -16,7 +16,7 @@ use std::ops::Range; /// assert!(Severity::Warning > Severity::Note); /// assert!(Severity::Note > Severity::Help); /// ``` -#[derive(Copy, Clone, PartialEq, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] #[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))] pub enum Severity { /// An unexpected bug. @@ -50,7 +50,7 @@ impl PartialOrd for Severity { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd)] #[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))] pub enum LabelStyle { /// Labels that describe the primary cause of a diagnostic. @@ -60,7 +60,7 @@ pub enum LabelStyle { } /// A label describing an underlined region of code associated with a diagnostic. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))] pub struct Label<FileId> { /// The style of the label. @@ -112,7 +112,9 @@ impl<FileId> Label<FileId> { /// Represents a diagnostic message that can provide information like errors and /// warnings to the user. -#[derive(Clone, Debug)] +/// +/// The position of a Diagnostic is considered to be the position of the [`Label`] that has the earliest starting position and has the highest style which appears in all the labels of the diagnostic. +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))] pub struct Diagnostic<FileId> { /// The overall severity of the diagnostic @@ -126,6 +128,8 @@ pub struct Diagnostic<FileId> { /// sense on its own, without additional context provided by labels and notes. pub message: String, /// Source labels that describe the cause of the diagnostic. + /// The order of the labels inside the vector does not have any meaning. + /// The labels are always arranged in the order they appear in the source code. pub labels: Vec<Label<FileId>>, /// Notes that are associated with the primary cause of the diagnostic. /// These can include line breaks for improved formatting. |