Fix up the userdocs index

A few docs weren't added to the index, re-run the generation and fix the
test to actually run in order to catch future issues.
This commit is contained in:
Ben Barham
2025-12-06 09:45:30 +10:00
parent 3f0732f0d9
commit b29a0a9b3d
8 changed files with 27 additions and 20 deletions

View File

@@ -56,6 +56,7 @@ GROUP(ExclusivityViolation,none,"exclusivity-violation")
GROUP(ExistentialAny,none,"existential-any") GROUP(ExistentialAny,none,"existential-any")
GROUP(ExistentialMemberAccess,none,"existential-member-access-limitations") GROUP(ExistentialMemberAccess,none,"existential-member-access-limitations")
GROUP(ExistentialType,none,"existential-type") GROUP(ExistentialType,none,"existential-type")
GROUP(ExplicitSendable,DefaultIgnoreWarnings,"explicit-sendable-annotations")
GROUP(ImplementationOnlyDeprecated,none,"implementation-only-deprecated") GROUP(ImplementationOnlyDeprecated,none,"implementation-only-deprecated")
GROUP(IsolatedConformances,none,"isolated-conformances") GROUP(IsolatedConformances,none,"isolated-conformances")
GROUP(MemberImportVisibility,none,"member-import-visibility") GROUP(MemberImportVisibility,none,"member-import-visibility")
@@ -87,7 +88,6 @@ GROUP(TemporaryPointers,none,"temporary-pointers")
GROUP(TrailingClosureMatching,none,"trailing-closure-matching") GROUP(TrailingClosureMatching,none,"trailing-closure-matching")
GROUP(UnknownWarningGroup,none,"unknown-warning-group") GROUP(UnknownWarningGroup,none,"unknown-warning-group")
GROUP(WeakMutability,none,"weak-mutability") GROUP(WeakMutability,none,"weak-mutability")
GROUP(ExplicitSendable,DefaultIgnoreWarnings,"explicit-sendable-annotations")
GROUP_LINK(PerformanceHints,ExistentialType) GROUP_LINK(PerformanceHints,ExistentialType)
GROUP_LINK(PerformanceHints,ReturnTypeImplicitCopy) GROUP_LINK(PerformanceHints,ReturnTypeImplicitCopy)

View File

@@ -31,13 +31,17 @@ Or upgrade all warnings except deprecated declaration to errors:
- <doc:string-interpolation-conformance> - <doc:string-interpolation-conformance>
- <doc:deprecated-declaration> - <doc:deprecated-declaration>
- <doc:implementation-only-deprecated> - <doc:implementation-only-deprecated>
- <doc:dynamic-exclusivity>
- <doc:embedded-restrictions> - <doc:embedded-restrictions>
- <doc:explicit-sendable-annotations>
- <doc:preconcurrency-import> - <doc:preconcurrency-import>
- <doc:foreign-reference-type>
- <doc:clang-declaration-import> - <doc:clang-declaration-import>
- <doc:isolated-conformances> - <doc:isolated-conformances>
- <doc:error-in-future-swift-version> - <doc:error-in-future-swift-version>
- <doc:module-version-missing> - <doc:module-version-missing>
- <doc:result-builder-methods> - <doc:result-builder-methods>
- <doc:semantic-copies>
- <doc:strict-language-features> - <doc:strict-language-features>
- <doc:strict-memory-safety> - <doc:strict-memory-safety>
- <doc:unknown-warning-group> - <doc:unknown-warning-group>
@@ -53,8 +57,11 @@ Or upgrade all warnings except deprecated declaration to errors:
- <doc:string-interpolation-conformance> - <doc:string-interpolation-conformance>
- <doc:deprecated-declaration> - <doc:deprecated-declaration>
- <doc:implementation-only-deprecated> - <doc:implementation-only-deprecated>
- <doc:dynamic-exclusivity>
- <doc:embedded-restrictions> - <doc:embedded-restrictions>
- <doc:explicit-sendable-annotations>
- <doc:preconcurrency-import> - <doc:preconcurrency-import>
- <doc:foreign-reference-type>
- <doc:clang-declaration-import> - <doc:clang-declaration-import>
- <doc:isolated-conformances> - <doc:isolated-conformances>
- <doc:error-in-future-swift-version> - <doc:error-in-future-swift-version>
@@ -69,6 +76,7 @@ Or upgrade all warnings except deprecated declaration to errors:
- <doc:conformance-isolation> - <doc:conformance-isolation>
- <doc:protocol-type-non-conformance> - <doc:protocol-type-non-conformance>
- <doc:result-builder-methods> - <doc:result-builder-methods>
- <doc:semantic-copies>
- <doc:sendable-metatypes> - <doc:sendable-metatypes>
- <doc:sending-closure-risks-data-race> - <doc:sending-closure-risks-data-race>
- <doc:sending-risks-data-race> - <doc:sending-risks-data-race>

View File

@@ -1,3 +1,3 @@
# Dynamic Exclusivity (Experimental Diagnostics) # Dynamic exclusivity (DynamicExclusivity)
TODO explain Experimental

View File

@@ -1,25 +1,22 @@
# Explicit Sendable annotations on public type declarations # Explicit `Sendable` annotations on public type declarations (ExplicitSendable)
If a public type doesn't have an explicit Sendable or non-Sendable annotation it is sometimes hard to discern whether that is intentional or not, especially if a type could be Sendable. Adds a warning for any public types without a `Sendable` annotation.
## Overview ## Overview
The Swift compiler would emit a warning if a public type has none of the following: When enabled, the compiler will emit a warning if a public type has none of the following:
- A conformance to `Sendable` protocol; - A conformance to `Sendable` protocol;
- An unavailable conformance to `Sendable` protocol; - An unavailable conformance to `Sendable` protocol;
- `~Sendable` conformance to suppress the inference. - `~Sendable` conformance to suppress the inference.
Let's consider a simple public type without any Senable annotations: For example, given a simple public type:
``` ```
public struct S { public struct S {
let x: Int let x: Int
} }
``` ```
When compiling with `-Wwarning ExplicitSendable` the following warning is going to be produced by the Swift compiler: As it has no `Sendable` annotations, this diagnostic group will add the following warning:
``` ```
1 | public struct S { 1 | public struct S {
| |- warning: public struct 'S' does not specify whether it is 'Sendable' or not [#ExplicitSendable] | |- warning: public struct 'S' does not specify whether it is 'Sendable' or not [#ExplicitSendable]

View File

@@ -1,3 +1,3 @@
# Semantic Copies (Experimental Diagnostics) # Semantic copies (SemanticCopies)
TODO explain Experimental

View File

@@ -66,7 +66,7 @@ let topicsHeader = "\n\n## Topics\n"
let swiftIncludeDir = "include/swift" let swiftIncludeDir = "include/swift"
let groupsFileName = "\(swiftIncludeDir)/AST/DiagnosticGroups.def" let groupsFileName = "\(swiftIncludeDir)/AST/DiagnosticGroups.def"
let groupRegex = /GROUP\((?<name>[a-zA-Z]+), "(?<file>.+)"\)/ let groupRegex = /GROUP\((?<name>[a-zA-Z]+),[^,]+,"(?<file>.+)"\)/
let featuresFileName = "\(swiftIncludeDir)/Basic/Features.def" let featuresFileName = "\(swiftIncludeDir)/Basic/Features.def"
let featuresRegex = /UPCOMING_FEATURE\((?<name>[a-zA-Z]+), .+\)/ let featuresRegex = /UPCOMING_FEATURE\((?<name>[a-zA-Z]+), .+\)/
@@ -95,17 +95,17 @@ do {
} }
func generateIndex() throws { func generateIndex() throws {
let groupsWithWarnings = try groupNamesWithWarnings()
let docs = try retrieveDocs(groupsWithWarnings).sorted { a, b in
return a.title < b.title
}
let groupsHandle = try createIndex(name: groupsDocFileName, header: groupsHeader) let groupsHandle = try createIndex(name: groupsDocFileName, header: groupsHeader)
defer { try? groupsHandle.close() } defer { try? groupsHandle.close() }
let featuresHandle = try createIndex(name: featuresDocFileName, header: featuresHeader) let featuresHandle = try createIndex(name: featuresDocFileName, header: featuresHeader)
defer { try? featuresHandle.close() } defer { try? featuresHandle.close() }
let groupsWithWarnings = try groupNamesWithWarnings()
let docs = try retrieveDocs(groupsWithWarnings).sorted { a, b in
return a.title < b.title
}
try groupsHandle.write(contentsOf: "\n\n## Groups with warnings\n".data(using: .utf8)!) try groupsHandle.write(contentsOf: "\n\n## Groups with warnings\n".data(using: .utf8)!)
for doc in docs where doc.kind == .groupWithWarnings { for doc in docs where doc.kind == .groupWithWarnings {
let ref = "- <doc:\(doc.name.dropLast(3))>\n" let ref = "- <doc:\(doc.name.dropLast(3))>\n"

View File

@@ -10,6 +10,5 @@
# RUN: %host-build-swift -swift-version 5 -enable-upcoming-feature BareSlashRegexLiterals %swift_src_root/utils/generate-doc-index.swift -o %t/generate-doc-index # RUN: %host-build-swift -swift-version 5 -enable-upcoming-feature BareSlashRegexLiterals %swift_src_root/utils/generate-doc-index.swift -o %t/generate-doc-index
# RUN: %t/generate-doc-index %swift_src_root %t # RUN: %t/generate-doc-index %swift_src_root %t
# RUN: diff -u %swift_src_root/userdocs/diagnostics/diagnostic-descriptions.md %t/diagnostic-descriptions.md
# RUN: diff -u %swift_src_root/userdocs/diagnostics/diagnostic-groups.md %t/diagnostic-groups.md # RUN: diff -u %swift_src_root/userdocs/diagnostics/diagnostic-groups.md %t/diagnostic-groups.md
# RUN: diff -u %swift_src_root/userdocs/diagnostics/upcoming-language-features.md %t/upcoming-language-features.md # RUN: diff -u %swift_src_root/userdocs/diagnostics/upcoming-language-features.md %t/upcoming-language-features.md

View File

@@ -138,6 +138,9 @@ config.swift_stdlib_enable_objc_interop = "@SWIFT_STDLIB_ENABLE_OBJC_INTEROP@" =
# Configured in DarwinSDKs.cmake # Configured in DarwinSDKs.cmake
config.freestanding_sdk_name = "@SWIFT_SDK_FREESTANDING_LIB_SUBDIR@" config.freestanding_sdk_name = "@SWIFT_SDK_FREESTANDING_LIB_SUBDIR@"
if '@SWIFT_BUILD_SWIFT_SYNTAX@' == 'TRUE':
config.available_features.add('swift_swift_parser')
config.swift_sdks = "@SWIFT_SDKS@".split(";") config.swift_sdks = "@SWIFT_SDKS@".split(";")
# Let the main config do the real work. # Let the main config do the real work.