You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In RFC 3498, we decided to capture all in-scope generic parameters in RPIT-like impl Trait opaque types, across all editions, for new features we were stabilizing such as return position impl Trait in Trait (RPITIT) and associated type position impl Trait (ATPIT), and to capture all in-scope generic parameters for RPIT on bare functions and on inherent functions and methods starting in the Rust 2024 edition. Doing this made the language more predictable and consistent, eliminated weird “tricks”, and, by solving key problems, allowed for the stabilization of RPITIT.
The new default behavior is "capture all generics that are in-scope." The use<...> clause below can be used to limit what gets captured.
Capturing an additional type parameter in function/method
implemented?
Witness:
// The old `foo` implementationfnfoo_old<T>(_:T) -> impluse<> Sized{}fnfoo<T>(_:T) -> implSized{}// ^^^^^^^^^^// ^ The returned opaque type captures `T`// but the hidden type does not.fnbar(x:()) -> implSized + 'static{foo(&x)//~^ ERROR returns a value referencing data owned by the//~| current function}
Capturing an additional lifetime/type/const parameter in non-sealed trait function
implemented?
Witness: trait implementations must update their capture definition to match
Capturing an additional type parameter in externally-callable trait function, regardless of whether the trait is sealed
implemented?
Note: will need to be implemented only over sealed traits, to avoid conflicting with the "any parameter in unsealed trait" rule immediately above.
Witness: Same as "additional type in function/method."
Removing the capture of a lifetime/type/const parameter in non-sealed trait function
implemented?
Witness: trait implementations must update their capture definition to match
The text was updated successfully, but these errors were encountered:
rustdoc-types
v0.28)From the RFC:
The new default behavior is "capture all generics that are in-scope." The
use<...>
clause below can be used to limit what gets captured.Examples of the feature:
Breaking changes
Capturing an additional type parameter in function/method
Witness:
Capturing an additional lifetime/type/const parameter in non-sealed trait function
Witness: trait implementations must update their capture definition to match
Capturing an additional type parameter in externally-callable trait function, regardless of whether the trait is sealed
Note: will need to be implemented only over sealed traits, to avoid conflicting with the "any parameter in unsealed trait" rule immediately above.
Witness: Same as "additional type in function/method."
Removing the capture of a lifetime/type/const parameter in non-sealed trait function
Witness: trait implementations must update their capture definition to match
The text was updated successfully, but these errors were encountered: