Skip to content

Commit

Permalink
Small cleanup for DiagnosticType (#3697)
Browse files Browse the repository at this point in the history
I was thinking about #3695 a little further after comments; this is a
small cleanup.
  • Loading branch information
jonmeow authored Feb 9, 2024
1 parent 7e7e870 commit 57948c6
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions toolchain/diagnostics/diagnostic_emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,14 @@ concept HasDiagnosticType =
requires { std::type_identity<typename Arg::DiagnosticType>(); };

// The default implementation with no translation.
template <typename Arg, typename X = int>
struct DiagnosticTypeForArg {
using StorageType = Arg;
static constexpr DiagnosticTypeTranslation Translation =
DiagnosticTypeTranslation::None;
};
template <typename Arg, typename /*Unused*/ = void>
struct DiagnosticTypeForArg
: public DiagnosticTypeInfo<Arg, DiagnosticTypeTranslation::None> {};

// Exposes a custom translation for an argument type.
template <typename Arg>
requires HasDiagnosticType<Arg>
struct DiagnosticTypeForArg<Arg> {
using StorageType = Arg::DiagnosticType::StorageType;
static constexpr DiagnosticTypeTranslation Translation =
Arg::DiagnosticType::Translation;
};
struct DiagnosticTypeForArg<Arg> : public Arg::DiagnosticType {};

// Use the DIAGNOSTIC macro to instantiate this.
// This stores static information about a diagnostic category.
Expand Down

0 comments on commit 57948c6

Please sign in to comment.