How to check if a reference uses interior mutibility

Hello, give a reference &T, is it possible to check if T contains interior mutability? It only matters if it contains UnsafeCell directly, not via reference/pointer/other form of Indirection.

For shallow shared mutability, there's this compiler-internal trait, but stabilizing it was declined on the grounds that it makes adding interior mutability to your struct a breaking change.

(For deep shared mutability, there is no solution.)

1 Like

Thanks. I'v decided to just copy the implementation of Freeze.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.