-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Consider to refactor json::Encoder::buffer_encode
#14302
Comments
Hy, As result fixing the bug mentioned in context of variance.rs#L744-L748 should not affect this code. For reference here is the codesnipped defining the Encodable trait:
|
I'm 'fixing' this by sticking in some transmutes on my branch, that means we can fix the underlying lifetimes bug (which I have also done) without refactoring as suggested here. Of course the problem still exists, so we still need to refactor. I have left FIXMEs in the code. |
cc me -- I've been working (really, really slowly) on a branch with some related fixes to that area of the type system. |
I mistakenly referenced this issue, sorry. |
Encode and friends have been moved out of tree now. |
internal: Add missing queries to per_query_memory_usage
Here is the implementation of
json::Encoder::buffer_encode
:Note that
to_encode_object
has typeEncodable<Encoder<'a>>
soto_encode_object.encode(...)
requires an Encoder instance with lifetime'a
, which in turn requires a Writer instance of lifetime'a
, but the given onem
is only stack local.rustc
should reject it.The reason why this is legit now is because of a bug in variance.rs#L744-L748, where an extra contravariant constraint should be added in presence of a trait reference. That bug is a soundness issue as well as a backward compatibility hazard, manifested in bugs such as #12470 and #14285.
But the patch for the trait reference variance bug is blocked by otherwise invalid
json::Encoder::buffer_encode
. We need to refactor it first. Nominate.The text was updated successfully, but these errors were encountered: