diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 858a2f21c6b75..5c939cbe773cb 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -713,6 +713,40 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { }) } + fn pretty_print_closure_inner( + &mut self, + did: DefId, + args: ty::GenericArgsRef<'tcx>, + ) -> Result<(), PrintError> { + if self.should_truncate() { + write!(self, "@...") + } else if self.tcx().sess.opts.unstable_opts.span_free_formats { + write!(self, "@")?; + self.print_def_path(did, args) + } else if let Some(did) = did.as_local() { + let span = self.tcx().def_span(did); + let loc = if with_forced_trimmed_paths() { + self.tcx() + .sess + .source_map() + .span_to_short_string(span, RemapPathScopeComponents::DIAGNOSTICS) + } else { + self.tcx().sess.source_map().span_to_diagnostic_string(span) + }; + write!( + self, + "@{}", + // This may end up in stderr diagnostics but it may also be + // emitted into MIR. Hence we use the remapped path if + // available + loc + ) + } else { + write!(self, "@")?; + self.print_def_path(did, args) + } + } + fn pretty_print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { match *ty.kind() { ty::Bool => write!(self, "bool")?, @@ -904,22 +938,12 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // // This will look like: // {async fn body of some_fn()} - let did_of_the_fn_item = self.tcx().parent(did); write!(self, " of ")?; + let did_of_the_fn_item = self.tcx().parent(did); self.print_def_path(did_of_the_fn_item, args)?; write!(self, "()")?; - } else if let Some(local_did) = did.as_local() { - let span = self.tcx().def_span(local_did); - write!( - self, - "@{}", - // This may end up in stderr diagnostics but it may also be emitted - // into MIR. Hence we use the remapped path if available - self.tcx().sess.source_map().span_to_diagnostic_string(span) - )?; } else { - write!(self, "@")?; - self.print_def_path(did, args)?; + self.pretty_print_closure_inner(did, args)?; } } else { self.print_def_path(did, args)?; @@ -937,63 +961,19 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { } ty::CoroutineWitness(did, args) => { write!(self, "{{")?; - if !self.tcx().sess.verbose_internals() { + if !self.should_print_verbose() { write!(self, "coroutine witness")?; - if let Some(did) = did.as_local() { - let span = self.tcx().def_span(did); - write!( - self, - "@{}", - // This may end up in stderr diagnostics but it may also be emitted - // into MIR. Hence we use the remapped path if available - self.tcx().sess.source_map().span_to_diagnostic_string(span) - )?; - } else { - write!(self, "@")?; - self.print_def_path(did, args)?; - } + self.pretty_print_closure_inner(did, args)?; } else { self.print_def_path(did, args)?; } - write!(self, "}}")? } ty::Closure(did, args) => { write!(self, "{{")?; if !self.should_print_verbose() { write!(self, "closure")?; - if self.should_truncate() { - write!(self, "@...}}")?; - return Ok(()); - } else { - if let Some(did) = did.as_local() { - if self.tcx().sess.opts.unstable_opts.span_free_formats { - write!(self, "@")?; - self.print_def_path(did.to_def_id(), args)?; - } else { - let span = self.tcx().def_span(did); - let loc = if with_forced_trimmed_paths() { - self.tcx().sess.source_map().span_to_short_string( - span, - RemapPathScopeComponents::DIAGNOSTICS, - ) - } else { - self.tcx().sess.source_map().span_to_diagnostic_string(span) - }; - write!( - self, - "@{}", - // This may end up in stderr diagnostics but it may also be - // emitted into MIR. Hence we use the remapped path if - // available - loc - )?; - } - } else { - write!(self, "@")?; - self.print_def_path(did, args)?; - } - } + self.pretty_print_closure_inner(did, args)?; } else { self.print_def_path(did, args)?; write!(self, " closure_kind_ty=")?; @@ -1011,43 +991,14 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { match self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(did)).unwrap() { hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Async, - hir::CoroutineSource::Closure, - ) => write!(self, "async closure")?, - hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::AsyncGen, + desugaring, hir::CoroutineSource::Closure, - ) => write!(self, "async gen closure")?, - hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Gen, - hir::CoroutineSource::Closure, - ) => write!(self, "gen closure")?, + ) => write!(self, "{desugaring}closure")?, _ => unreachable!( "coroutine from coroutine-closure should have CoroutineSource::Closure" ), - } - if let Some(did) = did.as_local() { - if self.tcx().sess.opts.unstable_opts.span_free_formats { - write!(self, "@")?; - self.print_def_path(did.to_def_id(), args)?; - } else { - let span = self.tcx().def_span(did); - // This may end up in stderr diagnostics but it may also be emitted - // into MIR. Hence we use the remapped path if available - let loc = if with_forced_trimmed_paths() { - self.tcx().sess.source_map().span_to_short_string( - span, - RemapPathScopeComponents::DIAGNOSTICS, - ) - } else { - self.tcx().sess.source_map().span_to_diagnostic_string(span) - }; - write!(self, "@{loc}")?; - } - } else { - write!(self, "@")?; - self.print_def_path(did, args)?; - } + }; + self.pretty_print_closure_inner(did, args)?; } else { self.print_def_path(did, args)?; write!(self, " closure_kind_ty=")?; diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 7a681a0b64e9d..e0edc76682a3b 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1651,49 +1651,15 @@ fn confirm_closure_candidate<'cx, 'tcx>( // I didn't see a good way to unify those. ty::CoroutineClosure(def_id, args) => { let args = args.as_coroutine_closure(); - let kind_ty = args.kind_ty(); Unnormalized::new_wip(args.coroutine_closure_sig().map_bound(|sig| { - // If we know the kind and upvars, use that directly. - // Otherwise, defer to `AsyncFnKindHelper::Upvars` to delay - // the projection, like the `AsyncFn*` traits do. - let output_ty = if let Some(_) = kind_ty.to_opt_closure_kind() - // Fall back to projection if upvars aren't constrained - && !args.tupled_upvars_ty().is_ty_var() - { - sig.to_coroutine_given_kind_and_upvars( - tcx, - args.parent_args(), - tcx.coroutine_for_closure(def_id), - ty::ClosureKind::FnOnce, - tcx.lifetimes.re_static, - args.tupled_upvars_ty(), - args.coroutine_captures_by_ref_ty(), - ) - } else { - let upvars_projection_def_id = - tcx.require_lang_item(LangItem::AsyncFnKindUpvars, obligation.cause.span); - let tupled_upvars_ty = Ty::new_projection( - tcx, - ty::IsRigid::No, - upvars_projection_def_id, - [ - ty::GenericArg::from(kind_ty), - Ty::from_closure_kind(tcx, ty::ClosureKind::FnOnce).into(), - tcx.lifetimes.re_static.into(), - sig.tupled_inputs_ty.into(), - args.tupled_upvars_ty().into(), - args.coroutine_captures_by_ref_ty().into(), - ], - ); - sig.to_coroutine( - tcx, - args.parent_args(), - Ty::from_closure_kind(tcx, ty::ClosureKind::FnOnce), - tcx.coroutine_for_closure(def_id), - tupled_upvars_ty, - ) - }; - + let output_ty = coroutine_closure_output_coroutine( + tcx, + obligation, + ty::ClosureKind::FnOnce, + tcx.lifetimes.re_static, + def_id, + args, + ); tcx.mk_fn_sig([sig.tupled_inputs_ty], output_ty, sig.fn_sig_kind) })) } @@ -1770,60 +1736,12 @@ fn confirm_async_closure_candidate<'cx, 'tcx>( let poly_cache_entry = match *self_ty.kind() { ty::CoroutineClosure(def_id, args) => { let args = args.as_coroutine_closure(); - let kind_ty = args.kind_ty(); let sig = args.coroutine_closure_sig().skip_binder(); let term = match item_name { - sym::CallOnceFuture | sym::CallRefFuture => { - if let Some(closure_kind) = kind_ty.to_opt_closure_kind() - // Fall back to projection if upvars aren't constrained - && !args.tupled_upvars_ty().is_ty_var() - { - if !closure_kind.extends(goal_kind) { - bug!("we should not be confirming if the closure kind is not met"); - } - sig.to_coroutine_given_kind_and_upvars( - tcx, - args.parent_args(), - tcx.coroutine_for_closure(def_id), - goal_kind, - env_region, - args.tupled_upvars_ty(), - args.coroutine_captures_by_ref_ty(), - ) - } else { - let upvars_projection_def_id = tcx - .require_lang_item(LangItem::AsyncFnKindUpvars, obligation.cause.span); - // When we don't know the closure kind (and therefore also the closure's upvars, - // which are computed at the same time), we must delay the computation of the - // generator's upvars. We do this using the `AsyncFnKindHelper`, which as a trait - // goal functions similarly to the old `ClosureKind` predicate, and ensures that - // the goal kind <= the closure kind. As a projection `AsyncFnKindHelper::Upvars` - // will project to the right upvars for the generator, appending the inputs and - // coroutine upvars respecting the closure kind. - // N.B. No need to register a `AsyncFnKindHelper` goal here, it's already in `nested`. - let tupled_upvars_ty = Ty::new_projection( - tcx, - ty::IsRigid::No, - upvars_projection_def_id, - [ - ty::GenericArg::from(kind_ty), - Ty::from_closure_kind(tcx, goal_kind).into(), - env_region.into(), - sig.tupled_inputs_ty.into(), - args.tupled_upvars_ty().into(), - args.coroutine_captures_by_ref_ty().into(), - ], - ); - sig.to_coroutine( - tcx, - args.parent_args(), - Ty::from_closure_kind(tcx, goal_kind), - tcx.coroutine_for_closure(def_id), - tupled_upvars_ty, - ) - } - } + sym::CallOnceFuture | sym::CallRefFuture => coroutine_closure_output_coroutine( + tcx, obligation, goal_kind, env_region, def_id, args, + ), sym::Output => sig.return_ty, name => bug!("no such associated type: {name}"), }; @@ -1912,6 +1830,72 @@ fn confirm_async_closure_candidate<'cx, 'tcx>( .with_addl_obligations(nested) } +/// Given a `CoroutineClosure(def_id, args)`, interpret it as a closure, +/// and return its output type for the given `goal_kind` and `env_region`. +fn coroutine_closure_output_coroutine<'tcx>( + tcx: TyCtxt<'tcx>, + obligation: &ProjectionTermObligation<'tcx>, + goal_kind: ty::ClosureKind, + env_region: ty::Region<'tcx>, + def_id: DefId, + args: ty::CoroutineClosureArgs>, +) -> Ty<'tcx> { + let kind_ty = args.kind_ty(); + let sig = args.coroutine_closure_sig().skip_binder(); + + // If we know the kind and upvars, use that directly. + // Otherwise, defer to `AsyncFnKindHelper::Upvars` to delay + // the projection, like the `AsyncFn*` traits do. + if let Some(closure_kind) = kind_ty.to_opt_closure_kind() + // Fall back to projection if upvars aren't constrained + && !args.tupled_upvars_ty().is_ty_var() + { + if !closure_kind.extends(goal_kind) { + bug!("we should not be confirming if the closure kind is not met"); + } + sig.to_coroutine_given_kind_and_upvars( + tcx, + args.parent_args(), + tcx.coroutine_for_closure(def_id), + goal_kind, + env_region, + args.tupled_upvars_ty(), + args.coroutine_captures_by_ref_ty(), + ) + } else { + let upvars_projection_def_id = + tcx.require_lang_item(LangItem::AsyncFnKindUpvars, obligation.cause.span); + // When we don't know the closure kind (and therefore also the closure's upvars, + // which are computed at the same time), we must delay the computation of the + // generator's upvars. We do this using the `AsyncFnKindHelper`, which as a trait + // goal functions similarly to the old `ClosureKind` predicate, and ensures that + // the goal kind <= the closure kind. As a projection `AsyncFnKindHelper::Upvars` + // will project to the right upvars for the generator, appending the inputs and + // coroutine upvars respecting the closure kind. + // N.B. No need to register a `AsyncFnKindHelper` goal here, it's already in `nested`. + let tupled_upvars_ty = Ty::new_projection( + tcx, + ty::IsRigid::No, + upvars_projection_def_id, + [ + ty::GenericArg::from(kind_ty), + Ty::from_closure_kind(tcx, goal_kind).into(), + env_region.into(), + sig.tupled_inputs_ty.into(), + args.tupled_upvars_ty().into(), + args.coroutine_captures_by_ref_ty().into(), + ], + ); + sig.to_coroutine( + tcx, + args.parent_args(), + Ty::from_closure_kind(tcx, goal_kind), + tcx.coroutine_for_closure(def_id), + tupled_upvars_ty, + ) + } +} + fn confirm_async_fn_kind_helper_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTermObligation<'tcx>, diff --git a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr index b64690bae6cde..5a379cc83447c 100644 --- a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -10,7 +10,7 @@ LL | | return 0u8; LL | | } | |_^ expected `u8`, found `()` -error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 23:22}` to be a future that resolves to `()`, but it resolves to `u8` +error[E0271]: expected `{async block@async-block-control-flow-static-semantics.rs:23:17}` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:26:39 | LL | let _: &dyn Future = █ @@ -26,7 +26,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 { | | | implicitly returns `()` as its body has no tail or `return` expression -error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 14:22}` to be a future that resolves to `()`, but it resolves to `u8` +error[E0271]: expected `{async block@async-block-control-flow-static-semantics.rs:14:17}` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:17:39 | LL | let _: &dyn Future = █ diff --git a/tests/ui/async-await/async-closures/is-not-fn.current.stderr b/tests/ui/async-await/async-closures/is-not-fn.current.stderr index 0fab1c15f27df..19d5f9966ffdc 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.current.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.current.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@is-not-fn.rs:8:23}` --> $DIR/is-not-fn.rs:8:14 | LL | needs_fn(async || {}); diff --git a/tests/ui/async-await/async-closures/is-not-fn.next.stderr b/tests/ui/async-await/async-closures/is-not-fn.next.stderr index 0fab1c15f27df..19d5f9966ffdc 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.next.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.next.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@is-not-fn.rs:8:23}` --> $DIR/is-not-fn.rs:8:14 | LL | needs_fn(async || {}); diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr index 412c31b1bd843..dc6183a45cef5 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr index 412c31b1bd843..dc6183a45cef5 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr index 0c153e2d0af36..1b640ebe2b894 100644 --- a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:47: 15:49} as Coroutine>::Return == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:47: 15:49}` +error[E0271]: type mismatch resolving `<{coroutine@coroutine-yielding-or-returning-itself.rs:15:47} as Coroutine>::Return == {coroutine@coroutine-yielding-or-returning-itself.rs:15:47}` --> $DIR/coroutine-yielding-or-returning-itself.rs:15:47 | LL | want_cyclic_coroutine_return(#[coroutine] || { @@ -23,7 +23,7 @@ LL | pub fn want_cyclic_coroutine_return(_: T) LL | where T: Coroutine | ^^^^^^^^^^ required by this bound in `want_cyclic_coroutine_return` -error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:46: 28:48} as Coroutine>::Yield == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:46: 28:48}` +error[E0271]: type mismatch resolving `<{coroutine@coroutine-yielding-or-returning-itself.rs:28:46} as Coroutine>::Yield == {coroutine@coroutine-yielding-or-returning-itself.rs:28:46}` --> $DIR/coroutine-yielding-or-returning-itself.rs:28:46 | LL | want_cyclic_coroutine_yield(#[coroutine] || { diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 646abaf4f7bde..0a6fb8dfcbb6c 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,7 +4,7 @@ error: implementation of `Coroutine` is not general enough LL | test(gen); | ^^^^^^^^^ implementation of `Coroutine` is not general enough | - = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... + = note: `{coroutine@...}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr index 64dc3a8b1f80c..9391325901ec6 100644 --- a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr +++ b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr @@ -18,7 +18,7 @@ LL | Ok(5) LL | Err(5) | ++++ + -error[E0271]: type mismatch resolving `<{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7} as Coroutine>::Return == i32` +error[E0271]: type mismatch resolving `<{coroutine@type-mismatch-signature-deduction.rs:8:5} as Coroutine>::Return == i32` --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Coroutine { diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr index ede830bf72c8b..c2aeb0ab13664 100644 --- a/tests/ui/impl-trait/issues/issue-78722-2.stderr +++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr @@ -12,7 +12,7 @@ LL | let f: F = async { 1 }; = note: expected opaque type `F` found `async` block `{async block@$DIR/issue-78722-2.rs:17:20: 17:25}` -error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:14:13: 14:18}` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `{async block@issue-78722-2.rs:14:13}` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722-2.rs:12:30 | LL | fn concrete_use() -> F { diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index 84c7dfb033849..9244d18c36b49 100644 --- a/tests/ui/impl-trait/issues/issue-78722.stderr +++ b/tests/ui/impl-trait/issues/issue-78722.stderr @@ -8,7 +8,7 @@ LL | let f: F = async { 1 }; = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0271]: expected `{async block@$DIR/issue-78722.rs:11:13: 11:18}` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `{async block@issue-78722.rs:11:13}` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index 407800eff1894..63f3bfcdda950 100644 --- a/tests/ui/impl-trait/nested-return-type4.stderr +++ b/tests/ui/impl-trait/nested-return-type4.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Future` captures lifeti LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future { | -- --------------------------------------------- opaque type defined here | | - | hidden type `{async block@$DIR/nested-return-type4.rs:4:5: 4:15}` captures the lifetime `'s` as defined here + | hidden type `{async block@...}` captures the lifetime `'s` as defined here LL | async move { let _s = s; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr index 8bec119ddbc01..f4620b958f0c6 100644 --- a/tests/ui/iterators/generator_returned_from_fn.stderr +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -28,7 +28,7 @@ error[E0700]: hidden type for `impl FnOnce() -> impl Iterator` captu LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------------------------ opaque type defined here | | - | hidden type `{gen closure@$DIR/generator_returned_from_fn.rs:43:13: 43:20}` captures the anonymous lifetime defined here + | hidden type `{gen closure@...}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | @@ -49,7 +49,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------- opaque type defined here | | - | hidden type `{gen closure body@$DIR/generator_returned_from_fn.rs:43:21: 50:6}` captures the anonymous lifetime defined here + | hidden type `{gen closure body@...}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | diff --git a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr index abf8e2d824b5d..c74c9b7b5cf3a 100644 --- a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr +++ b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@dont-suggest-boxing-async-closure-body.rs:9:9}` to return `Box<_>`, but it returns `{async closure body@$DIR/dont-suggest-boxing-async-closure-body.rs:9:23: 9:25}` +error[E0271]: expected `{async closure@dont-suggest-boxing-async-closure-body.rs:9:9}` to return `Box<_>`, but it returns `{async closure body@dont-suggest-boxing-async-closure-body.rs:9:23}` --> $DIR/dont-suggest-boxing-async-closure-body.rs:9:9 | LL | foo(async move || {}); @@ -18,7 +18,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 | LL | bar(async move || {}); - | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@dont-suggest-boxing-async-closure-body.rs:11:9}` + | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@...}` | | | arguments to this function are incorrect | diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr index bcd1a905194ef..e8f12e7476119 100644 --- a/tests/ui/suggestions/unnamable-types.stderr +++ b/tests/ui/suggestions/unnamable-types.stderr @@ -58,7 +58,7 @@ error: missing type for `const` item LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; | ^ | -note: however, the inferred type `{coroutine@$DIR/unnamable-types.rs:37:24: 37:33}` cannot be named +note: however, the inferred type `{coroutine@unnamable-types.rs:37:24}` cannot be named --> $DIR/unnamable-types.rs:37:24 | LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; diff --git a/tests/ui/traits/next-solver/async.fail.stderr b/tests/ui/traits/next-solver/async.fail.stderr index bc89842d16a14..328f1bc7d4384 100644 --- a/tests/ui/traits/next-solver/async.fail.stderr +++ b/tests/ui/traits/next-solver/async.fail.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async block@$DIR/async.rs:12:17: 12:22}` to be a future that resolves to `i32`, but it resolves to `()` +error[E0271]: expected `{async block@async.rs:12:17}` to be a future that resolves to `i32`, but it resolves to `()` --> $DIR/async.rs:12:17 | LL | needs_async(async {}); diff --git a/tests/ui/traits/next-solver/async.rs b/tests/ui/traits/next-solver/async.rs index fded774354759..cc6a99baf8d8d 100644 --- a/tests/ui/traits/next-solver/async.rs +++ b/tests/ui/traits/next-solver/async.rs @@ -10,7 +10,7 @@ fn needs_async(_: impl Future) {} #[cfg(fail)] fn main() { needs_async(async {}); - //[fail]~^ ERROR expected `{async block@$DIR/async.rs:12:17: 12:22}` to be a future that resolves to `i32`, but it resolves to `()` + //[fail]~^ ERROR expected `{async block@async.rs:12:17}` to be a future that resolves to `i32`, but it resolves to `()` } #[cfg(pass)] diff --git a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr index 6fc64fe4768a5..8da83ef139709 100644 --- a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr +++ b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr @@ -1,22 +1,22 @@ -error[E0271]: type mismatch resolving `T == {async block@$DIR/stalled-coroutine-obligations.rs:18:18: 18:23}` +error[E0271]: type mismatch resolving `T == {async block@stalled-coroutine-obligations.rs:18:18}` --> $DIR/stalled-coroutine-obligations.rs:18:14 | LL | let foo: T = async {}; | ^ types differ -error[E0271]: type mismatch resolving `U == {async block@$DIR/stalled-coroutine-obligations.rs:22:18: 22:23}` +error[E0271]: type mismatch resolving `U == {async block@stalled-coroutine-obligations.rs:22:18}` --> $DIR/stalled-coroutine-obligations.rs:22:14 | LL | let bar: U = async {}; | ^ types differ -error[E0271]: type mismatch resolving `T == {async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}` +error[E0271]: type mismatch resolving `T == {async block@stalled-coroutine-obligations.rs:33:18}` --> $DIR/stalled-coroutine-obligations.rs:33:14 | LL | let foo: T = async { a }; | ^ types differ -error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:41:9: 41:19}` +error[E0271]: type mismatch resolving `impl Future + Send == {async block@stalled-coroutine-obligations.rs:41:9}` --> $DIR/stalled-coroutine-obligations.rs:39:43 | LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send { diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr index f41b781f963d2..3f85d23144a4f 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.stderr +++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:18:9: 18:16} as Coroutine>::Yield == ()` +error[E0271]: type mismatch resolving `<{coroutine@issue-94429.rs:18:9} as Coroutine>::Yield == ()` --> $DIR/issue-94429.rs:15:26 | LL | fn run(&mut self) -> Self::Coro {