Skip to content

Commit 31739fb

Browse files
Remove the async_fn_in_trait lint
1 parent 67d984b commit 31739fb

34 files changed

+13
-194
lines changed

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ lint_associated_const_elided_lifetime = {$elided ->
2121
.suggestion = use the `'static` lifetime
2222
.note = cannot automatically infer `'static` because of other lifetimes in scope
2323
24-
lint_async_fn_in_trait = use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified
25-
.note = you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`
26-
.suggestion = you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change
27-
2824
lint_atomic_ordering_fence = memory fences cannot have `Relaxed` ordering
2925
.help = consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`
3026

compiler/rustc_lint/src/async_fn_in_trait.rs

Lines changed: 0 additions & 130 deletions
This file was deleted.

compiler/rustc_lint/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
// tidy-alphabetical-end
3737

3838
mod async_closures;
39-
mod async_fn_in_trait;
4039
pub mod builtin;
4140
mod context;
4241
mod dangling;
@@ -82,7 +81,6 @@ mod unqualified_local_imports;
8281
mod unused;
8382

8483
use async_closures::AsyncClosureUsage;
85-
use async_fn_in_trait::AsyncFnInTrait;
8684
use builtin::*;
8785
use dangling::*;
8886
use default_could_be_derived::DefaultCouldBeDerived;
@@ -238,7 +236,6 @@ late_lint_methods!(
238236
MissingDebugImplementations: MissingDebugImplementations,
239237
MissingDoc: MissingDoc,
240238
AsyncClosureUsage: AsyncClosureUsage,
241-
AsyncFnInTrait: AsyncFnInTrait,
242239
NonLocalDefinitions: NonLocalDefinitions::default(),
243240
ImplTraitOvercaptures: ImplTraitOvercaptures,
244241
IfLetRescope: IfLetRescope::default(),
@@ -604,6 +601,11 @@ fn register_builtins(store: &mut LintStore) {
604601
"converted into hard error, see issue #127323 \
605602
<https://github.com/rust-lang/rust/issues/127323> for more information",
606603
);
604+
store.register_removed(
605+
"async_fn_in_trait",
606+
"lint was relaxed since return-type notation is stabilized; \
607+
see <TODO> for more information",
608+
)
607609
}
608610

609611
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,20 +2100,6 @@ pub(crate) struct UnusedAllocationDiag;
21002100
#[diag(lint_unused_allocation_mut)]
21012101
pub(crate) struct UnusedAllocationMutDiag;
21022102

2103-
pub(crate) struct AsyncFnInTraitDiag {
2104-
pub sugg: Option<Vec<(Span, String)>>,
2105-
}
2106-
2107-
impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag {
2108-
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
2109-
diag.primary_message(fluent::lint_async_fn_in_trait);
2110-
diag.note(fluent::lint_note);
2111-
if let Some(sugg) = self.sugg {
2112-
diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect);
2113-
}
2114-
}
2115-
}
2116-
21172103
#[derive(LintDiagnostic)]
21182104
#[diag(lint_unit_bindings)]
21192105
pub(crate) struct UnitBindingsDiag {

tests/ui/async-await/in-trait/async-associated-types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ use std::fmt::Debug;
66
trait MyTrait<'a, 'b, T> where Self: 'a, T: Debug + Sized + 'b {
77
type MyAssoc;
88

9-
#[allow(async_fn_in_trait)]
109
async fn foo(&'a self, key: &'b T) -> Self::MyAssoc;
1110
}
1211

1312
impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
1413
type MyAssoc = (&'a U, &'b T);
1514

16-
#[allow(async_fn_in_trait)]
1715
async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
1816
(self, key)
1917
}

tests/ui/async-await/in-trait/async-default-fn-overridden.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
use std::future::Future;
55

66
trait AsyncTrait {
7-
#[allow(async_fn_in_trait)]
87
async fn default_impl() {
98
assert!(false);
109
}
1110

12-
#[allow(async_fn_in_trait)]
1311
async fn call_default_impl() {
1412
Self::default_impl().await
1513
}

tests/ui/async-await/in-trait/async-example-desugared-boxed.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::future::Future;
55
use std::pin::Pin;
66

7-
#[allow(async_fn_in_trait)]
87
pub trait MyTrait {
98
async fn foo(&self) -> i32;
109
}

tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: impl trait in impl method signature does not match trait method signature
2-
--> $DIR/async-example-desugared-boxed.rs:14:22
2+
--> $DIR/async-example-desugared-boxed.rs:13:22
33
|
44
LL | async fn foo(&self) -> i32;
55
| --------------------------- return type from trait method defined here
@@ -10,7 +10,7 @@ LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> {
1010
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
1111
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
1212
note: the lint level is defined here
13-
--> $DIR/async-example-desugared-boxed.rs:13:12
13+
--> $DIR/async-example-desugared-boxed.rs:12:12
1414
|
1515
LL | #[warn(refining_impl_trait)]
1616
| ^^^^^^^^^^^^^^^^^^^

tests/ui/async-await/in-trait/async-example-desugared-extra.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::pin::Pin;
66
use std::task::Poll;
77

88
pub trait MyTrait {
9-
#[allow(async_fn_in_trait)]
109
async fn foo(&self) -> i32;
1110
}
1211

tests/ui/async-await/in-trait/async-example-desugared-manual.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::future::Future;
55
use std::task::Poll;
66

7-
#[allow(async_fn_in_trait)]
87
pub trait MyTrait {
98
async fn foo(&self) -> i32;
109
}

0 commit comments

Comments
 (0)