diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index d4fafe38638a4..67337cd29b534 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -32,7 +32,7 @@ impl<'hir> LoweringContext<'_, 'hir> { pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> { ensure_sufficient_stack(|| { match &e.kind { - // Paranthesis expression does not have a HirId and is handled specially. + // Parenthesis expression does not have a HirId and is handled specially. ExprKind::Paren(ex) => { let mut ex = self.lower_expr_mut(ex); // Include parens in span, but only if it is a super-span. @@ -63,6 +63,20 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::ForLoop(pat, head, body, opt_label) => { return self.lower_expr_for(e, pat, head, body, *opt_label); } + // Similarly, async blocks do not use `e.id` but rather `closure_node_id`. + ExprKind::Async(capture_clause, closure_node_id, block) => { + let hir_id = self.lower_node_id(*closure_node_id); + self.lower_attrs(hir_id, &e.attrs); + return self.make_async_expr( + *capture_clause, + hir_id, + *closure_node_id, + None, + e.span, + hir::AsyncGeneratorKind::Block, + |this| this.with_new_scopes(|this| this.lower_block_expr(block)), + ); + } _ => (), } @@ -182,15 +196,6 @@ impl<'hir> LoweringContext<'_, 'hir> { self.arena.alloc_from_iter(arms.iter().map(|x| self.lower_arm(x))), hir::MatchSource::Normal, ), - ExprKind::Async(capture_clause, closure_node_id, block) => self.make_async_expr( - *capture_clause, - hir_id, - *closure_node_id, - None, - e.span, - hir::AsyncGeneratorKind::Block, - |this| this.with_new_scopes(|this| this.lower_block_expr(block)), - ), ExprKind::Await(expr) => { let dot_await_span = if expr.span.hi() < e.span.hi() { let span_with_whitespace = self @@ -324,7 +329,9 @@ impl<'hir> LoweringContext<'_, 'hir> { ), ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr), - ExprKind::Paren(_) | ExprKind::ForLoop(..) => unreachable!("already handled"), + ExprKind::Paren(_) | ExprKind::ForLoop(..) | ExprKind::Async(..) => { + unreachable!("already handled") + } ExprKind::MacCall(_) => panic!("{:?} shouldn't exist here", e.span), }; @@ -586,9 +593,9 @@ impl<'hir> LoweringContext<'_, 'hir> { /// This results in: /// /// ```text - /// std::future::identity_future(static move? |_task_context| -> { + /// static move? |_task_context| -> { /// - /// }) + /// } /// ``` pub(super) fn make_async_expr( &mut self, @@ -599,7 +606,7 @@ impl<'hir> LoweringContext<'_, 'hir> { span: Span, async_gen_kind: hir::AsyncGeneratorKind, body: impl FnOnce(&mut Self) -> hir::Expr<'hir>, - ) -> hir::ExprKind<'hir> { + ) -> hir::Expr<'hir> { let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span))); // Resume argument type: `ResumeTy` @@ -664,13 +671,12 @@ impl<'hir> LoweringContext<'_, 'hir> { }; let hir_id = self.lower_node_id(closure_node_id); - let unstable_span = - self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone()); - if self.tcx.features().closure_track_caller && let Some(attrs) = self.attrs.get(&outer_hir_id.local_id) && attrs.into_iter().any(|attr| attr.has_name(sym::track_caller)) { + let unstable_span = + self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone()); self.lower_attrs( hir_id, &[Attribute { @@ -689,22 +695,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ); } - let generator = hir::Expr { hir_id, kind: generator_kind, span: self.lower_span(span) }; - - // FIXME(swatinem): - // For some reason, the async block needs to flow through *any* - // call (like the identity function), as otherwise type and lifetime - // inference have a hard time figuring things out. - // Without this, we would get: - // E0720 in tests/ui/impl-trait/in-trait/default-body-with-rpit.rs - // E0700 in tests/ui/self/self_lifetime-async.rs - - // `future::identity_future`: - let identity_future = - self.expr_lang_item_path(unstable_span, hir::LangItem::IdentityFuture, None); - - // `future::identity_future(generator)`: - hir::ExprKind::Call(self.arena.alloc(identity_future), arena_vec![self; generator]) + hir::Expr { hir_id, kind: generator_kind, span: self.lower_span(span) } } /// Desugar `.await` into: @@ -1010,7 +1001,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } // Transform `async |x: u8| -> X { ... }` into - // `|x: u8| identity_future(|| -> X { ... })`. + // `|x: u8| || -> X { ... }`. let body_id = this.lower_fn_body(&outer_decl, |this| { let async_ret_ty = if let FnRetTy::Ty(ty) = &decl.output { let itctx = ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock); @@ -1019,7 +1010,7 @@ impl<'hir> LoweringContext<'_, 'hir> { None }; - let async_body = this.make_async_expr( + this.make_async_expr( capture_clause, closure_hir_id, inner_closure_id, @@ -1027,8 +1018,7 @@ impl<'hir> LoweringContext<'_, 'hir> { body.span, hir::AsyncGeneratorKind::Closure, |this| this.with_new_scopes(|this| this.lower_expr_mut(body)), - ); - this.expr(fn_decl_span, async_body) + ) }); body_id }); diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 41295f2b7b661..b69710f451979 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1180,7 +1180,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }, ); - (this.arena.alloc_from_iter(parameters), this.expr(body.span, async_expr)) + (this.arena.alloc_from_iter(parameters), async_expr) }) } diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 60fa5a99e103c..72ff317d45d6e 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -296,7 +296,6 @@ language_item_table! { // FIXME(swatinem): the following lang items are used for async lowering and // should become obsolete eventually. ResumeTy, sym::ResumeTy, resume_ty, Target::Struct, GenericRequirement::None; - IdentityFuture, sym::identity_future, identity_future_fn, Target::Fn, GenericRequirement::None; GetContext, sym::get_context, get_context_fn, Target::Fn, GenericRequirement::None; Context, sym::Context, context, Target::Struct, GenericRequirement::None; diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 6a0d5c01109df..ecbe4a97dd967 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -311,9 +311,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let fn_decl_span = if hir.body(body).generator_kind == Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure)) { - // Actually need to unwrap a few more layers of HIR to get to + // Actually need to unwrap one more layer of HIR to get to // the _real_ closure... - let async_closure = hir.parent_id(hir.parent_id(parent_hir_id)); + let async_closure = hir.parent_id(parent_hir_id); if let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }), .. diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 60e55c7b0cf57..3e8d4643f2756 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -928,12 +928,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir_id, kind: hir::ExprKind::Closure(..), .. - }) if let Some(Node::Expr(&hir::Expr { - hir_id, - kind: hir::ExprKind::Call(..), - .. - })) = self.tcx.hir().find_parent(hir_id) && - let Some(Node::Item(&hir::Item { + }) if let Some(Node::Item(&hir::Item { ident, kind: hir::ItemKind::Fn(ref sig, ..), .. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index fb579e4ff772a..18e47a13d77f4 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -791,7 +791,6 @@ symbols! { i64, i8, ident, - identity_future, if_let, if_let_guard, if_while_or_patterns, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 66d74fd05a67f..b6e70bd9e33e4 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3025,8 +3025,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } }; - let identity_future = tcx.require_lang_item(LangItem::IdentityFuture, None); - // Don't print the tuple of capture types 'print: { if !is_upvar_tys_infer_tuple { @@ -3039,12 +3037,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { None => err.note(&msg), }, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { - // Avoid printing the future from `core::future::identity_future`, it's not helpful - if tcx.parent(*def_id) == identity_future { - break 'print; - } - - // If the previous type is `identity_future`, this is the future generated by the body of an async function. + // If the previous type is async fn, this is the future generated by the body of an async function. // Avoid printing it twice (it was already printed in the `ty::Generator` arm below). let is_future = tcx.ty_is_opaque_future(ty); debug!( diff --git a/library/core/src/future/mod.rs b/library/core/src/future/mod.rs index 46cbcd43530d5..04f02d47f92cb 100644 --- a/library/core/src/future/mod.rs +++ b/library/core/src/future/mod.rs @@ -67,14 +67,10 @@ pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { unsafe { &mut *cx.0.as_ptr().cast() } } -// FIXME(swatinem): This fn is currently needed to work around shortcomings -// in type and lifetime inference. -// See the comment at the bottom of `LoweringContext::make_async_expr` and -// . #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] #[inline] -#[lang = "identity_future"] +#[cfg_attr(bootstrap, lang = "identity_future")] pub const fn identity_future>(f: Fut) -> Fut { f } diff --git a/src/tools/clippy/clippy_lints/src/manual_async_fn.rs b/src/tools/clippy/clippy_lints/src/manual_async_fn.rs index 3778eb4c732d7..f97c6bcb5d18c 100644 --- a/src/tools/clippy/clippy_lints/src/manual_async_fn.rs +++ b/src/tools/clippy/clippy_lints/src/manual_async_fn.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::match_function_call_with_def_id; use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt}; use if_chain::if_chain; use rustc_errors::Applicability; @@ -175,16 +174,10 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName]) fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) -> Option<&'tcx Body<'tcx>> { if_chain! { if let Some(block_expr) = block.expr; - if let Some(args) = cx - .tcx - .lang_items() - .identity_future_fn() - .and_then(|def_id| match_function_call_with_def_id(cx, block_expr, def_id)); - if args.len() == 1; if let Expr { kind: ExprKind::Closure(&Closure { body, .. }), .. - } = args[0]; + } = block_expr; let closure_body = cx.tcx.hir().body(body); if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block)); then { diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index f02f8ecb43d72..8edfd2eff7298 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -1904,16 +1904,7 @@ pub fn is_async_fn(kind: FnKind<'_>) -> bool { /// Peels away all the compiler generated code surrounding the body of an async function, pub fn get_async_fn_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Option<&'tcx Expr<'tcx>> { - if let ExprKind::Call( - _, - &[ - Expr { - kind: ExprKind::Closure(&Closure { body, .. }), - .. - }, - ], - ) = body.value.kind - { + if let ExprKind::Closure(&Closure { body, .. }) = body.value.kind { if let ExprKind::Block( Block { stmts: [], diff --git a/src/tools/clippy/tests/ui/author/blocks.stdout b/src/tools/clippy/tests/ui/author/blocks.stdout index c6acf24c21ecf..eb3e5189c8238 100644 --- a/src/tools/clippy/tests/ui/author/blocks.stdout +++ b/src/tools/clippy/tests/ui/author/blocks.stdout @@ -43,11 +43,7 @@ if let ExprKind::Block(block, None) = expr.kind if let ExprKind::Closure(CaptureBy::Value, fn_decl, body_id, _, None) = expr.kind && let FnRetTy::DefaultReturn(_) = fn_decl.output && expr1 = &cx.tcx.hir().body(body_id).value - && let ExprKind::Call(func, args) = expr1.kind - && let ExprKind::Path(ref qpath) = func.kind - && matches!(qpath, QPath::LangItem(LangItem::IdentityFuture, _)) - && args.len() == 1 - && let ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = args[0].kind + && let ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = expr1.kind && let FnRetTy::DefaultReturn(_) = fn_decl1.output && expr2 = &cx.tcx.hir().body(body_id1).value && let ExprKind::Block(block, None) = expr2.kind diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index ad4e5c6fcfd72..9ad8a70a2ce61 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -4,7 +4,7 @@ _0: GeneratorSavedTy { ty: impl std::future::Future, source_info: SourceInfo { - span: $DIR/async_await.rs:15:8: 15:14 (#9), + span: $DIR/async_await.rs:15:8: 15:14 (#8), scope: scope[0], }, ignore_for_traits: false, @@ -12,7 +12,7 @@ _1: GeneratorSavedTy { ty: impl std::future::Future, source_info: SourceInfo { - span: $DIR/async_await.rs:16:8: 16:14 (#12), + span: $DIR/async_await.rs:16:8: 16:14 (#11), scope: scope[0], }, ignore_for_traits: false, diff --git a/tests/ui/async-await/generator-desc.stderr b/tests/ui/async-await/generator-desc.stderr index 51ac9d86bfb47..042766f19ca90 100644 --- a/tests/ui/async-await/generator-desc.stderr +++ b/tests/ui/async-await/generator-desc.stderr @@ -2,16 +2,18 @@ error[E0308]: mismatched types --> $DIR/generator-desc.rs:10:19 | LL | fun(async {}, async {}); - | -------- ^^^^^^^^ - | | | - | | expected `async` block, found a different `async` block - | | arguments to this function are incorrect - | the expected `async` block + | --- -------- ^^^^^^^^ expected `async` block, found a different `async` block + | | | + | | the expected `async` block + | arguments to this function are incorrect | = note: expected `async` block `[async block@$DIR/generator-desc.rs:10:9: 10:17]` found `async` block `[async block@$DIR/generator-desc.rs:10:19: 10:27]` note: function defined here - --> $SRC_DIR/core/src/future/mod.rs:LL:COL + --> $DIR/generator-desc.rs:8:4 + | +LL | fn fun>(f1: F, f2: F) {} + | ^^^ ----- error[E0308]: mismatched types --> $DIR/generator-desc.rs:12:16 diff --git a/tests/ui/async-await/large_moves.attribute.stderr b/tests/ui/async-await/large_moves.attribute.stderr index 0c5452475a657..94f61caa25ddd 100644 --- a/tests/ui/async-await/large_moves.attribute.stderr +++ b/tests/ui/async-await/large_moves.attribute.stderr @@ -1,14 +1,8 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:13:13 + --> $DIR/large_moves.rs:19:14 | -LL | let x = async { - | _____________^ -LL | | let y = [0; 9999]; -LL | | dbg!(y); -LL | | thing(&y).await; -LL | | dbg!(y); -LL | | }; - | |_____^ value moved from here +LL | let z = (x, 42); + | ^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here @@ -17,14 +11,6 @@ note: the lint level is defined here LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ -error: moving 10024 bytes - --> $DIR/large_moves.rs:19:14 - | -LL | let z = (x, 42); - | ^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - error: moving 10024 bytes --> $DIR/large_moves.rs:19:13 | @@ -41,5 +27,5 @@ LL | let a = z.0; | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/async-await/large_moves.option.stderr b/tests/ui/async-await/large_moves.option.stderr index 0c5452475a657..94f61caa25ddd 100644 --- a/tests/ui/async-await/large_moves.option.stderr +++ b/tests/ui/async-await/large_moves.option.stderr @@ -1,14 +1,8 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:13:13 + --> $DIR/large_moves.rs:19:14 | -LL | let x = async { - | _____________^ -LL | | let y = [0; 9999]; -LL | | dbg!(y); -LL | | thing(&y).await; -LL | | dbg!(y); -LL | | }; - | |_____^ value moved from here +LL | let z = (x, 42); + | ^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here @@ -17,14 +11,6 @@ note: the lint level is defined here LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ -error: moving 10024 bytes - --> $DIR/large_moves.rs:19:14 - | -LL | let z = (x, 42); - | ^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - error: moving 10024 bytes --> $DIR/large_moves.rs:19:13 | @@ -41,5 +27,5 @@ LL | let a = z.0; | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/async-await/large_moves.rs b/tests/ui/async-await/large_moves.rs index d43d0eec0cabc..c8ed6bafe9c6d 100644 --- a/tests/ui/async-await/large_moves.rs +++ b/tests/ui/async-await/large_moves.rs @@ -10,7 +10,7 @@ // compile-flags: -Zmir-opt-level=0 fn main() { - let x = async { //~ ERROR large_assignments + let x = async { let y = [0; 9999]; dbg!(y); thing(&y).await; diff --git a/tests/ui/async-await/no-const-async.rs b/tests/ui/async-await/no-const-async.rs index cfb0ef1b33a2b..b3c59734e036f 100644 --- a/tests/ui/async-await/no-const-async.rs +++ b/tests/ui/async-await/no-const-async.rs @@ -3,4 +3,3 @@ pub const async fn x() {} //~^ ERROR functions cannot be both `const` and `async` -//~| ERROR cycle detected diff --git a/tests/ui/async-await/no-const-async.stderr b/tests/ui/async-await/no-const-async.stderr index 71c228958f6fd..90ec646c8c09c 100644 --- a/tests/ui/async-await/no-const-async.stderr +++ b/tests/ui/async-await/no-const-async.stderr @@ -7,36 +7,5 @@ LL | pub const async fn x() {} | | `async` because of this | `const` because of this -error[E0391]: cycle detected when computing type of `x::{opaque#0}` - --> $DIR/no-const-async.rs:4:24 - | -LL | pub const async fn x() {} - | ^ - | -note: ...which requires borrow-checking `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `x::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `x::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `x::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/async-await/track-caller/async-block.rs b/tests/ui/async-await/track-caller/async-block.rs index 8e81387c34bd0..8ddd4ab118615 100644 --- a/tests/ui/async-await/track-caller/async-block.rs +++ b/tests/ui/async-await/track-caller/async-block.rs @@ -1,9 +1,9 @@ // edition:2021 -#![feature(closure_track_caller, stmt_expr_attributes)] +#![feature(stmt_expr_attributes)] fn main() { let _ = #[track_caller] async { - //~^ ERROR attribute should be applied to a function definition [E0739] + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] }; } diff --git a/tests/ui/async-await/track-caller/async-block.stderr b/tests/ui/async-await/track-caller/async-block.stderr index 407439921c0d4..21d1054d22066 100644 --- a/tests/ui/async-await/track-caller/async-block.stderr +++ b/tests/ui/async-await/track-caller/async-block.stderr @@ -1,12 +1,12 @@ -error[E0739]: attribute should be applied to a function definition +error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/async-block.rs:6:13 | -LL | let _ = #[track_caller] async { - | _____________^^^^^^^^^^^^^^^_- -LL | | -LL | | }; - | |_____- not a function definition +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable error: aborting due to previous error -For more information about this error, try `rustc --explain E0739`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/panic-track-caller.rs b/tests/ui/async-await/track-caller/panic-track-caller.rs index f45243b0ea6f5..65bb23e0b4b9e 100644 --- a/tests/ui/async-await/track-caller/panic-track-caller.rs +++ b/tests/ui/async-await/track-caller/panic-track-caller.rs @@ -79,6 +79,16 @@ async fn foo_closure() { c().await } +// Since compilation is expected to fail for this fn when using +// `nofeat`, we test that separately in `async-block.rs` +#[cfg(feat)] +async fn foo_block() { + let a = #[track_caller] async { + panic!(); + }; + a.await +} + fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 { let loc = Arc::new(Mutex::new(None)); @@ -110,4 +120,7 @@ fn main() { #[cfg(feat)] assert_eq!(panicked_at(|| block_on(foo_closure())), 79); + + #[cfg(feat)] + assert_eq!(panicked_at(|| block_on(foo_block())), 89); } diff --git a/tests/ui/chalkify/bugs/async.rs b/tests/ui/chalkify/bugs/async.rs index 3169e4781ee2e..a1ef4732b6313 100644 --- a/tests/ui/chalkify/bugs/async.rs +++ b/tests/ui/chalkify/bugs/async.rs @@ -4,7 +4,7 @@ // compile-flags:-Z trait-solver=chalk // error-pattern:internal compiler error // failure-status:101 -// normalize-stderr-test "DefId([^)]*)" -> "..." +// normalize-stderr-test "DefId\([^)]*\)" -> "..." // normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" // normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" diff --git a/tests/ui/chalkify/bugs/async.stderr b/tests/ui/chalkify/bugs/async.stderr index 8043f1e5a0582..9c559640b2308 100644 --- a/tests/ui/chalkify/bugs/async.stderr +++ b/tests/ui/chalkify/bugs/async.stderr @@ -1,33 +1,3 @@ -error[E0277]: `[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future - --> $DIR/async.rs:23:29 - | -LL | async fn foo(x: u32) -> u32 { - | _____________________________- -LL | | x -LL | | } - | | ^ - | | | - | |_`[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future - | required by a bound introduced by this call - | - = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:23:29: 25:2]` - = note: [async fn body@$DIR/async.rs:23:29: 25:2] must be a future or must implement `IntoFuture` to be awaited -note: required by a bound in `identity_future` - --> $SRC_DIR/core/src/future/mod.rs:LL:COL - -error[E0277]: the size for values of type `<[async fn body@$DIR/async.rs:23:29: 25:2] as Future>::Output` cannot be known at compilation time - --> $DIR/async.rs:23:29 - | -LL | async fn foo(x: u32) -> u32 { - | _____________________________^ -LL | | x -LL | | } - | |_^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `<[async fn body@$DIR/async.rs:23:29: 25:2] as Future>::Output` -note: required by a bound in `identity_future` - --> $SRC_DIR/core/src/future/mod.rs:LL:COL - error[E0277]: `[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future --> $DIR/async.rs:23:25 | @@ -37,7 +7,7 @@ LL | async fn foo(x: u32) -> u32 { = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:23:29: 25:2]` = note: [async fn body@$DIR/async.rs:23:29: 25:2] must be a future or must implement `IntoFuture` to be awaited -error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:23:29: 25:2]], def_id: ...) }, Term::Ty(u32)), []), depth=0)` +error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:23:29: 25:2]], def_id: ... }, Term::Ty(u32)), []), depth=0)` --> $DIR/async.rs:23:25 | LL | async fn foo(x: u32) -> u32 { @@ -53,6 +23,6 @@ LL | async fn foo(x: u32) -> u32 { #8 [check_mod_item_types] checking item types in top-level module #9 [analysis] running analysis passes on this crate end of query stack -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs index a8d63a8145a2a..a4c91f3bc1880 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs @@ -1,7 +1,9 @@ +// edition:2021 #![feature(stmt_expr_attributes)] #![feature(generators)] fn main() { let _closure = #[track_caller] || {}; //~ `#[track_caller]` on closures let _generator = #[track_caller] || { yield; }; //~ `#[track_caller]` on closures + let _future = #[track_caller] async {}; //~ `#[track_caller]` on closures } diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr index ed63d74fe4d4e..cf2ea5fe1cac3 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr @@ -1,5 +1,5 @@ error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/feature-gate-closure_track_caller.rs:5:20 + --> $DIR/feature-gate-closure_track_caller.rs:6:20 | LL | let _closure = #[track_caller] || {}; | ^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _closure = #[track_caller] || {}; = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/feature-gate-closure_track_caller.rs:6:22 + --> $DIR/feature-gate-closure_track_caller.rs:7:22 | LL | let _generator = #[track_caller] || { yield; }; | ^^^^^^^^^^^^^^^ @@ -16,6 +16,15 @@ LL | let _generator = #[track_caller] || { yield; }; = note: see issue #87417 for more information = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/feature-gate-closure_track_caller.rs:8:19 + | +LL | let _future = #[track_caller] async {}; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs index ad3cc7c2524b9..0558d95128f4a 100644 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -1,5 +1,5 @@ -// check-pass // edition:2021 +// known-bug: #108304 #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.stderr new file mode 100644 index 0000000000000..b5fc9d44d3687 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.stderr @@ -0,0 +1,24 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/default-body-with-rpit.rs:11:9 + | +LL | "" + | ^^ expected `impl Debug`, got `&'static str` + | +note: previous use here + --> $DIR/default-body-with-rpit.rs:10:39 + | +LL | async fn baz(&self) -> impl Debug { + | _______________________________________^ +LL | | "" +LL | | } + | |_____^ + +error[E0720]: cannot resolve opaque type + --> $DIR/default-body-with-rpit.rs:10:28 + | +LL | async fn baz(&self) -> impl Debug { + | ^^^^^^^^^^ cannot resolve opaque type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/issues/issue-78722.rs b/tests/ui/impl-trait/issues/issue-78722.rs index 78233f300bdd0..7b5ab5f229835 100644 --- a/tests/ui/impl-trait/issues/issue-78722.rs +++ b/tests/ui/impl-trait/issues/issue-78722.rs @@ -12,7 +12,6 @@ struct Bug { } let f: F = async { 1 }; //~^ ERROR `async` blocks are not allowed in constants - //~| ERROR destructor of 1 }], } diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index c00df8087e895..05a2c135cf7c7 100644 --- a/tests/ui/impl-trait/issues/issue-78722.stderr +++ b/tests/ui/impl-trait/issues/issue-78722.stderr @@ -7,22 +7,13 @@ LL | let f: F = async { 1 }; = note: see issue #85368 for more information = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable -error[E0493]: destructor of `F` cannot be evaluated at compile-time - --> $DIR/issue-78722.rs:13:13 - | -LL | let f: F = async { 1 }; - | ^ the destructor for this type cannot be evaluated in constants -... -LL | }], - | - value is dropped here - error[E0271]: expected `[async block@$DIR/issue-78722.rs:11:13: 11:21]` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { | ^ expected `()`, found `u8` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0271, E0493, E0658. +Some errors have detailed explanations: E0271, E0658. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/parser/fn-header-semantic-fail.rs b/tests/ui/parser/fn-header-semantic-fail.rs index cf5d3dab4aada..71f18a27e7c11 100644 --- a/tests/ui/parser/fn-header-semantic-fail.rs +++ b/tests/ui/parser/fn-header-semantic-fail.rs @@ -11,7 +11,6 @@ fn main() { extern "C" fn ff4() {} // OK. const async unsafe extern "C" fn ff5() {} //~^ ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected trait X { async fn ft1(); //~ ERROR functions in traits cannot be declared `async` @@ -34,7 +33,6 @@ fn main() { //~^ ERROR functions in traits cannot be declared `async` //~| ERROR functions in traits cannot be declared const //~| ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected } impl Y { @@ -44,7 +42,6 @@ fn main() { extern "C" fn fi4() {} // OK. const async unsafe extern "C" fn fi5() {} //~^ ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected } extern "C" { diff --git a/tests/ui/parser/fn-header-semantic-fail.stderr b/tests/ui/parser/fn-header-semantic-fail.stderr index 2d8bd19a73108..7f7b7e835f824 100644 --- a/tests/ui/parser/fn-header-semantic-fail.stderr +++ b/tests/ui/parser/fn-header-semantic-fail.stderr @@ -8,19 +8,19 @@ LL | const async unsafe extern "C" fn ff5() {} | `const` because of this error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:19:9 + --> $DIR/fn-header-semantic-fail.rs:18:9 | LL | const fn ft3(); | ^^^^^ functions in traits cannot be const error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^ functions in traits cannot be const error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^-^^^^^---------------------------- @@ -29,19 +29,19 @@ LL | const async unsafe extern "C" fn ft5(); | `const` because of this error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:31:9 + --> $DIR/fn-header-semantic-fail.rs:30:9 | LL | const fn ft3() {} | ^^^^^ functions in traits cannot be const error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:33:9 + --> $DIR/fn-header-semantic-fail.rs:32:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^ functions in traits cannot be const error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:33:9 + --> $DIR/fn-header-semantic-fail.rs:32:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^-^^^^^------------------------------ @@ -50,7 +50,7 @@ LL | const async unsafe extern "C" fn ft5() {} | `const` because of this error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:45:9 + --> $DIR/fn-header-semantic-fail.rs:43:9 | LL | const async unsafe extern "C" fn fi5() {} | ^^^^^-^^^^^------------------------------ @@ -59,7 +59,7 @@ LL | const async unsafe extern "C" fn fi5() {} | `const` because of this error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:51:18 + --> $DIR/fn-header-semantic-fail.rs:48:18 | LL | extern "C" { | ---------- in this `extern` block @@ -72,7 +72,7 @@ LL | fn fe1(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:52:19 + --> $DIR/fn-header-semantic-fail.rs:49:19 | LL | extern "C" { | ---------- in this `extern` block @@ -86,7 +86,7 @@ LL | fn fe2(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:53:18 + --> $DIR/fn-header-semantic-fail.rs:50:18 | LL | extern "C" { | ---------- in this `extern` block @@ -100,7 +100,7 @@ LL | fn fe3(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:54:23 + --> $DIR/fn-header-semantic-fail.rs:51:23 | LL | extern "C" { | ---------- in this `extern` block @@ -114,7 +114,7 @@ LL | fn fe4(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:55:42 + --> $DIR/fn-header-semantic-fail.rs:52:42 | LL | extern "C" { | ---------- in this `extern` block @@ -128,7 +128,7 @@ LL | fn fe5(); | ~~ error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:55:9 + --> $DIR/fn-header-semantic-fail.rs:52:9 | LL | const async unsafe extern "C" fn fe5(); | ^^^^^-^^^^^---------------------------- @@ -137,7 +137,7 @@ LL | const async unsafe extern "C" fn fe5(); | `const` because of this error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:17:9 + --> $DIR/fn-header-semantic-fail.rs:16:9 | LL | async fn ft1(); | -----^^^^^^^^^^ @@ -150,7 +150,7 @@ LL | async fn ft1(); = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | const async unsafe extern "C" fn ft5(); = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:29:9 + --> $DIR/fn-header-semantic-fail.rs:28:9 | LL | async fn ft1() {} | -----^^^^^^^^^ @@ -176,7 +176,7 @@ LL | async fn ft1() {} = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:33:9 + --> $DIR/fn-header-semantic-fail.rs:32:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -188,115 +188,7 @@ LL | const async unsafe extern "C" fn ft5() {} = note: see issue #91611 for more information = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable -error[E0391]: cycle detected when computing type of `main::ff5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:12:44 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^ - | -note: ...which requires borrow-checking `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `main::ff5::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `main::ff5::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `main::ff5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error[E0391]: cycle detected when computing type of `main::::ft5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:33:48 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^ - | -note: ...which requires borrow-checking `main::::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `main::::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `main::::ft5::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `main::::ft5::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `main::::ft5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error[E0391]: cycle detected when computing type of `main::::fi5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:45:48 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^ - | -note: ...which requires borrow-checking `main::::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `main::::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `main::::fi5::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `main::::fi5::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `main::::fi5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error: aborting due to 21 previous errors +error: aborting due to 18 previous errors -Some errors have detailed explanations: E0379, E0391, E0706. +Some errors have detailed explanations: E0379, E0706. For more information about an error, try `rustc --explain E0379`. diff --git a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 90ea062395283..b827beb504d5c 100644 --- a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -69,18 +69,15 @@ note: required by a bound in `Pin::

::new` error[E0308]: mismatched types --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5 | +LL | fn zap() -> BoxFuture<'static, i32> { + | ----------------------- expected `Pin + Send + 'static)>>` because of return type LL | / async { LL | | 42 LL | | } - | | ^ - | | | - | |_____expected `Pin>`, found `async` block - | arguments to this function are incorrect + | |_____^ expected `Pin>`, found `async` block | - = note: expected struct `Pin + Send>>` + = note: expected struct `Pin + Send + 'static)>>` found `async` block `[async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6]` -note: function defined here - --> $SRC_DIR/core/src/future/mod.rs:LL:COL help: you need to pin and box this expression | LL ~ Box::pin(async {