From 89e1d956ef074b4599334020f68182489ad286d5 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 26 Jun 2025 15:34:11 -0700 Subject: [PATCH] Revert "Fix a compiler crash with '@'_lifetime(inout x), add diagnostic" This reverts commit 080b68292d0cfcd95b2c15bad5b0da4b9774627e. --- include/swift/AST/DiagnosticsParse.def | 2 +- lib/Parse/ParseDecl.cpp | 6 ------ test/Parse/lifetime_attr.swift | 2 +- test/Sema/lifetime_depend_infer.swift | 5 ----- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def index b60a0333d08e1..a7062f6d8fedc 100644 --- a/include/swift/AST/DiagnosticsParse.def +++ b/include/swift/AST/DiagnosticsParse.def @@ -2147,7 +2147,7 @@ ERROR(expected_lparen_after_lifetime_dependence, PointsToFirstBadToken, ERROR(expected_identifier_or_index_or_self_after_lifetime_dependence, PointsToFirstBadToken, - "expected 'copy', 'borrow', or '&' followed by an identifier, index or 'self' in lifetime dependence specifier", + "expected identifier, index or self in lifetime dependence specifier", ()) ERROR(expected_rparen_after_lifetime_dependence, PointsToFirstBadToken, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 0d217b191d114..2ccab361f60a7 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -5014,7 +5014,6 @@ ParserResult Parser::parseLifetimeEntry(SourceLoc loc) { SmallVector sources; SourceLoc rParenLoc; bool foundParamId = false; - bool invalidSourceDescriptor = false; status = parseList( tok::r_paren, lParenLoc, rParenLoc, /*AllowSepAfterLast=*/false, diag::expected_rparen_after_lifetime_dependence, [&]() -> ParserStatus { @@ -5031,7 +5030,6 @@ ParserResult Parser::parseLifetimeEntry(SourceLoc loc) { auto sourceDescriptor = parseLifetimeDescriptor(*this, lifetimeDependenceKind); if (!sourceDescriptor) { - invalidSourceDescriptor = true; listStatus.setIsParseError(); return listStatus; } @@ -5039,10 +5037,6 @@ ParserResult Parser::parseLifetimeEntry(SourceLoc loc) { return listStatus; }); - if (invalidSourceDescriptor) { - status.setIsParseError(); - return status; - } if (!foundParamId) { diagnose( Tok, diff --git a/test/Parse/lifetime_attr.swift b/test/Parse/lifetime_attr.swift index d679b0c4b6a32..091ca62ad2ef1 100644 --- a/test/Parse/lifetime_attr.swift +++ b/test/Parse/lifetime_attr.swift @@ -24,7 +24,7 @@ func testMissingLParenError(_ ne: NE) -> NE { // expected-error{{cannot infer th ne } -@_lifetime() // expected-error{{expected 'copy', 'borrow', or '&' followed by an identifier, index or 'self' in lifetime dependence specifier}} +@_lifetime() // expected-error{{expected identifier, index or self in lifetime dependence specifier}} func testMissingDependence(_ ne: NE) -> NE { // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}} ne } diff --git a/test/Sema/lifetime_depend_infer.swift b/test/Sema/lifetime_depend_infer.swift index 7997c5240bf0f..62be7d92f2897 100644 --- a/test/Sema/lifetime_depend_infer.swift +++ b/test/Sema/lifetime_depend_infer.swift @@ -591,11 +591,6 @@ func f_inout_no_infer(a: inout MutNE, b: NE) {} // expected-error @-1{{a function with a ~Escapable 'inout' parameter requires '@_lifetime(a: ...)'}} // expected-note @-2{{use '@_lifetime(a: copy a) to forward the inout dependency}} -// Invalid keyword for the dependence kind. -// -@_lifetime(a: inout a) // expected-error{{expected 'copy', 'borrow', or '&' followed by an identifier, index or 'self' in lifetime dependence specifier}} -func f_inout_bad_keyword(a: inout MutableRawSpan) {} - // Don't allow a useless borrow dependency on an inout param--it is misleading. // @_lifetime(a: &a) // expected-error{{invalid use of inout dependence on the same inout parameter}}