Skip to content

Commit 3c8ef82

Browse files
committed
Enable usable of Span by default
Usage of Span was temporarily behind an experimental feature flag. Now that SE-0447 has been accepted, remove the experimental feature flag and allow Span usage everywhere. Implements rdar://144819992.
1 parent e24598b commit 3c8ef82

25 files changed

+23
-93
lines changed

include/swift/AST/DiagnosticsSema.def

-4
Original file line numberDiff line numberDiff line change
@@ -7980,10 +7980,6 @@ ERROR(noncopyable_cannot_have_read_set_accessor,none,
79807980
"noncopyable %select{variable|subscript}0 cannot provide a read and set accessor",
79817981
(unsigned))
79827982

7983-
ERROR(span_requires_feature_flag,none,
7984-
"'%0' requires -enable-experimental-feature Span",
7985-
(StringRef))
7986-
79877983
//------------------------------------------------------------------------------
79887984
// MARK: Init accessors
79897985
//------------------------------------------------------------------------------

include/swift/Basic/Features.def

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ EXPERIMENTAL_FEATURE(MacrosOnImports, true)
234234
EXPERIMENTAL_FEATURE(TupleConformances, false)
235235
EXPERIMENTAL_FEATURE(FullTypedThrows, false)
236236
EXPERIMENTAL_FEATURE(SameElementRequirements, false)
237-
EXPERIMENTAL_FEATURE(Span, true)
238237

239238
// Whether to enable @_used and @_section attributes
240239
EXPERIMENTAL_FEATURE(SymbolLinkageMarkers, true)

lib/AST/FeatureSet.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ UNINTERESTING_FEATURE(GroupActorErrors)
197197
UNINTERESTING_FEATURE(SameElementRequirements)
198198
UNINTERESTING_FEATURE(UnspecifiedMeansMainActorIsolated)
199199
UNINTERESTING_FEATURE(GenerateForceToMainActorThunks)
200-
UNINTERESTING_FEATURE(Span)
201200

202201
static bool usesFeatureSendingArgsAndResults(Decl *decl) {
203202
auto isFunctionTypeWithSending = [](Type type) {

lib/Sema/TypeCheckType.cpp

-30
Original file line numberDiff line numberDiff line change
@@ -1724,32 +1724,6 @@ static void diagnoseGenericArgumentsOnSelf(const TypeResolution &resolution,
17241724
}
17251725
}
17261726

1727-
/// Diagnose when this is one of the Span types, which currently requires
1728-
/// an experimental feature to use.
1729-
static void diagnoseSpanType(TypeDecl *typeDecl, SourceLoc loc,
1730-
const DeclContext *dc) {
1731-
if (loc.isInvalid())
1732-
return;
1733-
1734-
if (!typeDecl->isStdlibDecl())
1735-
return;
1736-
1737-
ASTContext &ctx = typeDecl->getASTContext();
1738-
if (ctx.LangOpts.hasFeature(Feature::Span))
1739-
return;
1740-
1741-
auto nameString = typeDecl->getName().str();
1742-
if (nameString != "Span" && nameString != "RawSpan")
1743-
return;
1744-
1745-
// Don't require this in the standard library or _Concurrency library.
1746-
auto module = dc->getParentModule();
1747-
if (module->isStdlibModule() || module->getName().str() == "_Concurrency")
1748-
return;
1749-
1750-
ctx.Diags.diagnose(loc, diag::span_requires_feature_flag, nameString);
1751-
}
1752-
17531727
/// Resolve the given identifier type representation as an unqualified type,
17541728
/// returning the type it references.
17551729
/// \param silContext Used to look up generic parameters in SIL mode.
@@ -1886,8 +1860,6 @@ resolveUnqualifiedIdentTypeRepr(const TypeResolution &resolution,
18861860
return ErrorType::get(ctx);
18871861
}
18881862

1889-
diagnoseSpanType(currentDecl, repr->getLoc(), DC);
1890-
18911863
repr->setValue(currentDecl, currentDC);
18921864
return current;
18931865
}
@@ -2108,8 +2080,6 @@ static Type resolveQualifiedIdentTypeRepr(const TypeResolution &resolution,
21082080
member = memberTypes.back().Member;
21092081
inferredAssocType = memberTypes.back().InferredAssociatedType;
21102082
repr->setValue(member, nullptr);
2111-
2112-
diagnoseSpanType(member, repr->getLoc(), DC);
21132083
}
21142084

21152085
return maybeDiagnoseBadMemberType(member, memberType, inferredAssocType);

test/Interop/C/swiftify-import/counted-by-noescape.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_feature_SafeInteropWrappers
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-ide-test -print-module -module-to-print=CountedByNoEscapeClang -plugin-path %swift-plugin-dir -I %S/Inputs -source-filename=x -enable-experimental-feature SafeInteropWrappers -enable-experimental-feature Span | %FileCheck %s
3+
// RUN: %target-swift-ide-test -print-module -module-to-print=CountedByNoEscapeClang -plugin-path %swift-plugin-dir -I %S/Inputs -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s
54

65
// swift-ide-test doesn't currently typecheck the macro expansions, so run the compiler as well
76
// RUN: %empty-directory(%t)

test/Interop/C/swiftify-import/sized-by-noescape.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_feature_SafeInteropWrappers
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-ide-test -print-module -module-to-print=SizedByNoEscapeClang -plugin-path %swift-plugin-dir -I %S/Inputs -source-filename=x -enable-experimental-feature SafeInteropWrappers -enable-experimental-feature Span | %FileCheck %s
3+
// RUN: %target-swift-ide-test -print-module -module-to-print=SizedByNoEscapeClang -plugin-path %swift-plugin-dir -I %S/Inputs -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s
54

65
// swift-ide-test doesn't currently typecheck the macro expansions, so run the compiler as well
76
// RUN: %empty-directory(%t)

test/Interop/Cxx/stdlib/std-span-interface.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %S/Inputs -enable-experimental-feature LifetimeDependence -enable-experimental-feature Span -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=StdSpan -source-filename=x -enable-experimental-cxx-interop -Xcc -std=c++20 -module-cache-path %t > %t/interface.swift
2+
// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %S/Inputs -enable-experimental-feature LifetimeDependence -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=StdSpan -source-filename=x -enable-experimental-cxx-interop -Xcc -std=c++20 -module-cache-path %t > %t/interface.swift
33
// RUN: %FileCheck %s < %t/interface.swift
44

55
// REQUIRES: swift_feature_SafeInteropWrappers
6-
// REQUIRES: swift_feature_Span
76
// REQUIRES: swift_feature_LifetimeDependence
87

98
// FIXME swift-ci linux tests do not support std::span

test/Macros/SwiftifyImport/CountedBy/MutableSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span > %t.log 2>&1
3+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions > %t.log 2>&1
54
// RUN: %FileCheck --match-full-lines %s < %t.log
65

76
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .nonescaping(pointer: .param(1)))

test/Macros/SwiftifyImport/CountedBy/SimpleSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
54

65
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .nonescaping(pointer: .param(1)))
76
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {

test/Macros/SwiftifyImport/CountedBy/SimpleSpanWithReturn.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
54

65
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .nonescaping(pointer: .param(1)))
76
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {

test/Macros/SwiftifyImport/CountedBy/SpanAndUnsafeBuffer.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
54

65
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len1"), .countedBy(pointer: .param(3), count: "len2"), .nonescaping(pointer: .param(1)))
76
func myFunc(_ ptr1: UnsafePointer<CInt>, _ len1: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {

test/Macros/SwiftifyImport/CxxSpan/LifetimeboundSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11

22
// REQUIRES: swift_swift_parser
3-
// REQUIRES: swift_feature_Span
43
// REQUIRES: swift_feature_LifetimeDependence
54

6-
// RUN: %target-swift-frontend %s -enable-experimental-cxx-interop -I %S/Inputs -Xcc -std=c++20 -swift-version 5 -module-name main -disable-availability-checking -typecheck -enable-experimental-feature Span -enable-experimental-feature LifetimeDependence -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
5+
// RUN: %target-swift-frontend %s -enable-experimental-cxx-interop -I %S/Inputs -Xcc -std=c++20 -swift-version 5 -module-name main -disable-availability-checking -typecheck -enable-experimental-feature LifetimeDependence -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
76

87
// FIXME swift-ci linux tests do not support std::span
98
// UNSUPPORTED: OS=linux-gnu

test/Macros/SwiftifyImport/CxxSpan/NoEscapeSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -enable-experimental-feature Span -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
54

65
public struct SpanOfInt {
76
init(_ x: Span<CInt>) {}

test/Macros/SwiftifyImport/MacroErrors/NullableSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify -enable-experimental-feature Span
3+
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
54

65
// XFAIL: *
76
// expanded form errors with "type 'Span' does not conform to protocol 'Escapable'" because Optional doesn't support ~Escapable yet

test/Macros/SwiftifyImport/SizedBy/MutableRawSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span > %t.log 2>&1
3+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions > %t.log 2>&1
54
// RUN: %FileCheck --match-full-lines %s < %t.log
65

76
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .nonescaping(pointer: .param(1)))

test/Macros/SwiftifyImport/SizedBy/Opaque.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span -verify 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -verify 2>&1 | %FileCheck --match-full-lines %s
54

65
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"))
76
func nonnullUnsafeRawBufferPointer(_ ptr: OpaquePointer, _ size: CInt) {

test/Macros/SwiftifyImport/SizedBy/SimpleRawSpan.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
54

65
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .nonescaping(pointer: .param(1)))
76
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {

test/Macros/SwiftifyImport/SizedBy/SimpleRawSpanWithReturn.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: swift_swift_parser
2-
// REQUIRES: swift_feature_Span
32

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
54

65
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .nonescaping(pointer: .param(1)))
76
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {

test/SILOptimizer/lifetime_dependence/diagnostic_passes.sil

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-sil-opt %s \
22
// RUN: -diagnostics -sil-verify-all \
33
// RUN: -enable-experimental-feature LifetimeDependence \
4-
// RUN: -enable-experimental-feature Span \
54
// RUN: | %FileCheck %s
65

76
// Test SIL expected from SILGen output. Run all diagnostic passes which includes lifetime dependence handling:
@@ -13,7 +12,6 @@
1312

1413
// REQUIRES: swift_in_compiler
1514
// REQUIRES: swift_feature_LifetimeDependence
16-
// REQUIRES: swift_feature_Span
1715

1816
sil_stage raw
1917

test/SILOptimizer/lifetime_dependence/stdlib_span.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
// RUN: -sil-verify-all \
55
// RUN: -module-name test \
66
// RUN: -disable-access-control \
7-
// RUN: -enable-experimental-feature LifetimeDependence \
8-
// RUN: -enable-experimental-feature Span
7+
// RUN: -enable-experimental-feature LifetimeDependence
98

109
// REQUIRES: swift_in_compiler
1110
// REQUIRES: swift_feature_LifetimeDependence
12-
// REQUIRES: swift_feature_Span
1311

1412
// Test dependencies on the standard library Span APIs.
1513

test/SILOptimizer/mutable_span_bounds_check_tests.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -emit-module-path %t/SpanExtras.swiftmodule %S/Inputs/SpanExtras.swift -enable-builtin-module -enable-experimental-feature LifetimeDependence -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature Span -O
3-
// RUN: %target-swift-frontend -I %t -O -emit-sil %s -enable-experimental-feature Span -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-SIL
4-
// RUN: %target-swift-frontend -I %t -O -emit-ir %s -enable-experimental-feature Span -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-IR
2+
// RUN: %target-swift-frontend -emit-module-path %t/SpanExtras.swiftmodule %S/Inputs/SpanExtras.swift -enable-builtin-module -enable-experimental-feature LifetimeDependence -enable-experimental-feature AllowUnsafeAttribute -O
3+
// RUN: %target-swift-frontend -I %t -O -emit-sil %s -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-SIL
4+
// RUN: %target-swift-frontend -I %t -O -emit-ir %s -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-IR
55

66
// REQUIRES: swift_in_compiler
77
// REQUIRES: swift_feature_LifetimeDependence
8-
// REQUIRES: swift_feature_Span
98
// REQUIRES: swift_feature_AllowUnsafeAttribute
109

1110
// REQUIRES: swift_stdlib_no_asserts, optimized_stdlib

test/SILOptimizer/span_bounds_check_tests.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// RUN: %target-swift-frontend %s -emit-sil -O \
22
// RUN: -disable-availability-checking \
33
// RUN: -enable-experimental-feature LifetimeDependence \
4-
// RUN: -enable-experimental-feature Span | %FileCheck %s --check-prefix=CHECK-SIL
4+
// RUN: | %FileCheck %s --check-prefix=CHECK-SIL
55

66
// RUN: %target-swift-frontend %s -emit-ir -O \
77
// RUN: -disable-availability-checking \
88
// RUN: -enable-experimental-feature LifetimeDependence \
9-
// RUN: -enable-experimental-feature Span | %FileCheck %s --check-prefix=CHECK-IR
9+
// RUN: | %FileCheck %s --check-prefix=CHECK-IR
1010

1111
// REQUIRES: swift_in_compiler
1212
// REQUIRES: swift_feature_LifetimeDependence
13-
// REQUIRES: swift_feature_Span
1413
// REQUIRES: swift_stdlib_no_asserts, optimized_stdlib
1514

1615
// Bounds check should be eliminated

test/embedded/availability-macos.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// Checks that in Embedded Swift, we allow using stdlib types even when they
22
// have declared availability to be higher than our macOS deployment target.
33

4-
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos14 -enable-experimental-feature Embedded -enable-experimental-feature Span
5-
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos15 -enable-experimental-feature Embedded -enable-experimental-feature Span
4+
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos14 -enable-experimental-feature Embedded
5+
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos15 -enable-experimental-feature Embedded
66

77
// REQUIRES: swift_in_compiler
88
// REQUIRES: swift_feature_Embedded
9-
// REQUIRES: swift_feature_Span
109
// REQUIRES: OS=macosx
1110

1211
func f(_: Span<Int>) { } // Span is @available(SwiftStdlib 6.1, *)

test/stdlib/BridgedArrayNonContiguous.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// RUN: %target-run-stdlib-swift -enable-experimental-feature LifetimeDependence -enable-experimental-feature Span
13+
// RUN: %target-run-stdlib-swift -enable-experimental-feature LifetimeDependence
1414

1515
// REQUIRES: executable_test
1616
// REQUIRES: objc_interop
1717
// REQUIRES: swift_feature_LifetimeDependence
18-
// REQUIRES: swift_feature_Span
1918

2019
import StdlibUnittest
2120

test/stdlib/span_requires_feature.swift

-12
This file was deleted.

0 commit comments

Comments
 (0)