Drop for dynamic objects#402
Conversation
db28d0b to
bb160fc
Compare
There was a problem hiding this comment.
Do we want to create an issue for this ? Not sure if this is tracked somewhere..
compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/codegen/typ.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/codegen/place.rs
Outdated
Show resolved
Hide resolved
15388e3 to
671b741
Compare
There was a problem hiding this comment.
Does this typecheck? We want a pointer to an unimplemented function, and instead we're getting an unimplemented function that returns a fn pointer.
There was a problem hiding this comment.
It does type check, we cast to the same type in the if case. I don't think we have any unit tests that hit this, only the standard library regression.
There was a problem hiding this comment.
The issue is that this code is called in a constructor, so it will always fail at CBMC time (which is sound, but not helpful). I think what we want is to make a function whose body is unimplemented, and put a pointer to that function into the vtable.
There was a problem hiding this comment.
Do we still need the hook here? Or could we just move its logic inside the regular codegen?
There was a problem hiding this comment.
Without it, we fail on:
failures:
[expected] expected/replace-hashmap/main.rs
[expected] expected/replace-vec/main.rs
There was a problem hiding this comment.
Can we assert this above? Would that be a better check than matching on loc_ty.kind()
There was a problem hiding this comment.
The conditional doesn't work as a check, because asserting the inverse in the dynamic case fails whenever the instance def is InstanceDef::DropGlue instead of ::Virtual. This structure also matches how the Cranelift backend handles this case.
There was a problem hiding this comment.
This would be in the case of dropping a slice?
There was a problem hiding this comment.
We've also seen it be a fat pointer to a nested dynamic object.
There was a problem hiding this comment.
use the expect_fail macro
Description of changes:
RMC does not current codegen calls to drop for dynamic objects. This PR does that, inserting vtable calls as necessary.
Resolved issues:
Resolves #66
Should also resolve #435
Call-outs:
SizeAndAlignOfDsttests. This patch has a workaround to insert acodegen_unimplementedcall in the case that drop fails to typecheck, which maintains soundness (the current implementation is not sound because it does not call drop at all).Testing:
Existing plus 7 new regressions.
Not really.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.