mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This comes up often when passing a MutableSpan as an 'inout' argument. The
vague diagnostic was causing developers to attempt incorrect @_lifetime
annotations. Be clear about why the annotation is needed and which annotation
should be used.
(cherry picked from commit df0b81c88d)
17 lines
665 B
Swift
17 lines
665 B
Swift
// RUN: %target-typecheck-verify-swift -disable-availability-checking
|
|
// REQUIRES: asserts
|
|
|
|
struct NE : ~Escapable { // expected-error{{an implicit initializer cannot return a ~Escapable result}}
|
|
}
|
|
|
|
@_lifetime(copy ne) // expected-error{{'@_lifetime' attribute is only valid when experimental feature Lifetimes is enabled}}
|
|
func derive(_ ne: NE) -> NE { // expected-error{{a function cannot return a ~Escapable result}}
|
|
ne
|
|
}
|
|
|
|
func f_inout_infer(a: inout MutableRawSpan) {}
|
|
|
|
func f_inout_no_infer(a: inout MutableRawSpan, b: RawSpan) {}
|
|
// expected-error @-1{{a function cannot have a ~Escapable 'inout' parameter 'a' in addition to other ~Escapable parameters}}
|
|
|