From ff98c90910b9a13b6788389d91c85581dc46b785 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 31 Dec 2023 15:58:17 +1100 Subject: [PATCH] coverage: Never decrease the start column to 0 Line/column numbers are 1-based, so if the start column is already 1 at this point, we would decrement it to 0 and confuse `llvm-cov`. --- compiler/rustc_mir_transform/src/coverage/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index 89d0f34b4761..a6e4fd349fef 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -277,7 +277,7 @@ fn make_code_region( if span.hi() == span.lo() { // Extend an empty span by one character so the region will be counted. if span.hi() == body_span.hi() { - start_col = start_col.saturating_sub(1); + start_col = start_col.saturating_sub(1).max(1); } else { end_col = start_col + 1; }