diff options
| author | bors <bors@rust-lang.org> | 2023-07-11 13:48:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-11 13:48:59 +0000 |
| commit | b3ab80c1190d8be65aa3727e0a1f77cfd2e6a1dd (patch) | |
| tree | 7ad7f7b7db0431d11be4fb5f25bb1cd4288dfa0e /compiler/rustc_codegen_llvm/src/allocator.rs | |
| parent | d8899c577bc11308a0db96e8378373be93330a8f (diff) | |
| parent | 6b214bbc1128aa6bd9ddf732396fda7230dfeb64 (diff) | |
| download | rust-b3ab80c1190d8be65aa3727e0a1f77cfd2e6a1dd.tar.gz rust-b3ab80c1190d8be65aa3727e0a1f77cfd2e6a1dd.zip | |
Auto merge of #113175 - bryangarza:safe-transmute-rustc-coinductive, r=compiler-errors
Enable coinduction support for Safe Transmute
This patch adds the `#[rustc_coinductive]` annotation to `BikeshedIntrinsicFrom`, 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:
```rs
#[repr(C)] struct A(&'static B);
#[repr(C)] struct B(&'static A);
```
```rs
#[repr(C)]
enum IList<'a> { Nil, Cons(isize, &'a IList<'a>) }
#[repr(C)]
enum UList<'a> { Nil, Cons(usize, &'a UList<'a>) }
```
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 the `Sized` trait. Leveraging this trait actually solved the problem entirely, and it saves a lot of duplicate work that would have had to happen in `rustc_transmute`.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/allocator.rs')
0 files changed, 0 insertions, 0 deletions
