Skip to content

Commit f890a8d

Browse files
committed
Diagnostic message: suppress printing "requires LifetimeDependence"
Adopters of the new Span and MutableSpan types should not encounter information about an experimental feature when they attempt to use these types in unsupported ways, such as simply returning them from a function. Fixes rdar://151788740 (Diagnostic message: suppress printing "requires '-enable-experimental-feature LifetimeDependence'") (cherry picked from commit 50a69bc)
1 parent 86699a2 commit f890a8d

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8219,15 +8219,13 @@ ERROR(lifetime_parameter_requires_inout, none,
82198219
//------------------------------------------------------------------------------
82208220

82218221
ERROR(lifetime_dependence_feature_required_return, none,
8222-
"%0 with a ~Escapable result requires "
8223-
"'-enable-experimental-feature LifetimeDependence'", (StringRef))
8222+
"%0 cannot return a ~Escapable result", (StringRef))
82248223
ERROR(lifetime_dependence_feature_required_mutating, none,
8225-
"%0 with ~Escapable 'self' requires "
8226-
"'-enable-experimental-feature LifetimeDependence'", (StringRef))
8224+
"%0 cannot have a ~Escapable 'self'", (StringRef))
82278225
ERROR(lifetime_dependence_feature_required_inout, none,
8228-
"%0 with a ~Escapable 'inout' parameter requires "
8229-
"'-enable-experimental-feature LifetimeDependence'",
8230-
// arg list is interchangable with lifetime_dependence_cannot_infer_inout
8226+
"%0 cannot have a ~Escapable 'inout' parameter %1",
8227+
// this arg list must be compatible with
8228+
// lifetime_dependence_cannot_infer_inout
82318229
(StringRef, Identifier))
82328230

82338231
ERROR(lifetime_dependence_cannot_infer_return, none,

test/Interop/Cxx/class/nonescapable-errors.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public func importInvalid(_ x: Invalid) {
109109
}
110110

111111
// CHECK: error: a function with a ~Escapable result needs a parameter to depend on
112-
// CHECK-NO-LIFETIMES: test.swift:11:32: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
112+
// CHECK-NO-LIFETIMES: test.swift:11:32: error: a function cannot return a ~Escapable result
113113
public func noAnnotations() -> View {
114114
// CHECK: nonescapable.h:16:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
115115
// CHECK-NO-LIFETIMES: nonescapable.h:16:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
@@ -121,12 +121,12 @@ public func noAnnotations() -> View {
121121
f2(nil, nil)
122122
// CHECK: nonescapable.h:24:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport]
123123
// CHECK-NO-LIFETIMES: nonescapable.h:24:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport]
124-
// CHECK-NO-LIFETIMES: nonescapable.h:24:6: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
124+
// CHECK-NO-LIFETIMES: nonescapable.h:24:6: error: a function cannot return a ~Escapable result
125125
g(nil)
126126
h1(nil)
127-
// CHECK-NO-LIFETIMES: nonescapable.h:34:21: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
127+
// CHECK-NO-LIFETIMES: nonescapable.h:34:21: error: a function cannot return a ~Escapable result
128128
h2(nil)
129-
// CHECK-NO-LIFETIMES: nonescapable.h:35:21: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
129+
// CHECK-NO-LIFETIMES: nonescapable.h:35:21: error: a function cannot return a ~Escapable result
130130
h3(nil)
131131
i1()
132132
// CHECK: nonescapable.h:39:39: error: template parameter 'Missing' does not exist
@@ -135,18 +135,18 @@ public func noAnnotations() -> View {
135135
// CHECK: nonescapable.h:45:33: error: template parameter 'S' expected to be a type parameter
136136
// CHECK-NO-LIFETIMES: nonescapable.h:45:33: error: template parameter 'S' expected to be a type parameter
137137
j1()
138-
// CHECK-NO-LIFETIMES: nonescapable.h:63:41: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
138+
// CHECK-NO-LIFETIMES: nonescapable.h:63:41: error: a function cannot return a ~Escapable result
139139
j2()
140-
// CHECK-NO-LIFETIMES: nonescapable.h:64:41: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
140+
// CHECK-NO-LIFETIMES: nonescapable.h:64:41: error: a function cannot return a ~Escapable result
141141
j3()
142142
k1();
143-
// CHECK-NO-LIFETIMES: nonescapable.h:70:15: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
143+
// CHECK-NO-LIFETIMES: nonescapable.h:70:15: error: a function cannot return a ~Escapable result
144144
k2();
145-
// CHECK-NO-LIFETIMES: nonescapable.h:71:22: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
145+
// CHECK-NO-LIFETIMES: nonescapable.h:71:22: error: a function cannot return a ~Escapable result
146146
k3();
147147
l1();
148148
// CHECK: nonescapable.h:77:12: error: a function with a ~Escapable result needs a parameter to depend on
149-
// CHECK-NO-LIFETIMES: nonescapable.h:77:12: error: a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'
149+
// CHECK-NO-LIFETIMES: nonescapable.h:77:12: error: a function cannot return a ~Escapable result
150150
l2();
151151
return View()
152152
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %target-typecheck-verify-swift -disable-availability-checking
22
// REQUIRES: asserts
33

4-
struct NE : ~Escapable { // expected-error{{an implicit initializer with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
4+
struct NE : ~Escapable { // expected-error{{an implicit initializer cannot return a ~Escapable result}}
55
}
66

77
@lifetime(copy ne) // expected-error{{'@lifetime' attribute is only valid when experimental feature LifetimeDependence is enabled}} expected-error{{expected declaration}}
8-
func derive(_ ne: NE) -> NE { // expected-error{{a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
8+
func derive(_ ne: NE) -> NE { // expected-error{{a function cannot return a ~Escapable result}}
99
ne
1010
}

test/Sema/lifetime_depend_nofeature.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
// Check that functions that require lifetime dependence are prohibited without the flag.
77

88
// Don't allow empty initialization.
9-
struct EmptyNonEscapable: ~Escapable {} // expected-error{{an implicit initializer with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
9+
struct EmptyNonEscapable: ~Escapable {} // expected-error{{an implicit initializer cannot return a ~Escapable result}}
1010

1111
// Don't allow non-Escapable return values.
12-
func neReturn(span: RawSpan) -> RawSpan { span } // expected-error{{a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
12+
func neReturn(span: RawSpan) -> RawSpan { span } // expected-error{{a function cannot return a ~Escapable result}}
1313

14-
func neInout(span: inout RawSpan) {} // expected-error{{a function with a ~Escapable 'inout' parameter requires '-enable-experimental-feature LifetimeDependence'}}
14+
func neInout(span: inout RawSpan) {} // expected-error{{a function cannot have a ~Escapable 'inout' parameter 'span'}}
1515

1616
struct S {
17-
func neReturn(span: RawSpan) -> RawSpan { span } // expected-error{{a method with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
17+
func neReturn(span: RawSpan) -> RawSpan { span } // expected-error{{a method cannot return a ~Escapable result}}
1818

19-
func neInout(span: inout RawSpan) {} // expected-error{{a method with a ~Escapable 'inout' parameter requires '-enable-experimental-feature LifetimeDependence'}}
19+
func neInout(span: inout RawSpan) {} // expected-error{{a method cannot have a ~Escapable 'inout' parameter 'span'}}
2020
}
2121

2222
class C {
23-
func neReturn(span: RawSpan) -> RawSpan { span } // expected-error{{a method with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
23+
func neReturn(span: RawSpan) -> RawSpan { span } // expected-error{{a method cannot return a ~Escapable result}}
2424

25-
func neInout(span: inout RawSpan) {} // expected-error{{a method with a ~Escapable 'inout' parameter requires '-enable-experimental-feature LifetimeDependence'}}
25+
func neInout(span: inout RawSpan) {} // expected-error{{a method cannot have a ~Escapable 'inout' parameter 'span'}}
2626
}

0 commit comments

Comments
 (0)