mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 06:28:11 +00:00
We set the `declaring_impl_decls` state to modify the evaluation of LookupImplWitness instructions formed inside an `impl as` decl's constraint. However while checking that constraint, we may form other specifics through calls to generic classes, etc. Specifics are canonical and are keyed by their arguments and the generic ID. This means every time we see the same arguments for a specific, we must produce the same instructions. The `declaring_impl_decls` state can break that, causing instructions inside the specific to be formed in a way they wouldn't at another time. To fix this, remove the effect of `declaring_impl_decls` while resolving a specific. This keeps the specific's evaluation consistent so that the key truly represents the canonical specific for its arguments. This doesn't break anything. Existing LookupImplWitnesses (such as in a class decl) are not guaranteed to point to an `impl as` when they are modified by a specific. It is designators in the `impl as` constraint that are guaranteed as such. Designators in an `extend require impls` statement in a named constraint will be pointed to the `impl as` through another mechanism in a followup, which will make the `impl_as_named_constraint.carbon` test pass again.