Fix misleading Lifetime diagnostics for inout parameters

Correctly diagnose this as:
"invalid use of inout dependence on the same inout parameter

    @_lifetime(a: &a)
    func f_inout_useless(a: inout MutableRawSpan) {}

Correctly diagnose this as:
"lifetime-dependent parameter must be 'inout'":

    @_lifetime(a: borrow a)
    func f_inout_useless(a: borrowing MutableRawSpan) {}

(cherry picked from commit 05fa82b7a7)
This commit is contained in:
Andrew Trick
2025-06-24 23:50:25 -07:00
parent e409752e00
commit fcbcc8c1e4
3 changed files with 3 additions and 2 deletions

View File

@@ -8244,7 +8244,7 @@ ERROR(lifetime_dependence_cannot_use_default_escapable_consuming, none,
"invalid lifetime dependence on an Escapable value with %0 ownership",
(StringRef))
ERROR(lifetime_dependence_cannot_use_parsed_borrow_inout, none,
"invalid use of borrow dependence on the same inout parameter",
"invalid use of inout dependence on the same inout parameter",
())
ERROR(lifetime_dependence_duplicate_target, none,
"invalid duplicate target lifetime dependencies on function", ())