Repository navigation
Fix drop of Wrapper<dyn T> and fix unsized cast too - #1981
Merged
Merged
Conversation
- TODO: Check if we need to handle slice.
I also joined the code to handle referencing a place.
danielsn
approved these changes
Dec 10, 2022
Comment on lines
+586
to
+592
| let data = if proj_expr.typ().is_pointer() { | ||
| proj_expr | ||
| } else if proj_expr.typ().is_array_like() { | ||
| proj_expr.array_to_ptr() | ||
| } else { | ||
| proj_expr.address_of() | ||
| }; |
Contributor
There was a problem hiding this comment.
Does this happen often enough it could use a utility fn?
Contributor
Author
There was a problem hiding this comment.
I haven't bumped into it in other places yet but I can still move this to a utility function.
Comment on lines
+1059
to
+1065
| let src_pointee_ty = pointee_type(coerce_info.src_ty).unwrap(); | ||
| let dst_data_expr = if src_pointee_ty.is_array() { | ||
| src_goto_expr.cast_to(self.codegen_ty(*src_elt_type).to_pointer()) | ||
| } else { | ||
| // A struct that contains the type being coerced to a slice. | ||
| src_goto_expr.cast_to(dst_data_type) | ||
| }; |
Contributor
There was a problem hiding this comment.
A comment explaining this using C like pseudocode might make it easier to follow
| Stmt::skip(loc) | ||
| } | ||
| InstanceDef::DropGlue(_def_id, Some(_)) => { | ||
| let place_ref = self.codegen_place_ref(place); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of changes:
Fix direct call to drop a fat pointer to a structure with an unsized element. Join similar code that we had to build a reference to a place.
Resolved issues:
Resolves #426
Related RFC:
Call-outs:
While inspecting the code, I realized that we were probably not handling slice correctly. The test I added also uncovered an issue with unsized cast, which I also fixed here.
Testing:
How is this change tested? New test + fixme test
Is this a refactor change? No
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.