| 1 | //! Diagnostic data structures. |
| 2 | |
| 3 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{ |
| 4 | stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::{Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#}, |
| 5 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#, |
| 6 | }; |
| 7 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#; |
| 8 | |
| 9 | #[cfg(feature = "serialization")] |
| 10 | use serderust-analyzer cargo serde 1.0.117 crate/::{Deserializerust-analyzer cargo serde 1.0.117 de/Deserialize#, Serializerust-analyzer cargo serde 1.0.117 ser/Serialize#}; |
| 11 | |
| 12 | /// A severity level for diagnostic messages. |
| 13 | /// |
| 14 | /// These are ordered in the following way: |
| 15 | /// |
| 16 | /// ```rust |
| 17 | /// use codespan_reporting::diagnostic::Severity; |
| 18 | /// |
| 19 | /// assert!(Severity::Bug > Severity::Error); |
| 20 | /// assert!(Severity::Error > Severity::Warning); |
| 21 | /// assert!(Severity::Warning > Severity::Note); |
| 22 | /// assert!(Severity::Note > Severity::Help); |
| 23 | /// ``` |
| 24 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 25 | #[cfg_attr(feature = "serialization", derive(Serializerust-analyzer cargo serde_derive 1.0.117 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.117 Deserialize:))] |
| 26 | pub enum Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity# { |
| 27 | /// A help message. |
| 28 | Helprust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Help#, |
| 29 | /// A note. |
| 30 | Noterust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Note#, |
| 31 | /// A warning. |
| 32 | Warningrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Warning#, |
| 33 | /// An error. |
| 34 | Errorrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Error#, |
| 35 | /// An unexpected bug. |
| 36 | Bugrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Bug#, |
| 37 | } |
| 38 | |
| 39 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)] |
| 40 | #[cfg_attr(feature = "serialization", derive(Serializerust-analyzer cargo serde_derive 1.0.117 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.117 Deserialize:))] |
| 41 | pub enum LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle# { |
| 42 | /// Labels that describe the primary cause of a diagnostic. |
| 43 | Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary#, |
| 44 | /// Labels that provide additional context for a diagnostic. |
| 45 | Secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Secondary#, |
| 46 | } |
| 47 | |
| 48 | /// A label describing an underlined region of code associated with a diagnostic. |
| 49 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 50 | #[cfg_attr(feature = "serialization", derive(Serializerust-analyzer cargo serde_derive 1.0.117 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.117 Deserialize:))] |
| 51 | pub struct Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId> { |
| 52 | /// The style of the label. |
| 53 | pub stylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#style.: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 54 | /// The file that we are labelling. |
| 55 | pub file_idrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#file_id.: FileId, |
| 56 | /// The range in bytes we are going to include in the final snippet. |
| 57 | pub rangerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#range.: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, |
| 58 | /// An optional message to provide some additional information for the |
| 59 | /// underlined code. These should not include line breaks. |
| 60 | pub messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 61 | } |
| 62 | |
| 63 | impl<FileId> Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId> { |
| 64 | /// Create a new label. |
| 65 | pub fn newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]new().( |
| 66 | style: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 67 | file_id: FileId, |
| 68 | range: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>>, |
| 69 | ) -> Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId> { |
| 70 | Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label# { |
| 71 | stylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#style., |
| 72 | file_idrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#file_id., |
| 73 | rangerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#range.: range.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 74 | messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /// Create a new label with a style of [`LabelStyle::Primary`]. |
| 79 | /// |
| 80 | /// [`LabelStyle::Primary`]: LabelStyle::Primary |
| 81 | pub fn primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]primary().(file_id: FileId, range: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>>) -> Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId> { |
| 82 | Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]new().(LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary#, file_id, range) |
| 83 | } |
| 84 | |
| 85 | /// Create a new label with a style of [`LabelStyle::Secondary`]. |
| 86 | /// |
| 87 | /// [`LabelStyle::Secondary`]: LabelStyle::Secondary |
| 88 | pub fn secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]secondary().(file_id: FileId, range: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>>) -> Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId> { |
| 89 | Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]new().(LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Secondary#, file_id, range) |
| 90 | } |
| 91 | |
| 92 | /// Add a message to the diagnostic. |
| 93 | pub fn with_messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]with_message().(mut self, message: impl ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#) -> Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId> { |
| 94 | self.messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#message. = message.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().(); |
| 95 | self |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /// Represents a diagnostic message that can provide information like errors and |
| 100 | /// warnings to the user. |
| 101 | /// |
| 102 | /// 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. |
| 103 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 104 | #[cfg_attr(feature = "serialization", derive(Serializerust-analyzer cargo serde_derive 1.0.117 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.117 Deserialize:))] |
| 105 | pub struct Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 106 | /// The overall severity of the diagnostic |
| 107 | pub severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#severity.: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 108 | /// An optional code that identifies this diagnostic. |
| 109 | pub coderust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#code.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 110 | /// The main message associated with this diagnostic. |
| 111 | /// |
| 112 | /// These should not include line breaks, and in order support the 'short' |
| 113 | /// diagnostic display mod, the message should be specific enough to make |
| 114 | /// sense on its own, without additional context provided by labels and notes. |
| 115 | pub messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 116 | /// Source labels that describe the cause of the diagnostic. |
| 117 | /// The order of the labels inside the vector does not have any meaning. |
| 118 | /// The labels are always arranged in the order they appear in the source code. |
| 119 | pub labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#labels.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId>>, |
| 120 | /// Notes that are associated with the primary cause of the diagnostic. |
| 121 | /// These can include line breaks for improved formatting. |
| 122 | pub notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#notes.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 123 | } |
| 124 | |
| 125 | impl<FileId> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 126 | /// Create a new diagnostic. |
| 127 | pub fn newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]new().(severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 128 | Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic# { |
| 129 | severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#severity., |
| 130 | coderust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#code.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 131 | messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |
| 132 | labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#labels.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 133 | notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#notes.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | /// Create a new diagnostic with a severity of [`Severity::Bug`]. |
| 138 | /// |
| 139 | /// [`Severity::Bug`]: Severity::Bug |
| 140 | pub fn bugrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]bug().() -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 141 | Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]new().(Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Bugrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Bug#) |
| 142 | } |
| 143 | |
| 144 | /// Create a new diagnostic with a severity of [`Severity::Error`]. |
| 145 | /// |
| 146 | /// [`Severity::Error`]: Severity::Error |
| 147 | pub fn errorrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]error().() -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 148 | Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]new().(Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Errorrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Error#) |
| 149 | } |
| 150 | |
| 151 | /// Create a new diagnostic with a severity of [`Severity::Warning`]. |
| 152 | /// |
| 153 | /// [`Severity::Warning`]: Severity::Warning |
| 154 | pub fn warningrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]warning().() -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 155 | Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]new().(Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Warningrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Warning#) |
| 156 | } |
| 157 | |
| 158 | /// Create a new diagnostic with a severity of [`Severity::Note`]. |
| 159 | /// |
| 160 | /// [`Severity::Note`]: Severity::Note |
| 161 | pub fn noterust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]note().() -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 162 | Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]new().(Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Noterust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Note#) |
| 163 | } |
| 164 | |
| 165 | /// Create a new diagnostic with a severity of [`Severity::Help`]. |
| 166 | /// |
| 167 | /// [`Severity::Help`]: Severity::Help |
| 168 | pub fn helprust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]help().() -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 169 | Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::newrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]new().(Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Helprust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Help#) |
| 170 | } |
| 171 | |
| 172 | /// Set the error code of the diagnostic. |
| 173 | pub fn with_coderust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_code().(mut self, code: impl ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 174 | self.coderust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#code. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(code.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().()); |
| 175 | self |
| 176 | } |
| 177 | |
| 178 | /// Set the message of the diagnostic. |
| 179 | pub fn with_messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_message().(mut self, message: impl ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 180 | self.messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#message. = message.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().(); |
| 181 | self |
| 182 | } |
| 183 | |
| 184 | /// Add a label to the diagnostic. |
| 185 | pub fn with_labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_label().(mut self, label: Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId>) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 186 | self.labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#labels..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(label); |
| 187 | self |
| 188 | } |
| 189 | |
| 190 | /// Add some labels to the diagnostic. |
| 191 | pub fn with_labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_labels().(mut self, mut labels: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId>>) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 192 | self.labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#labels..appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut labels); |
| 193 | self |
| 194 | } |
| 195 | |
| 196 | /// Add some labels to the diagnostic. |
| 197 | pub fn with_labels_iterrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_labels_iter().( |
| 198 | mut self, |
| 199 | labels: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#<FileId>>, |
| 200 | ) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 201 | self.labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#labels..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(labels); |
| 202 | self |
| 203 | } |
| 204 | |
| 205 | /// Add a note to the diagnostic. |
| 206 | pub fn with_noterust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_note().(mut self, note: impl ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 207 | self.notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#notes..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(note.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().()); |
| 208 | self |
| 209 | } |
| 210 | |
| 211 | /// Add some notes to the diagnostic. |
| 212 | pub fn with_notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_notes().(mut self, mut notes: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 213 | self.notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#notes..appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut notes); |
| 214 | self |
| 215 | } |
| 216 | |
| 217 | /// Add some notes to the diagnostic. |
| 218 | pub fn with_notes_iterrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_notes_iter().( |
| 219 | mut self, |
| 220 | notes: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 221 | ) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<FileId> { |
| 222 | self.notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#notes..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(notes); |
| 223 | self |
| 224 | } |
| 225 | } |