Skip to content

Commit 2f02a4e

Browse files
committed
coverage: Don't underflow column number
I noticed this when running coverage on a debug build of rustc. There may be other places that do this but I'm just fixing the one I hit.
1 parent f4a7ce9 commit 2f02a4e

File tree

1 file changed

+1
-1
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+1
-1
lines changed

compiler/rustc_mir_transform/src/coverage/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ fn make_code_region(
515515
// Extend an empty span by one character so the region will be counted.
516516
let CharPos(char_pos) = start_col;
517517
if span.hi() == body_span.hi() {
518-
start_col = CharPos(char_pos - 1);
518+
start_col = CharPos(char_pos.saturating_sub(1));
519519
} else {
520520
end_col = CharPos(char_pos + 1);
521521
}

0 commit comments

Comments
 (0)