Files
swift-mirror/test/Unsafe/hashable_synthesis.swift
Doug Gregor 1142fa3bdd [Strict memory safety] Eliminate spurious warnings with synthesized Codable
When synthesizing code for Codable conformances involving unsafe types,
make sure to wrap the resulting expressions in "unsafe" when strict memory safety is enabled.

Tweak the warning-emission logic to suppress warnings about spurious
"unsafe" expressions when the compiler generated the "unsafe" itself,
so we don't spam the developer with warnings they can't fix. Also make
the checking for other suppression considerations safe when there are
no source locations, eliminating a potential assertion.

Fixes rdar://153665692.
2025-07-10 09:03:04 -07:00

19 lines
351 B
Swift

// RUN: %target-typecheck-verify-swift -strict-memory-safety
@unsafe public struct UnsafeStruct: Hashable {
public var string: String
}
@unsafe public enum UnsafeEnum: Hashable {
case something(Int)
}
@safe public struct SafeStruct: Hashable {
public var us: UnsafeStruct
}
@safe public enum SafeEnum: Hashable {
case something(UnsafeEnum)
}