Skip to content

Commit

Permalink
Merge pull request #1601 from rust-lang/TC/lifetime-capture-rules-2024
Browse files Browse the repository at this point in the history
Add Lifetime Capture Rules 2024
  • Loading branch information
ehuss authored Nov 25, 2024
2 parents 63b590a + 3a8bef7 commit 3b28797
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/types/impl-trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,10 @@ Behind each return-position `impl Trait` abstract type is some hidden concrete t
r[type.impl-trait.generic-capture.auto]

r[type.impl-trait.generic-capture.auto.intro]
Return-position `impl Trait` abstract types automatically capture certain of the in-scope generic parameters. Everywhere, these automatically capture all in-scope type and const generic parameters.
Return-position `impl Trait` abstract types automatically capture all in-scope generic parameters, including generic type, const, and lifetime parameters (including higher-ranked ones).

r[type.impl-trait.generic-capture.auto.trait]
On items of trait impls and trait definitions, these types additionally automatically capture all in-scope generic lifetime parameters, including higher-ranked ones\1

r[type.impl-trait.generic-capture.auto.fn]
On free functions and on associated functions and methods of inherent impls, only the generic lifetime parameters that appear in the bounds of abstract return type are captured.
r[type.impl-trait.generic-capture.edition2024]
> **Edition differences**: Before the 2024 edition, on free functions and on associated functions and methods of inherent impls, generic lifetime parameters that do not appear in the bounds of the abstract return type are not automatically captured.
## Precise capturing

Expand Down

0 comments on commit 3b28797

Please sign in to comment.