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
Fill in prose to describe the async_fn_in_trait lint
We're stabilizing `async fn` in trait (AFIT), but we have some
reservations about how people might use this in the definitions of
publicly-visible traits, so we're going to lint about that.
This is a bit of an odd lint for `rustc`. We normally don't lint just
to have people confirm that they understand how Rust works. But in
this one exceptional case, this seems like the right thing to do as
compared to the other plausible alternatives.
In this commit, we describe the nature of this odd lint.
Copy file name to clipboardexpand all lines: compiler/rustc_lint/messages.ftl
+3-3
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@ lint_array_into_iter =
5
5
.use_explicit_into_iter_suggestion =
6
6
or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
7
7
8
-
lint_async_fn_in_trait = usage of `async fn` in trait is discouraged because they do not automatically have auto trait bounds
9
-
.note = you can suppress this lint if you plan to use the trait locally, for concrete types, or do not care about auto traits like `Send` on the future
10
-
.suggestion = you can alternatively desugar the `async fn` and any add additional traits such as `Send` to the signature
8
+
lint_async_fn_in_trait = use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified
9
+
.note = you can suppress this lint if you plan to use the trait locally, for concrete types, or do not care about auto traits like `Send` on the `Future`
10
+
.suggestion = you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`
11
11
12
12
lint_atomic_ordering_fence = memory fences cannot have `Relaxed` ordering
13
13
.help = consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`
Copy file name to clipboardexpand all lines: tests/ui/async-await/in-trait/warn.stderr
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
-
error: usage of `async fn` in trait is discouraged because they do not automatically have auto trait bounds
1
+
error: use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified
2
2
--> $DIR/warn.rs:7:5
3
3
|
4
4
LL | async fn not_send();
5
5
| ^^^^^
6
6
|
7
-
= note: you can suppress this lint if you plan to use the trait locally, for concrete types, or do not care about auto traits like `Send` on the future
7
+
= note: you can suppress this lint if you plan to use the trait locally, for concrete types, or do not care about auto traits like `Send` on the `Future`
8
8
note: the lint level is defined here
9
9
--> $DIR/warn.rs:4:9
10
10
|
11
11
LL | #![deny(async_fn_in_trait)]
12
12
| ^^^^^^^^^^^^^^^^^
13
-
help: you can alternatively desugar the `async fn` and any add additional traits such as `Send` to the signature
13
+
help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`
0 commit comments