Skip to content

Avoid spurious "previous iteration of loop" errors#87998

Merged
bors merged 1 commit intorust-lang:masterfrom
nneonneo:master
Sep 30, 2021
Merged

Avoid spurious "previous iteration of loop" errors#87998
bors merged 1 commit intorust-lang:masterfrom
nneonneo:master

Conversation

@nneonneo
Copy link
Copy Markdown
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.

Loading
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