Add use<> markers for edition 2024 compatibility

By default, edition 2024 will capture all types and lifetimes present in
the function signature when using RPIT, while edition 2021 will capture
only the lifetimes present in the RPIT itself. Adding explicit `use<>`
markers will disable the edition-specific automatic rules when they
differ.
This commit is contained in:
Samuel Tardieu 2025-04-13 10:33:29 +02:00
parent 443547425d
commit 20649a87d1
2 changed files with 6 additions and 6 deletions

View file

@ -75,7 +75,7 @@ impl S {
async fn elided(_: &i32) -> i32 { 42 }
// should be ignored
fn elided_not_bound(_: &i32) -> impl Future<Output = i32> {
fn elided_not_bound(_: &i32) -> impl Future<Output = i32> + use<> {
async { 42 }
}
@ -84,7 +84,7 @@ async fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> i32 { 42 }
// should be ignored
#[allow(clippy::needless_lifetimes)]
fn explicit_not_bound<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> {
fn explicit_not_bound<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + use<> {
async { 42 }
}
@ -94,7 +94,7 @@ mod issue_5765 {
struct A;
impl A {
fn f(&self) -> impl Future<Output = ()> {
fn f(&self) -> impl Future<Output = ()> + use<> {
async {}
}
}

View file

@ -102,7 +102,7 @@ fn elided(_: &i32) -> impl Future<Output = i32> + '_ {
}
// should be ignored
fn elided_not_bound(_: &i32) -> impl Future<Output = i32> {
fn elided_not_bound(_: &i32) -> impl Future<Output = i32> + use<> {
async { 42 }
}
@ -114,7 +114,7 @@ fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + 'a +
// should be ignored
#[allow(clippy::needless_lifetimes)]
fn explicit_not_bound<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> {
fn explicit_not_bound<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + use<> {
async { 42 }
}
@ -124,7 +124,7 @@ mod issue_5765 {
struct A;
impl A {
fn f(&self) -> impl Future<Output = ()> {
fn f(&self) -> impl Future<Output = ()> + use<> {
async {}
}
}