mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
When we check an `impl` decl, find the containing `match_first` block, if any, and store a connection to it in the `SemIR::Impl` structure, along with the impl's position in that `match_first` block so that we can sort/prioritize the `SemIR::Impl`s later. Also, update the `is_final` flag if the `match_first` block is modified as `final`. But ensure we diagnose trying to put a `final impl`, or a redeclaration of one, in a `match_first` block. Also diagnose if an impl is attached to a `match_first` block more than once - either in two different blocks or in the same block at different positions. Putting the `match_first` connection on the `SemIR::Impl` structure means we have to import it, so implement import and add a smoke test for that, which ensures nothing explodes. Drop the `scope_stack` entry for the `match_first` block, as it was not needed. Once we started tracking the `match_first` size on the `Context` class, it became more straightforward to just store the `match_first` decl `InstId` in the same place. The `match_first` block is not supposed to act like a different scope for the purpose of redecls anyhow, so it's a bit simpler this way.