rust/tests
Matthias Krüger e0d71f500c
Rollup merge of #97373 - dimpolo:cell_dispatch_from_dyn, r=dtolnay
impl DispatchFromDyn for Cell and UnsafeCell

After some fruitful discussion on [Internals](https://internals.rust-lang.org/t/impl-dispatchfromdyn-for-cell-2/16520) here's my first PR to rust-lang/rust 🎉

Please let me know if there's something I missed.

This adds `DispatchFromDyn` impls for `Cell`, `UnsafeCell` and `SyncUnsafeCell`.
An existing test is also expanded to test the `Cell` impl (which requires the `UnsafeCell` impl)

The different `RefCell` types can not implement `DispatchFromDyn` since they have more than one (non ZST) field.

 

**Edit:**
### What:
These changes allow one to make types like `MyRc`(code below), to be object safe method receivers after implementing `DispatchFromDyn` and `Deref` for them.

This allows for code like this:
```rust
struct MyRc<T: ?Sized>(Cell<NonNull<RcBox<T>>>);

/* impls for DispatchFromDyn, CoerceUnsized and Deref for MyRc*/

trait Trait {
    fn foo(self: MyRc<Self>);
}

let impls_trait = ...;
let rc = MyRc::new(impls_trait) as MyRc<dyn Trait>;
rc.foo();
```

Note: `Cell` and `UnsafeCell` won't directly become valid method receivers since they don't implement `Deref`. Making use of these changes requires a wrapper type and nightly features.

### Why:
A custom pointer type with interior mutability allows one to store extra information in the pointer itself.
These changes allow for such a type to be a method receiver.

### Examples:
My use case is a cycle aware custom `Rc` implementation that when dropping a cycle marks some references dangling.

On the [forum](https://internals.rust-lang.org/t/impl-dispatchfromdyn-for-cell/14762/8) andersk mentioned that they track if a `Gc` reference is rooted with an extra bit in the reference itself.
2023-01-26 07:53:21 +01:00
..
assembly bump failing assembly & codegen tests from LLVM 14 to LLVM 15 2023-01-17 20:02:01 +01:00
auxiliary
codegen Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm 2023-01-19 08:04:26 +00:00
codegen-units
debuginfo
incremental
mir-opt Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillot 2023-01-26 03:10:52 +00:00
pretty
run-make
run-make-fulldeps Fix run-make-fulldeps test 2023-01-16 14:46:44 +00:00
run-pass-valgrind
rustdoc rustdoc: rearrange HTML in primitive reference links 2023-01-23 17:32:22 -07:00
rustdoc-gui rustdoc: simplify settings popover DOM 2023-01-23 15:08:33 -07:00
rustdoc-js rustdoc: update search test cases 2023-01-14 12:04:12 -07:00
rustdoc-js-std rustdoc: update search test cases 2023-01-14 12:04:12 -07:00
rustdoc-json
rustdoc-ui Revert "Update newly failing UI tests" 2023-01-19 20:27:00 +01:00
ui Rollup merge of #97373 - dimpolo:cell_dispatch_from_dyn, r=dtolnay 2023-01-26 07:53:21 +01:00
ui-fulldeps Rollup merge of #106897 - estebank:issue-99430, r=davidtwco 2023-01-25 22:19:52 +01:00
COMPILER_TESTS.md