mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Without this, we emit a copy of noncopyable type error since we do not insert a mark_must_check on lazily initialized global initializers. rdar://111402912
35 lines
604 B
Swift
35 lines
604 B
Swift
// RUN: %target-swift-emit-sil -sil-verify-all -parse-as-library -verify %s
|
|
|
|
struct S: ~Copyable {
|
|
let s: String
|
|
init(_ s: String) { self.s = s }
|
|
deinit { print("deiniting \(s)") }
|
|
}
|
|
|
|
struct M4 : ~Copyable {
|
|
var s1: S
|
|
var s2: S
|
|
init(_ s: String) {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
func rewriteTwo(_ one: inout S, _ two: inout S) {
|
|
one = S("new1")
|
|
two = S("new2")
|
|
}
|
|
|
|
var m = M4("1")
|
|
var m2 = M4("1")
|
|
|
|
struct Doit {
|
|
static var m3 = M4("1")
|
|
static var m4 = M4("1")
|
|
|
|
// We should get no diagnostics.
|
|
static func run() {
|
|
rewriteTwo(&m.s1, &m2.s2)
|
|
rewriteTwo(&m3.s1, &m4.s2)
|
|
}
|
|
}
|