mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 11:35:48 +01:00
Implement basic bool and int formatting for diagnostics (#4411)
Note, this supports plurals, but doesn't apply it anywhere. I'm mainly doing that to demonstrate the approach regarding syntax. See format_providers.h for details.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
#include "toolchain/check/return.h"
|
||||
#include "toolchain/diagnostics/format_providers.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
|
||||
@@ -104,23 +105,19 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
|
||||
cast_type_id,
|
||||
[&] {
|
||||
CARBON_DIAGNOSTIC(IncompleteTypeInVarDecl, Error,
|
||||
"{0} has incomplete type {1}",
|
||||
llvm::StringLiteral, SemIR::TypeId);
|
||||
return context.emitter().Build(
|
||||
type_node, IncompleteTypeInVarDecl,
|
||||
parent_class_decl ? llvm::StringLiteral("field")
|
||||
: llvm::StringLiteral("variable"),
|
||||
cast_type_id);
|
||||
"{0:field|variable} has incomplete type {1}",
|
||||
BoolAsSelect, SemIR::TypeId);
|
||||
return context.emitter().Build(type_node, IncompleteTypeInVarDecl,
|
||||
parent_class_decl.has_value(),
|
||||
cast_type_id);
|
||||
},
|
||||
[&] {
|
||||
CARBON_DIAGNOSTIC(AbstractTypeInVarDecl, Error,
|
||||
"{0} has abstract type {1}", llvm::StringLiteral,
|
||||
SemIR::TypeId);
|
||||
return context.emitter().Build(
|
||||
type_node, AbstractTypeInVarDecl,
|
||||
parent_class_decl ? llvm::StringLiteral("field")
|
||||
: llvm::StringLiteral("variable"),
|
||||
cast_type_id);
|
||||
"{0:field|variable} has abstract type {1}",
|
||||
BoolAsSelect, SemIR::TypeId);
|
||||
return context.emitter().Build(type_node, AbstractTypeInVarDecl,
|
||||
parent_class_decl.has_value(),
|
||||
cast_type_id);
|
||||
});
|
||||
if (parent_class_decl) {
|
||||
CARBON_CHECK(context_node_kind == Parse::NodeKind::VariableIntroducer,
|
||||
|
||||
Reference in New Issue
Block a user