andyhill
(Andy Hill)
1
Hi, is there a compiler flag [-warn-implicit-copy?] to warn when the compiler is making an implicit copy of an otherwise consumed variable? For example, with the flag set, the compiler will warn on the first use of s below as shown in the comment:
struct S {
let v = "hi"
consuming func value() -> String { return v }
}
func f() {
let s = S()
print(s.value()) // WARNING: compiler implicitly makes a copy of s to be consumed here
print(s.value()) // original value of s consumed here
}
f()
This is to follow up on this Github Issue. Running swiftc --help, I don't see any applicable flag. Please let me know where to post if this is the wrong forum. Thanks.