Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check for live drops in constants after drop elaboration #71824
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
Check for live drops in constants after drop elaboration #71824
Changes from all commits
cecfa43
d73674e
a77f046
f5370fa
a43e486
21ddf4d
9e2ee32
2dcf7db
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oli-obk Is this even reachable? I'd think we don't keep
Drop
terminators around after drop elaboration for types that do not need dropping...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed not reachable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this looks like it second-guessing drop elaboration which already determined that this drop is indeed necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is reachable. I'm not sure yet why, but I am guessing the reason is that
needs_drop
is its own analysis, while drop elaboration relies onMaybeInitializedPlaces
andMaybeUninitializedPlaces
to make a decision. We could probably rewrite drop elaboration in terms of theNeedsDrop
qualif, which would (afaict) allowpost_drop_elaboration
to not do any checks except for looking forDrop
terminators.Of course such a change would insta-stabilize the feature gate from this PR without any reasonable way to avoid said stabilization. So I'm tempted to stabilize the feature but leave a FIXME on this function to merge its qualif checks into
elaborate_drops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative would be to ignore qualifs here, and just follow what drop elaboration does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do keep following the qualifs to get an edge in precision over drop elaboration (maybe we have to, for backwards compat), we should add a test case for a program where the qualifs are more precise than drop elaboration is (i.e. a program that would get rejected if we just always called
check_live_drop
), and reference that testcase from the code here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust/src/test/ui/consts/drop_none.rs
Lines 3 to 10 in a985d8e
Is this what you're looking for? We do have to keep this for back-compat, see #57734
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot to post that here: the follow-up to this discussion is at #83351.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you already found an equivalent one.