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

Avoid spurious "previous iteration of loop" errors #87998

Merged
merged 1 commit into from
Sep 30, 2021

Conversation

nneonneo
Copy link
Contributor

@nneonneo nneonneo commented Aug 13, 2021

Only follow backwards edges during get_moved_indexes if the move path is definitely initialized at loop entry. Otherwise, the error occurred prior to the loop, so we ignore the backwards edges to avoid generating misleading "value moved here, in previous iteration of loop" errors.

This patch also slightly improves the analysis of inits, including NonPanicPathOnly initializations (which are ignored by drop_flag_effects::for_location_inits). This is required for the definite initialization analysis, but may also help find certain skipped reinits in rare cases.

Patch passes all non-ignored src/test/ui testcases.

Fixes #72649.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wesleywiser (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2021
@nneonneo nneonneo changed the title Fix issue #72649: avoid spurious "previous iteration of loop" errors. Avoid spurious "previous iteration of loop" errors Aug 13, 2021
@nneonneo
Copy link
Contributor Author

nneonneo commented Aug 13, 2021

r? @estebank for diagnostics

@rust-log-analyzer

This comment has been minimized.

@inquisitivecrystal inquisitivecrystal added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 24, 2021
@bors
Copy link
Contributor

bors commented Sep 9, 2021

☔ The latest upstream changes (presumably #80522) made this pull request unmergeable. Please resolve the merge conflicts.

@nneonneo
Copy link
Contributor Author

nneonneo commented Sep 9, 2021

@estebank (or @wesleywiser, etc.): Could I get some feedback on this PR?

…" errors.

Only follow backwards edges during get_moved_indexes if the move path is
definitely initialized at loop entry. Otherwise, the error occurred prior to the
loop, so we ignore the backwards edges to avoid generating misleading "value
moved here, in previous iteration of loop" errors.

This patch also slightly improves the analysis of inits, including
NonPanicPathOnly initializations (which are ignored by
drop_flag_effects::for_location_inits). This is required for the definite
initialization analysis, but may also help find certain skipped reinits in rare
cases.

Patch passes all non-ignored src/test/ui testcases.
@nneonneo
Copy link
Contributor Author

@rustbot label: +A-diagnostics +D-papercut

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. labels Sep 13, 2021
@jyn514
Copy link
Member

jyn514 commented Sep 29, 2021

r? @oli-obk

@jyn514 jyn514 assigned oli-obk and unassigned estebank Sep 29, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Sep 29, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Sep 29, 2021

📌 Commit 6ff5b47 has been approved by oli-obk

@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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2021
@bors
Copy link
Contributor

bors commented Sep 29, 2021

⌛ Testing commit 6ff5b47 with merge a96024910d3b9c35b06242b5aa6fb14ffdeaf714...

@bors
Copy link
Contributor

bors commented Sep 29, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 29, 2021
@ehuss
Copy link
Contributor

ehuss commented Sep 29, 2021

@bors retry
Issue with Windows LLDB

@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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2021
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 30, 2021

⌛ Testing commit 6ff5b47 with merge 6dc08b9...

@bors
Copy link
Contributor

bors commented Sep 30, 2021

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 6dc08b9 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 30, 2021
@bors bors merged commit 6dc08b9 into rust-lang:master Sep 30, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 30, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6dc08b9): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. 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.

Wrong error message about uninitialized variable in loop