Even more usage of TypeInstId (#5296)

Use TypeInstId in many more places where the instruction is required
to/known to always be a type value. This should be a somewhat exhaustive
set of places, as it covers all instructions given to
GetTypeIdFromTypeInstId().

The things of interest here are:

- Singleton instructions are always of type TypeType, so they are now
TypeInstIds.
- ErrorInst::SingletonInstId gets upcast to be an InstId because it's
sometimes used to define the type of a variable (as in `auto inst_id =
SemIR::ErrorInst::SingletonInstId;` that may hold other InstIds.
- Parse nodes don't really know about TypeInstId, so NodeStack::Push
needs to do some special casing to avoid CHECK failures when given a
TypeInstId but expecting an InstId. We leave a TODO behind here because
the nodes which are being pushed a TypeInstId should probably be taught
to expect that, but such a change is a bit tricky, so too much for this
PR.
This commit is contained in:
Dana Jansens
2025-04-11 21:47:43 +00:00
committed by GitHub
parent 0e8d354567
commit f0663715dd
15 changed files with 67 additions and 37 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ struct TypeParam {
// Constraint that a type is a specific builtin. See ValidateSignature for
// details.
template <const InstId& BuiltinId>
template <const TypeInstId& BuiltinId>
struct BuiltinType {
static auto Check(const File& sem_ir, ValidateState& /*state*/,
TypeId type_id) -> bool {