| 1 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::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#; |
| 2 | 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#; |
| 3 | |
| 4 | use craterust-analyzer cargo codespan-reporting 0.12.0 crate/::diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/::{LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#}; |
| 5 | use craterust-analyzer cargo codespan-reporting 0.12.0 crate/::filesrust-analyzer cargo codespan-reporting 0.12.0 files/::{Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#, Locationrust-analyzer cargo codespan-reporting 0.12.0 files/Location#}; |
| 6 | use craterust-analyzer cargo codespan-reporting 0.12.0 crate/::termrust-analyzer cargo codespan-reporting 0.12.0 term/::{Charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#, Configrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#}; |
| 7 | |
| 8 | #[cfg(feature = "termcolor")] |
| 9 | use { |
| 10 | craterust-analyzer cargo codespan-reporting 0.12.0 crate/::termrust-analyzer cargo codespan-reporting 0.12.0 term/::Stylesrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#, |
| 11 | termcolorrust-analyzer cargo termcolor 1.4.1 crate/::{ColorSpecrust-analyzer cargo termcolor 1.4.1 ColorSpec#, WriteColorrust-analyzer cargo termcolor 1.4.1 WriteColor#}, |
| 12 | }; |
| 13 | |
| 14 | #[cfg(feature = "std")] |
| 15 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{selfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#}; |
| 16 | |
| 17 | #[cfg(not(feature = "std"))] |
| 18 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{Argumentsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Arguments#, Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#}; |
| 19 | |
| 20 | /// The 'location focus' of a source code snippet. |
| 21 | pub struct Locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus# { |
| 22 | /// The user-facing name of the file. |
| 23 | pub namerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 24 | /// The location. |
| 25 | pub locationrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#location.: Locationrust-analyzer cargo codespan-reporting 0.12.0 files/Location#, |
| 26 | } |
| 27 | |
| 28 | /// Single-line label, with an optional message. |
| 29 | /// |
| 30 | /// ```text |
| 31 | /// ^^^^^^^^^ blah blah |
| 32 | /// ``` |
| 33 | pub type SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'diagnostic> = (LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, &'diagnostic str); |
| 34 | |
| 35 | /// A multi-line label to render. |
| 36 | /// |
| 37 | /// Locations are relative to the start of where the source code is rendered. |
| 38 | pub enum MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#<'diagnostic> { |
| 39 | /// Multi-line label top. |
| 40 | /// The contained value indicates where the label starts. |
| 41 | /// |
| 42 | /// ```text |
| 43 | /// ╭────────────^ |
| 44 | /// ``` |
| 45 | /// |
| 46 | /// Can also be rendered at the beginning of the line |
| 47 | /// if there is only whitespace before the label starts. |
| 48 | /// |
| 49 | /// /// ```text |
| 50 | /// ╭ |
| 51 | /// ``` |
| 52 | Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(usize), |
| 53 | /// Left vertical labels for multi-line labels. |
| 54 | /// |
| 55 | /// ```text |
| 56 | /// │ |
| 57 | /// ``` |
| 58 | Leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Left#, |
| 59 | /// Multi-line label bottom, with an optional message. |
| 60 | /// The first value indicates where the label ends. |
| 61 | /// |
| 62 | /// ```text |
| 63 | /// ╰────────────^ blah blah |
| 64 | /// ``` |
| 65 | Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(usize, &'diagnostic str), |
| 66 | } |
| 67 | |
| 68 | #[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:)] |
| 69 | enum VerticalBoundrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound# { |
| 70 | Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#Top#, |
| 71 | Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#Bottom#, |
| 72 | } |
| 73 | |
| 74 | type Underlinerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Underline# = (LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, VerticalBoundrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#); |
| 75 | |
| 76 | /// A renderer of display list entries. |
| 77 | /// |
| 78 | /// The following diagram gives an overview of each of the parts of the renderer's output: |
| 79 | /// |
| 80 | /// ```text |
| 81 | /// ┌ outer gutter |
| 82 | /// │ ┌ left border |
| 83 | /// │ │ ┌ inner gutter |
| 84 | /// │ │ │ ┌─────────────────────────── source ─────────────────────────────┐ |
| 85 | /// │ │ │ │ │ |
| 86 | /// ┌──────────────────────────────────────────────────────────────────────────── |
| 87 | /// header ── │ error[0001]: oh noes, a cupcake has occurred! |
| 88 | /// snippet start ── │ ┌─ test:9:0 |
| 89 | /// snippet empty ── │ │ |
| 90 | /// snippet line ── │ 9 │ ╭ Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake |
| 91 | /// snippet line ── │ 10 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly |
| 92 | /// │ │ ╭─│─────────^ |
| 93 | /// snippet break ── │ · │ │ |
| 94 | /// snippet line ── │ 33 │ │ │ Muffin danish chocolate soufflé pastry icing bonbon oat cake. |
| 95 | /// snippet line ── │ 34 │ │ │ Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow |
| 96 | /// │ │ │ ╰─────────────────────────────^ blah blah |
| 97 | /// snippet break ── │ · │ |
| 98 | /// snippet line ── │ 38 │ │ Brownie lemon drops chocolate jelly-o candy canes. Danish marzipan |
| 99 | /// snippet line ── │ 39 │ │ jujubes soufflé carrot cake marshmallow tiramisu caramels candy canes. |
| 100 | /// │ │ │ ^^^^^^^^^^^^^^^^^^^ -------------------- blah blah |
| 101 | /// │ │ │ │ |
| 102 | /// │ │ │ blah blah |
| 103 | /// │ │ │ note: this is a note |
| 104 | /// snippet line ── │ 40 │ │ Fruitcake jelly-o danish toffee. Tootsie roll pastry cheesecake |
| 105 | /// snippet line ── │ 41 │ │ soufflé marzipan. Chocolate bar oat cake jujubes lollipop pastry |
| 106 | /// snippet line ── │ 42 │ │ cupcake. Candy canes cupcake toffee gingerbread candy canes muffin |
| 107 | /// │ │ │ ^^^^^^^^^^^^^^^^^^ blah blah |
| 108 | /// │ │ ╰──────────^ blah blah |
| 109 | /// snippet break ── │ · |
| 110 | /// snippet line ── │ 82 │ gingerbread toffee chupa chups chupa chups jelly-o cotton candy. |
| 111 | /// │ │ ^^^^^^ ------- blah blah |
| 112 | /// snippet empty ── │ │ |
| 113 | /// snippet note ── │ = blah blah |
| 114 | /// snippet note ── │ = blah blah blah |
| 115 | /// │ blah blah |
| 116 | /// snippet note ── │ = blah blah blah |
| 117 | /// │ blah blah |
| 118 | /// empty ── │ |
| 119 | /// ``` |
| 120 | /// |
| 121 | /// Filler text from http://www.cupcakeipsum.com |
| 122 | pub struct Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#<'writer, 'config> { |
| 123 | #[cfg(feature = "termcolor")] |
| 124 | writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer.: &'writer mut dyn WriteColorrust-analyzer cargo termcolor 1.4.1 WriteColor#, |
| 125 | #[cfg(not(feature = "termcolor"))] |
| 126 | writer: &'writer mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 127 | configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config.: &'config Configrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#, |
| 128 | } |
| 129 | |
| 130 | impl<'writer, 'config> Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#<'writer, 'config> { |
| 131 | /// Construct a renderer from the given writer and config. |
| 132 | pub fn newrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]new().( |
| 133 | #[cfg(feature = "termcolor")] writer: &'writer mut dyn WriteColorrust-analyzer cargo termcolor 1.4.1 WriteColor#, |
| 134 | #[cfg(not(feature = "termcolor"))] writer: &'writer mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 135 | config: &'config Configrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#, |
| 136 | ) -> Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#<'writer, 'config> { |
| 137 | Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer# { writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer., configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config. } |
| 138 | } |
| 139 | |
| 140 | fn charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().(&self) -> &'config Charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars# { |
| 141 | &self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars. |
| 142 | } |
| 143 | |
| 144 | #[cfg(feature = "termcolor")] |
| 145 | fn stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().(&self) -> &'config Stylesrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles# { |
| 146 | &self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..stylesrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#styles. |
| 147 | } |
| 148 | |
| 149 | /// Diagnostic header, with severity, code, and message. |
| 150 | /// |
| 151 | /// ```text |
| 152 | /// error[E0001]: unexpected type in `+` application |
| 153 | /// ``` |
| 154 | pub fn render_headerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_header().( |
| 155 | &mut self, |
| 156 | locus: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#>, |
| 157 | severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 158 | code: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>, |
| 159 | message: &str, |
| 160 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 161 | // Write locus |
| 162 | // |
| 163 | // ```text |
| 164 | // test:2:9: |
| 165 | // ``` |
| 166 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(locus) = locus { |
| 167 | self.snippet_locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]snippet_locus().(locus)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 168 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, ": ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 169 | } |
| 170 | |
| 171 | // Write severity name |
| 172 | // |
| 173 | // ```text |
| 174 | // error |
| 175 | // ``` |
| 176 | #[cfg(feature = "termcolor")] |
| 177 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().headerrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]header().(severity))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 178 | match severity { |
| 179 | Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Bugrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Bug# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "bug")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 180 | Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Errorrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Error# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "error")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 181 | Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Warningrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Warning# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "warning")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 182 | Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Helprust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Help# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "help")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 183 | Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#::Noterust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#Note# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "note")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 184 | } |
| 185 | |
| 186 | // Write error code |
| 187 | // |
| 188 | // ```text |
| 189 | // [E0001] |
| 190 | // ``` |
| 191 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(code) = &code.filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|code| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().code.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()) { |
| 192 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "[{}]", code)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 193 | } |
| 194 | |
| 195 | // Write diagnostic message |
| 196 | // |
| 197 | // ```text |
| 198 | // : unexpected type in `+` application |
| 199 | // ``` |
| 200 | #[cfg(feature = "termcolor")] |
| 201 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().header_messagerust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#header_message.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 202 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, ": {}", message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 203 | #[cfg(feature = "termcolor")] |
| 204 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 205 | |
| 206 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 207 | |
| 208 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 209 | } |
| 210 | |
| 211 | /// Empty line. |
| 212 | pub fn render_emptyrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_empty().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 213 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 214 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 215 | } |
| 216 | |
| 217 | /// Top left border and locus. |
| 218 | /// |
| 219 | /// ```text |
| 220 | /// ┌─ test:2:9 |
| 221 | /// ``` |
| 222 | pub fn render_snippet_startrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_snippet_start().( |
| 223 | &mut self, |
| 224 | outer_padding: usize, |
| 225 | locus: &Locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#, |
| 226 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 227 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 228 | |
| 229 | #[cfg(feature = "termcolor")] |
| 230 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().source_borderrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#source_border.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 231 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().snippet_startrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#snippet_start.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 232 | #[cfg(feature = "termcolor")] |
| 233 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 234 | |
| 235 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 236 | self.snippet_locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]snippet_locus().(locus)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 237 | |
| 238 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 239 | |
| 240 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 241 | } |
| 242 | |
| 243 | /// A line of source code. |
| 244 | /// |
| 245 | /// ```text |
| 246 | /// 10 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly |
| 247 | /// │ ╭─│─────────^ |
| 248 | /// ``` |
| 249 | #[allow(clippy::too_many_arguments)] |
| 250 | pub fn render_snippet_sourcerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_snippet_source().( |
| 251 | &mut self, |
| 252 | outer_padding: usize, |
| 253 | line_number: usize, |
| 254 | source: &str, |
| 255 | severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 256 | single_labels: &[SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'_>], |
| 257 | num_multi_labels: usize, |
| 258 | multi_labels: &[(usize, LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#<'_>)], |
| 259 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 260 | // Trim trailing newlines, linefeeds, and null chars from source, if they exist. |
| 261 | // FIXME: Use the number of trimmed placeholders when rendering single line carets |
| 262 | let source = source.trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().(['\n', '\r', '\0'].as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()); |
| 263 | |
| 264 | // Write source line |
| 265 | // |
| 266 | // ```text |
| 267 | // 10 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly |
| 268 | // ``` |
| 269 | { |
| 270 | // Write outer gutter (with line number) and border |
| 271 | self.outer_gutter_numberrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter_number().(line_number, outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 272 | self.border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 273 | |
| 274 | // Write inner gutter (with multi-line continuations on the left if necessary) |
| 275 | let mut multi_labels_iter = multi_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 276 | for label_column in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_multi_labels { |
| 277 | match multi_labels_iter.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 278 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((label_index, label_style, label)) if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().label_column => { |
| 279 | match label { |
| 280 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(start) |
| 281 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().source.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().source.trim_startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() => |
| 282 | { |
| 283 | self.label_multi_top_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_top_left().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 284 | } |
| 285 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(..) => self.inner_gutter_spacerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_space().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 286 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Left# | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(..) => { |
| 287 | self.label_multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_left().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 288 | } |
| 289 | } |
| 290 | multi_labels_iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 291 | } |
| 292 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, _, _)) | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.inner_gutter_spacerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_space().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // Write source text |
| 297 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 298 | let mut in_primary = false; |
| 299 | for (metrics, ch) in self.char_metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]char_metrics().(source.char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().()) { |
| 300 | let column_range = metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().ch.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().()); |
| 301 | |
| 302 | // Check if we are overlapping a primary label |
| 303 | let is_primary = single_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|(ls, range, _)| { |
| 304 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls rust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[LabelStyle][`PartialEq<Self>`]eq().==rust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[LabelStyle][`PartialEq<Self>`]eq(). rust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[LabelStyle][`PartialEq<Self>`]eq().LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary# && is_overlappingrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/is_overlapping().(range, &column_range) |
| 305 | }) || multi_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|(_, ls, label)| { |
| 306 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls rust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[LabelStyle][`PartialEq<Self>`]eq().==rust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[LabelStyle][`PartialEq<Self>`]eq(). rust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[LabelStyle][`PartialEq<Self>`]eq().LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary# |
| 307 | && match label { |
| 308 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(start) => column_range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start, |
| 309 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Left# => true, |
| 310 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(start, _) => column_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start, |
| 311 | } |
| 312 | }); |
| 313 | |
| 314 | // Set the source color if we are in a primary label |
| 315 | if is_primary && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_primary { |
| 316 | #[cfg(feature = "termcolor")] |
| 317 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary#))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 318 | in_primary = true; |
| 319 | } else if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_primary && in_primary { |
| 320 | #[cfg(feature = "termcolor")] |
| 321 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 322 | in_primary = false; |
| 323 | } |
| 324 | |
| 325 | match ch { |
| 326 | '\t' => (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.).try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|_| writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " "))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 327 | _ => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", ch)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 328 | } |
| 329 | } |
| 330 | if in_primary { |
| 331 | #[cfg(feature = "termcolor")] |
| 332 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 333 | } |
| 334 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 335 | } |
| 336 | |
| 337 | // Write single labels underneath source |
| 338 | // |
| 339 | // ```text |
| 340 | // │ - ---- ^^^ second mutable borrow occurs here |
| 341 | // │ │ │ |
| 342 | // │ │ first mutable borrow occurs here |
| 343 | // │ first borrow later used by call |
| 344 | // │ help: some help here |
| 345 | // ``` |
| 346 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().single_labels.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 347 | // Our plan is as follows: |
| 348 | // |
| 349 | // 1. Do an initial scan to find: |
| 350 | // - The number of non-empty messages. |
| 351 | // - The right-most start and end positions of labels. |
| 352 | // - A candidate for a trailing label (where the label's message |
| 353 | // is printed to the left of the caret). |
| 354 | // 2. Check if the trailing label candidate overlaps another label - |
| 355 | // if so we print it underneath the carets with the other labels. |
| 356 | // 3. Print a line of carets, and (possibly) the trailing message |
| 357 | // to the left. |
| 358 | // 4. Print vertical lines pointing to the carets, and the messages |
| 359 | // for those carets. |
| 360 | // |
| 361 | // We try our best avoid introducing new dynamic allocations, |
| 362 | // instead preferring to iterate over the labels multiple times. It |
| 363 | // is unclear what the performance tradeoffs are however, so further |
| 364 | // investigation may be required. |
| 365 | |
| 366 | // The number of non-empty messages to print. |
| 367 | let mut num_messages = 0; |
| 368 | // The right-most start position, eg: |
| 369 | // |
| 370 | // ```text |
| 371 | // -^^^^---- ^^^^^^^ |
| 372 | // │ |
| 373 | // right-most start position |
| 374 | // ``` |
| 375 | let mut max_label_start = 0; |
| 376 | // The right-most end position, eg: |
| 377 | // |
| 378 | // ```text |
| 379 | // -^^^^---- ^^^^^^^ |
| 380 | // │ |
| 381 | // right-most end position |
| 382 | // ``` |
| 383 | let mut max_label_end = 0; |
| 384 | // A trailing message, eg: |
| 385 | // |
| 386 | // ```text |
| 387 | // ^^^ second mutable borrow occurs here |
| 388 | // ``` |
| 389 | let mut trailing_label = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 390 | |
| 391 | for (label_index, label) in single_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 392 | let (_, range, message) = label; |
| 393 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().message.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 394 | num_messages rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 395 | } |
| 396 | max_label_start = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(max_label_start, range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.); |
| 397 | max_label_end = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(max_label_end, range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.); |
| 398 | // This is a candidate for the trailing label, so let's record it. |
| 399 | if range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().max_label_end { |
| 400 | if message.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 401 | trailing_label = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 402 | } else { |
| 403 | trailing_label = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((label_index, label)); |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((trailing_label_index, (_, trailing_range, _))) = trailing_label { |
| 408 | // Check to see if the trailing label candidate overlaps any of |
| 409 | // the other labels on the current line. |
| 410 | if single_labels |
| 411 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 412 | .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 413 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(label_index, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().trailing_label_index) |
| 414 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|(_, (_, range, _))| is_overlappingrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/is_overlapping().(trailing_range, range)) |
| 415 | { |
| 416 | // If it does, we'll instead want to render it below the |
| 417 | // carets along with the other hanging labels. |
| 418 | trailing_label = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | // Write a line of carets |
| 423 | // |
| 424 | // ```text |
| 425 | // │ ^^^^^^ -------^^^^^^^^^-------^^^^^----- ^^^^ trailing label message |
| 426 | // ``` |
| 427 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 428 | self.border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 429 | self.inner_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter().(severity, num_multi_labels, multi_labels)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 430 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 431 | |
| 432 | let mut previous_label_style = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 433 | let placeholder_metrics = Metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics# { |
| 434 | byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index.: source.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().(), |
| 435 | unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.: 1, |
| 436 | }; |
| 437 | for (metrics, ch) in self |
| 438 | .char_metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]char_metrics().(source.char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().()) |
| 439 | // Add a placeholder source column at the end to allow for |
| 440 | // printing carets at the end of lines, eg: |
| 441 | // |
| 442 | // ```text |
| 443 | // 1 │ Hello world! |
| 444 | // │ ^ |
| 445 | // ``` |
| 446 | .chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().((placeholder_metrics, '\0'))) |
| 447 | { |
| 448 | // Find the current label style at this column |
| 449 | let column_range = metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().ch.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().()); |
| 450 | let current_label_style = single_labels |
| 451 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 452 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(_, range, _)| is_overlappingrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/is_overlapping().(range, &column_range)) |
| 453 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(label_style, _, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style) |
| 454 | .max_by_keyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max_by_key().(label_priority_keyrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/label_priority_key().); |
| 455 | |
| 456 | // Update writer style if necessary |
| 457 | if previous_label_style rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().current_label_style { |
| 458 | match current_label_style { |
| 459 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 460 | #[cfg(feature = "termcolor")] |
| 461 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 462 | } |
| 463 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] |
| 464 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(label_style) => { |
| 465 | #[cfg(feature = "termcolor")] |
| 466 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | let caret_ch = match current_label_style { |
| 472 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().single_primary_caretrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#single_primary_caret.), |
| 473 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Secondary#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().single_secondary_caretrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#single_secondary_caret.), |
| 474 | // Only print padding if we are before the end of the last single line caret |
| 475 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# if metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().max_label_end => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(' '), |
| 476 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 477 | }; |
| 478 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(caret_ch) = caret_ch { |
| 479 | // FIXME: improve rendering of carets between character boundaries |
| 480 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.).try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|_| writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", caret_ch))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 481 | } |
| 482 | |
| 483 | previous_label_style = current_label_style; |
| 484 | } |
| 485 | // Reset style if it was previously set |
| 486 | if previous_label_style.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 487 | #[cfg(feature = "termcolor")] |
| 488 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 489 | } |
| 490 | // Write first trailing label message |
| 491 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] |
| 492 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, (label_style, _, message))) = trailing_label { |
| 493 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 494 | #[cfg(feature = "termcolor")] |
| 495 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 496 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 497 | #[cfg(feature = "termcolor")] |
| 498 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 499 | } |
| 500 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 501 | |
| 502 | // Write hanging labels pointing to carets |
| 503 | // |
| 504 | // ```text |
| 505 | // │ │ │ |
| 506 | // │ │ first mutable borrow occurs here |
| 507 | // │ first borrow later used by call |
| 508 | // │ help: some help here |
| 509 | // ``` |
| 510 | if num_messages rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().trailing_label.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]iter().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() { |
| 511 | // Write first set of vertical lines before hanging labels |
| 512 | // |
| 513 | // ```text |
| 514 | // │ │ │ |
| 515 | // ``` |
| 516 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 517 | self.border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 518 | self.inner_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter().(severity, num_multi_labels, multi_labels)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 519 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 520 | self.caret_pointersrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]caret_pointers().( |
| 521 | severity, |
| 522 | max_label_start, |
| 523 | single_labels, |
| 524 | trailing_label, |
| 525 | source.char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().(), |
| 526 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 527 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 528 | |
| 529 | // Write hanging labels pointing to carets |
| 530 | // |
| 531 | // ```text |
| 532 | // │ │ first mutable borrow occurs here |
| 533 | // │ first borrow later used by call |
| 534 | // │ help: some help here |
| 535 | // ``` |
| 536 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] |
| 537 | for (label_style, range, message) in |
| 538 | hanging_labelsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/hanging_labels().(single_labels, trailing_label).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 539 | { |
| 540 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 541 | self.border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 542 | self.inner_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter().(severity, num_multi_labels, multi_labels)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 543 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 544 | self.caret_pointersrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]caret_pointers().( |
| 545 | severity, |
| 546 | max_label_start, |
| 547 | single_labels, |
| 548 | trailing_label, |
| 549 | source |
| 550 | .char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().() |
| 551 | .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|(byte_index, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().byte_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.), |
| 552 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 553 | #[cfg(feature = "termcolor")] |
| 554 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 555 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 556 | #[cfg(feature = "termcolor")] |
| 557 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 558 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | // Write top or bottom label carets underneath source |
| 564 | // |
| 565 | // ```text |
| 566 | // │ ╰───│──────────────────^ woops |
| 567 | // │ ╭─│─────────^ |
| 568 | // ``` |
| 569 | for (multi_label_index, (_, label_style, label)) in multi_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 570 | let (label_style, range, bottom_message) = match label { |
| 571 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Left# => continue, // no label caret needed |
| 572 | // no label caret needed if this can be started in front of the line |
| 573 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(start) if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().source.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().source.trim_startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() => { |
| 574 | continue |
| 575 | } |
| 576 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(range) => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style, range, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 577 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(range, message) => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style, range, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(message)), |
| 578 | }; |
| 579 | |
| 580 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 581 | self.border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 582 | |
| 583 | // Write inner gutter. |
| 584 | // |
| 585 | // ```text |
| 586 | // │ ╭─│───│ |
| 587 | // ``` |
| 588 | let mut underline = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 589 | let mut multi_labels_iter = multi_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 590 | for label_column in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_multi_labels { |
| 591 | match multi_labels_iter.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 592 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((i, (label_index, ls, label))) if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().label_column => { |
| 593 | match label { |
| 594 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Left# => { |
| 595 | self.label_multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_left().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls, underline.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(s, _)| s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 596 | } |
| 597 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(..) if multi_label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i => { |
| 598 | self.label_multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_left().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls, underline.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(s, _)| s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 599 | } |
| 600 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(..) if multi_label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i => { |
| 601 | self.label_multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_left().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls, underline.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(s, _)| s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 602 | } |
| 603 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(..) if multi_label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i => { |
| 604 | underline = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls, VerticalBoundrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#Top#)); |
| 605 | self.label_multi_top_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_top_left().(severity, label_style)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 606 | } |
| 607 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(..) if multi_label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i => { |
| 608 | underline = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls, VerticalBoundrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#Bottom#)); |
| 609 | self.label_multi_bottom_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_bottom_left().(severity, label_style)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 610 | } |
| 611 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(..) | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(..) => { |
| 612 | self.inner_gutter_columnrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_column().(severity, underline)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 613 | } |
| 614 | } |
| 615 | multi_labels_iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 616 | } |
| 617 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, _)) | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.inner_gutter_columnrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_column().(severity, underline)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | // Finish the top or bottom caret |
| 622 | match bottom_message { |
| 623 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.label_multi_top_caretrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_top_caret().(severity, label_style, source, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().range)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 624 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(message) => { |
| 625 | self.label_multi_bottom_caretrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_bottom_caret().(severity, label_style, source, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().range, message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 631 | } |
| 632 | |
| 633 | /// An empty source line, for providing additional whitespace to source snippets. |
| 634 | /// |
| 635 | /// ```text |
| 636 | /// │ │ │ |
| 637 | /// ``` |
| 638 | pub fn render_snippet_emptyrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_snippet_empty().( |
| 639 | &mut self, |
| 640 | outer_padding: usize, |
| 641 | severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 642 | num_multi_labels: usize, |
| 643 | multi_labels: &[(usize, LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#<'_>)], |
| 644 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 645 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 646 | self.border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 647 | self.inner_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter().(severity, num_multi_labels, multi_labels)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 648 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 649 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 650 | } |
| 651 | |
| 652 | /// A broken source line, for labeling skipped sections of source. |
| 653 | /// |
| 654 | /// ```text |
| 655 | /// · │ │ |
| 656 | /// ``` |
| 657 | pub fn render_snippet_breakrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_snippet_break().( |
| 658 | &mut self, |
| 659 | outer_padding: usize, |
| 660 | severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 661 | num_multi_labels: usize, |
| 662 | multi_labels: &[(usize, LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#<'_>)], |
| 663 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 664 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 665 | self.border_left_breakrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left_break().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 666 | self.inner_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter().(severity, num_multi_labels, multi_labels)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 667 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 668 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 669 | } |
| 670 | |
| 671 | /// Additional notes. |
| 672 | /// |
| 673 | /// ```text |
| 674 | /// = expected type `Int` |
| 675 | /// found type `String` |
| 676 | /// ``` |
| 677 | pub fn render_snippet_noterust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]render_snippet_note().( |
| 678 | &mut self, |
| 679 | outer_padding: usize, |
| 680 | message: &str, |
| 681 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 682 | for (note_line_index, line) in message.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 683 | self.outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 684 | match note_line_index { |
| 685 | 0 => { |
| 686 | #[cfg(feature = "termcolor")] |
| 687 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().note_bulletrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#note_bullet.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 688 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().note_bulletrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#note_bullet.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 689 | #[cfg(feature = "termcolor")] |
| 690 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 691 | } |
| 692 | _ => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 693 | } |
| 694 | // Write line of message |
| 695 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self, " {}", line)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 696 | } |
| 697 | |
| 698 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 699 | } |
| 700 | |
| 701 | /// Adds tab-stop aware unicode-width computations to an iterator over |
| 702 | /// character indices. Assumes that the character indices begin at the start |
| 703 | /// of the line. |
| 704 | fn char_metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]char_metrics().( |
| 705 | &self, |
| 706 | char_indices: impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (usize, char)>, |
| 707 | ) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (Metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#, char)> { |
| 708 | use unicode_widthrust-analyzer cargo unicode-width 0.1.14 crate/::UnicodeWidthCharrust-analyzer cargo unicode-width 0.1.14 UnicodeWidthChar#; |
| 709 | |
| 710 | let tab_width = self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..tab_widthrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#tab_width.; |
| 711 | let mut unicode_column = 0; |
| 712 | |
| 713 | char_indices.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |(byte_index, ch)| { |
| 714 | let metrics = Metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics# { |
| 715 | byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index., |
| 716 | unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.: match (ch, tab_width) { |
| 717 | ('\t', 0) => 0, // Guard divide-by-zero |
| 718 | ('\t', _) => tab_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().(unicode_column rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().tab_width), |
| 719 | (ch, _) => ch.widthrust-analyzer cargo unicode-width 0.1.14 impl#[char][UnicodeWidthChar]width().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0), |
| 720 | }, |
| 721 | }; |
| 722 | unicode_column rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.; |
| 723 | |
| 724 | (metrics, ch) |
| 725 | }) |
| 726 | } |
| 727 | |
| 728 | /// Location focus. |
| 729 | fn snippet_locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]snippet_locus().(&mut self, locus: &Locusrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 730 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 731 | self, |
| 732 | "{name}:{line_number}:{column_number}", |
| 733 | name = locus.namerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#name., |
| 734 | line_number = locus.locationrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#location..line_numberrust-analyzer cargo codespan-reporting 0.12.0 files/Location#line_number., |
| 735 | column_number = locus.locationrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Locus#location..column_numberrust-analyzer cargo codespan-reporting 0.12.0 files/Location#column_number., |
| 736 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 737 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 738 | } |
| 739 | |
| 740 | /// The outer gutter of a source line. |
| 741 | fn outer_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter().(&mut self, outer_padding: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 742 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{space: >width$} ", space = "", width = outer_padding)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 743 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 744 | } |
| 745 | |
| 746 | /// The outer gutter of a source line, with line number. |
| 747 | fn outer_gutter_numberrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]outer_gutter_number().( |
| 748 | &mut self, |
| 749 | line_number: usize, |
| 750 | outer_padding: usize, |
| 751 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 752 | #[cfg(feature = "termcolor")] |
| 753 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().line_numberrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#line_number.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 754 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 755 | self, |
| 756 | "{line_number: >width$}", |
| 757 | line_number = line_number, |
| 758 | width = outer_padding, |
| 759 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 760 | #[cfg(feature = "termcolor")] |
| 761 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 762 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 763 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 764 | } |
| 765 | |
| 766 | /// The left-hand border of a source line. |
| 767 | fn border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 768 | #[cfg(feature = "termcolor")] |
| 769 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().source_borderrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#source_border.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 770 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().source_border_leftrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#source_border_left.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 771 | #[cfg(feature = "termcolor")] |
| 772 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 773 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 774 | } |
| 775 | |
| 776 | /// The broken left-hand border of a source line. |
| 777 | fn border_left_breakrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]border_left_break().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 778 | #[cfg(feature = "termcolor")] |
| 779 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().source_borderrust-analyzer cargo codespan-reporting 0.12.0 term/config/Styles#source_border.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 780 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().source_border_left_breakrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#source_border_left_break.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 781 | #[cfg(feature = "termcolor")] |
| 782 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 783 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 784 | } |
| 785 | |
| 786 | /// Write vertical lines pointing to carets. |
| 787 | fn caret_pointersrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]caret_pointers().( |
| 788 | &mut self, |
| 789 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 790 | max_label_start: usize, |
| 791 | single_labels: &[SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'_>], |
| 792 | trailing_label: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'_>)>, |
| 793 | char_indices: impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (usize, char)>, |
| 794 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 795 | for (metrics, ch) in self.char_metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]char_metrics().(char_indices) { |
| 796 | let column_range = metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().ch.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().()); |
| 797 | let label_style = hanging_labelsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/hanging_labels().(single_labels, trailing_label) |
| 798 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(_, range, _)| column_range.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`]contains().(&range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.)) |
| 799 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(label_style, _, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_style) |
| 800 | .max_by_keyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max_by_key().(label_priority_keyrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/label_priority_key().); |
| 801 | |
| 802 | let mut spaces = match label_style { |
| 803 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width., |
| 804 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] |
| 805 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(label_style) => { |
| 806 | #[cfg(feature = "termcolor")] |
| 807 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 808 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().pointer_leftrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#pointer_left.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 809 | #[cfg(feature = "termcolor")] |
| 810 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 811 | 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width. |
| 812 | } |
| 813 | }; |
| 814 | // Only print padding if we are before the end of the last single line caret |
| 815 | if metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().max_label_start { |
| 816 | spaces.try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|_| writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " "))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 821 | } |
| 822 | |
| 823 | /// The left of a multi-line label. |
| 824 | /// |
| 825 | /// ```text |
| 826 | /// │ |
| 827 | /// ``` |
| 828 | fn label_multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_left().( |
| 829 | &mut self, |
| 830 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 831 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] label_style: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 832 | underline: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#>, |
| 833 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 834 | match underline { |
| 835 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 836 | // Continue an underline horizontally |
| 837 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] |
| 838 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(label_style) => { |
| 839 | #[cfg(feature = "termcolor")] |
| 840 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 841 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().multi_toprust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_top.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 842 | #[cfg(feature = "termcolor")] |
| 843 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 844 | } |
| 845 | } |
| 846 | #[cfg(feature = "termcolor")] |
| 847 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 848 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_left.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 849 | #[cfg(feature = "termcolor")] |
| 850 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 851 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 852 | } |
| 853 | |
| 854 | /// The top-left of a multi-line label. |
| 855 | /// |
| 856 | /// ```text |
| 857 | /// ╭ |
| 858 | /// ``` |
| 859 | fn label_multi_top_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_top_left().( |
| 860 | &mut self, |
| 861 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 862 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] label_style: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 863 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 864 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 865 | #[cfg(feature = "termcolor")] |
| 866 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 867 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().multi_top_leftrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_top_left.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 868 | #[cfg(feature = "termcolor")] |
| 869 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 870 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 871 | } |
| 872 | |
| 873 | /// The bottom left of a multi-line label. |
| 874 | /// |
| 875 | /// ```text |
| 876 | /// ╰ |
| 877 | /// ``` |
| 878 | fn label_multi_bottom_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_bottom_left().( |
| 879 | &mut self, |
| 880 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 881 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] label_style: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 882 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 883 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 884 | #[cfg(feature = "termcolor")] |
| 885 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 886 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().multi_bottom_leftrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_bottom_left.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 887 | #[cfg(feature = "termcolor")] |
| 888 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 889 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 890 | } |
| 891 | |
| 892 | /// Multi-line label top. |
| 893 | /// |
| 894 | /// ```text |
| 895 | /// ─────────────^ |
| 896 | /// ``` |
| 897 | fn label_multi_top_caretrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_top_caret().( |
| 898 | &mut self, |
| 899 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 900 | label_style: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 901 | source: &str, |
| 902 | start: usize, |
| 903 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 904 | #[cfg(feature = "termcolor")] |
| 905 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 906 | |
| 907 | for (metrics, _) in self |
| 908 | .char_metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]char_metrics().(source.char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().()) |
| 909 | .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|(metrics, _)| metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) |
| 910 | { |
| 911 | // FIXME: improve rendering of carets between character boundaries |
| 912 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.) |
| 913 | .try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|_| writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().multi_toprust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_top.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 914 | } |
| 915 | |
| 916 | let caret_start = match label_style { |
| 917 | LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary# => self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars..multi_primary_caret_startrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_primary_caret_start., |
| 918 | LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Secondary# => self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars..multi_secondary_caret_startrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_secondary_caret_start., |
| 919 | }; |
| 920 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", caret_start)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 921 | #[cfg(feature = "termcolor")] |
| 922 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 923 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 924 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 925 | } |
| 926 | |
| 927 | /// Multi-line label bottom, with a message. |
| 928 | /// |
| 929 | /// ```text |
| 930 | /// ─────────────^ expected `Int` but found `String` |
| 931 | /// ``` |
| 932 | fn label_multi_bottom_caretrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_bottom_caret().( |
| 933 | &mut self, |
| 934 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 935 | label_style: LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, |
| 936 | source: &str, |
| 937 | start: usize, |
| 938 | message: &str, |
| 939 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 940 | #[cfg(feature = "termcolor")] |
| 941 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 942 | |
| 943 | for (metrics, _) in self |
| 944 | .char_metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]char_metrics().(source.char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().()) |
| 945 | .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|(metrics, _)| metrics.byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().start) |
| 946 | { |
| 947 | // FIXME: improve rendering of carets between character boundaries |
| 948 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#metrics.unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.) |
| 949 | .try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|_| writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", self.charsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]chars().().multi_bottomrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_bottom.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 950 | } |
| 951 | |
| 952 | let caret_end = match label_style { |
| 953 | LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary# => self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars..multi_primary_caret_startrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_primary_caret_start., |
| 954 | LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Secondary# => self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars..multi_secondary_caret_startrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_secondary_caret_start., |
| 955 | }; |
| 956 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{}", caret_end)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 957 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().message.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 958 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " {}", message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 959 | } |
| 960 | #[cfg(feature = "termcolor")] |
| 961 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 962 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 963 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 964 | } |
| 965 | |
| 966 | /// Writes an empty gutter space, or continues an underline horizontally. |
| 967 | fn inner_gutter_columnrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_column().( |
| 968 | &mut self, |
| 969 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 970 | underline: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Underlinerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Underline#>, |
| 971 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 972 | match underline { |
| 973 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.inner_gutter_spacerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_space().(), |
| 974 | #[cfg_attr(not(feature = "termcolor"), allow(unused))] |
| 975 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((label_style, vertical_bound)) => { |
| 976 | #[cfg(feature = "termcolor")] |
| 977 | self.set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(self.stylesrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]styles().().labelrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Styles]label().(severity, label_style))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 978 | let ch = match vertical_bound { |
| 979 | VerticalBoundrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#Top# => self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars..multi_toprust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_top., |
| 980 | VerticalBoundrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/VerticalBound#Bottom# => self.configrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#config..charsrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#chars..multi_bottomrust-analyzer cargo codespan-reporting 0.12.0 term/config/Chars#multi_bottom., |
| 981 | }; |
| 982 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, "{0}{0}", ch)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 983 | #[cfg(feature = "termcolor")] |
| 984 | self.resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 985 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 986 | } |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | /// Writes an empty gutter space. |
| 991 | fn inner_gutter_spacerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_space().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 992 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self, " ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 993 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 994 | } |
| 995 | |
| 996 | /// Writes an inner gutter, with the left lines if necessary. |
| 997 | fn inner_gutterrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter().( |
| 998 | &mut self, |
| 999 | severity: Severityrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Severity#, |
| 1000 | num_multi_labels: usize, |
| 1001 | multi_labels: &[(usize, LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#, MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#<'_>)], |
| 1002 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> { |
| 1003 | let mut multi_labels_iter = multi_labels.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 1004 | for label_column in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_multi_labels { |
| 1005 | match multi_labels_iter.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 1006 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((label_index, ls, label)) if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().label_column => match label { |
| 1007 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Left# | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Bottomrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Bottom#(..) => { |
| 1008 | self.label_multi_leftrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]label_multi_left().(severity, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ls, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1009 | multi_labels_iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 1010 | } |
| 1011 | MultiLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#::Toprust-analyzer cargo codespan-reporting 0.12.0 term/renderer/MultiLabel#Top#(..) => { |
| 1012 | self.inner_gutter_spacerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_space().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1013 | multi_labels_iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 1014 | } |
| 1015 | }, |
| 1016 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, _, _)) | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.inner_gutter_spacerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'writer, 'config>`]inner_gutter_space().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 1021 | } |
| 1022 | } |
| 1023 | |
| 1024 | #[cfg(not(feature = "std"))] |
| 1025 | impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# for Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#<'_, '_> { |
| 1026 | fn write_str(&mut self, s: &str) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 1027 | selfrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/.writer.write_str(s) |
| 1028 | } |
| 1029 | |
| 1030 | fn write_char(&mut self, c: char) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 1031 | selfrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/.writer.write_char(c) |
| 1032 | } |
| 1033 | |
| 1034 | fn write_fmt(&mut self, args: Arguments<'_>) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 1035 | selfrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/.writer.write_fmt(args) |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | #[cfg(feature = "std")] |
| 1040 | impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# for Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#<'_, '_> { |
| 1041 | fn writerust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][Write]write().(&mut self, buf: &[u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 1042 | self.writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer..writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write().(buf) |
| 1043 | } |
| 1044 | |
| 1045 | fn flushrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][Write]flush().(&mut self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 1046 | self.writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer..flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#flush().() |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | #[cfg(feature = "termcolor")] |
| 1051 | impl WriteColorrust-analyzer cargo termcolor 1.4.1 WriteColor# for Rendererrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#<'_, '_> { |
| 1052 | fn supports_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]supports_color().(&self) -> bool { |
| 1053 | self.writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer..supports_colorrust-analyzer cargo termcolor 1.4.1 impl#[`&'a mut T`][WriteColor]supports_color().() |
| 1054 | } |
| 1055 | |
| 1056 | fn set_colorrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]set_color().(&mut self, spec: &ColorSpecrust-analyzer cargo termcolor 1.4.1 ColorSpec#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 1057 | self.writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer..set_colorrust-analyzer cargo termcolor 1.4.1 WriteColor#set_color().(spec) |
| 1058 | } |
| 1059 | |
| 1060 | fn resetrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]reset().(&mut self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 1061 | self.writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer..resetrust-analyzer cargo termcolor 1.4.1 WriteColor#reset().() |
| 1062 | } |
| 1063 | |
| 1064 | fn is_synchronousrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/impl#[`Renderer<'_, '_>`][WriteColor]is_synchronous().(&self) -> bool { |
| 1065 | self.writerrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Renderer#writer..is_synchronousrust-analyzer cargo termcolor 1.4.1 impl#[`&'a mut T`][WriteColor]is_synchronous().() |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | struct Metricsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics# { |
| 1070 | byte_indexrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#byte_index.: usize, |
| 1071 | unicode_widthrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/Metrics#unicode_width.: usize, |
| 1072 | } |
| 1073 | |
| 1074 | /// Check if two ranges overlap |
| 1075 | fn is_overlappingrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/is_overlapping().(range0: &Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, range1: &Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>) -> bool { |
| 1076 | let start = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(range0.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., range1.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.); |
| 1077 | let end = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(range0.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end., range1.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.); |
| 1078 | start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().end |
| 1079 | } |
| 1080 | |
| 1081 | /// For prioritizing primary labels over secondary labels when rendering carets. |
| 1082 | fn label_priority_keyrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/label_priority_key().(label_style: &LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#) -> u8 { |
| 1083 | match label_style { |
| 1084 | LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Secondaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Secondary# => 0, |
| 1085 | LabelStylerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#::Primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/LabelStyle#Primary# => 1, |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | /// Return an iterator that yields the labels that require hanging messages |
| 1090 | /// rendered underneath them. |
| 1091 | fn hanging_labelsrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/hanging_labels().<'labels, 'diagnostic>( |
| 1092 | single_labels: &'labels [SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'diagnostic>], |
| 1093 | trailing_label: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &'labels SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'diagnostic>)>, |
| 1094 | ) -> impl 'labels + DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &'labels SingleLabelrust-analyzer cargo codespan-reporting 0.12.0 term/renderer/SingleLabel#<'diagnostic>> { |
| 1095 | single_labels |
| 1096 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 1097 | .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 1098 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(_, (_, _, message))| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().message.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()) |
| 1099 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(move |(i, _)| trailing_label.map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(true, |(j, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().j)) |
| 1100 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, label)| label) |
| 1101 | } |