Skip to content

[Diagnostics] Add new groups to the 'deprecated' diagnostic group #76454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
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
8 changes: 2 additions & 6 deletions include/swift/AST/DiagnosticGroups.def
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@

GROUP(no_group, "")

GROUP(deprecated, "deprecated.md")
GROUP_LINK(deprecated, availability_deprecated)

GROUP(availability_deprecated, "availability_deprecated.md")

GROUP(unknown_warning_group, "unknown_warning_group.md")
GROUP(DeprecatedDeclaration, "DeprecatedDeclaration.md")
GROUP(UnknownWarningGroup, "UnknownWarningGroup.md")

#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
#include "swift/AST/DefineDiagnosticGroupsMacros.h"
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ERROR(error_missing_arg_value,none,
(StringRef, unsigned))
ERROR(error_unknown_arg,none,
"unknown argument: '%0'", (StringRef))
GROUPED_WARNING(unknown_warning_group, unknown_warning_group, none,
GROUPED_WARNING(unknown_warning_group, UnknownWarningGroup, none,
"unknown warning group: '%0'", (StringRef))
ERROR(error_invalid_arg_value,none,
"invalid value '%1' in '%0'", (StringRef, StringRef))
Expand Down
44 changes: 25 additions & 19 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -3134,10 +3134,11 @@ ERROR(witness_unavailable,none,
"unavailable %kind0 was used to satisfy a requirement of protocol %1%select{|: %2}2",
(const ValueDecl *, const ProtocolDecl *, StringRef))

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

WARNING(unavailable_conformance,none,
"conformance of %0 to protocol %1 is already unavailable",
Expand Down Expand Up @@ -6652,14 +6653,14 @@ NOTE(availability_obsoleted, none,
"%0 was obsoleted in %1 %2",
(const ValueDecl *, StringRef, llvm::VersionTuple))

GROUPED_WARNING(availability_deprecated, availability_deprecated, Deprecation,
GROUPED_WARNING(availability_deprecated, DeprecatedDeclaration, Deprecation,
"%0 %select{is|%select{is|was}3}1 "
"deprecated%select{| in %2%select{| %4}3}1%select{|: %5}5",
(const ValueDecl *, bool, StringRef, bool, llvm::VersionTuple,
StringRef))

GROUPED_WARNING(
availability_deprecated_rename, availability_deprecated, Deprecation,
availability_deprecated_rename, DeprecatedDeclaration, Deprecation,
"%0 %select{is|%select{is|was}3}1 "
"deprecated%select{| in %2%select{| %4}3}1: "
"%select{renamed to|replaced by}5%" REPLACEMENT_DECL_KIND_SELECT "6 "
Expand Down Expand Up @@ -6837,11 +6838,12 @@ NOTE(conformance_availability_obsoleted, none,
"conformance of %0 to %1 was obsoleted in %2 %3",
(Type, Type, StringRef, llvm::VersionTuple))

WARNING(conformance_availability_deprecated, Deprecation,
"conformance of %0 to %1 %select{is|%select{is|was}4}2 "
"deprecated%select{| in %3%select{| %5}4}2%select{|: %6}6",
(Type, Type, bool, StringRef, bool, llvm::VersionTuple,
StringRef))
GROUPED_WARNING(conformance_availability_deprecated,
DeprecatedDeclaration, Deprecation,
"conformance of %0 to %1 %select{is|%select{is|was}4}2 "
"deprecated%select{| in %3%select{| %5}4}2%select{|: %6}6",
(Type, Type, bool, StringRef, bool, llvm::VersionTuple,
StringRef))

ERROR(conformance_availability_only_version_newer, none,
"conformance of %0 to %1 is only available in %2 %3 or newer",
Expand Down Expand Up @@ -7107,15 +7109,19 @@ ERROR(override_nsobject_hash_error,none,
"'NSObject.hash(into:)' is not overridable; "
"did you mean to override 'NSObject.hash'?", ())

WARNING(hashvalue_implementation,Deprecation,
"'Hashable.hashValue' is deprecated as a protocol requirement; "
"conform type %0 to 'Hashable' by implementing 'hash(into:)' instead",
(Type))
GROUPED_WARNING(
hashvalue_implementation, DeprecatedDeclaration, Deprecation,
"'Hashable.hashValue' is deprecated as a protocol requirement; "
"conform type %0 to 'Hashable' by implementing 'hash(into:)' instead",
(Type))

WARNING(executor_enqueue_deprecated_owned_job_implementation,Deprecation,
"'Executor.enqueue(Job)' is deprecated as a protocol requirement; "
"conform type %0 to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead",
(Type))
GROUPED_WARNING(
executor_enqueue_deprecated_owned_job_implementation,
DeprecatedDeclaration, Deprecation,
"'Executor.enqueue(Job)' is deprecated as a protocol requirement; "
"conform type %0 to 'Executor' by implementing 'func enqueue(ExecutorJob)' "
"instead",
(Type))
WARNING(executor_enqueue_unused_implementation, none,
"'Executor.enqueue(ExecutorJob)' will never be used, due to the presence of "
"'enqueue(UnownedJob)'",
Expand Down
16 changes: 13 additions & 3 deletions lib/AST/DiagnosticGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ constexpr bool isGroupInSupergroup() {
return true;
return false;
}
// Check for isGroupInSupergroup itself
static_assert(!isGroupInSupergroup<DiagGroupID::no_group,
DiagGroupID::DeprecatedDeclaration>() &&
"Bug in isGroupInSupergroup");

static_assert(!hasCycle(), "Diagnostic groups graph has a cycle!");
// Sanity check for the "no_group" group
Expand All @@ -216,9 +220,15 @@ static_assert(std::get<0>(diagnosticGroupConnections).supergroups.size() == 0,
"no_group isn't a top-level group");
static_assert(std::get<0>(diagnosticGroupConnections).subgroups.size() == 0,
"no_group shouldn't have subgroups");
// Check groups have expected supergroups
static_assert(isGroupInSupergroup<DiagGroupID::availability_deprecated,
DiagGroupID::deprecated>());
// Check groups have associated diagnostics
#define CHECK_NOT_EMPTY(Group) \
static_assert( \
std::get<(uint16_t)DiagGroupID::Group>(diagnosticGroupConnections) \
.diagnostics.size() > 0, \
"'" #Group "' group shouldn't be empty.");
CHECK_NOT_EMPTY(DeprecatedDeclaration)
CHECK_NOT_EMPTY(UnknownWarningGroup)
#undef CHECK_NOT_EMPTY

} // end namespace validation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func testCaseTrivialValue4() {
// expected-note @-8 {{capturing use}}
}

class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead [availability_deprecated]}}
class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead [DeprecatedDeclaration]}}
var next: Klass? = nil
}
func inoutUserKlass(_ k: inout Klass) {}
Expand Down
10 changes: 5 additions & 5 deletions test/Concurrency/custom_executor_enqueue_availability.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
// 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

// REQUIRES: concurrency
// REQUIRES: OS=macosx
Expand Down Expand Up @@ -55,7 +55,7 @@ final class TripleExecutor: SerialExecutor {

// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
// expected-note@+1{{use 'ExecutorJob' instead}}
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}}
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]}}

func enqueue(_ job: consuming ExecutorJob) {}

Expand Down
12 changes: 6 additions & 6 deletions test/Concurrency/custom_executor_enqueue_impls.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify %s
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete %s
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation %s
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify %s
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete %s
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation %s

// REQUIRES: concurrency
// REQUIRES: asserts
Expand Down Expand Up @@ -41,7 +41,7 @@ final class TripleExecutor: SerialExecutor {

// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
// expected-note@+1{{use 'ExecutorJob' instead}}
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}}
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]}}

func enqueue(_ job: consuming ExecutorJob) {}

Expand All @@ -65,7 +65,7 @@ final class NoneExecutor: SerialExecutor { // expected-error{{type 'NoneExecutor
final class StillDeprecated: SerialExecutor {
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
// expected-note@+1{{use 'ExecutorJob' instead}}
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}}
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]}}

func asUnownedSerialExecutor() -> UnownedSerialExecutor {
UnownedSerialExecutor(ordinary: self)
Expand Down
36 changes: 18 additions & 18 deletions test/Sema/availability_literals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extension SLD: ExpressibleByStringLiteral {
init(stringLiteral value: StringLiteralType) {}
}

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


struct SLU {}
Expand All @@ -30,8 +30,8 @@ extension ILD: ExpressibleByIntegerLiteral {
init(integerLiteral value: IntegerLiteralType) {}
}

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

struct ILU {}

Expand All @@ -51,8 +51,8 @@ extension NLD: ExpressibleByNilLiteral {
init(nilLiteral: ()) {}
}

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

struct NLU {}

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

struct BLU {}
@available(macOS 100, *)
Expand All @@ -87,8 +87,8 @@ struct FLD {}
extension FLD: ExpressibleByFloatLiteral {
init(floatLiteral value: FloatLiteralType) {}
}
let _: FLD = .init(floatLiteral: 0.1) // expected-warning{{'init(floatLiteral:)' is deprecated [availability_deprecated]}}
let _: FLD = 0.1 // expected-warning{{'init(floatLiteral:)' is deprecated [availability_deprecated]}}
let _: FLD = .init(floatLiteral: 0.1) // expected-warning{{'init(floatLiteral:)' is deprecated [DeprecatedDeclaration]}}
let _: FLD = 0.1 // expected-warning{{'init(floatLiteral:)' is deprecated [DeprecatedDeclaration]}}

struct FLU {}
@available(macOS 100, *)
Expand All @@ -104,8 +104,8 @@ struct ALD {}
extension ALD: ExpressibleByArrayLiteral {
init(arrayLiteral elements: Int...) {}
}
let _: ALD = .init(arrayLiteral: 1) // expected-warning{{'init(arrayLiteral:)' is deprecated [availability_deprecated]}}
let _: ALD = [1] // expected-warning{{'init(arrayLiteral:)' is deprecated [availability_deprecated]}}
let _: ALD = .init(arrayLiteral: 1) // expected-warning{{'init(arrayLiteral:)' is deprecated [DeprecatedDeclaration]}}
let _: ALD = [1] // expected-warning{{'init(arrayLiteral:)' is deprecated [DeprecatedDeclaration]}}

struct ALU {}
@available(macOS 100, *)
Expand All @@ -121,8 +121,8 @@ struct DLD {}
extension DLD: ExpressibleByDictionaryLiteral {
init(dictionaryLiteral elements: (Int, Int)...) {}
}
let _: DLD = .init(dictionaryLiteral: (1,1)) // expected-warning{{'init(dictionaryLiteral:)' is deprecated [availability_deprecated]}}
let _: DLD = [1: 1] // expected-warning{{'init(dictionaryLiteral:)' is deprecated [availability_deprecated]}}
let _: DLD = .init(dictionaryLiteral: (1,1)) // expected-warning{{'init(dictionaryLiteral:)' is deprecated [DeprecatedDeclaration]}}
let _: DLD = [1: 1] // expected-warning{{'init(dictionaryLiteral:)' is deprecated [DeprecatedDeclaration]}}

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

struct USLU {}
@available(macOS 100, *)
Expand All @@ -157,8 +157,8 @@ struct GCLD {}
extension GCLD: ExpressibleByExtendedGraphemeClusterLiteral {
init(extendedGraphemeClusterLiteral value: Character) {}
}
let _: GCLD = .init(extendedGraphemeClusterLiteral: "🇧🇷") // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [availability_deprecated]}}
let _: GCLD = "🇧🇷" // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [availability_deprecated]}}
let _: GCLD = .init(extendedGraphemeClusterLiteral: "🇧🇷") // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [DeprecatedDeclaration]}}
let _: GCLD = "🇧🇷" // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [DeprecatedDeclaration]}}

struct GCLU {}
@available(macOS 100, *)
Expand Down
4 changes: 2 additions & 2 deletions test/Sema/bitwse_copyable_underscore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// RUN: -disable-availability-checking \
// RUN: -print-diagnostic-groups

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

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