From 7bb2d8b0765e6737f43b501135d91bc8ab64db7a Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sat, 31 Aug 2019 15:43:24 +0100 Subject: [PATCH] Slightly clean up the error for recursive `async fn` * Make it clear that type erasure is required, not just pointer indirection. * Don't make the message specific to direct recursion. --- src/librustc_typeck/check/mod.rs | 4 ++-- .../ui/async-await/recursive-async-impl-trait-type.stderr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index a80550486d62..7855008a2822 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1420,8 +1420,8 @@ fn check_opaque_for_cycles<'tcx>( tcx.sess, span, E0733, "recursion in an `async fn` requires boxing", ) - .span_label(span, "an `async fn` cannot invoke itself directly") - .note("a recursive `async fn` must be rewritten to return a boxed future.") + .span_label(span, "recursive `async fn`") + .note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`.") .emit(); } else { let mut err = struct_span_err!( diff --git a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr index 8781a9c444d0..9ee014021804 100644 --- a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr +++ b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr @@ -2,9 +2,9 @@ error[E0733]: recursion in an `async fn` requires boxing --> $DIR/recursive-async-impl-trait-type.rs:5:40 | LL | async fn recursive_async_function() -> () { - | ^^ an `async fn` cannot invoke itself directly + | ^^ recursive `async fn` | - = note: a recursive `async fn` must be rewritten to return a boxed future. + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`. error: aborting due to previous error