Files
swift-mirror/test/SILOptimizer/moveonly_addresschecker_trivial_read.swift
Joe Groff b5d242ad2c MoveOnlyChecker: Don't follow trivial transitive uses of borrows.
Trivial values don't have ownership tracked, so their uses can't affect the
lifetime of the original borrow. Fixes rdar://148457155.
2025-04-02 13:25:46 -07:00

27 lines
470 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
func use(_: Int32) {}
struct NoncopyableYieldingSubscript: ~Copyable {
subscript() -> Int16 {
_read {
yield 0
}
}
}
func foo(component: inout NoncopyableYieldingSubscript, condition: Bool) {
let extracted: Int32
switch condition {
case true:
extracted = Int32(component[])
case false:
extracted = Int32(component[])
}
use(extracted)
}