Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage: Don't underflow column number #97368

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

tmandry
Copy link
Member

@tmandry tmandry commented May 24, 2022

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.

r? @wesleywiser @richkadel

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.
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 24, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 24, 2022
@@ -515,7 +515,7 @@ fn make_code_region(
// Extend an empty span by one character so the region will be counted.
let CharPos(char_pos) = start_col;
if span.hi() == body_span.hi() {
start_col = CharPos(char_pos - 1);
start_col = CharPos(char_pos.saturating_sub(1));
Copy link
Member

@wesleywiser wesleywiser May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should fix the rest of this function to use saturating math since it's not much code? Specifically, can we also fix the addition on lines 520, 531 and 533?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmandry - Do you mind doing that, if you agree it's worth it?

Sorry for the bug, but I thought lookup_file_pos() should never return less than 1. Maybe I misunderstood or the implementation changed, but that's not something the compiler would have enforced of course, so this is a good fix. Thanks.

@@ -515,7 +515,7 @@ fn make_code_region(
// Extend an empty span by one character so the region will be counted.
let CharPos(char_pos) = start_col;
if span.hi() == body_span.hi() {
start_col = CharPos(char_pos - 1);
start_col = CharPos(char_pos.saturating_sub(1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmandry - Do you mind doing that, if you agree it's worth it?

Sorry for the bug, but I thought lookup_file_pos() should never return less than 1. Maybe I misunderstood or the implementation changed, but that's not something the compiler would have enforced of course, so this is a good fix. Thanks.

@Dylan-DPC Dylan-DPC added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 25, 2022
@JohnCSimon
Copy link
Member

Ping from triage:
@tmandry what is the status of this PR? It hasn't been updated in a while

@jyn514
Copy link
Member

jyn514 commented Apr 26, 2023

This seems like a strict improvement to me - @wesleywiser @richkadel feel free to open a follow-up issue if you feel strongly about using saturating arithmetic for the addition too.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 26, 2023

📌 Commit 2f02a4e has been approved by jyn514

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 26, 2023
@jyn514
Copy link
Member

jyn514 commented Apr 26, 2023

mmm coverage tests are somewhat likely to fail I'm remembering

@bors rollup=maybe

@bors
Copy link
Contributor

bors commented Apr 26, 2023

⌛ Testing commit 2f02a4e with merge 8763965...

@bors
Copy link
Contributor

bors commented Apr 26, 2023

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing 8763965 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 26, 2023
@bors bors merged commit 8763965 into rust-lang:master Apr 26, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 26, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8763965): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.0% [-3.4%, -0.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-3.4%, -0.6%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-3.0%, -2.7%] 4
All ❌✅ (primary) - - 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants