Add diagnostic support so that we can just pass in TypeId. (#3695)

Note we may also want to do this with NameId, maybe some other things,
but the TypeId use is pretty broad and repetitive -- I thought I'd start
with it first.
This commit is contained in:
Jon Ross-Perkins
2024-02-09 16:25:23 +00:00
committed by GitHub
parent bdff7ccf28
commit 1bf4dc53d9
16 changed files with 168 additions and 104 deletions
+8 -8
View File
@@ -78,10 +78,11 @@ static auto BuildFunctionDecl(Context& context,
return_type_id = context.AsCompleteType(return_type_id, [&] {
CARBON_DIAGNOSTIC(IncompleteTypeInFunctionReturnType, Error,
"Function returns incomplete type `{0}`.", std::string);
return context.emitter().Build(
return_node_and_id->first, IncompleteTypeInFunctionReturnType,
context.sem_ir().StringifyType(return_type_id));
"Function returns incomplete type `{0}`.",
SemIR::TypeId);
return context.emitter().Build(return_node_and_id->first,
IncompleteTypeInFunctionReturnType,
return_type_id);
});
if (!SemIR::GetInitRepr(context.sem_ir(), return_type_id)
@@ -241,10 +242,9 @@ auto HandleFunctionDefinitionStart(Context& context,
CARBON_DIAGNOSTIC(
IncompleteTypeInFunctionParam, Error,
"Parameter has incomplete type `{0}` in function definition.",
std::string);
return context.emitter().Build(
param_id, IncompleteTypeInFunctionParam,
context.sem_ir().StringifyType(param.type_id()));
SemIR::TypeId);
return context.emitter().Build(param_id, IncompleteTypeInFunctionParam,
param.type_id());
});
}