-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Enable coinduction support for Safe Transmute #113175
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
Enable coinduction support for Safe Transmute #113175
Conversation
This patch adds the `#[rustc_coinductive]` annotation to `BikeshedIntrinsicFrom`, so that it's possible to compute transmutability for recursive types.
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
This PR marks the We shouldn't be committing to too much by making this trait coinductive, given that 1. it's not intended to be user implementable and has no user-written implementations, 2. it has no supertraits, and 3. is unstable. @rfcbot fcp merge |
Team member @compiler-errors has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I think it would be good for lcnr to have a look at this since afaik they have a good understanding of coinduction. |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b3ab80c): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 655.7s -> 656.645s (0.14%) |
This patch adds the
#[rustc_coinductive]
annotation toBikeshedIntrinsicFrom
, so that it's possible to compute transmutability for recursive types.Motivation
Safe Transmute currently already supports references (#110662). However, if a type is implemented recursively, it leads to an infinite loop when we try to check if transmutation is safe.
A couple simple examples that one might want to write, that are currently not possible to check transmutability for:
Previously, @jswrenn was considering writing a co-inductive solver from scratch, just for the
rustc_tranmsute
crate. Later on as I started working on Safe Transmute myself, I came across the#[rustc_coinductive]
annotation, which is currently only being used for theSized
trait. Leveraging this trait actually solved the problem entirely, and it saves a lot of duplicate work that would have had to happen inrustc_transmute
.