#64470 added an IndirectlyMutableLocals analysis to track whether a local could possibly be mutated through a pointer at a given point in the program. However, this analysis overlooked the fact that a shared reference to a Freeze field of a struct could be converted to a shared reference to a !Freeze field of that same struct by offsetting a pointer.
This does not currently cause any unsoundness in the language, since this analysis is only used in const contexts, where the required operations are forbidden. However, we need to fix this before it becomes possible to take a mutable reference or mutate an UnsafeCell or other !Freeze type in a const context.
#64980 added a test that demonstrates the incorrect behavior.
#64470 added an
IndirectlyMutableLocalsanalysis to track whether a local could possibly be mutated through a pointer at a given point in the program. However, this analysis overlooked the fact that a shared reference to aFreezefield of a struct could be converted to a shared reference to a!Freezefield of that same struct by offsetting a pointer.This does not currently cause any unsoundness in the language, since this analysis is only used in const contexts, where the required operations are forbidden. However, we need to fix this before it becomes possible to take a mutable reference or mutate an
UnsafeCellor other!Freezetype in a const context.#64980 added a test that demonstrates the incorrect behavior.