Skip to content

Commit 87ea119

Browse files
authored
Disable resilience on _RegexParser (#397)
_RegexParser does not need resilience as it's only ever going to be used by _StringProcessing and RegexBuilder.
1 parent f779459 commit 87ea119

File tree

9 files changed

+13
-28
lines changed

9 files changed

+13
-28
lines changed

Package.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ let availabilityDefinition = PackageDescription.SwiftSetting.unsafeFlags([
77
"-Xfrontend",
88
"-define-availability",
99
"-Xfrontend",
10-
#"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999"#,
10+
"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
1111
])
1212

13-
let stdlibSettings: [PackageDescription.SwiftSetting] = [
13+
/// Swift settings for building a private stdlib-like module that is to be used
14+
/// by other stdlib-like modules only.
15+
let privateStdlibSettings: [PackageDescription.SwiftSetting] = [
16+
.unsafeFlags(["-Xfrontend", "-disable-implicit-concurrency-module-import"]),
17+
.unsafeFlags(["-Xfrontend", "-disable-implicit-string-processing-module-import"]),
18+
]
19+
20+
/// Swift settings for building a user-facing stdlib-like module.
21+
let publicStdlibSettings: [PackageDescription.SwiftSetting] = [
1422
.unsafeFlags(["-enable-library-evolution"]),
1523
.unsafeFlags(["-Xfrontend", "-disable-implicit-concurrency-module-import"]),
1624
.unsafeFlags(["-Xfrontend", "-disable-implicit-string-processing-module-import"]),
@@ -43,7 +51,7 @@ let package = Package(
4351
.target(
4452
name: "_RegexParser",
4553
dependencies: [],
46-
swiftSettings: stdlibSettings),
54+
swiftSettings: privateStdlibSettings),
4755
.testTarget(
4856
name: "MatchingEngineTests",
4957
dependencies: [
@@ -55,11 +63,11 @@ let package = Package(
5563
.target(
5664
name: "_StringProcessing",
5765
dependencies: ["_RegexParser", "_CUnicode"],
58-
swiftSettings: stdlibSettings),
66+
swiftSettings: publicStdlibSettings),
5967
.target(
6068
name: "RegexBuilder",
6169
dependencies: ["_StringProcessing", "_RegexParser"],
62-
swiftSettings: stdlibSettings),
70+
swiftSettings: publicStdlibSettings),
6371
.testTarget(
6472
name: "RegexTests",
6573
dependencies: ["_StringProcessing"],

Sources/_RegexParser/Regex/AST/AST.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extension AST {
2929

3030
extension AST {
3131
/// A node in the regex AST.
32-
@frozen
3332
public indirect enum Node:
3433
Hashable, _TreeNode //, _ASTPrintable ASTValue, ASTAction
3534
{
@@ -249,7 +248,6 @@ extension AST {
249248
}
250249

251250
public struct Reference: Hashable {
252-
@frozen
253251
public enum Kind: Hashable {
254252
// \n \gn \g{n} \g<n> \g'n' (?n) (?(n)...
255253
// Oniguruma: \k<n>, \k'n'

Sources/_RegexParser/Regex/AST/Atom.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ extension AST {
1919
self.location = loc
2020
}
2121

22-
@frozen
2322
public enum Kind: Hashable {
2423
/// Just a character
2524
///
@@ -146,7 +145,6 @@ extension AST.Atom {
146145

147146
// Characters, character types, literals, etc., derived from
148147
// an escape sequence.
149-
@frozen
150148
public enum EscapedBuiltin: Hashable {
151149
// TODO: better doc comments
152150

@@ -399,7 +397,6 @@ extension AST.Atom {
399397
}
400398

401399
extension AST.Atom.CharacterProperty {
402-
@frozen
403400
public enum Kind: Hashable {
404401
/// Matches any character, equivalent to Oniguruma's '\O'.
405402
case any
@@ -438,7 +435,6 @@ extension AST.Atom.CharacterProperty {
438435
}
439436

440437
// TODO: erm, separate out or fold into something? splat it in?
441-
@frozen
442438
public enum PCRESpecialCategory: String, Hashable {
443439
case alphanumeric = "Xan"
444440
case posixSpace = "Xps"
@@ -450,7 +446,6 @@ extension AST.Atom.CharacterProperty {
450446

451447
extension AST.Atom {
452448
/// Anchors and other built-in zero-width assertions.
453-
@frozen
454449
public enum AssertionKind: String {
455450
/// \A
456451
case startOfSubject = #"\A"#

Sources/_RegexParser/Regex/AST/CustomCharClass.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ extension AST {
2727
self.location = sr
2828
}
2929

30-
@frozen
3130
public enum Member: Hashable {
3231
/// A nested custom character class `[[ab][cd]]`
3332
case custom(CustomCharacterClass)
@@ -59,13 +58,11 @@ extension AST {
5958
self.rhs = rhs
6059
}
6160
}
62-
@frozen
6361
public enum SetOp: String, Hashable {
6462
case subtraction = "--"
6563
case intersection = "&&"
6664
case symmetricDifference = "~~"
6765
}
68-
@frozen
6966
public enum Start: String {
7067
case normal = "["
7168
case inverted = "[^"

Sources/_RegexParser/Regex/AST/Quantification.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ extension AST {
3636
self.trivia = trivia
3737
}
3838

39-
@frozen
4039
public enum Amount: Hashable {
4140
case zeroOrMore // *
4241
case oneOrMore // +
@@ -47,7 +46,6 @@ extension AST {
4746
case range(Located<Int>, Located<Int>) // {n,m}
4847
}
4948

50-
@frozen
5149
public enum Kind: String, Hashable {
5250
case eager = ""
5351
case reluctant = "?"

Sources/_RegexParser/Utility/MissingUnicode.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ extension Unicode {
1919
// other script types.
2020

2121
/// Character script types.
22-
@frozen
2322
public enum Script: String, Hashable {
2423
case adlam = "Adlam"
2524
case ahom = "Ahom"
@@ -188,7 +187,6 @@ extension Unicode {
188187

189188
/// POSIX character properties not already covered by general categories or
190189
/// binary properties.
191-
@frozen
192190
public enum POSIXProperty: String, Hashable {
193191
case alnum = "alnum"
194192
case blank = "blank"
@@ -206,7 +204,6 @@ extension Unicode {
206204

207205
/// Unicode.GeneralCategory + cases for "meta categories" such as "L", which
208206
/// encompasses Lu | Ll | Lt | Lm | Lo.
209-
@frozen
210207
public enum ExtendedGeneralCategory: String, Hashable {
211208
case other = "C"
212209
case control = "Cc"
@@ -257,7 +254,6 @@ extension Unicode {
257254
/// A list of Unicode properties that can either be true or false.
258255
///
259256
/// https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt
260-
@frozen
261257
public enum BinaryProperty: String, Hashable {
262258
case asciiHexDigit = "ASCII_Hex_Digit"
263259
case alphabetic = "Alphabetic"
@@ -333,7 +329,6 @@ extension Unicode {
333329
// property.
334330

335331
/// Oniguruma properties that are not covered by Unicode spellings.
336-
@frozen
337332
public enum OnigurumaSpecialProperty: String, Hashable {
338333
case inBasicLatin = "In_Basic_Latin"
339334
case inLatin1Supplement = "In_Latin_1_Supplement"

Sources/_StringProcessing/MatchingOptions.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,6 @@ extension MatchingOptions {
205205
// Whitespace options are only relevant during parsing, not compilation.
206206
case .extended, .extraExtended:
207207
return nil
208-
@unknown default:
209-
// Ignore unknown
210-
return nil
211208
}
212209
}
213210

Sources/_StringProcessing/Regex/DSLTree.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,6 @@ extension DSLTree.Node {
507507
child._addCaptures(to: &list, optionalNesting: nesting)
508508
case .clearer, .repeater, .stopper:
509509
break
510-
@unknown default:
511-
fatalError()
512510
}
513511

514512
case let .convertedRegexLiteral(n, _):

Tests/RegexBuilderTests/AlgorithmsTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import XCTest
1313
import _StringProcessing
1414
import RegexBuilder
1515

16-
@available(SwiftStdlib 5.7, *)
1716
class RegexConsumerTests: XCTestCase {
1817
func testMatches() {
1918
let regex = Capture(OneOrMore(.digit)) { 2 * Int($0)! }

0 commit comments

Comments
 (0)