Skip to content

Commit db2fa7b

Browse files
committed
[Diagnostics] Use the educational note name for the category name
1 parent 6f6b8dd commit db2fa7b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/AST/DiagnosticEngine.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,7 @@ DiagnosticEngine::diagnosticInfoForDiagnostic(const Diagnostic &diagnostic,
13371337

13381338
auto groupID = diagnostic.getGroupID();
13391339
StringRef Category;
1340+
const char * const *associatedNotes = nullptr;
13401341
if (isAPIDigesterBreakageDiagnostic(diagnostic.getID()))
13411342
Category = "api-digester-breaking-change";
13421343
else if (isNoUsageDiagnostic(diagnostic.getID()))
@@ -1345,6 +1346,10 @@ DiagnosticEngine::diagnosticInfoForDiagnostic(const Diagnostic &diagnostic,
13451346
Category = getDiagGroupInfoByID(groupID).name;
13461347
else if (isDeprecationDiagnostic(diagnostic.getID()))
13471348
Category = "deprecation";
1349+
else if ((associatedNotes = educationalNotes[(uint32_t)diagnostic.getID()]) &&
1350+
*associatedNotes) {
1351+
Category = llvm::sys::path::stem(*associatedNotes);
1352+
}
13481353

13491354
auto fixIts = diagnostic.getFixIts();
13501355
if (loc.isValid()) {

test/diagnostics/educational_notes_serialization.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
typealias Fn = () -> ()
99
extension Fn {}
10-
// CHECK: [[@LINE-1]]:1: error: non-nominal type 'Fn' (aka '() -> ()') cannot be extended [{{.*}}nominal-types.md] []
10+
// CHECK: [[@LINE-1]]:1: error: non-nominal type 'Fn' (aka '() -> ()') cannot be extended [{{.*}}nominal-types.md] [nominal-types]
1111

1212

1313
// Shares the flag record with `Fn`
1414
typealias Dup = () -> ()
1515
extension Dup {}
16-
// CHECK: [[@LINE-1]]:1: error: non-nominal type 'Dup' (aka '() -> ()') cannot be extended [{{.*}}nominal-types.md] []
16+
// CHECK: [[@LINE-1]]:1: error: non-nominal type 'Dup' (aka '() -> ()') cannot be extended [{{.*}}nominal-types.md] [nominal-types]
1717

1818
do {
1919
func noNote(_: Int) {}

0 commit comments

Comments
 (0)