diff --git a/test/Interop/Cxx/class/nonescapable-errors.swift b/test/Interop/Cxx/class/nonescapable-errors.swift index 5f65c51c0b45d..cf6f13a2875b5 100644 --- a/test/Interop/Cxx/class/nonescapable-errors.swift +++ b/test/Interop/Cxx/class/nonescapable-errors.swift @@ -1,8 +1,21 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: not %target-swift-frontend -typecheck -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs %t/test.swift -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s -// RUN: not %target-swift-frontend -typecheck -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs %t/test.swift -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s -check-prefix=CHECK-NO-LIFETIMES - +// +// RUN: %target-swift-frontend -typecheck -verify %t%{fs-sep}test.swift \ +// RUN: -I %swift_src_root%{fs-sep}lib%{fs-sep}ClangImporter%{fs-sep}SwiftBridging -I %t%{fs-sep}Inputs \ +// RUN: -cxx-interoperability-mode=default \ +// RUN: -verify-ignore-unrelated \ +// RUN: -verify-additional-file %t%{fs-sep}Inputs%{fs-sep}nonescapable.h \ +// RUN: -verify-additional-prefix LIFETIMES- \ +// RUN: -enable-experimental-feature LifetimeDependence +// +// RUN: %target-swift-frontend -typecheck -verify %t%{fs-sep}test.swift \ +// RUN: -I %swift_src_root%{fs-sep}lib%{fs-sep}ClangImporter%{fs-sep}SwiftBridging -I %t%{fs-sep}Inputs \ +// RUN: -cxx-interoperability-mode=default \ +// RUN: -verify-ignore-unrelated \ +// RUN: -verify-additional-file %t%{fs-sep}Inputs%{fs-sep}nonescapable.h \ +// RUN: -verify-additional-prefix NO-LIFETIMES- +// // REQUIRES: swift_feature_LifetimeDependence //--- Inputs/module.modulemap @@ -36,22 +49,28 @@ struct SWIFT_ESCAPABLE TemplatedOwner { using TemplatedIntOwner = TemplatedOwner; using TemplatedFloatOwner = TemplatedOwner; +// expected-warning@+1 {{the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies}} Owner f(int* x [[clang::lifetimebound]]) { return Owner{0}; } +// expected-warning@+1 {{the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies}} Owner f2(int* x [[clang::lifetimebound]], int* y [[clang::lifetimebound]]) { return Owner{0}; } +// expected-warning@+1 {{the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies}} TemplatedIntOwner f3(int* x [[clang::lifetimebound]]) { return TemplatedOwner{0}; } +// expected-warning@+1 {{the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies}} TemplatedFloatOwner f4(int* x [[clang::lifetimebound]]) { return TemplatedOwner{0}; } +// expected-warning@+2 {{the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated}} +// expected-NO-LIFETIMES-error@+1 {{a function cannot return a ~Escapable result}} View g(int* x) { return View(x); } @@ -62,16 +81,24 @@ struct SWIFT_ESCAPABLE_IF(F, S) MyPair { S second; }; +// expected-NO-LIFETIMES-error@+1 {{a function cannot return a ~Escapable result}} MyPair h1(int* x); + +// expected-NO-LIFETIMES-error@+1 {{a function cannot return a ~Escapable result}} MyPair h2(int* x); + +// OK; MyPair is not ~Escapable MyPair h3(int* x); +// expected-error@+3 {{template parameter 'Missing' does not exist}} +// expected-error@+2 {{template parameter 'Missing' does not exist}} template struct SWIFT_ESCAPABLE_IF(F, Missing) MyPair2 { F first; S second; }; +// expected-error@+2 {{template parameter 'S' expected to be a type parameter}} template struct SWIFT_ESCAPABLE_IF(F, S) MyType { F field; @@ -91,27 +118,51 @@ struct Outer { }; }; +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} Outer::NonTemplated::Inner j1(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} Outer::NonTemplated::Inner j2(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + Outer::NonTemplated::Inner j3(); template struct SWIFT_ESCAPABLE_IF(Ts) MyTuple {}; +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} MyTuple k1(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} MyTuple k2(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + MyTuple k3(); using ViewVector = std::vector; using OwnerVector = std::vector; +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} ViewVector l1(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + OwnerVector l2(); +// expected-note@+3 {{function 'usedToCrash' unavailable (cannot import)}} +// expected-note@+2 {{return type unavailable (cannot import)}} +// expected-note@+1 {{pointer to non-escapable type 'View' cannot be imported}} const View* usedToCrash(const View* p) { return p; } +// expected-note@+1 {{escapable record 'Invalid' cannot have non-escapable field 'v'}} struct SWIFT_ESCAPABLE Invalid { View v; }; @@ -141,37 +192,101 @@ struct ComplexRecord { ComplexRecord(const ComplexRecord &other) = default; }; +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} Aggregate m1(); -ComplexRecord m2(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + +ComplexRecord m2(); // expected-note {{'m2()' has been explicitly marked unavailable here}} +// expected-error@+1 {{multiple SWIFT_NONESCAPABLE annotations found on 'DoubleNonEscapableAnnotation'}} struct SWIFT_NONESCAPABLE SWIFT_NONESCAPABLE DoubleNonEscapableAnnotation {}; +// expected-note@-1 {{SWIFT_NONESCAPABLE annotation found here}} +// expected-note@-2 {{SWIFT_NONESCAPABLE annotation found here}} + +// expected-error@+1 {{multiple SWIFT_ESCAPABLE annotations found on 'DoubleEscapableAnnotation'}} struct SWIFT_ESCAPABLE SWIFT_ESCAPABLE DoubleEscapableAnnotation {}; +// expected-note@-1 {{SWIFT_ESCAPABLE annotation found here}} +// expected-note@-2 {{SWIFT_ESCAPABLE annotation found here}} +// expected-error@+3 {{multiple SWIFT_ESCAPABLE_IF annotations found on 'DoubleEscapableIfAnnotation'}} +// expected-error@+2 {{multiple SWIFT_ESCAPABLE_IF annotations found on 'DoubleEscapableIfAnnotation'}} template struct SWIFT_ESCAPABLE_IF(F) SWIFT_ESCAPABLE_IF(S) DoubleEscapableIfAnnotation {}; +// expected-note@-1 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-note@-2 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-note@-3 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-note@-4 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-error@+1 {{multiple conflicting annotations found on 'EscapableNonEscapable'}} struct SWIFT_ESCAPABLE SWIFT_NONESCAPABLE EscapableNonEscapable {}; +// expected-note@-1 {{SWIFT_ESCAPABLE annotation found here}} +// expected-note@-2 {{SWIFT_NONESCAPABLE annotation found here}} + +// expected-error@+1 {{multiple conflicting annotations found on 'DoubleEscapableNonEscapable'}} struct SWIFT_ESCAPABLE SWIFT_NONESCAPABLE SWIFT_NONESCAPABLE SWIFT_ESCAPABLE DoubleEscapableNonEscapable {}; +// expected-note@-1 {{SWIFT_ESCAPABLE annotation found here}} +// expected-note@-2 {{SWIFT_NONESCAPABLE annotation found here}} +// expected-note@-3 {{SWIFT_NONESCAPABLE annotation found here}} +// expected-note@-4 {{SWIFT_ESCAPABLE annotation found here}} +// expected-error@+2 {{multiple conflicting annotations found on 'EscapableIfEscapable'}} template struct SWIFT_ESCAPABLE_IF(T) SWIFT_ESCAPABLE EscapableIfEscapable {}; +// expected-note@-1 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-note@-2 {{SWIFT_ESCAPABLE annotation found here}} +// expected-error@+2 {{multiple conflicting annotations found on 'NonEscapableIfEscapable'}} template struct SWIFT_ESCAPABLE_IF(T) SWIFT_NONESCAPABLE NonEscapableIfEscapable {}; +// expected-note@-1 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-note@-2 {{SWIFT_NONESCAPABLE annotation found here}} +// expected-error@+2 {{SWIFT_ESCAPABLE_IF is invalid because it is only supported in class templates}} +// expected-error@+1 {{multiple conflicting annotations found on 'NonTemplateEscapableIf'}} struct SWIFT_ESCAPABLE SWIFT_ESCAPABLE_IF(T) NonTemplateEscapableIf {}; +// expected-note@-1 {{SWIFT_ESCAPABLE annotation found here}} +// expected-note@-2 {{SWIFT_ESCAPABLE_IF annotation found here}} +// expected-warning@+3 {{the returned type 'DoubleNonEscapableAnnotation' is annotated as non-escapable; its lifetime dependencies must be annotated}} +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} DoubleNonEscapableAnnotation n1(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + DoubleEscapableAnnotation n2(); + DoubleEscapableIfAnnotation n3(); + DoubleEscapableIfAnnotation n4(); + +// expected-warning@+3 {{the returned type 'EscapableNonEscapable' is annotated as non-escapable; its lifetime dependencies must be annotated}} +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} EscapableNonEscapable n5(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + +// expected-warning@+3 {{the returned type 'DoubleEscapableNonEscapable' is annotated as non-escapable; its lifetime dependencies must be annotated}} +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} DoubleEscapableNonEscapable n6(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + EscapableIfEscapable n7(); + +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} NonEscapableIfEscapable n8(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + NonTemplateEscapableIf n9(); + // We infer that MyPair is ~Escapable from `NonEscapable`, but still emit diagnostics for `Missing` +// expected-LIFETIMES-error@+2 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+1 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} MyPair>> n10(); +// expected-NO-LIFETIMES-error@-1 {{a function cannot return a ~Escapable result}} + // Don't emit the same diagnostic twice MyPair n11(); @@ -180,155 +295,57 @@ MyPair n11(); import Test import CxxStdlib -// CHECK: error: cannot find type 'Invalid' in scope -// CHECK: note: escapable record 'Invalid' cannot have non-escapable field 'v' -// CHECK-NO-LIFETIMES: error: cannot find type 'Invalid' in scope -// CHECK-NO-LIFETIMES: note: escapable record 'Invalid' cannot have non-escapable field 'v' -public func importInvalid(_ x: Invalid) { -} +// expected-error@+1 {{cannot find type 'Invalid' in scope}} +public func importInvalid(_ x: Invalid) {} -// CHECK: error: a function with a ~Escapable result needs a parameter to depend on -// CHECK-NO-LIFETIMES: test.swift:13:32: error: a function cannot return a ~Escapable result +// expected-LIFETIMES-error@+3 {{a function with a ~Escapable result needs a parameter to depend on}} +// expected-LIFETIMES-note@+2 {{'@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies}} +// expected-NO-LIFETIMES-error@+1 {{a function cannot return a ~Escapable result}} public func noAnnotations() -> View { - // CHECK: nonescapable.h:25:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:25:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] f(nil) - // CHECK: nonescapable.h:29:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:29:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // No duplicate warning for f2: - // CHECK-NOT: nonescapable.h:29 f2(nil, nil) - // CHECK: nonescapable.h:33:19: warning: the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:33:19: warning: the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // No duplicate warning for f3: - // CHECK-NOT: nonescapable.h:33 f3(nil) - // CHECK: nonescapable.h:37:21: warning: the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:37:21: warning: the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport] - // No duplicate warning for f4: - // CHECK-NOT: nonescapable.h:35 f4(nil) - // CHECK: nonescapable.h:41:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:41:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:41:6: error: a function cannot return a ~Escapable result g(nil) h1(nil) - // CHECK-NO-LIFETIMES: nonescapable.h:51:21: error: a function cannot return a ~Escapable result h2(nil) - // CHECK-NO-LIFETIMES: nonescapable.h:52:21: error: a function cannot return a ~Escapable result h3(nil) i1() - // CHECK: nonescapable.h:56:39: error: template parameter 'Missing' does not exist - // CHECK-NO-LIFETIMES: nonescapable.h:56:39: error: template parameter 'Missing' does not exist i2() - // CHECK: nonescapable.h:62:33: error: template parameter 'S' expected to be a type parameter - // CHECK-NO-LIFETIMES: nonescapable.h:62:33: error: template parameter 'S' expected to be a type parameter j1() - // CHECK: nonescapable.h:80:41: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK: note: '@_lifetime(immortal)' can be used to indicate that values produced - // CHECK-NO-LIFETIMES: nonescapable.h:80:41: error: a function cannot return a ~Escapable result j2() - // CHECK: nonescapable.h:81:41: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:81:41: error: a function cannot return a ~Escapable result - // CHECK: note: '@_lifetime(immortal)' can be used to indicate that values produced j3() - k1(); - // CHECK: nonescapable.h:87:15: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK: nonescapable.h:87:15: note: '@_lifetime(immortal)' can be used to indicate that values produced - // CHECK-NO-LIFETIMES: nonescapable.h:87:15: error: a function cannot return a ~Escapable result - - k2(); - // CHECK: nonescapable.h:88:22: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:88:22: error: a function cannot return a ~Escapable result - // CHECK: note: '@_lifetime(immortal)' can be used to indicate that values produced - k3(); - l1(); - // CHECK: nonescapable.h:94:12: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK: nonescapable.h:94:12: note: '@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies - // CHECK-NO-LIFETIMES: nonescapable.h:94:12: error: a function cannot return a ~Escapable result + k1() + k2() + k3() + l1() l2(); return View() } public func diagnoseInvalidSwiftAttributes() { n1() - // CHECK: nonescapable.h:133:46: error: multiple SWIFT_NONESCAPABLE annotations found on 'DoubleNonEscapableAnnotation' - // CHECK: nonescapable.h:150:30: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:133:46: error: multiple SWIFT_NONESCAPABLE annotations found on 'DoubleNonEscapableAnnotation' - // CHECK-NO-LIFETIMES: nonescapable.h:150:30: error: a function cannot return a ~Escapable result n2() - // CHECK: nonescapable.h:134:40: error: multiple SWIFT_ESCAPABLE annotations found on 'DoubleEscapableAnnotation' - // CHECK-NO-LIFETIMES: nonescapable.h:134:40: error: multiple SWIFT_ESCAPABLE annotations found on 'DoubleEscapableAnnotation' n3() - // CHECK: nonescapable.h:137:52: error: multiple SWIFT_ESCAPABLE_IF annotations found on 'DoubleEscapableIfAnnotation' - // CHECK-NO-LIFETIMES: nonescapable.h:137:52: error: multiple SWIFT_ESCAPABLE_IF annotations found on 'DoubleEscapableIfAnnotation' n4() - // CHECK: nonescapable.h:137:52: error: multiple SWIFT_ESCAPABLE_IF annotations found on 'DoubleEscapableIfAnnotation' - // CHECK-NO-LIFETIMES: nonescapable.h:137:52: error: multiple SWIFT_ESCAPABLE_IF annotations found on 'DoubleEscapableIfAnnotation' n5() - // CHECK: nonescapable.h:154:23: warning: the returned type 'EscapableNonEscapable' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport] - // CHECK: nonescapable.h:154:23: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:154:23: warning: the returned type 'EscapableNonEscapable' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:154:23: error: a function cannot return a ~Escapable result n6() - // CHECK: nonescapable.h:155:29: warning: the returned type 'DoubleEscapableNonEscapable' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport] - // CHECK: nonescapable.h:140:78: error: multiple conflicting annotations found on 'DoubleEscapableNonEscapable' - // CHECK: nonescapable.h:155:29: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:155:29: warning: the returned type 'DoubleEscapableNonEscapable' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport] - // CHECK-NO-LIFETIMES: nonescapable.h:140:78: error: multiple conflicting annotations found on 'DoubleEscapableNonEscapable' - // CHECK-NO-LIFETIMES: nonescapable.h:155:29: error: a function cannot return a ~Escapable result n7() - // CHECK: nonescapable.h:143:46: error: multiple conflicting annotations found on 'EscapableIfEscapable' - // CHECK-NO-LIFETIMES: nonescapable.h:143:46: error: multiple conflicting annotations found on 'EscapableIfEscapable' n8() - // CHECK: nonescapable.h:146:49: error: multiple conflicting annotations found on 'NonEscapableIfEscapable' - // CHECK-NO-LIFETIMES: nonescapable.h:146:49: error: multiple conflicting annotations found on 'NonEscapableIfEscapable' - // CHECK: nonescapable.h:157:32: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:157:32: error: a function cannot return a ~Escapable result n9() - // CHECK: nonescapable.h:148:24: error: SWIFT_ESCAPABLE_IF is invalid because it is only supported in class templates - // CHECK: nonescapable.h:148:46: error: multiple conflicting annotations found on 'NonTemplateEscapableIf' - // CHECK-NO-LIFETIMES: nonescapable.h:148:24: error: SWIFT_ESCAPABLE_IF is invalid because it is only supported in class templates - // CHECK-NO-LIFETIME: nonescapable.h:148:46: error: multiple conflicting annotations found on 'NonTemplateEscapableIf' n10() - // CHECK: nonescapable.h:56:39: error: template parameter 'Missing' does not exist - // CHECK: nonescapable.h:160:87: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:56:39: error: template parameter 'Missing' does not exist - // CHECK-NO-LIFETIMES: nonescapable.h:160:87: error: a function cannot return a ~Escapable result - n11() + n11() } public func test3(_ x: inout View) { - usedToCrash(&x) - // CHECK: error: cannot find 'usedToCrash' in scope - // CHECK: note: function 'usedToCrash' unavailable (cannot import) - // CHECK: note: return type unavailable (cannot import) - // CHECK: pointer to non-escapable type 'View' cannot be imported - // CHECK-NO-LIFETIMES: error: cannot find 'usedToCrash' in scope - // CHECK-NO-LIFETIMES: note: function 'usedToCrash' unavailable (cannot import) - // CHECK-NO-LIFETIMES: note: return type unavailable (cannot import) - // CHECK-NO-LIFETIMES: pointer to non-escapable type 'View' cannot be imported + usedToCrash(&x) // expected-error {{cannot find 'usedToCrash' in scope}} } public func optional() { _ = NonEscapableOptional() - // CHECK: error: cannot infer the lifetime dependence scope on an initializer with a ~Escapable parameter, specify '@_lifetime(borrow {{.*}})' or '@_lifetime(copy {{.*}})' - // CHECK-NO-LIFETIMES: error: an initializer cannot return a ~Escapable result - // CHECK-NO-LIFETIMES: error: an initializer cannot return a ~Escapable result } public func inferedEscapability() { m1() - // CHECK: nonescapable.h:130:11: error: a function with a ~Escapable result needs a parameter to depend on - // CHECK-NO-LIFETIMES: nonescapable.h:130:11: error: a function cannot return a ~Escapable result - m2() - // CHECK: error: 'm2()' is unavailable: return type is unavailable in Swift - // CHECK: note: 'm2()' has been explicitly marked unavailable here - // CHECK-NO-LIFETIMES: error: 'm2()' is unavailable: return type is unavailable in Swift - // CHECK-NO-LIFETIMES: note: 'm2()' has been explicitly marked unavailable here + m2() // expected-error {{'m2()' is unavailable: return type is unavailable in Swift}} } - - // CHECK-NOT: error - // CHECK-NOT: warning - // CHECK-NO-LIFETIMES-NOT: error - // CHECK-NO-LIFETIMES-NOT: warning