Skip to content

Commit a5715f4

Browse files
committed
Change diagnostic message to point at docs.
1 parent 0660218 commit a5715f4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

toolchain/diagnostics/diagnostic.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ struct DiagnosticBase {
119119
: Kind(kind), Level(level), Format(format) {
120120
static_assert((... && !(std::is_same_v<Args, llvm::StringRef> ||
121121
std::is_same_v<Args, llvm::StringLiteral>)),
122-
"For diagnostics, use a format provider (see "
123-
"toolchain/diagnostics/format_providers.h) or std::string to "
124-
"avoid lifetime issues.");
122+
"String type disallowed in diagnostics. See "
123+
"https://github.com/carbon-language/carbon-lang/blob/trunk/"
124+
"toolchain/docs/diagnostics.md#diagnostic-parameter-types");
125125
}
126126

127127
// The diagnostic's kind.

toolchain/docs/diagnostics.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@ methods for formatting arguments:
167167
- This includes `char` and integer types (`int`, `int32_t`, and so on).
168168
- String types can be added as needed, but stringifying values using the
169169
methods noted below is preferred.
170-
- Use `llvm::StringLiteral` where appropriate; use `std::string` when
171-
allocations are required.
170+
- Use `std::string` when allocations are required.
172171
- `llvm::StringRef` is disallowed due to lifetime issues.
172+
- `llvm::StringLiteral` is disallowed because format providers such as
173+
`BoolAsSelect` should work in cases where a `StringLiteral` could be
174+
used.
173175
- `llvm::format_provider<...>` specializations.
174176
- `BoolAsSelect` and `IntAsSelect` from
175177
[format_providers.h](/toolchain/diagnostics/format_providers.h) are

0 commit comments

Comments
 (0)