]> git.lizzy.rs Git - rust.git/commitdiff
replacing sub's that can wrap by saturating_sub's
authorAurélien Deharbe <aurelien.deharbe@ssi.gouv.fr>
Fri, 11 Sep 2020 09:11:11 +0000 (11:11 +0200)
committerAurélien Deharbe <aurelien.deharbe@ssi.gouv.fr>
Fri, 11 Sep 2020 09:11:11 +0000 (11:11 +0200)
compiler/rustc_errors/src/emitter.rs

index 5a654e83aed8e1408178006f34f60dd11b70a0fc..4555168af0ab526bafca9d45a7eb5415c852cf22 100644 (file)
@@ -959,15 +959,15 @@ fn render_source_line(
                         '_',
                         line_offset + pos,
                         width_offset + depth,
-                        code_offset + annotation.start_col - left,
+                        (code_offset + annotation.start_col).saturating_sub(left),
                         style,
                     );
                 }
                 _ if self.teach => {
                     buffer.set_style_range(
                         line_offset,
-                        code_offset + annotation.start_col - left,
-                        code_offset + annotation.end_col - left,
+                        (code_offset + annotation.start_col).saturating_sub(left),
+                        (code_offset + annotation.end_col).saturating_sub(left),
                         style,
                         annotation.is_primary,
                     );