Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticGroups.def
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GROUP(ExclusivityViolation,none,"exclusivity-violation")
GROUP(ExistentialAny,none,"existential-any")
GROUP(ExistentialMemberAccess,none,"existential-member-access-limitations")
GROUP(ExistentialType,none,"existential-type")
GROUP(ExplicitSendable,DefaultIgnoreWarnings,"explicit-sendable-annotations")
GROUP(ImplementationOnlyDeprecated,none,"implementation-only-deprecated")
GROUP(IsolatedConformances,none,"isolated-conformances")
GROUP(MemberImportVisibility,none,"member-import-visibility")
Expand Down Expand Up @@ -87,7 +88,6 @@ GROUP(TemporaryPointers,none,"temporary-pointers")
GROUP(TrailingClosureMatching,none,"trailing-closure-matching")
GROUP(UnknownWarningGroup,none,"unknown-warning-group")
GROUP(WeakMutability,none,"weak-mutability")
GROUP(ExplicitSendable,DefaultIgnoreWarnings,"explicit-sendable-annotations")

GROUP_LINK(PerformanceHints,ExistentialType)
GROUP_LINK(PerformanceHints,ReturnTypeImplicitCopy)
Expand Down
8 changes: 8 additions & 0 deletions userdocs/diagnostics/diagnostic-groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ Or upgrade all warnings except deprecated declaration to errors:
- <doc:string-interpolation-conformance>
- <doc:deprecated-declaration>
- <doc:implementation-only-deprecated>
- <doc:dynamic-exclusivity>
- <doc:embedded-restrictions>
- <doc:explicit-sendable-annotations>
- <doc:preconcurrency-import>
- <doc:foreign-reference-type>
- <doc:clang-declaration-import>
- <doc:isolated-conformances>
- <doc:error-in-future-swift-version>
- <doc:module-version-missing>
- <doc:result-builder-methods>
- <doc:semantic-copies>
- <doc:strict-language-features>
- <doc:strict-memory-safety>
- <doc:unknown-warning-group>
Expand All @@ -53,8 +57,11 @@ Or upgrade all warnings except deprecated declaration to errors:
- <doc:string-interpolation-conformance>
- <doc:deprecated-declaration>
- <doc:implementation-only-deprecated>
- <doc:dynamic-exclusivity>
- <doc:embedded-restrictions>
- <doc:explicit-sendable-annotations>
- <doc:preconcurrency-import>
- <doc:foreign-reference-type>
- <doc:clang-declaration-import>
- <doc:isolated-conformances>
- <doc:error-in-future-swift-version>
Expand All @@ -69,6 +76,7 @@ Or upgrade all warnings except deprecated declaration to errors:
- <doc:conformance-isolation>
- <doc:protocol-type-non-conformance>
- <doc:result-builder-methods>
- <doc:semantic-copies>
- <doc:sendable-metatypes>
- <doc:sending-closure-risks-data-race>
- <doc:sending-risks-data-race>
Expand Down
4 changes: 2 additions & 2 deletions userdocs/diagnostics/dynamic-exclusivity.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Dynamic Exclusivity (Experimental Diagnostics)
# Dynamic exclusivity (DynamicExclusivity)

TODO explain
Experimental
13 changes: 5 additions & 8 deletions userdocs/diagnostics/explicit-sendable-annotations.md
Original file line number Diff line number Diff line change
@@ -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

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;
- An unavailable conformance to `Sendable` protocol;
- `~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 {
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 {
| |- warning: public struct 'S' does not specify whether it is 'Sendable' or not [#ExplicitSendable]
Expand Down
4 changes: 2 additions & 2 deletions userdocs/diagnostics/semantic-copies.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Semantic Copies (Experimental Diagnostics)
# Semantic copies (SemanticCopies)

TODO explain
Experimental
12 changes: 6 additions & 6 deletions utils/generate-doc-index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let topicsHeader = "\n\n## Topics\n"
let swiftIncludeDir = "include/swift"

let groupsFileName = "\(swiftIncludeDir)/AST/DiagnosticGroups.def"
let groupRegex = /GROUP\((?<name>[a-zA-Z]+), "(?<file>.+)"\)/
let groupRegex = /GROUP\((?<name>[a-zA-Z]+),[^,]+,"(?<file>.+)"\)/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format of each group line was completely changed a while back


let featuresFileName = "\(swiftIncludeDir)/Basic/Features.def"
let featuresRegex = /UPCOMING_FEATURE\((?<name>[a-zA-Z]+), .+\)/
Expand Down Expand Up @@ -95,17 +95,17 @@ do {
}

func generateIndex() throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just moving all the computation that generates errors to before we write so that we don't do any partial writes

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)
defer { try? groupsHandle.close() }

let featuresHandle = try createIndex(name: featuresDocFileName, header: featuresHeader)
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)!)
for doc in docs where doc.kind == .groupWithWarnings {
let ref = "- <doc:\(doc.name.dropLast(3))>\n"
Expand Down
1 change: 0 additions & 1 deletion validation-test/docs/userdoc_indices.test
Original file line number Diff line number Diff line change
Expand Up @@ -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: %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/upcoming-language-features.md %t/upcoming-language-features.md
3 changes: 3 additions & 0 deletions validation-test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ config.swift_stdlib_enable_objc_interop = "@SWIFT_STDLIB_ENABLE_OBJC_INTEROP@" =
# Configured in DarwinSDKs.cmake
config.freestanding_sdk_name = "@SWIFT_SDK_FREESTANDING_LIB_SUBDIR@"

if '@SWIFT_BUILD_SWIFT_SYNTAX@' == 'TRUE':
config.available_features.add('swift_swift_parser')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xedin for noticing this!

config.swift_sdks = "@SWIFT_SDKS@".split(";")

# Let the main config do the real work.
Expand Down