swiftlang / swift-experimental-string-processing

An early experimental general-purpose pattern matching engine for Swift.
Apache License 2.0
278 stars 47 forks source link

Suppress compiler warnings about Errors with non-Sendable members #727

Closed tshortli closed 7 months ago

tshortli commented 7 months ago

A type conforming to Error must be Sendable, but DelimiterLexError and CompilerLexError carry source locations represented by UnsafeRawPointer, which is inherently non-Sendable. The compiler diagnoses the failure to meet Sendable requirements on these error types, which will prevent Swift 6 adoption in _RegexParser and also generates build log spam every time the compiler and standard library are built. There are a couple ways to resolve this problem:

  1. Refactor so that the errors do not need to carry source locations.
  2. Refactor to avoid using Error (the code using these errors would not require Sendable if it were not for Error's inherent Sendable requirement).
  3. Suppress the warnings with an @unchecked Sendable wrapper.

Option 1 probably requires significant refactoring and option 2 seems undesirable since it means that the implementation must forgo the convenience of Swift's error handling model. Therefore this PR implements option 3 as the most expedient way to stop the diagnostic spam, leaving improvement on the status quo as a future exercise.

Also includes a drive-by fix for a trivial, unrelated warning.

tshortli commented 7 months ago

@swift-ci please test

tshortli commented 7 months ago

@swift-ci please test Windows

natecook1000 commented 7 months ago

Unless there are exceptional circumstances, please make changes on main before/at the same time as landing them on swift/main. Thanks!

Updating main in #729.

tshortli commented 7 months ago

Unless there are exceptional circumstances, please make changes on main before/at the same time as landing them on swift/main. Thanks!

Sorry, I think I'm just very confused about how this is supposed to work in this repo. It looked to me like main was very out of date and therefore was abandoned or something but I must have been looking at the wrong thing.