Files
swift-mirror/test/SILOptimizer/moveonly_correct.swift
Kavon Farvardin 3e3e93bb28 Test: ~Copyable passed inout within closure
Add test coverage for a code pattern that briefly broke on main.

rdar://162749287
2025-11-05 16:08:04 -08:00

39 lines
983 B
Swift

// RUN: %target-swift-frontend %s -sil-verify-all -c -o /dev/null
// This file is suppose to contain programs that are "correct" through emitting
// an object file, so no diagnostic tests in here, please!
// rdar://118274699
struct Env: ~Copyable {
var constants: Int
}
struct VM: ~Copyable {
let env = Env(constants: 0)
mutating func run() {
env.constants
}
}
// rdar://109232806
public protocol P_109232806 {}
public struct M_109232806: ~Copyable {
var x: P_109232806? = nil
var y: Int { 0 }
}
public func test_109232806(m: borrowing M_109232806) {
_ = m.y
}
// rdar://162749287
struct DonutEventHandler: ~Copyable {
mutating func deliciouslyDo<Result>(
operation: (inout Self) async throws -> Result,
withHandler handler: (Int) async throws -> Void
) async rethrows -> Result {
return try await withoutActuallyEscaping(handler) { escapingHandler in
return try await operation(&self)
}
}
}