about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorAurélien Deharbe <aurelien.deharbe@ssi.gouv.fr>2020-09-11 11:11:11 +0200
committerAurélien Deharbe <aurelien.deharbe@ssi.gouv.fr>2020-09-11 11:11:11 +0200
commit439b7661616ec26092176baf905a0ceeb4a3c620 (patch)
treec599011e63950ef61081545706a9e8d707315c8d /compiler/rustc_errors/src
parent94b4de0e0793c8921d30e0fb886be712d17db6e5 (diff)
downloadrust-439b7661616ec26092176baf905a0ceeb4a3c620.tar.gz
rust-439b7661616ec26092176baf905a0ceeb4a3c620.zip
replacing sub's that can wrap by saturating_sub's
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/emitter.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 5a654e83aed..4555168af0a 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -959,15 +959,15 @@ impl EmitterWriter {
                         '_',
                         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,
                     );