Files
swift-mirror/test/SILGen/noncopyable_enum_unexpected_case.swift
Joe Groff e3fef32a9b SILGen: Don't use diagnoseUnexpectedEnumCase intrinsic for noncopyable enums.
It should be impossible to reach an unexpected case statically while using
noncopyable enums, and the intrinsic has not been updated to remove its
`Copyable` requirement. Emit a plain trap in cases where this code emission
path might still occur, such as when a redundant but incomplete set of case
patterns follow a wildcard pattern. Fixes rdar://130037881.
2024-06-17 14:29:56 -10:00

18 lines
417 B
Swift

// RUN: %target-swift-emit-silgen -verify %s
struct NC: ~Copyable {}
enum NoncopyableEnum: ~Copyable {
case copyable(Int)
case noncopyable(NC)
}
func test(foo: consuming NoncopyableEnum) {
switch foo {
case let x: // expected-warning{{'x' was never used}}
break
case .copyable(let x): // expected-warning{{already handled by previous patterns}} expected-warning{{'x' was never used}}
break
}
}