Skip to content

Commit cd6864a

Browse files
authored
Merge pull request #76454 from DmT021/wp/deprecated-diagnostic-groups
[Diagnostics] Add new groups to the 'deprecated' diagnostic group
2 parents 4b3931c + aa5e10f commit cd6864a

33 files changed

+375
-346
lines changed

β€Žinclude/swift/AST/DiagnosticGroups.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@
2222

2323
GROUP(no_group, "")
2424

25-
GROUP(deprecated, "deprecated.md")
26-
GROUP_LINK(deprecated, availability_deprecated)
27-
28-
GROUP(availability_deprecated, "availability_deprecated.md")
29-
30-
GROUP(unknown_warning_group, "unknown_warning_group.md")
25+
GROUP(DeprecatedDeclaration, "DeprecatedDeclaration.md")
26+
GROUP(UnknownWarningGroup, "UnknownWarningGroup.md")
3127

3228
#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
3329
#include "swift/AST/DefineDiagnosticGroupsMacros.h"

β€Žinclude/swift/AST/DiagnosticsFrontend.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ERROR(error_missing_arg_value,none,
8989
(StringRef, unsigned))
9090
ERROR(error_unknown_arg,none,
9191
"unknown argument: '%0'", (StringRef))
92-
GROUPED_WARNING(unknown_warning_group, unknown_warning_group, none,
92+
GROUPED_WARNING(unknown_warning_group, UnknownWarningGroup, none,
9393
"unknown warning group: '%0'", (StringRef))
9494
ERROR(error_invalid_arg_value,none,
9595
"invalid value '%1' in '%0'", (StringRef, StringRef))

β€Žinclude/swift/AST/DiagnosticsSema.def

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,10 +3153,11 @@ ERROR(witness_unavailable,none,
31533153
"unavailable %kind0 was used to satisfy a requirement of protocol %1%select{|: %2}2",
31543154
(const ValueDecl *, const ProtocolDecl *, StringRef))
31553155

3156-
WARNING(witness_deprecated,none,
3157-
"deprecated default implementation is used to satisfy %kind0 required by "
3158-
"protocol %1%select{|: %2}2",
3159-
(const ValueDecl *, Identifier, StringRef))
3156+
GROUPED_WARNING(
3157+
witness_deprecated, DeprecatedDeclaration, none,
3158+
"deprecated default implementation is used to satisfy %kind0 required by "
3159+
"protocol %1%select{|: %2}2",
3160+
(const ValueDecl *, Identifier, StringRef))
31603161

31613162
WARNING(unavailable_conformance,none,
31623163
"conformance of %0 to protocol %1 is already unavailable",
@@ -6677,14 +6678,14 @@ NOTE(availability_obsoleted, none,
66776678
"%0 was obsoleted in %1 %2",
66786679
(const ValueDecl *, StringRef, llvm::VersionTuple))
66796680

6680-
GROUPED_WARNING(availability_deprecated, availability_deprecated, Deprecation,
6681+
GROUPED_WARNING(availability_deprecated, DeprecatedDeclaration, Deprecation,
66816682
"%0 %select{is|%select{is|was}3}1 "
66826683
"deprecated%select{| in %2%select{| %4}3}1%select{|: %5}5",
66836684
(const ValueDecl *, bool, StringRef, bool, llvm::VersionTuple,
66846685
StringRef))
66856686

66866687
GROUPED_WARNING(
6687-
availability_deprecated_rename, availability_deprecated, Deprecation,
6688+
availability_deprecated_rename, DeprecatedDeclaration, Deprecation,
66886689
"%0 %select{is|%select{is|was}3}1 "
66896690
"deprecated%select{| in %2%select{| %4}3}1: "
66906691
"%select{renamed to|replaced by}5%" REPLACEMENT_DECL_KIND_SELECT "6 "
@@ -6863,11 +6864,12 @@ NOTE(conformance_availability_obsoleted, none,
68636864
"conformance of %0 to %1 was obsoleted in %2 %3",
68646865
(Type, Type, StringRef, llvm::VersionTuple))
68656866

6866-
WARNING(conformance_availability_deprecated, Deprecation,
6867-
"conformance of %0 to %1 %select{is|%select{is|was}4}2 "
6868-
"deprecated%select{| in %3%select{| %5}4}2%select{|: %6}6",
6869-
(Type, Type, bool, StringRef, bool, llvm::VersionTuple,
6870-
StringRef))
6867+
GROUPED_WARNING(conformance_availability_deprecated,
6868+
DeprecatedDeclaration, Deprecation,
6869+
"conformance of %0 to %1 %select{is|%select{is|was}4}2 "
6870+
"deprecated%select{| in %3%select{| %5}4}2%select{|: %6}6",
6871+
(Type, Type, bool, StringRef, bool, llvm::VersionTuple,
6872+
StringRef))
68716873

68726874
ERROR(conformance_availability_only_version_newer, none,
68736875
"conformance of %0 to %1 is only available in %2 %3 or newer",
@@ -7133,15 +7135,19 @@ ERROR(override_nsobject_hash_error,none,
71337135
"'NSObject.hash(into:)' is not overridable; "
71347136
"did you mean to override 'NSObject.hash'?", ())
71357137

7136-
WARNING(hashvalue_implementation,Deprecation,
7137-
"'Hashable.hashValue' is deprecated as a protocol requirement; "
7138-
"conform type %0 to 'Hashable' by implementing 'hash(into:)' instead",
7139-
(Type))
7138+
GROUPED_WARNING(
7139+
hashvalue_implementation, DeprecatedDeclaration, Deprecation,
7140+
"'Hashable.hashValue' is deprecated as a protocol requirement; "
7141+
"conform type %0 to 'Hashable' by implementing 'hash(into:)' instead",
7142+
(Type))
71407143

7141-
WARNING(executor_enqueue_deprecated_owned_job_implementation,Deprecation,
7142-
"'Executor.enqueue(Job)' is deprecated as a protocol requirement; "
7143-
"conform type %0 to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead",
7144-
(Type))
7144+
GROUPED_WARNING(
7145+
executor_enqueue_deprecated_owned_job_implementation,
7146+
DeprecatedDeclaration, Deprecation,
7147+
"'Executor.enqueue(Job)' is deprecated as a protocol requirement; "
7148+
"conform type %0 to 'Executor' by implementing 'func enqueue(ExecutorJob)' "
7149+
"instead",
7150+
(Type))
71457151
WARNING(executor_enqueue_unused_implementation, none,
71467152
"'Executor.enqueue(ExecutorJob)' will never be used, due to the presence of "
71477153
"'enqueue(UnownedJob)'",

β€Žlib/AST/DiagnosticGroups.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ constexpr bool isGroupInSupergroup() {
208208
return true;
209209
return false;
210210
}
211+
// Check for isGroupInSupergroup itself
212+
static_assert(!isGroupInSupergroup<DiagGroupID::no_group,
213+
DiagGroupID::DeprecatedDeclaration>() &&
214+
"Bug in isGroupInSupergroup");
211215

212216
static_assert(!hasCycle(), "Diagnostic groups graph has a cycle!");
213217
// Sanity check for the "no_group" group
@@ -216,9 +220,15 @@ static_assert(std::get<0>(diagnosticGroupConnections).supergroups.size() == 0,
216220
"no_group isn't a top-level group");
217221
static_assert(std::get<0>(diagnosticGroupConnections).subgroups.size() == 0,
218222
"no_group shouldn't have subgroups");
219-
// Check groups have expected supergroups
220-
static_assert(isGroupInSupergroup<DiagGroupID::availability_deprecated,
221-
DiagGroupID::deprecated>());
223+
// Check groups have associated diagnostics
224+
#define CHECK_NOT_EMPTY(Group) \
225+
static_assert( \
226+
std::get<(uint16_t)DiagGroupID::Group>(diagnosticGroupConnections) \
227+
.diagnostics.size() > 0, \
228+
"'" #Group "' group shouldn't be empty.");
229+
CHECK_NOT_EMPTY(DeprecatedDeclaration)
230+
CHECK_NOT_EMPTY(UnknownWarningGroup)
231+
#undef CHECK_NOT_EMPTY
222232

223233
} // end namespace validation
224234

β€Žtest/Concurrency/concurrentfunction_capturediagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func testCaseTrivialValue4() {
9090
// expected-note @-8 {{capturing use}}
9191
}
9292

93-
class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead [availability_deprecated]}}
93+
class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead [DeprecatedDeclaration]}}
9494
var next: Klass? = nil
9595
}
9696
func inoutUserKlass(_ k: inout Klass) {}

β€Žtest/Concurrency/custom_executor_enqueue_availability.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify
2-
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
3-
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
1+
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify
2+
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
3+
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4+
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
55

66
// REQUIRES: concurrency
77
// REQUIRES: OS=macosx
@@ -55,7 +55,7 @@ final class TripleExecutor: SerialExecutor {
5555

5656
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
5757
// expected-note@+1{{use 'ExecutorJob' instead}}
58-
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead}}
58+
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead [DeprecatedDeclaration]}}
5959

6060
func enqueue(_ job: consuming ExecutorJob) {}
6161

β€Žtest/Concurrency/custom_executor_enqueue_impls.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify %s
2-
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
3-
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete %s
4-
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation %s
1+
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify %s
2+
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
3+
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete %s
4+
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation %s
55

66
// REQUIRES: concurrency
77
// REQUIRES: asserts
@@ -41,7 +41,7 @@ final class TripleExecutor: SerialExecutor {
4141

4242
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
4343
// expected-note@+1{{use 'ExecutorJob' instead}}
44-
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead}}
44+
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead [DeprecatedDeclaration]}}
4545

4646
func enqueue(_ job: consuming ExecutorJob) {}
4747

@@ -65,7 +65,7 @@ final class NoneExecutor: SerialExecutor { // expected-error{{type 'NoneExecutor
6565
final class StillDeprecated: SerialExecutor {
6666
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
6767
// expected-note@+1{{use 'ExecutorJob' instead}}
68-
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'StillDeprecated' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead}}
68+
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'StillDeprecated' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead [DeprecatedDeclaration]}}
6969

7070
func asUnownedSerialExecutor() -> UnownedSerialExecutor {
7171
UnownedSerialExecutor(ordinary: self)

β€Žtest/Sema/availability_literals.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ extension SLD: ExpressibleByStringLiteral {
1010
init(stringLiteral value: StringLiteralType) {}
1111
}
1212

13-
let _ = SLD(stringLiteral: "") // expected-warning{{'init(stringLiteral:)' is deprecated [availability_deprecated]}}
14-
let _: SLD = "" // expected-warning{{'init(stringLiteral:)' is deprecated [availability_deprecated]}}
13+
let _ = SLD(stringLiteral: "") // expected-warning{{'init(stringLiteral:)' is deprecated [DeprecatedDeclaration]}}
14+
let _: SLD = "" // expected-warning{{'init(stringLiteral:)' is deprecated [DeprecatedDeclaration]}}
1515

1616

1717
struct SLU {}
@@ -30,8 +30,8 @@ extension ILD: ExpressibleByIntegerLiteral {
3030
init(integerLiteral value: IntegerLiteralType) {}
3131
}
3232

33-
let _ = ILD(integerLiteral: 1) // expected-warning{{'init(integerLiteral:)' is deprecated [availability_deprecated]}}
34-
let _: ILD = 1 // expected-warning{{'init(integerLiteral:)' is deprecated [availability_deprecated]}}
33+
let _ = ILD(integerLiteral: 1) // expected-warning{{'init(integerLiteral:)' is deprecated [DeprecatedDeclaration]}}
34+
let _: ILD = 1 // expected-warning{{'init(integerLiteral:)' is deprecated [DeprecatedDeclaration]}}
3535

3636
struct ILU {}
3737

@@ -51,8 +51,8 @@ extension NLD: ExpressibleByNilLiteral {
5151
init(nilLiteral: ()) {}
5252
}
5353

54-
let _: NLD = .init(nilLiteral: ()) // expected-warning{{'init(nilLiteral:)' is deprecated [availability_deprecated]}}
55-
let _: NLD = nil // expected-warning{{'init(nilLiteral:)' is deprecated [availability_deprecated]}}
54+
let _: NLD = .init(nilLiteral: ()) // expected-warning{{'init(nilLiteral:)' is deprecated [DeprecatedDeclaration]}}
55+
let _: NLD = nil // expected-warning{{'init(nilLiteral:)' is deprecated [DeprecatedDeclaration]}}
5656

5757
struct NLU {}
5858

@@ -70,8 +70,8 @@ struct BLD {}
7070
extension BLD: ExpressibleByBooleanLiteral {
7171
init(booleanLiteral value: BooleanLiteralType) {}
7272
}
73-
let _: BLD = .init(booleanLiteral: false) // expected-warning{{'init(booleanLiteral:)' is deprecated [availability_deprecated]}}
74-
let _: BLD = false // expected-warning{{'init(booleanLiteral:)' is deprecated [availability_deprecated]}}
73+
let _: BLD = .init(booleanLiteral: false) // expected-warning{{'init(booleanLiteral:)' is deprecated [DeprecatedDeclaration]}}
74+
let _: BLD = false // expected-warning{{'init(booleanLiteral:)' is deprecated [DeprecatedDeclaration]}}
7575

7676
struct BLU {}
7777
@available(macOS 100, *)
@@ -87,8 +87,8 @@ struct FLD {}
8787
extension FLD: ExpressibleByFloatLiteral {
8888
init(floatLiteral value: FloatLiteralType) {}
8989
}
90-
let _: FLD = .init(floatLiteral: 0.1) // expected-warning{{'init(floatLiteral:)' is deprecated [availability_deprecated]}}
91-
let _: FLD = 0.1 // expected-warning{{'init(floatLiteral:)' is deprecated [availability_deprecated]}}
90+
let _: FLD = .init(floatLiteral: 0.1) // expected-warning{{'init(floatLiteral:)' is deprecated [DeprecatedDeclaration]}}
91+
let _: FLD = 0.1 // expected-warning{{'init(floatLiteral:)' is deprecated [DeprecatedDeclaration]}}
9292

9393
struct FLU {}
9494
@available(macOS 100, *)
@@ -104,8 +104,8 @@ struct ALD {}
104104
extension ALD: ExpressibleByArrayLiteral {
105105
init(arrayLiteral elements: Int...) {}
106106
}
107-
let _: ALD = .init(arrayLiteral: 1) // expected-warning{{'init(arrayLiteral:)' is deprecated [availability_deprecated]}}
108-
let _: ALD = [1] // expected-warning{{'init(arrayLiteral:)' is deprecated [availability_deprecated]}}
107+
let _: ALD = .init(arrayLiteral: 1) // expected-warning{{'init(arrayLiteral:)' is deprecated [DeprecatedDeclaration]}}
108+
let _: ALD = [1] // expected-warning{{'init(arrayLiteral:)' is deprecated [DeprecatedDeclaration]}}
109109

110110
struct ALU {}
111111
@available(macOS 100, *)
@@ -121,8 +121,8 @@ struct DLD {}
121121
extension DLD: ExpressibleByDictionaryLiteral {
122122
init(dictionaryLiteral elements: (Int, Int)...) {}
123123
}
124-
let _: DLD = .init(dictionaryLiteral: (1,1)) // expected-warning{{'init(dictionaryLiteral:)' is deprecated [availability_deprecated]}}
125-
let _: DLD = [1: 1] // expected-warning{{'init(dictionaryLiteral:)' is deprecated [availability_deprecated]}}
124+
let _: DLD = .init(dictionaryLiteral: (1,1)) // expected-warning{{'init(dictionaryLiteral:)' is deprecated [DeprecatedDeclaration]}}
125+
let _: DLD = [1: 1] // expected-warning{{'init(dictionaryLiteral:)' is deprecated [DeprecatedDeclaration]}}
126126

127127
struct DLU {}
128128
@available(macOS 100, *)
@@ -139,8 +139,8 @@ extension USLD: ExpressibleByUnicodeScalarLiteral {
139139
typealias UnicodeScalarLiteralType = Character
140140
init(unicodeScalarLiteral value: UnicodeScalarLiteralType) {}
141141
}
142-
let _: USLD = .init(unicodeScalarLiteral: "a") // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated [availability_deprecated]}}
143-
let _: USLD = "a" // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated [availability_deprecated]}}
142+
let _: USLD = .init(unicodeScalarLiteral: "a") // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated [DeprecatedDeclaration]}}
143+
let _: USLD = "a" // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated [DeprecatedDeclaration]}}
144144

145145
struct USLU {}
146146
@available(macOS 100, *)
@@ -157,8 +157,8 @@ struct GCLD {}
157157
extension GCLD: ExpressibleByExtendedGraphemeClusterLiteral {
158158
init(extendedGraphemeClusterLiteral value: Character) {}
159159
}
160-
let _: GCLD = .init(extendedGraphemeClusterLiteral: "πŸ‡§πŸ‡·") // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [availability_deprecated]}}
161-
let _: GCLD = "πŸ‡§πŸ‡·" // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [availability_deprecated]}}
160+
let _: GCLD = .init(extendedGraphemeClusterLiteral: "πŸ‡§πŸ‡·") // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [DeprecatedDeclaration]}}
161+
let _: GCLD = "πŸ‡§πŸ‡·" // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [DeprecatedDeclaration]}}
162162

163163
struct GCLU {}
164164
@available(macOS 100, *)

β€Žtest/Sema/bitwse_copyable_underscore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// RUN: -disable-availability-checking \
33
// RUN: -print-diagnostic-groups
44

5-
struct S : _BitwiseCopyable {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable [availability_deprecated]}}
5+
struct S : _BitwiseCopyable {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable [DeprecatedDeclaration]}}
66

7-
func f<T : _BitwiseCopyable>(_ t: T) {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable [availability_deprecated]}}
7+
func f<T : _BitwiseCopyable>(_ t: T) {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable [DeprecatedDeclaration]}}

0 commit comments

Comments
Β (0)