Skip to content

Require TestContentContext conform to ConvertibleFromBytes. - #2000

Merged
grynspan merged 1 commit into
mainfrom
jgrynspan/TestContentContext-ConvertibleFromBytes
Oct 31, 2026
Merged

grynspan merged 1 commit into
mainfrom
jgrynspan/TestContentContext-ConvertibleFromBytes

Conversation

@grynspan

Copy link
Copy Markdown
Contributor

The associated type TestContentContext in the _TestDiscovery module is constrained to BitwiseCopyable. Swift recently introduced ConvertibleFromBytes which refines BitwiseCopyable and guarantees that conforming types have no uninhabited members (in other words, all bit patterns are valid instances).

This PR changes the constraint on TestContentContext to ConvertibleFromBytes. This improves type safety somewhat by ensuring that a library using _TestDiscovery cannot specify a type here that has a trap representation (for instance, UnsafeRawPointer and 0x0) which Swift Testing cannot guard against.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

The associated type `TestContentContext` in the `_TestDiscovery` module is constrained to `BitwiseCopyable`. Swift recently introduced `ConvertibleFromBytes` which refines `BitwiseCopyable` and guarantees that conforming types have no uninhabited members (in other words, all bit patterns are valid instances).

This PR changes the constraint on `TestContentContext` to `ConvertibleFromBytes`. This improves type safety somewhat by ensuring that a library using `_TestDiscovery` cannot specify a type here that has a trap representation (for instance, `UnsafeRawPointer` and `0x0`) which Swift Testing cannot guard against.
@grynspan grynspan added this to the Swift 6.5.0 (main) milestone Oct 31, 2026
@grynspan grynspan self-assigned this Oct 31, 2026
@grynspan grynspan added enhancement New feature or request discovery 🔎 test content discovery labels Oct 31, 2026
@grynspan
grynspan merged commit 5ccf72d into main Oct 31, 2026
32 of 37 checks passed
@grynspan
grynspan deleted the jgrynspan/TestContentContext-ConvertibleFromBytes branch October 31, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discovery 🔎 test content discovery enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants