@@ -651,37 +651,39 @@ class LifetimeDependenceChecker {
651
651
652
652
case ParsedLifetimeDependenceKind::Borrow: LLVM_FALLTHROUGH;
653
653
case ParsedLifetimeDependenceKind::Inout: {
654
- // @lifetime(borrow x) is valid only for borrowing parameters.
655
- // @lifetime(inout x) is valid only for inout parameters.
656
- if (!isCompatibleWithOwnership (parsedLifetimeKind, type, loweredOwnership,
657
- isInterfaceFile ())) {
658
- diagnose (loc,
659
- diag::lifetime_dependence_cannot_use_parsed_borrow_consuming,
660
- getNameForParsedLifetimeDependenceKind (parsedLifetimeKind),
661
- getOwnershipSpelling (loweredOwnership));
662
- return std::nullopt;
663
- }
664
- return LifetimeDependenceKind::Scope;
665
- }
666
- case ParsedLifetimeDependenceKind::Inherit:
667
- // @lifetime(copy x) is only invalid for Escapable types.
668
- if (type->isEscapable ()) {
669
- if (loweredOwnership == ValueOwnership::Shared) {
670
- diagnose (loc, diag::lifetime_dependence_invalid_inherit_escapable_type,
671
- descriptor.getString (), " borrow " );
672
- } else if (loweredOwnership == ValueOwnership::InOut) {
673
- diagnose (loc, diag::lifetime_dependence_invalid_inherit_escapable_type,
674
- descriptor.getString (), " &" );
675
- } else {
654
+ // @lifetime(borrow x) is valid only for borrowing parameters.
655
+ // @lifetime(&x) is valid only for inout parameters.
656
+ if (!isCompatibleWithOwnership (parsedLifetimeKind, type, loweredOwnership,
657
+ isInterfaceFile ())) {
676
658
diagnose (
659
+ loc,
660
+ diag::lifetime_dependence_cannot_use_parsed_borrow_consuming,
661
+ getNameForParsedLifetimeDependenceKind (parsedLifetimeKind),
662
+ getOwnershipSpelling (loweredOwnership));
663
+ return std::nullopt;
664
+ }
665
+ return LifetimeDependenceKind::Scope;
666
+ }
667
+ case ParsedLifetimeDependenceKind::Inherit: {
668
+ // @lifetime(copy x) is only invalid for Escapable types.
669
+ if (type->isEscapable ()) {
670
+ if (loweredOwnership == ValueOwnership::Shared) {
671
+ diagnose (loc, diag::lifetime_dependence_invalid_inherit_escapable_type,
672
+ descriptor.getString (), " borrow " );
673
+ } else if (loweredOwnership == ValueOwnership::InOut) {
674
+ diagnose (loc, diag::lifetime_dependence_invalid_inherit_escapable_type,
675
+ descriptor.getString (), " &" );
676
+ } else {
677
+ diagnose (
677
678
loc,
678
679
diag::lifetime_dependence_cannot_use_default_escapable_consuming,
679
680
getOwnershipSpelling (loweredOwnership));
681
+ }
682
+ return std::nullopt;
680
683
}
681
- return std::nullopt;
684
+ return LifetimeDependenceKind::Inherit;
685
+ }
682
686
}
683
- return LifetimeDependenceKind::Inherit;
684
- }
685
687
}
686
688
687
689
// Finds the ParamDecl* and its index from a LifetimeDescriptor
0 commit comments