-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for dyn upcasting coercion #65991
Comments
Refactor vtable codegen This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends. This is preparation for the implementation of trait upcasting feature. cc rust-lang#65991 Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3. cc `@RalfJung` `@bjorn3`
Refactor vtable codegen This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends. This is preparation for the implementation of trait upcasting feature. cc rust-lang#65991 Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3. cc `@RalfJung` `@bjorn3`
This is currently blocked on resolving the safety conditions for upcasting. The following updated document describes my current thinking, looking for feedback: |
I was playing around with this and discovered that the feature gate (and its incomplete_features warning) can be bypassed using This will upcast a fn upcast<Dyn: ?Sized + Unsize<dyn Foo>>(bar: &Dyn) -> &dyn Foo { bar } Would this mean the |
Came to comment the same observation that @dimpolo has made: I think the impl of |
That makes sense, although really I just want to stabilize this. |
cc #89460, which is tracking a future-compat lint that seems related to this feature. |
Unfortunately, trait upcasting is still [incomplete/unstable](rust-lang/rust#65991). Forcing every implementation of `CompiledTrace` to implement `as_any` is a manual way of allow upcasting. Counter-intuitively, we use the upcast to `Any` to allow us to downcast to a concrete implementation of `CompiledTrace`. `depot.rs` can now call `downcast::<LLVMCompiledTrace>` to get at the `LLVMCompiledTrace`. This will then allow us to push methods out of `CompiledTrace` and into `LLVMCompiledTrace`.
Unfortunately, trait upcasting is still [incomplete/unstable](rust-lang/rust#65991). Forcing every implementation of `CompiledTrace` to implement `as_any` is a manual way of allow upcasting. Counter-intuitively, we use the upcast to `Any` to allow us to downcast to a concrete implementation of `CompiledTrace`. `depot.rs` can now call `downcast::<LLVMCompiledTrace>` to get at the `LLVMCompiledTrace`. This will then allow us to push methods out of `CompiledTrace` and into `LLVMCompiledTrace`.
Can we have a status update with regards to the reverted stabilization? The current status update says "We are in the process of stabilizing" since January, with no mention of the recent soundness issues. |
The stabilization is currently blocked on the fix of the unsoundness bug tracked in #120222. The fix is in #120248, but needs a bit more work. I've been occupied by the never type stuff which is urgent because some of the changes are edition based. I hope I'll have time soon to finish #120248. This is also blocked on rust reference PR, which someone needs to take over: rust-lang/reference#1259 (comment). |
When using Box<dyn ProviderConfig>, you would have to upcast the dyn ProviderConfig to dyn Any. This feature is currently experimental (rust-lang/rust#65991). As ProviderConfig is always going to be turned into an Any, it has no real purpose anyways. BREAKING
* feat: added internal work to fork * fix: added missing changes * feat: implemented config * fix: added lib cratetype * fix: AndroidConfig has to be public * fix: missing match in instance * fix: don't load java vm in initialize_module, as it will be called before the config was passed * feat: added default logging implementation for android * feat: implemented symmetric algorithm for encryption, *not tested * fix: change traits to use Box<dyn Any> When using Box<dyn ProviderConfig>, you would have to upcast the dyn ProviderConfig to dyn Any. This feature is currently experimental (rust-lang/rust#65991). As ProviderConfig is always going to be turned into an Any, it has no real purpose anyways. BREAKING * test(mod.rs): adding the tests again * feat: Add set_key_size and set_algorithm_parameter_spec methods to Builder * fix: Update set_algorithm_parameter_spec method in Builder * feat: docs for set_block_modes, set_key_size and set_algorithm_parameter_spec * fix: builder methods using wrong parameters * feat: wrapped KeyGenerator for symmetric encryption * feat: added symetrical encryption for android * fix: added more paddings * fix: readded common tests * fix: readded other tests * fix: mod.rs * fix: wrang hash names for signature --------- Co-authored-by: markoisus <[email protected]> Co-authored-by: Dexter <[email protected]> Co-authored-by: Baibars <[email protected]>
It looks like the blocking bug #120222 have been fixed out, and what's next for this stabilization? |
@Kish29 the next steps are changing the reference (cc rust-lang/reference#1259) and doing a new stabilization PR :) |
This comment was marked as off-topic.
This comment was marked as off-topic.
unstable-book: `trait_upcasting` example should not have `#![allow(incomplete_features)]` Tracking issue: rust-lang#65991 `trait_upcasting` is not currently an incomplete feature; therefore examples of its use do not require `#![allow(incomplete_features)]`.
unstable-book: `trait_upcasting` example should not have `#![allow(incomplete_features)]` Tracking issue: rust-lang#65991 `trait_upcasting` is not currently an incomplete feature; therefore examples of its use do not require `#![allow(incomplete_features)]`.
Rollup merge of rust-lang#130370 - kpreid:patch-2, r=compiler-errors unstable-book: `trait_upcasting` example should not have `#![allow(incomplete_features)]` Tracking issue: rust-lang#65991 `trait_upcasting` is not currently an incomplete feature; therefore examples of its use do not require `#![allow(incomplete_features)]`.
…pkin Never emit `vptr` for empty/auto traits Emiting `vptr`s for empty/auto traits is unnecessary (rust-lang#114942) and causes unsoundness in `trait_upcasting` (rust-lang#131813). This PR should ensure that we never emit vtables for such traits. See the linked issues for more details. I'm not sure if I can add tests for the vtable layout. So this PR only adds tests for the soundness hole (i.e., the segmentation fault will disappear after this PR). Fixes rust-lang#114942 Fixes rust-lang#131813 Cc rust-lang#65991 (tracking issue for `trait_upcasting`) r? `@WaffleLapkin` (per rust-lang#131813 (comment))
Rollup merge of rust-lang#131864 - lrh2000:upcast_reorder, r=WaffleLapkin Never emit `vptr` for empty/auto traits Emiting `vptr`s for empty/auto traits is unnecessary (rust-lang#114942) and causes unsoundness in `trait_upcasting` (rust-lang#131813). This PR should ensure that we never emit vtables for such traits. See the linked issues for more details. I'm not sure if I can add tests for the vtable layout. So this PR only adds tests for the soundness hole (i.e., the segmentation fault will disappear after this PR). Fixes rust-lang#114942 Fixes rust-lang#131813 Cc rust-lang#65991 (tracking issue for `trait_upcasting`) r? `@WaffleLapkin` (per rust-lang#131813 (comment))
This is a tracking issue for RFC3324. Corresponding MCP is here.
The feature gate for the issue is
#![feature(trait_upcasting)]
.STATUS UPDATE
We are in the process of stabilizing.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Stablize, Stabilize RFC3324 dyn upcasting coercion #118133trait_upcasting
feature #101718Previous discussions
dyn Trait
values rfcs#3324Unresolved Questions
CurrentlyCoerceUnsized
trait cannot express this case: a smart pointers that wrap a raw pointer and don't guarantee via a custom invariant that it is valid. Maybe a separateCoerceUnsizedUnsafe
trait is needed. (see Trait upcasting coercion (part4) #88010 (comment)).Before stabilizing it we should check that libs-api is ok with upcasting for all dyn-allowed traits in the library, since those we can't change.(addressed by Tracking issue for dyn upcasting coercion #65991 (comment))Implementation history
Unsafety checking for raw dyn pointers: Trait upcasting coercion (part4) #88010 (not prefered approach, likely will need to do nothing here, but need a design meeting discussion with lang-team)Solution: https://rust-lang.zulipchat.com/#narrow/stream/326132-t-types.2Fmeetings/topic/meeting.202022-09-02.20planning/near/296826711, Commit to safety rules for dyn trait upcasting #101336deref_into_dyn_supertrait
#89460Add trait_upcasting related languages changes reference#1259trait_upcasting
feature #101718The text was updated successfully, but these errors were encountered: