From 73be83c431e638b1a4ec1011cc9ddf5d189d5ba0 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 12:22:29 -0700 Subject: [PATCH 01/17] Delay def collection for expression-like nodes These expression-like nodes are anon const args, const blocks, closures, and generators. They need to have their def collection delayed because some anon const args turn into `ConstArgKind::Path`, which has no DefId. Thus defs that could have an anon const as their parent must be delayed as well. --- compiler/rustc_ast_lowering/src/asm.rs | 12 --- compiler/rustc_ast_lowering/src/expr.rs | 81 ++++++++++++--------- compiler/rustc_ast_lowering/src/lib.rs | 23 +++--- compiler/rustc_resolve/src/def_collector.rs | 76 +++++-------------- 4 files changed, 74 insertions(+), 118 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index ea7b8c114f490..5aa2b2989382d 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -7,7 +7,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_session::parse::feature_err; -use rustc_span::symbol::kw; use rustc_span::{sym, Span}; use rustc_target::asm; @@ -222,18 +221,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { }; // Wrap the expression in an AnonConst. - let parent_def_id = self.current_def_id_parent; let node_id = self.next_node_id(); - // HACK(min_generic_const_args): see lower_anon_const - if !expr.is_potential_trivial_const_arg() { - self.create_def( - parent_def_id, - node_id, - kw::Empty, - DefKind::AnonConst, - *op_sp, - ); - } let anon_const = AnonConst { id: node_id, value: P(expr) }; hir::InlineAsmOperand::SymFn { anon_const: self.lower_anon_const_to_anon_const(&anon_const), diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 124fe6bd380d2..a949d6a10621a 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -77,7 +77,13 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), ExprKind::ConstBlock(c) => { let c = self.with_new_scopes(c.value.span, |this| { - let def_id = this.local_def_id(c.id); + let def_id = this.create_def( + this.current_def_id_parent, + c.id, + kw::Empty, + DefKind::InlineConst, + c.value.span, + ); hir::ConstBlock { def_id, hir_id: this.lower_node_id(c.id), @@ -207,31 +213,40 @@ impl<'hir> LoweringContext<'_, 'hir> { body, fn_decl_span, fn_arg_span, - }) => match coroutine_kind { - Some(coroutine_kind) => self.lower_expr_coroutine_closure( - binder, - *capture_clause, - e.id, - hir_id, - *coroutine_kind, - fn_decl, - body, - *fn_decl_span, - *fn_arg_span, - ), - None => self.lower_expr_closure( - binder, - *capture_clause, + }) => { + let closure_def = self.create_def( + self.current_def_id_parent, e.id, - hir_id, - *constness, - *movability, - fn_decl, - body, - *fn_decl_span, - *fn_arg_span, - ), - }, + kw::Empty, + DefKind::Closure, + e.span, + ); + self.with_def_id_parent(closure_def, |this| match coroutine_kind { + Some(coroutine_kind) => this.lower_expr_coroutine_closure( + binder, + *capture_clause, + e.id, + hir_id, + *coroutine_kind, + fn_decl, + body, + *fn_decl_span, + *fn_arg_span, + ), + None => this.lower_expr_closure( + binder, + *capture_clause, + e.id, + hir_id, + *constness, + *movability, + fn_decl, + body, + *fn_decl_span, + *fn_arg_span, + ), + }) + } ExprKind::Gen(capture_clause, block, genblock_kind, decl_span) => { let desugaring_kind = match genblock_kind { GenBlockKind::Async => hir::CoroutineDesugaring::Async, @@ -383,15 +398,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let mut generic_args = ThinVec::new(); for (idx, arg) in args.into_iter().enumerate() { if legacy_args_idx.contains(&idx) { - let parent_def_id = self.current_def_id_parent; let node_id = self.next_node_id(); - - // HACK(min_generic_const_args): see lower_anon_const - if !arg.is_potential_trivial_const_arg() { - // Add a definition for the in-band const def. - self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span); - } - let anon_const = AnonConst { id: node_id, value: arg }; generic_args.push(AngleBracketedArg::Arg(GenericArg::Const(anon_const))); } else { @@ -625,7 +632,13 @@ impl<'hir> LoweringContext<'_, 'hir> { coroutine_source: hir::CoroutineSource, body: impl FnOnce(&mut Self) -> hir::Expr<'hir>, ) -> hir::ExprKind<'hir> { - let closure_def_id = self.local_def_id(closure_node_id); + let closure_def_id = self.create_def( + self.current_def_id_parent, + closure_node_id, + kw::Empty, + DefKind::Closure, + span, + ); let coroutine_kind = hir::CoroutineKind::Desugared(desugaring_kind, coroutine_source); // The `async` desugaring takes a resume argument and maintains a `task_context`, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 224787c335beb..880a488e9664e 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -2465,19 +2465,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// See [`hir::ConstArg`] for when to use this function vs /// [`Self::lower_anon_const_to_const_arg`]. fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst { - if c.value.is_potential_trivial_const_arg() { - // HACK(min_generic_const_args): see DefCollector::visit_anon_const - // Over there, we guess if this is a bare param and only create a def if - // we think it's not. However we may can guess wrong (see there for example) - // in which case we have to create the def here. - self.create_def( - self.current_def_id_parent, - c.id, - kw::Empty, - DefKind::AnonConst, - c.value.span, - ); - } + // HACK(min_generic_const_args): see DefCollector::visit_anon_const + // We delay creation of defs for expression-like things, including anon consts. + // This is because some anon consts end up as `ConstArgKind::Path`'s instead. + self.create_def( + self.current_def_id_parent, + c.id, + kw::Empty, + DefKind::AnonConst, + c.value.span, + ); self.arena.alloc(self.with_new_scopes(c.value.span, |this| { let def_id = this.local_def_id(c.id); diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index ed23870dfdf8b..188c97d3c63ae 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -182,10 +182,10 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { }); } - fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { + fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: Span, _: NodeId) { if let FnKind::Fn(_, _, sig, _, generics, body) = fn_kind { match sig.header.coroutine_kind { - Some(coroutine_kind) => { + Some(_) => { self.visit_generics(generics); // For async functions, we need to create their inner defs inside of a @@ -196,17 +196,10 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { self.visit_param(param); } self.visit_fn_ret_ty(&sig.decl.output); - // If this async fn has no body (i.e. it's an async fn signature in a trait) - // then the closure_def will never be used, and we should avoid generating a - // def-id for it. if let Some(body) = body { - let closure_def = self.create_def( - coroutine_kind.closure_id(), - kw::Empty, - DefKind::Closure, - span, - ); - self.with_parent(closure_def, |this| this.visit_block(body)); + // HACK(min_generic_const_args): expression-like things (including coroutines) + // have their defs created later, in ast_lowering + self.visit_block(body); } return; } @@ -314,64 +307,29 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { } fn visit_anon_const(&mut self, constant: &'a AnonConst) { - // HACK(min_generic_const_args): don't create defs for anon consts if we think they will - // later be turned into ConstArgKind::Path's. because this is before resolve is done, we - // may accidentally identify a construction of a unit struct as a param and not create a - // def. we'll then create a def later in ast lowering in this case. the parent of nested - // items will be messed up, but that's ok because there can't be any if we're just looking - // for bare idents. - if constant.value.is_potential_trivial_const_arg() { - visit::walk_anon_const(self, constant) - } else { - let def = - self.create_def(constant.id, kw::Empty, DefKind::AnonConst, constant.value.span); - self.with_parent(def, |this| visit::walk_anon_const(this, constant)); - } + // HACK(min_generic_const_args): expressions with defs (const blocks, + // anon consts, closures/generators) have their defs created later, + // during ast_lowering + visit::walk_anon_const(self, constant) } fn visit_expr(&mut self, expr: &'a Expr) { - let parent_def = match expr.kind { + // HACK(min_generic_const_args): expressions with defs (const blocks, + // anon consts, closures/generators) have their defs created later, + // during ast_lowering + match expr.kind { ExprKind::MacCall(..) => return self.visit_macro_invoc(expr.id), - ExprKind::Closure(ref closure) => { - // Async closures desugar to closures inside of closures, so - // we must create two defs. - let closure_def = self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span); - match closure.coroutine_kind { - Some(coroutine_kind) => { - self.with_parent(closure_def, |this| { - let coroutine_def = this.create_def( - coroutine_kind.closure_id(), - kw::Empty, - DefKind::Closure, - expr.span, - ); - this.with_parent(coroutine_def, |this| visit::walk_expr(this, expr)); - }); - return; - } - None => closure_def, - } - } - ExprKind::Gen(_, _, _, _) => { - self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span) - } ExprKind::ConstBlock(ref constant) => { for attr in &expr.attrs { visit::walk_attribute(self, attr); } - let def = self.create_def( - constant.id, - kw::Empty, - DefKind::InlineConst, - constant.value.span, - ); - self.with_parent(def, |this| visit::walk_anon_const(this, constant)); + visit::walk_anon_const(self, constant); return; } - _ => self.parent_def, - }; + _ => {} + } - self.with_parent(parent_def, |this| visit::walk_expr(this, expr)); + visit::walk_expr(self, expr); } fn visit_ty(&mut self, ty: &'a Ty) { From 60bc83de4208e5c73d537ace5259bf39b3c042e3 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 13:57:23 -0700 Subject: [PATCH 02/17] Create defs before lowering NodeId This ensures the correct DefId <-> HirId mapping is made. --- compiler/rustc_ast_lowering/src/expr.rs | 45 +- .../anonymous-higher-ranked-lifetime.stderr | 22 +- tests/ui/argument-suggestions/basic.stderr | 2 +- .../argument-suggestions/exotic-calls.stderr | 2 +- .../argument-suggestions/issue-98894.stderr | 2 +- .../argument-suggestions/issue-98897.stderr | 2 +- .../argument-suggestions/issue-99482.stderr | 2 +- tests/ui/asm/x86_64/type-check-2.stderr | 2 +- .../async-closures/not-clone-closure.stderr | 11 +- .../async-await/async-closures/not-fn.stderr | 12 +- tests/ui/attributes/dump_def_parents.stderr | 30 +- tests/ui/block-result/issue-20862.stderr | 2 +- ...immutable-upvar-mutation-impl-trait.stderr | 16 +- .../borrow-immutable-upvar-mutation.stderr | 47 +- .../borrow-raw-address-of-mutability.stderr | 36 +- tests/ui/borrowck/borrowck-in-static.stderr | 5 +- .../borrowck/borrowck-move-by-capture.stderr | 22 +- tests/ui/borrowck/issue-103624.stderr | 19 +- ...ted-closure-outlives-borrowed-value.stderr | 2 +- tests/ui/borrowck/issue-81899.stderr | 2 +- .../issue-87456-point-to-closure.stderr | 18 +- .../issue-88434-minimal-example.stderr | 2 +- ...-88434-removal-index-should-be-less.stderr | 2 +- ...5079-missing-move-in-nested-closure.stderr | 2 +- tests/ui/borrowck/mutability-errors.stderr | 174 +++-- ...ove-upvar-from-non-once-ref-closure.stderr | 19 +- .../expect-infer-var-appearing-twice.stderr | 15 +- .../closure_context/issue-26046-fn-mut.stderr | 18 +- .../issue-26046-fn-once.stderr | 18 +- .../closure-origin-array-diagnostics.stderr | 19 +- .../closure-origin-tuple-diagnostics.stderr | 19 +- .../2229_closure_analysis/issue-90465.stderr | 18 +- .../migrations/auto_traits.stderr | 59 +- .../insignificant_drop_attr_migrations.stderr | 38 +- .../migrations/macro.stderr | 4 +- .../migrations/migrations_rustfix.stderr | 23 +- .../migrations/mir_calls_to_shims.stderr | 22 +- .../migrations/multi_diagnostics.stderr | 133 ++-- .../migrations/precise.stderr | 59 +- .../migrations/significant_drop.stderr | 220 +++--- .../binder/nested-closures-regions.stderr | 4 +- tests/ui/closures/closure-move-sync.stderr | 10 +- tests/ui/closures/closure-no-fn-1.stderr | 2 +- tests/ui/closures/closure-no-fn-2.stderr | 2 +- tests/ui/closures/closure-no-fn-3.stderr | 2 +- tests/ui/closures/closure-no-fn-4.stderr | 2 +- tests/ui/closures/closure-no-fn-5.stderr | 2 +- tests/ui/closures/closure-reform-bad.stderr | 4 +- tests/ui/closures/closure-wrong-kind.stderr | 5 +- .../closure_cap_coerce_many_fail.stderr | 20 +- ...n-with-leaking-placeholders.current.stderr | 2 +- tests/ui/closures/issue-25439.stderr | 2 +- tests/ui/closures/issue-90871.stderr | 2 +- tests/ui/closures/multiple-fn-bounds.stderr | 2 +- .../print/closure-print-generic-1.stderr | 2 +- .../print/closure-print-generic-2.stderr | 4 +- ...re-print-generic-trim-off-verbose-2.stderr | 2 +- .../closure-print-generic-verbose-2.stderr | 2 +- ...wrong-closure-arg-suggestion-125325.stderr | 5 +- tests/ui/codegen/overflow-during-mono.stderr | 8 +- .../coerce-expect-unsized-ascribed.stderr | 6 +- .../issue-33784.stderr | 4 +- .../const_param_ty_bad.stderr | 4 +- .../unify-op-with-fn-call.stderr | 16 +- .../ui/const-generics/nested-type.full.stderr | 2 +- .../ui/const-generics/nested-type.min.stderr | 2 +- tests/ui/consts/const-size_of-cycle.stderr | 2 +- tests/ui/consts/issue-44415.stderr | 2 +- tests/ui/coroutine/clone-impl-static.stderr | 8 +- tests/ui/coroutine/clone-impl.stderr | 93 ++- tests/ui/coroutine/clone-rpit.next.stderr | 36 +- tests/ui/coroutine/coroutine-with-nll.stderr | 19 +- ...outine-yielding-or-returning-itself.stderr | 4 +- .../drop-tracking-parent-expression.stderr | 6 +- tests/ui/coroutine/drop-yield-twice.stderr | 2 +- tests/ui/coroutine/issue-105084.stderr | 18 +- tests/ui/coroutine/issue-48048.stderr | 18 +- tests/ui/coroutine/issue-68112.stderr | 20 +- tests/ui/coroutine/issue-88653.stderr | 13 +- tests/ui/coroutine/not-send-sync.stderr | 4 +- tests/ui/coroutine/parent-expression.stderr | 6 +- tests/ui/coroutine/pattern-borrow.stderr | 16 +- .../print/coroutine-print-verbose-1.stderr | 22 +- tests/ui/coroutine/ref-upvar-not-send.stderr | 4 +- .../ui/coroutine/resume-arg-late-bound.stderr | 2 +- .../coroutine/static-not-unpin.current.stderr | 4 +- .../ui/coroutine/static-not-unpin.next.stderr | 4 +- .../type-mismatch-signature-deduction.stderr | 2 +- tests/ui/coroutine/yield-in-args.stderr | 11 +- .../ui/coroutine/yield-while-iterating.stderr | 15 +- .../yield-while-local-borrowed.stderr | 38 +- tests/ui/deprecation/deprecation-lint.stderr | 2 +- tests/ui/error-codes/E0057.stderr | 4 +- tests/ui/error-codes/E0767.stderr | 2 +- tests/ui/fn/fn-closure-mutable-capture.stderr | 5 +- .../fn-help-with-err.stderr | 2 +- .../hrtb-doesnt-borrow-self-1.stderr | 6 +- .../hrtb-doesnt-borrow-self-2.stderr | 6 +- .../trait-bounds/issue-62203-hrtb-ice.stderr | 2 +- tests/ui/impl-trait/auto-trait-leak2.stderr | 4 +- .../impl-trait/impl-fn-hrtb-bounds-2.stderr | 2 +- tests/ui/impl-trait/issue-99073.stderr | 2 +- tests/ui/impl-trait/issues/issue-74282.stderr | 2 +- .../must_outlive_least_region_or_bound.stderr | 2 +- .../recursive-coroutine-boxed.next.stderr | 2 +- ...ecursive-coroutine-indirect.current.stderr | 12 +- .../recursive-coroutine-indirect.next.stderr | 12 +- .../recursive-impl-trait-type-indirect.stderr | 10 +- .../static-return-lifetime-infered.stderr | 4 +- .../hint-closure-signature-119266.stderr | 4 +- .../interior-mutability.stderr | 4 +- .../intrinsics/const-eval-select-bad.stderr | 4 +- tests/ui/issues/issue-12127.stderr | 2 +- tests/ui/issues/issue-21600.stderr | 31 +- tests/ui/issues/issue-22638.stderr | 2 +- tests/ui/issues/issue-24036.stderr | 6 +- tests/ui/issues/issue-34349.stderr | 21 +- tests/ui/issues/issue-4335.stderr | 5 +- tests/ui/issues/issue-48838.stderr | 2 +- tests/ui/issues/issue-50600.stderr | 2 +- tests/ui/issues/issue-50688.stderr | 2 +- tests/ui/issues/issue-51154.stderr | 2 +- tests/ui/kindck/kindck-nonsendable-1.stderr | 8 +- tests/ui/lint/lint_map_unit_fn.stderr | 28 +- tests/ui/lint/non-local-defs/consts.stderr | 54 +- .../ui/lint/non-local-defs/exhaustive.stderr | 5 +- .../ui/lint/non-local-defs/weird-exprs.stderr | 83 +-- tests/ui/lint/trivial_casts.stderr | 2 +- .../methods/filter-relevant-fn-bounds.stderr | 6 +- tests/ui/methods/method-missing-call.stderr | 2 +- tests/ui/mismatched_types/E0631.stderr | 4 +- ...osure-arg-type-mismatch-issue-45727.stderr | 4 +- .../closure-arg-type-mismatch.stderr | 6 +- .../closure-ref-114180.stderr | 2 +- .../ui/mismatched_types/issue-36053-2.stderr | 16 +- .../unboxed-closures-vtable-mismatch.stderr | 2 +- ...-move-out-of-closure-env-issue-1965.stderr | 5 +- .../fallback-closure-wrap.fallback.stderr | 2 +- tests/ui/nll/closure-captures.stderr | 132 ++-- .../escape-argument-callee.stderr | 2 +- .../escape-argument.stderr | 2 +- .../escape-upvar-nested.stderr | 10 +- .../escape-upvar-ref.stderr | 2 +- ...pagate-approximated-fail-no-postdom.stderr | 8 +- .../propagate-approximated-ref.stderr | 9 +- ...er-to-static-comparing-against-free.stderr | 15 +- ...oximated-shorter-to-static-no-bound.stderr | 10 +- ...mated-shorter-to-static-wrong-bound.stderr | 10 +- .../propagate-approximated-val.stderr | 9 +- .../propagate-despite-same-free-region.stderr | 8 +- ...ail-to-approximate-longer-no-bounds.stderr | 9 +- ...-to-approximate-longer-wrong-bounds.stderr | 9 +- .../propagate-from-trait-match.stderr | 11 +- .../return-wrong-bound-region.stderr | 2 +- ...e-52663-span-decl-captured-variable.stderr | 5 +- tests/ui/nll/issue-54556-stephaneyfx.stderr | 2 +- tests/ui/nll/issue-55850.stderr | 13 +- .../projection-no-regions-closure.stderr | 8 +- .../projection-one-region-closure.stderr | 8 +- ...tion-one-region-trait-bound-closure.stderr | 10 +- ...e-region-trait-bound-static-closure.stderr | 10 +- ...tion-two-region-trait-bound-closure.stderr | 16 +- ...ram-closure-approximate-lower-bound.stderr | 4 +- ...m-closure-outlives-from-return-type.stderr | 2 +- ...-closure-outlives-from-where-clause.stderr | 39 +- tests/ui/no-send-res-ports.stderr | 20 +- tests/ui/not-clone-closure.stderr | 22 +- tests/ui/on-unimplemented/parent-label.stderr | 31 +- tests/ui/parser/expr-as-stmt.stderr | 2 +- .../recover-fn-trait-from-fn-kw.stderr | 2 +- ...truct-literal-restrictions-in-lamda.stderr | 2 +- .../move-ref-patterns-closure-captures.stderr | 71 +- .../const_parameters/closures.stderr | 6 +- tests/ui/polymorphization/coroutine.stderr | 28 +- tests/ui/polymorphization/lifetimes.stderr | 2 +- tests/ui/polymorphization/predicates.stderr | 2 +- .../type_parameters/closures.stderr | 32 +- tests/ui/polymorphization/unsized_cast.stderr | 22 +- tests/ui/print_type_sizes/coroutine.stdout | 2 +- .../coroutine_discr_placement.stdout | 2 +- tests/ui/recursion/issue-23302-1.stderr | 6 +- tests/ui/recursion/issue-23302-2.stderr | 6 +- tests/ui/recursion/issue-83150.stderr | 6 +- .../const-trait-bounds.stderr | 4 +- ...borrowck-call-is-borrow-issue-12224.stderr | 17 +- tests/ui/span/move-closure.stderr | 2 +- tests/ui/static/issue-24446.stderr | 2 +- ...rg-where-it-should-have-been-called.stderr | 6 +- tests/ui/suggestions/call-boxed.stderr | 4 +- .../dont-suggest-ref/move-into-closure.stderr | 655 +++++++++++------- ...rg-where-it-should-have-been-called.stderr | 4 +- .../fn-or-tuple-struct-without-args.stderr | 4 +- .../suggestions/issue-84973-blacklist.stderr | 4 +- .../late-bound-in-borrow-closure-sugg.stderr | 15 +- ...gestion-in-proper-span-issue-121267.stderr | 2 +- .../missing-lifetimes-in-signature.stderr | 2 +- .../suggestions/option-content-move2.stderr | 58 +- .../suggestions/option-content-move3.stderr | 84 ++- tests/ui/suggestions/return-closures.stderr | 4 +- .../suggestions/sugg-else-for-closure.stderr | 4 +- tests/ui/suggestions/suggest-box.stderr | 2 +- .../types/into-inference-needs-type.stderr | 4 +- tests/ui/suggestions/unnamable-types.stderr | 2 +- tests/ui/symbol-names/impl1.legacy.stderr | 8 +- tests/ui/symbol-names/impl1.v0.stderr | 8 +- .../issue-91949-hangs-on-recursion.stderr | 2 +- tests/ui/traits/issue-99875.stderr | 4 +- .../traits/next-solver/coroutine.fail.stderr | 4 +- .../try-on-option-diagnostics.stderr | 13 +- tests/ui/tuple/wrong_argument_ice-4.stderr | 4 +- .../self-in-enum-definition.stderr | 18 +- .../issue-53092-2.stderr | 2 +- .../type-alias-impl-trait/issue-63279.stderr | 4 +- .../type-alias-impl-trait/issue-94429.stderr | 2 +- .../recursive-fn-tait.stderr | 2 +- .../point-at-inference-issue-116155.stderr | 2 +- ...-index-modulo-higher-ranked-regions.stderr | 2 +- tests/ui/typeck/cyclic_type_ice.stderr | 2 +- tests/ui/typeck/issue-31173.stderr | 8 +- .../return_type_containing_closure.stderr | 2 +- .../typeck_type_placeholder_item.stderr | 4 +- .../unboxed-closure-illegal-move.stderr | 20 +- .../unboxed-closure-no-cyclic-sig.stderr | 2 +- ...-infer-fn-once-move-from-projection.stderr | 5 +- .../unboxed-closures-mutate-upvar.stderr | 18 +- ...sures-mutated-upvar-from-fn-closure.stderr | 19 +- ...ed-closures-static-call-wrong-trait.stderr | 2 +- 227 files changed, 2183 insertions(+), 1531 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index a949d6a10621a..54d2a3a41b00a 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -70,6 +70,7 @@ impl<'hir> LoweringContext<'_, 'hir> { _ => (), } + self.create_def_if_needed_for(e); let hir_id = self.lower_node_id(e.id); self.lower_attrs(hir_id, &e.attrs); @@ -77,13 +78,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), ExprKind::ConstBlock(c) => { let c = self.with_new_scopes(c.value.span, |this| { - let def_id = this.create_def( - this.current_def_id_parent, - c.id, - kw::Empty, - DefKind::InlineConst, - c.value.span, - ); + let def_id = this.local_def_id(c.id); hir::ConstBlock { def_id, hir_id: this.lower_node_id(c.id), @@ -214,13 +209,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn_decl_span, fn_arg_span, }) => { - let closure_def = self.create_def( - self.current_def_id_parent, - e.id, - kw::Empty, - DefKind::Closure, - e.span, - ); + let closure_def = self.local_def_id(e.id); self.with_def_id_parent(closure_def, |this| match coroutine_kind { Some(coroutine_kind) => this.lower_expr_coroutine_closure( binder, @@ -371,6 +360,34 @@ impl<'hir> LoweringContext<'_, 'hir> { }) } + /// HACK(min_generic_const_args): we delay creation of expression defs until ast_lowering + /// + /// This only creates a def for the top-level expression. If it has nested expressions that + /// need defs, those are handled by the recursion in the main lowering logic. + fn create_def_if_needed_for(&mut self, e: &Expr) { + match &e.kind { + ExprKind::ConstBlock(c) => { + self.create_def( + self.current_def_id_parent, + c.id, + kw::Empty, + DefKind::InlineConst, + c.value.span, + ); + } + ExprKind::Closure(_) => { + self.create_def( + self.current_def_id_parent, + e.id, + kw::Empty, + DefKind::Closure, + e.span, + ); + } + _ => {} + } + } + fn lower_unop(&mut self, u: UnOp) -> hir::UnOp { match u { UnOp::Deref => hir::UnOp::Deref, diff --git a/tests/ui/anonymous-higher-ranked-lifetime.stderr b/tests/ui/anonymous-higher-ranked-lifetime.stderr index c28d856ad55fd..de3e90ecc4238 100644 --- a/tests/ui/anonymous-higher-ranked-lifetime.stderr +++ b/tests/ui/anonymous-higher-ranked-lifetime.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:2:5 | LL | f1(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -23,7 +23,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:3:5 | LL | f2(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -44,7 +44,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:4:5 | LL | f3(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -65,7 +65,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:5:5 | LL | f4(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -86,7 +86,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:6:5 | LL | f5(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -107,7 +107,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:7:5 | LL | g1(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -128,7 +128,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:8:5 | LL | g2(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -149,7 +149,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:9:5 | LL | g3(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -170,7 +170,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:10:5 | LL | g4(|_: (), _: ()| {}); - | ^^^--------------^^^^ + | ^^^-----------------^ | | | | | found signature defined here | expected due to this @@ -191,7 +191,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:11:5 | LL | h1(|_: (), _: (), _: (), _: ()| {}); - | ^^^----------------------------^^^^ + | ^^^-------------------------------^ | | | | | found signature defined here | expected due to this @@ -212,7 +212,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 | LL | h2(|_: (), _: (), _: (), _: ()| {}); - | ^^^----------------------------^^^^ + | ^^^-------------------------------^ | | | | | found signature defined here | expected due to this diff --git a/tests/ui/argument-suggestions/basic.stderr b/tests/ui/argument-suggestions/basic.stderr index 2d52df2123369..adc06f6ee9b16 100644 --- a/tests/ui/argument-suggestions/basic.stderr +++ b/tests/ui/argument-suggestions/basic.stderr @@ -92,7 +92,7 @@ note: closure defined here --> $DIR/basic.rs:26:19 | LL | let closure = |x| x; - | ^^^ + | ^^^^^ help: provide the argument | LL | closure(/* x */); diff --git a/tests/ui/argument-suggestions/exotic-calls.stderr b/tests/ui/argument-suggestions/exotic-calls.stderr index aca3b8a343343..f14e25b94ff7a 100644 --- a/tests/ui/argument-suggestions/exotic-calls.stderr +++ b/tests/ui/argument-suggestions/exotic-calls.stderr @@ -59,7 +59,7 @@ note: closure defined here --> $DIR/exotic-calls.rs:21:13 | LL | let x = || {}; - | ^^ + | ^^^^^ help: remove the extra argument | LL - x(1i32); diff --git a/tests/ui/argument-suggestions/issue-98894.stderr b/tests/ui/argument-suggestions/issue-98894.stderr index 93e604c3101fb..97458fa18697d 100644 --- a/tests/ui/argument-suggestions/issue-98894.stderr +++ b/tests/ui/argument-suggestions/issue-98894.stderr @@ -8,7 +8,7 @@ note: closure defined here --> $DIR/issue-98894.rs:2:6 | LL | (|_, ()| ())(if true {} else {return;}); - | ^^^^^^^ + | ^^^^^^^^^^ help: provide the argument | LL | (|_, ()| ())(if true {} else {return;}, ()); diff --git a/tests/ui/argument-suggestions/issue-98897.stderr b/tests/ui/argument-suggestions/issue-98897.stderr index 671e3d99d8552..0a856882e139a 100644 --- a/tests/ui/argument-suggestions/issue-98897.stderr +++ b/tests/ui/argument-suggestions/issue-98897.stderr @@ -8,7 +8,7 @@ note: closure defined here --> $DIR/issue-98897.rs:2:6 | LL | (|_, ()| ())([return, ()]); - | ^^^^^^^ + | ^^^^^^^^^^ help: provide the argument | LL | (|_, ()| ())([return, ()], ()); diff --git a/tests/ui/argument-suggestions/issue-99482.stderr b/tests/ui/argument-suggestions/issue-99482.stderr index be40787461523..bf07a7b90494f 100644 --- a/tests/ui/argument-suggestions/issue-99482.stderr +++ b/tests/ui/argument-suggestions/issue-99482.stderr @@ -8,7 +8,7 @@ note: closure defined here --> $DIR/issue-99482.rs:2:13 | LL | let f = |_: (), f: fn()| f; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ help: provide the argument | LL | let _f = f((), main); diff --git a/tests/ui/asm/x86_64/type-check-2.stderr b/tests/ui/asm/x86_64/type-check-2.stderr index c72e695aefb83..a3695affcd308 100644 --- a/tests/ui/asm/x86_64/type-check-2.stderr +++ b/tests/ui/asm/x86_64/type-check-2.stderr @@ -6,7 +6,7 @@ LL | asm!("{}", in(xmm_reg) SimdNonCopy(0.0, 0.0, 0.0, 0.0)); | = note: `SimdNonCopy` does not implement the Copy trait -error: cannot use value of type `{closure@$DIR/type-check-2.rs:44:28: 44:36}` for inline assembly +error: cannot use value of type `{closure@$DIR/type-check-2.rs:44:28: 44:38}` for inline assembly --> $DIR/type-check-2.rs:44:28 | LL | asm!("{}", in(reg) |x: i32| x); diff --git a/tests/ui/async-await/async-closures/not-clone-closure.stderr b/tests/ui/async-await/async-closures/not-clone-closure.stderr index aea48a455c218..e1432f5eb3f62 100644 --- a/tests/ui/async-await/async-closures/not-clone-closure.stderr +++ b/tests/ui/async-await/async-closures/not-clone-closure.stderr @@ -1,14 +1,17 @@ -error[E0277]: the trait bound `NotClonableUpvar: Clone` is not satisfied in `{async closure@$DIR/not-clone-closure.rs:29:21: 29:34}` +error[E0277]: the trait bound `NotClonableUpvar: Clone` is not satisfied in `{async closure@$DIR/not-clone-closure.rs:29:21: 31:6}` --> $DIR/not-clone-closure.rs:32:15 | LL | not_clone.clone(); - | ^^^^^ within `{async closure@$DIR/not-clone-closure.rs:29:21: 29:34}`, the trait `Clone` is not implemented for `NotClonableUpvar`, which is required by `{async closure@$DIR/not-clone-closure.rs:29:21: 29:34}: Clone` + | ^^^^^ within `{async closure@$DIR/not-clone-closure.rs:29:21: 31:6}`, the trait `Clone` is not implemented for `NotClonableUpvar`, which is required by `{async closure@$DIR/not-clone-closure.rs:29:21: 31:6}: Clone` | note: required because it's used within this closure --> $DIR/not-clone-closure.rs:29:21 | -LL | let not_clone = async move || { - | ^^^^^^^^^^^^^ +LL | let not_clone = async move || { + | _____________________^ +LL | | println!("{z:?}"); +LL | | }; + | |_____^ help: consider annotating `NotClonableUpvar` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/async-await/async-closures/not-fn.stderr b/tests/ui/async-await/async-closures/not-fn.stderr index 9c40613599a8e..a7fe6dd591ac0 100644 --- a/tests/ui/async-await/async-closures/not-fn.stderr +++ b/tests/ui/async-await/async-closures/not-fn.stderr @@ -1,10 +1,14 @@ error: async closure does not implement `FnMut` because it captures state from its environment --> $DIR/not-fn.rs:11:14 | -LL | needs_fn(async || { - | -------- ^^^^^^^^ - | | - | required by a bound introduced by this call +LL | needs_fn(async || { + | _____--------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | x += 1; +LL | | }); + | |_____^ | note: required by a bound in `needs_fn` --> $DIR/not-fn.rs:8:28 diff --git a/tests/ui/attributes/dump_def_parents.stderr b/tests/ui/attributes/dump_def_parents.stderr index b2cc32d09b07e..966d9e7ff1408 100644 --- a/tests/ui/attributes/dump_def_parents.stderr +++ b/tests/ui/attributes/dump_def_parents.stderr @@ -1,8 +1,14 @@ error: rustc_dump_def_parents: DefId(..) --> $DIR/dump_def_parents.rs:8:13 | -LL | || { - | ^^ +LL | / || { +LL | | +LL | | qux::< +LL | | { +... | +LL | | >(); +LL | | }; + | |_____________^ | note: DefId(..) --> $DIR/dump_def_parents.rs:6:9 @@ -46,8 +52,14 @@ LL | | }, note: DefId(..) --> $DIR/dump_def_parents.rs:8:13 | -LL | || { - | ^^ +LL | / || { +LL | | +LL | | qux::< +LL | | { +... | +LL | | >(); +LL | | }; + | |_____________^ note: DefId(..) --> $DIR/dump_def_parents.rs:6:9 | @@ -95,8 +107,14 @@ LL | | }, note: DefId(..) --> $DIR/dump_def_parents.rs:8:13 | -LL | || { - | ^^ +LL | / || { +LL | | +LL | | qux::< +LL | | { +... | +LL | | >(); +LL | | }; + | |_____________^ note: DefId(..) --> $DIR/dump_def_parents.rs:6:9 | diff --git a/tests/ui/block-result/issue-20862.stderr b/tests/ui/block-result/issue-20862.stderr index 1df3a6836206b..093bbb8378548 100644 --- a/tests/ui/block-result/issue-20862.stderr +++ b/tests/ui/block-result/issue-20862.stderr @@ -7,7 +7,7 @@ LL | |y| x + y | ^^^^^^^^^ expected `()`, found closure | = note: expected unit type `()` - found closure `{closure@$DIR/issue-20862.rs:2:5: 2:8}` + found closure `{closure@$DIR/issue-20862.rs:2:5: 2:14}` error[E0618]: expected function, found `()` --> $DIR/issue-20862.rs:7:13 diff --git a/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.stderr b/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.stderr index 2b16206cd7742..edaa903c0f8d8 100644 --- a/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.stderr +++ b/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.stderr @@ -1,13 +1,15 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation-impl-trait.rs:11:9 | -LL | fn bar() -> impl Fn() -> usize { - | --- ------------------ change this to return `FnMut` instead of `Fn` -LL | let mut x = 0; -LL | move || { - | ------- in this closure -LL | x += 1; - | ^^^^^^ cannot assign +LL | fn bar() -> impl Fn() -> usize { + | --- ------------------ change this to return `FnMut` instead of `Fn` +LL | let mut x = 0; +LL | / move || { +LL | | x += 1; + | | ^^^^^^ cannot assign +LL | | x +LL | | } + | |_____- in this closure error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrow-immutable-upvar-mutation.stderr b/tests/ui/borrowck/borrow-immutable-upvar-mutation.stderr index a0eaf1f163b02..0f16d139daa5f 100644 --- a/tests/ui/borrowck/borrow-immutable-upvar-mutation.stderr +++ b/tests/ui/borrowck/borrow-immutable-upvar-mutation.stderr @@ -5,8 +5,9 @@ LL | fn to_fn>(f: F) -> F { | - change this to accept `FnMut` instead of `Fn` ... LL | let _f = to_fn(|| x = 42); - | ----- -- ^^^^^^ cannot assign - | | | + | ----- ---^^^^^^ + | | | | + | | | cannot assign | | in this closure | expects `Fn` instead of `FnMut` @@ -17,8 +18,9 @@ LL | fn to_fn>(f: F) -> F { | - change this to accept `FnMut` instead of `Fn` ... LL | let _g = to_fn(|| set(&mut y)); - | ----- -- ^^^^^^ cannot borrow as mutable - | | | + | ----- -------^^^^^^- + | | | | + | | | cannot borrow as mutable | | in this closure | expects `Fn` instead of `FnMut` @@ -29,8 +31,9 @@ LL | fn to_fn>(f: F) -> F { | - change this to accept `FnMut` instead of `Fn` ... LL | to_fn(|| z = 42); - | ----- -- ^^^^^^ cannot assign - | | | + | ----- ---^^^^^^ + | | | | + | | | cannot assign | | in this closure | expects `Fn` instead of `FnMut` @@ -41,8 +44,9 @@ LL | fn to_fn>(f: F) -> F { | - change this to accept `FnMut` instead of `Fn` ... LL | let _f = to_fn(move || x = 42); - | ----- ------- ^^^^^^ cannot assign - | | | + | ----- --------^^^^^^ + | | | | + | | | cannot assign | | in this closure | expects `Fn` instead of `FnMut` @@ -53,8 +57,9 @@ LL | fn to_fn>(f: F) -> F { | - change this to accept `FnMut` instead of `Fn` ... LL | let _g = to_fn(move || set(&mut y)); - | ----- ------- ^^^^^^ cannot borrow as mutable - | | | + | ----- ------------^^^^^^- + | | | | + | | | cannot borrow as mutable | | in this closure | expects `Fn` instead of `FnMut` @@ -65,21 +70,25 @@ LL | fn to_fn>(f: F) -> F { | - change this to accept `FnMut` instead of `Fn` ... LL | to_fn(move || z = 42); - | ----- ------- ^^^^^^ cannot assign - | | | + | ----- --------^^^^^^ + | | | | + | | | cannot assign | | in this closure | expects `Fn` instead of `FnMut` error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:53:9 | -LL | fn foo() -> Box usize> { - | --- ---------------------- change this to return `FnMut` instead of `Fn` -LL | let mut x = 0; -LL | Box::new(move || { - | ------- in this closure -LL | x += 1; - | ^^^^^^ cannot assign +LL | fn foo() -> Box usize> { + | --- ---------------------- change this to return `FnMut` instead of `Fn` +LL | let mut x = 0; +LL | Box::new(move || { + | ______________- +LL | | x += 1; + | | ^^^^^^ cannot assign +LL | | x +LL | | }) + | |_____- in this closure error: aborting due to 7 previous errors diff --git a/tests/ui/borrowck/borrow-raw-address-of-mutability.stderr b/tests/ui/borrowck/borrow-raw-address-of-mutability.stderr index 4b5b368287e16..e05bade4bc320 100644 --- a/tests/ui/borrowck/borrow-raw-address-of-mutability.stderr +++ b/tests/ui/borrowck/borrow-raw-address-of-mutability.stderr @@ -37,28 +37,32 @@ LL | let mut f = || { error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/borrow-raw-address-of-mutability.rs:29:17 | -LL | fn make_fn(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn make_fn(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | let f = make_fn(|| { - | ------- -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | let y = &raw mut x; - | ^^^^^^^^^^ cannot borrow as mutable +LL | let f = make_fn(|| { + | _____________-------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | let y = &raw mut x; + | | ^^^^^^^^^^ cannot borrow as mutable +LL | | }); + | |_____- in this closure error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/borrow-raw-address-of-mutability.rs:37:17 | -LL | fn make_fn(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn make_fn(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | let f = make_fn(move || { - | ------- ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | let y = &raw mut x; - | ^^^^^^^^^^ cannot borrow as mutable +LL | let f = make_fn(move || { + | _____________-------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | let y = &raw mut x; + | | ^^^^^^^^^^ cannot borrow as mutable +LL | | }); + | |_____- in this closure error: aborting due to 5 previous errors diff --git a/tests/ui/borrowck/borrowck-in-static.stderr b/tests/ui/borrowck/borrowck-in-static.stderr index 745b02ae21b81..05092113fb14b 100644 --- a/tests/ui/borrowck/borrowck-in-static.stderr +++ b/tests/ui/borrowck/borrowck-in-static.stderr @@ -4,8 +4,9 @@ error[E0507]: cannot move out of `x`, a captured variable in an `Fn` closure LL | let x = Box::new(0); | - captured outer variable LL | Box::new(|| x) - | -- ^ move occurs because `x` has type `Box`, which does not implement the `Copy` trait - | | + | ---^ + | | | + | | move occurs because `x` has type `Box`, which does not implement the `Copy` trait | captured by this `Fn` closure | help: consider cloning the value if the performance cost is acceptable diff --git a/tests/ui/borrowck/borrowck-move-by-capture.stderr b/tests/ui/borrowck/borrowck-move-by-capture.stderr index 9915acfe06537..93e1a22f5e48f 100644 --- a/tests/ui/borrowck/borrowck-move-by-capture.stderr +++ b/tests/ui/borrowck/borrowck-move-by-capture.stderr @@ -1,16 +1,18 @@ error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | -LL | let bar: Box<_> = Box::new(3); - | --- captured outer variable -LL | let _g = to_fn_mut(|| { - | -- captured by this `FnMut` closure -LL | let _h = to_fn_once(move || -> isize { *bar }); - | ^^^^^^^^^^^^^^^^ ---- - | | | - | | variable moved due to use in closure - | | move occurs because `bar` has type `Box`, which does not implement the `Copy` trait - | `bar` is moved here +LL | let bar: Box<_> = Box::new(3); + | --- captured outer variable +LL | let _g = to_fn_mut(|| { + | ________________________- +LL | | let _h = to_fn_once(move || -> isize { *bar }); + | | ^^^^^^^^^^^^^^^^ ---- + | | | | + | | | variable moved due to use in closure + | | | move occurs because `bar` has type `Box`, which does not implement the `Copy` trait + | | `bar` is moved here +LL | | }); + | |_____- captured by this `FnMut` closure | help: clone the value before moving it into the closure | diff --git a/tests/ui/borrowck/issue-103624.stderr b/tests/ui/borrowck/issue-103624.stderr index 603055beadcef..3f4918932bae5 100644 --- a/tests/ui/borrowck/issue-103624.stderr +++ b/tests/ui/borrowck/issue-103624.stderr @@ -1,14 +1,17 @@ error[E0507]: cannot move out of `self.b`, as `self` is a captured variable in an `Fn` closure --> $DIR/issue-103624.rs:16:13 | -LL | async fn foo(&self) { - | ----- captured outer variable -LL | let bar = self.b.bar().await; -LL | spawn_blocking(move || { - | ------- captured by this `Fn` closure -LL | -LL | self.b; - | ^^^^^^ move occurs because `self.b` has type `StructB`, which does not implement the `Copy` trait +LL | async fn foo(&self) { + | ----- captured outer variable +LL | let bar = self.b.bar().await; +LL | spawn_blocking(move || { + | ________________________- +LL | | +LL | | self.b; + | | ^^^^^^ move occurs because `self.b` has type `StructB`, which does not implement the `Copy` trait +LL | | +LL | | }) + | |_________- captured by this `Fn` closure | note: if `StructB` implemented `Clone`, you could clone the value --> $DIR/issue-103624.rs:23:1 diff --git a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr index 5887752800b55..0e19e2a98e62b 100644 --- a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr +++ b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let _action = move || { | ------- | | | - | | return type of closure `{closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:11}` contains a lifetime `'2` + | | return type of closure `{closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:15}` contains a lifetime `'2` | lifetime `'1` represents this closure's body LL | || f() // The `nested` closure | ^^^^^^ returning this value requires that `'1` must outlive `'2` diff --git a/tests/ui/borrowck/issue-81899.stderr b/tests/ui/borrowck/issue-81899.stderr index 1da573ea97c19..7eb356fa22209 100644 --- a/tests/ui/borrowck/issue-81899.stderr +++ b/tests/ui/borrowck/issue-81899.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | panic!() | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:11:5 | -note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>` +note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:37}>` --> $DIR/issue-81899.rs:11:5 | LL | panic!() diff --git a/tests/ui/borrowck/issue-87456-point-to-closure.stderr b/tests/ui/borrowck/issue-87456-point-to-closure.stderr index a0c7cac2addd0..432126afd1b2e 100644 --- a/tests/ui/borrowck/issue-87456-point-to-closure.stderr +++ b/tests/ui/borrowck/issue-87456-point-to-closure.stderr @@ -1,14 +1,18 @@ error[E0507]: cannot move out of `val`, a captured variable in an `FnMut` closure --> $DIR/issue-87456-point-to-closure.rs:10:28 | -LL | let val = String::new(); - | --- captured outer variable +LL | let val = String::new(); + | --- captured outer variable LL | -LL | take_mut(|| { - | -- captured by this `FnMut` closure -LL | -LL | let _foo: String = val; - | ^^^ move occurs because `val` has type `String`, which does not implement the `Copy` trait +LL | take_mut(|| { + | ______________- +LL | | +LL | | let _foo: String = val; + | | ^^^ move occurs because `val` has type `String`, which does not implement the `Copy` trait +LL | | +LL | | +LL | | }) + | |_____- captured by this `FnMut` closure | help: consider borrowing here | diff --git a/tests/ui/borrowck/issue-88434-minimal-example.stderr b/tests/ui/borrowck/issue-88434-minimal-example.stderr index b32331ce448e6..428a7b3cc73c2 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.stderr +++ b/tests/ui/borrowck/issue-88434-minimal-example.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | panic!() | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:10:5 | -note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>` +note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:31}>` --> $DIR/issue-88434-minimal-example.rs:10:5 | LL | panic!() diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index e3c881dd46503..da8d446640909 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | panic!() | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | -note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` +note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:37}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr index d7762621cc5c7..ba913b754bed2 100644 --- a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr @@ -24,7 +24,7 @@ error: lifetime may not live long enough LL | move |()| s.chars().map(|c| format!("{}{}", c, s)) | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `Map, {closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:11:29: 11:32}>` contains a lifetime `'2` + | | return type of closure `Map, {closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:11:29: 11:54}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/borrowck/mutability-errors.stderr b/tests/ui/borrowck/mutability-errors.stderr index 3cab3ccb993c9..810c75af9d044 100644 --- a/tests/ui/borrowck/mutability-errors.stderr +++ b/tests/ui/borrowck/mutability-errors.stderr @@ -137,112 +137,146 @@ LL | &mut (*f()).0; error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:40:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | x = (1,); - | ^^^^^^^^ cannot assign +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); + | | ^^^^^^^^ cannot assign +LL | | x.0 = 1; +LL | | &mut x; +LL | | &mut x.0; +LL | | }); + | |_____- in this closure error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:41:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | x = (1,); -LL | x.0 = 1; - | ^^^^^^^ cannot assign +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); +LL | | x.0 = 1; + | | ^^^^^^^ cannot assign +LL | | &mut x; +LL | | &mut x.0; +LL | | }); + | |_____- in this closure error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:42:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` -... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | &mut x; - | ^^^^^^ cannot borrow as mutable +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); +LL | | x.0 = 1; +LL | | &mut x; + | | ^^^^^^ cannot borrow as mutable +LL | | &mut x.0; +LL | | }); + | |_____- in this closure error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:43:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` -... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); +LL | | x.0 = 1; +LL | | &mut x; +LL | | &mut x.0; + | | ^^^^^^^^ cannot borrow as mutable +LL | | }); + | |_____- in this closure error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:46:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | x = (1,); - | ^^^^^^^^ cannot assign +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); + | | ^^^^^^^^ cannot assign +LL | | x.0 = 1; +LL | | &mut x; +LL | | &mut x.0; +LL | | }); + | |_____- in this closure error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:47:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | x = (1,); -LL | x.0 = 1; - | ^^^^^^^ cannot assign +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); +LL | | x.0 = 1; + | | ^^^^^^^ cannot assign +LL | | &mut x; +LL | | &mut x.0; +LL | | }); + | |_____- in this closure error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:48:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` -... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | &mut x; - | ^^^^^^ cannot borrow as mutable +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); +LL | | x.0 = 1; +LL | | &mut x; + | | ^^^^^^ cannot borrow as mutable +LL | | &mut x.0; +LL | | }); + | |_____- in this closure error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:49:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` -... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | x = (1,); +LL | | x.0 = 1; +LL | | &mut x; +LL | | &mut x.0; + | | ^^^^^^^^ cannot borrow as mutable +LL | | }); + | |_____- in this closure error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/mutability-errors.rs:53:14 diff --git a/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr b/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr index 177e9c8d2487e..e522c2691f100 100644 --- a/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr +++ b/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr @@ -1,14 +1,17 @@ error[E0507]: cannot move out of `y`, a captured variable in an `Fn` closure --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:12:9 | -LL | let y = vec![format!("World")]; - | - captured outer variable -LL | call(|| { - | -- captured by this `Fn` closure -LL | y.into_iter(); - | ^ ----------- `y` moved due to this method call - | | - | move occurs because `y` has type `Vec`, which does not implement the `Copy` trait +LL | let y = vec![format!("World")]; + | - captured outer variable +LL | call(|| { + | __________- +LL | | y.into_iter(); + | | ^ ----------- `y` moved due to this method call + | | | + | | move occurs because `y` has type `Vec`, which does not implement the `Copy` trait +LL | | +LL | | }); + | |_____- captured by this `Fn` closure | note: `into_iter` takes ownership of the receiver `self`, which moves `y` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL diff --git a/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr index c0f222b016db7..c59c9872e9067 100644 --- a/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr +++ b/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -1,13 +1,14 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-infer-var-appearing-twice.rs:14:5 | -LL | with_closure(|x: u32, y: i32| { - | ^ ---------------- found signature defined here - | _____| - | | -LL | | -LL | | }); - | |______^ expected due to this +LL | with_closure(|x: u32, y: i32| { + | ______^ - + | | __________________| +LL | || +LL | || }); + | ||_____-^ expected due to this + | |_____| + | found signature defined here | = note: expected closure signature `fn(_, u32) -> _` found closure signature `fn(_, i32) -> _` diff --git a/tests/ui/closure_context/issue-26046-fn-mut.stderr b/tests/ui/closure_context/issue-26046-fn-mut.stderr index 0b58180bcca77..c1d64e07a829b 100644 --- a/tests/ui/closure_context/issue-26046-fn-mut.stderr +++ b/tests/ui/closure_context/issue-26046-fn-mut.stderr @@ -1,15 +1,17 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut` --> $DIR/issue-26046-fn-mut.rs:4:19 | -LL | let closure = || { - | ^^ this closure implements `FnMut`, not `Fn` -LL | num += 1; - | --- closure is `FnMut` because it mutates the variable `num` here -... -LL | Box::new(closure) - | ----------------- the requirement to implement `Fn` derives from here +LL | let closure = || { + | ___________________^ +LL | | num += 1; + | | --- closure is `FnMut` because it mutates the variable `num` here +LL | | }; + | |_____^ this closure implements `FnMut`, not `Fn` +LL | +LL | Box::new(closure) + | ----------------- the requirement to implement `Fn` derives from here | - = note: required for the cast from `Box<{closure@$DIR/issue-26046-fn-mut.rs:4:19: 4:21}>` to `Box<(dyn Fn() + 'static)>` + = note: required for the cast from `Box<{closure@$DIR/issue-26046-fn-mut.rs:4:19: 6:6}>` to `Box<(dyn Fn() + 'static)>` error: aborting due to 1 previous error diff --git a/tests/ui/closure_context/issue-26046-fn-once.stderr b/tests/ui/closure_context/issue-26046-fn-once.stderr index 66fb1856cbbbf..da139dbea0948 100644 --- a/tests/ui/closure_context/issue-26046-fn-once.stderr +++ b/tests/ui/closure_context/issue-26046-fn-once.stderr @@ -1,15 +1,17 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/issue-26046-fn-once.rs:4:19 | -LL | let closure = move || { - | ^^^^^^^ this closure implements `FnOnce`, not `Fn` -LL | vec - | --- closure is `FnOnce` because it moves the variable `vec` out of its environment -... -LL | Box::new(closure) - | ----------------- the requirement to implement `Fn` derives from here +LL | let closure = move || { + | ___________________^ +LL | | vec + | | --- closure is `FnOnce` because it moves the variable `vec` out of its environment +LL | | }; + | |_____^ this closure implements `FnOnce`, not `Fn` +LL | +LL | Box::new(closure) + | ----------------- the requirement to implement `Fn` derives from here | - = note: required for the cast from `Box<{closure@$DIR/issue-26046-fn-once.rs:4:19: 4:26}>` to `Box<(dyn Fn() -> Vec + 'static)>` + = note: required for the cast from `Box<{closure@$DIR/issue-26046-fn-once.rs:4:19: 6:6}>` to `Box<(dyn Fn() -> Vec + 'static)>` error: aborting due to 1 previous error diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr index 1172f54c15088..ccacbe201f6a7 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr @@ -1,15 +1,16 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/closure-origin-array-diagnostics.rs:9:13 | -LL | let c = || { - | ^^ this closure implements `FnOnce`, not `Fn` -LL | let [_, _s] = s; - | - closure is `FnOnce` because it moves the variable `s` out of its environment -LL | }; -LL | expect_fn(c); - | --------- - the requirement to implement `Fn` derives from here - | | - | required by a bound introduced by this call +LL | let c = || { + | _____________^ +LL | | let [_, _s] = s; + | | - closure is `FnOnce` because it moves the variable `s` out of its environment +LL | | }; + | |_____^ this closure implements `FnOnce`, not `Fn` +LL | expect_fn(c); + | --------- - the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call | note: required by a bound in `expect_fn` --> $DIR/closure-origin-array-diagnostics.rs:5:17 diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr index 4abe5eda22d76..c04648f8a2458 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr @@ -1,15 +1,16 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/closure-origin-tuple-diagnostics.rs:9:13 | -LL | let c = || { - | ^^ this closure implements `FnOnce`, not `Fn` -LL | let s = s.1; - | --- closure is `FnOnce` because it moves the variable `s.1` out of its environment -LL | }; -LL | expect_fn(c); - | --------- - the requirement to implement `Fn` derives from here - | | - | required by a bound introduced by this call +LL | let c = || { + | _____________^ +LL | | let s = s.1; + | | --- closure is `FnOnce` because it moves the variable `s.1` out of its environment +LL | | }; + | |_____^ this closure implements `FnOnce`, not `Fn` +LL | expect_fn(c); + | --------- - the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call | note: required by a bound in `expect_fn` --> $DIR/closure-origin-tuple-diagnostics.rs:5:17 diff --git a/tests/ui/closures/2229_closure_analysis/issue-90465.stderr b/tests/ui/closures/2229_closure_analysis/issue-90465.stderr index ccca24764e42a..e844f9ea381c3 100644 --- a/tests/ui/closures/2229_closure_analysis/issue-90465.stderr +++ b/tests/ui/closures/2229_closure_analysis/issue-90465.stderr @@ -1,14 +1,18 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/issue-90465.rs:17:14 | -LL | let c0 = move || { - | ^^^^^^^ +LL | let c0 = move || { + | ______________^ +LL | | +LL | | +LL | | let _ = f0; + | | -- in Rust 2018, this causes the closure to capture `f0`, but in Rust 2021, it has no effect +LL | | +LL | | }; + | |_____^ ... -LL | let _ = f0; - | -- in Rust 2018, this causes the closure to capture `f0`, but in Rust 2021, it has no effect -... -LL | } - | - in Rust 2018, `f0` is dropped here along with the closure, but in Rust 2021 `f0` is not part of the closure +LL | } + | - in Rust 2018, `f0` is dropped here along with the closure, but in Rust 2021 `f0` is not part of the closure | = note: for more information, see note: the lint level is defined here diff --git a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr index fdcada468e093..519e143c1fbaf 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr @@ -1,11 +1,17 @@ error: changes to closure capture in Rust 2021 will affect which traits the closure implements --> $DIR/auto_traits.rs:22:19 | -LL | thread::spawn(move || unsafe { - | ^^^^^^^ in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0` does not implement `Send` -... -LL | *fptr.0 = 20; - | ------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0` +LL | thread::spawn(move || unsafe { + | ___________________^ +LL | | +LL | | +LL | | +LL | | +LL | | *fptr.0 = 20; + | | ------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0` +LL | | +LL | | }).join().unwrap(); + | |_____^ in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0` does not implement `Send` | = note: for more information, see note: the lint level is defined here @@ -25,14 +31,20 @@ LL ~ } }).join().unwrap(); error: changes to closure capture in Rust 2021 will affect which traits the closure implements --> $DIR/auto_traits.rs:42:19 | -LL | thread::spawn(move || unsafe { - | ^^^^^^^ - | | - | in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0.0` does not implement `Send` - | in Rust 2018, this closure implements `Sync` as `fptr` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr` is not fully captured and `fptr.0.0` does not implement `Sync` -... -LL | *fptr.0.0 = 20; - | --------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0` +LL | thread::spawn(move || unsafe { + | ___________________^ +LL | | +LL | | +LL | | +... | +LL | | *fptr.0.0 = 20; + | | --------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0` +LL | | +LL | | }).join().unwrap(); + | | ^ + | | | + | |_____in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0.0` does not implement `Send` + | in Rust 2018, this closure implements `Sync` as `fptr` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr` is not fully captured and `fptr.0.0` does not implement `Sync` | = note: for more information, see help: add a dummy let to cause `fptr` to be fully captured @@ -47,14 +59,21 @@ LL ~ } }).join().unwrap(); error: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements --> $DIR/auto_traits.rs:67:13 | -LL | let c = || { - | ^^ in Rust 2018, this closure implements `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f` is not fully captured and `f.1` does not implement `Clone` -... -LL | let f_1 = f.1; - | --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.1` +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | +LL | | let f_1 = f.1; + | | --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.1` +LL | | +LL | | println!("{:?}", f_1.0); +LL | | }; + | |_____^ in Rust 2018, this closure implements `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f` is not fully captured and `f.1` does not implement `Clone` ... -LL | } - | - in Rust 2018, `f` is dropped here, but in Rust 2021, only `f.1` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `f` is dropped here, but in Rust 2021, only `f.1` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `f` to be fully captured diff --git a/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr b/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr index a0795c12928ff..32f6a3eb70a03 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr @@ -1,14 +1,19 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop_attr_migrations.rs:39:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | = note: for more information, see note: the lint level is defined here @@ -25,14 +30,19 @@ LL + let _ = &t; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop_attr_migrations.rs:59:13 | -LL | let c = move || { - | ^^^^^^^ -... -LL | let _t = t.1; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` +LL | let c = move || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.1; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` +LL | | +LL | | }; + | |_____^ ... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t` to be fully captured diff --git a/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr b/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr index 7ea5136d11910..fb22dad836143 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr @@ -2,7 +2,9 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/macro.rs:19:13 | LL | let _ = || dbg!(a.0); - | ^^ --- in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0` + | ^^^^^^^^---^ + | | + | in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0` ... LL | } | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure diff --git a/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr b/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr index 94526487e6792..19dab171e0e35 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr @@ -1,14 +1,19 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/migrations_rustfix.rs:19:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | = note: for more information, see note: the lint level is defined here @@ -26,7 +31,9 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/migrations_rustfix.rs:33:13 | LL | let c = || t.0; - | ^^ --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` + | ^^^--- + | | + | in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` ... LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure diff --git a/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr index 2b76deca37708..b806075dec85e 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr @@ -1,14 +1,20 @@ error: changes to closure capture in Rust 2021 will affect which traits the closure implements --> $DIR/mir_calls_to_shims.rs:20:38 | -LL | let result = panic::catch_unwind(move || { - | ^^^^^^^ - | | - | in Rust 2018, this closure implements `RefUnwindSafe` as `f` implements `RefUnwindSafe`, but in Rust 2021, this closure will no longer implement `RefUnwindSafe` because `f` is not fully captured and `f.0` does not implement `RefUnwindSafe` - | in Rust 2018, this closure implements `UnwindSafe` as `f` implements `UnwindSafe`, but in Rust 2021, this closure will no longer implement `UnwindSafe` because `f` is not fully captured and `f.0` does not implement `UnwindSafe` -... -LL | f.0() - | --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.0` +LL | let result = panic::catch_unwind(move || { + | ______________________________________^ +LL | | +LL | | +LL | | +... | +LL | | f.0() + | | --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.0` +LL | | +LL | | }); + | | ^ + | | | + | |_____in Rust 2018, this closure implements `RefUnwindSafe` as `f` implements `RefUnwindSafe`, but in Rust 2021, this closure will no longer implement `RefUnwindSafe` because `f` is not fully captured and `f.0` does not implement `RefUnwindSafe` + | in Rust 2018, this closure implements `UnwindSafe` as `f` implements `UnwindSafe`, but in Rust 2021, this closure will no longer implement `UnwindSafe` because `f` is not fully captured and `f.0` does not implement `UnwindSafe` | = note: for more information, see note: the lint level is defined here diff --git a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr index 138778ff5d723..83a8088b13fde 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr @@ -1,17 +1,23 @@ error: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements --> $DIR/multi_diagnostics.rs:37:13 | -LL | let c = || { - | ^^ in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | +LL | | let _f_1 = f1.0; + | | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` +LL | | +LL | | let _f_2 = f2.1; + | | ---- in Rust 2018, this closure captures all of `f2`, but in Rust 2021, it will only capture `f2.1` +LL | | +LL | | }; + | |_____^ in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` ... -LL | let _f_1 = f1.0; - | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` -LL | -LL | let _f_2 = f2.1; - | ---- in Rust 2018, this closure captures all of `f2`, but in Rust 2021, it will only capture `f2.1` -... -LL | } - | - in Rust 2018, `f2` is dropped here, but in Rust 2021, only `f2.1` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `f2` is dropped here, but in Rust 2021, only `f2.1` will be dropped here as part of the closure | = note: for more information, see note: the lint level is defined here @@ -28,11 +34,18 @@ LL + let _ = (&f1, &f2); error: changes to closure capture in Rust 2021 will affect which traits the closure implements --> $DIR/multi_diagnostics.rs:56:13 | -LL | let c = || { - | ^^ in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` -... -LL | let _f_1 = f1.0; - | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | +LL | | let _f_1 = f1.0; + | | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` +LL | | +LL | | let _f_2 = f1.1; +LL | | }; + | |_____^ in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` | = note: for more information, see help: add a dummy let to cause `f1` to be fully captured @@ -44,17 +57,23 @@ LL + let _ = &f1; error: changes to closure capture in Rust 2021 will affect which traits the closure implements --> $DIR/multi_diagnostics.rs:81:13 | -LL | let c = || { - | ^^ - | | - | in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` - | in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.2` does not implement `Clone` -... -LL | let _f_0 = f1.0; - | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` -LL | -LL | let _f_2 = f1.2; - | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.2` +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +... | +LL | | let _f_0 = f1.0; + | | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` +LL | | +LL | | let _f_2 = f1.2; + | | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.2` +LL | | +LL | | }; + | | ^ + | | | + | |_____in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` + | in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.2` does not implement `Clone` | = note: for more information, see help: add a dummy let to cause `f1` to be fully captured @@ -66,20 +85,26 @@ LL + let _ = &f1; error: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements --> $DIR/multi_diagnostics.rs:100:13 | -LL | let c = || { - | ^^ in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | +LL | | let _f_0 = f1.0; + | | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` +LL | | +LL | | let _f_1 = f1.1; + | | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.1` +LL | | +LL | | }; + | |_____^ in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f1` is not fully captured and `f1.0` does not implement `Clone` ... -LL | let _f_0 = f1.0; - | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` -LL | -LL | let _f_1 = f1.1; - | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.1` -... -LL | } - | - - | | - | in Rust 2018, `f1` is dropped here, but in Rust 2021, only `f1.0` will be dropped here as part of the closure - | in Rust 2018, `f1` is dropped here, but in Rust 2021, only `f1.1` will be dropped here as part of the closure +LL | } + | - + | | + | in Rust 2018, `f1` is dropped here, but in Rust 2021, only `f1.0` will be dropped here as part of the closure + | in Rust 2018, `f1` is dropped here, but in Rust 2021, only `f1.1` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `f1` to be fully captured @@ -91,18 +116,24 @@ LL + let _ = &f1; error: changes to closure capture in Rust 2021 will affect which traits the closure implements --> $DIR/multi_diagnostics.rs:133:19 | -LL | thread::spawn(move || unsafe { - | ^^^^^^^ - | | - | in Rust 2018, this closure implements `Send` as `fptr1` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr1` is not fully captured and `fptr1.0.0` does not implement `Send` - | in Rust 2018, this closure implements `Sync` as `fptr1` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr1` is not fully captured and `fptr1.0.0` does not implement `Sync` - | in Rust 2018, this closure implements `Send` as `fptr2` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr2` is not fully captured and `fptr2.0` does not implement `Send` -... -LL | *fptr1.0.0 = 20; - | ---------- in Rust 2018, this closure captures all of `fptr1`, but in Rust 2021, it will only capture `fptr1.0.0` -LL | -LL | *fptr2.0 = 20; - | -------- in Rust 2018, this closure captures all of `fptr2`, but in Rust 2021, it will only capture `fptr2.0` +LL | thread::spawn(move || unsafe { + | ___________________^ +LL | | +LL | | +LL | | +... | +LL | | *fptr1.0.0 = 20; + | | ---------- in Rust 2018, this closure captures all of `fptr1`, but in Rust 2021, it will only capture `fptr1.0.0` +LL | | +LL | | *fptr2.0 = 20; + | | -------- in Rust 2018, this closure captures all of `fptr2`, but in Rust 2021, it will only capture `fptr2.0` +LL | | +LL | | }).join().unwrap(); + | | ^ + | | | + | | in Rust 2018, this closure implements `Send` as `fptr1` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr1` is not fully captured and `fptr1.0.0` does not implement `Send` + | |_____in Rust 2018, this closure implements `Sync` as `fptr1` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr1` is not fully captured and `fptr1.0.0` does not implement `Sync` + | in Rust 2018, this closure implements `Send` as `fptr2` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr2` is not fully captured and `fptr2.0` does not implement `Send` | = note: for more information, see help: add a dummy let to cause `fptr1`, `fptr2` to be fully captured diff --git a/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr b/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr index eff26a4d6f5f6..3c00f325020eb 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr @@ -1,14 +1,20 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/precise.rs:20:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | let _t = &t.1; +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | = note: for more information, see note: the lint level is defined here @@ -25,24 +31,29 @@ LL + let _ = &t; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/precise.rs:45:13 | -LL | let c = || { - | ^^ -... -LL | let _x = u.0.0; - | ----- in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.0.0` -LL | -LL | let _x = u.0.1; - | ----- in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.0.1` -LL | -LL | let _x = u.1.0; - | ----- in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.1.0` +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _x = u.0.0; + | | ----- in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.0.0` +LL | | +LL | | let _x = u.0.1; + | | ----- in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.0.1` +LL | | +LL | | let _x = u.1.0; + | | ----- in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.1.0` +LL | | +LL | | }; + | |_____^ ... -LL | } - | - - | | - | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.0` will be dropped here as part of the closure - | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.1` will be dropped here as part of the closure - | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.1.0` will be dropped here as part of the closure +LL | } + | - + | | + | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.0` will be dropped here as part of the closure + | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.1` will be dropped here as part of the closure + | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.1.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `u` to be fully captured diff --git a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr index 54ad20f898338..a79935ac91822 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr @@ -1,24 +1,29 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:25:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | let _t1 = t1.0; + | | ---- in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0` +LL | | +LL | | let _t2 = t2.0; + | | ---- in Rust 2018, this closure captures all of `t2`, but in Rust 2021, it will only capture `t2.0` +LL | | +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -LL | -LL | let _t1 = t1.0; - | ---- in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0` -LL | -LL | let _t2 = t2.0; - | ---- in Rust 2018, this closure captures all of `t2`, but in Rust 2021, it will only capture `t2.0` -... -LL | } - | - - | | - | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure - | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure - | in Rust 2018, `t2` is dropped here, but in Rust 2021, only `t2.0` will be dropped here as part of the closure +LL | } + | - + | | + | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure + | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure + | in Rust 2018, `t2` is dropped here, but in Rust 2021, only `t2.0` will be dropped here as part of the closure | = note: for more information, see note: the lint level is defined here @@ -35,20 +40,26 @@ LL + let _ = (&t, &t1, &t2); error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:50:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | let _t1 = t1.0; + | | ---- in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0` +LL | | +LL | | let _t2 = t2; +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -LL | -LL | let _t1 = t1.0; - | ---- in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0` -... -LL | } - | - - | | - | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure - | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure +LL | } + | - + | | + | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure + | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t`, `t1` to be fully captured @@ -60,14 +71,20 @@ LL + let _ = (&t, &t1); error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:71:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | println!("{:?}", t1.1); +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t` to be fully captured @@ -79,14 +96,19 @@ LL + let _ = &t; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:91:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t` to be fully captured @@ -98,14 +120,19 @@ LL + let _ = &t; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:109:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.0; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +LL | | +LL | | }; + | |_____^ ... -LL | let _t = t.0; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t` to be fully captured @@ -117,14 +144,19 @@ LL + let _ = &t; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:125:13 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | +LL | | let _t = t.1; + | | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` +LL | | +LL | | }; + | |_____^ ... -LL | let _t = t.1; - | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` -... -LL | } - | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t` to be fully captured @@ -136,19 +168,25 @@ LL + let _ = &t; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:143:13 | -LL | let c = move || { - | ^^^^^^^ +LL | let c = move || { + | _____________^ +LL | | +LL | | +LL | | +LL | | println!("{:?} {:?}", t1.1, t.1); + | | ---- --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` + | | | + | | in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.1` +LL | | +LL | | +LL | | }; + | |_____^ ... -LL | println!("{:?} {:?}", t1.1, t.1); - | ---- --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` - | | - | in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.1` -... -LL | } - | - - | | - | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.1` will be dropped here as part of the closure - | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure +LL | } + | - + | | + | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.1` will be dropped here as part of the closure + | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `t1`, `t` to be fully captured @@ -160,14 +198,19 @@ LL + let _ = (&t1, &t); error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:163:21 | -LL | let c = || { - | ^^ +LL | let c = || { + | _____________________^ +LL | | +LL | | +LL | | +LL | | tuple.0; + | | ------- in Rust 2018, this closure captures all of `tuple`, but in Rust 2021, it will only capture `tuple.0` +LL | | +LL | | }; + | |_____________^ ... -LL | tuple.0; - | ------- in Rust 2018, this closure captures all of `tuple`, but in Rust 2021, it will only capture `tuple.0` -... -LL | } - | - in Rust 2018, `tuple` is dropped here, but in Rust 2021, only `tuple.0` will be dropped here as part of the closure +LL | } + | - in Rust 2018, `tuple` is dropped here, but in Rust 2021, only `tuple.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `tuple` to be fully captured @@ -179,14 +222,19 @@ LL + let _ = &tuple; error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:181:17 | -LL | let c = || { - | ^^ -... -LL | tuple.0; - | ------- in Rust 2018, this closure captures all of `tuple`, but in Rust 2021, it will only capture `tuple.0` +LL | let c = || { + | _________________^ +LL | | +LL | | +LL | | +LL | | tuple.0; + | | ------- in Rust 2018, this closure captures all of `tuple`, but in Rust 2021, it will only capture `tuple.0` +LL | | +LL | | }; + | |_________^ ... -LL | }; - | - in Rust 2018, `tuple` is dropped here, but in Rust 2021, only `tuple.0` will be dropped here as part of the closure +LL | }; + | - in Rust 2018, `tuple` is dropped here, but in Rust 2021, only `tuple.0` will be dropped here as part of the closure | = note: for more information, see help: add a dummy let to cause `tuple` to be fully captured @@ -199,7 +247,9 @@ error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:201:18 | LL | let _c = || tup.0; - | ^^ ----- in Rust 2018, this closure captures all of `tup`, but in Rust 2021, it will only capture `tup.0` + | ^^^----- + | | + | in Rust 2018, this closure captures all of `tup`, but in Rust 2021, it will only capture `tup.0` ... LL | } | - in Rust 2018, `tup` is dropped here, but in Rust 2021, only `tup.0` will be dropped here as part of the closure diff --git a/tests/ui/closures/binder/nested-closures-regions.stderr b/tests/ui/closures/binder/nested-closures-regions.stderr index a30339ac67b1c..5ba8682579391 100644 --- a/tests/ui/closures/binder/nested-closures-regions.stderr +++ b/tests/ui/closures/binder/nested-closures-regions.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/nested-closures-regions.rs:8:24 | LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: main::{closure#0}::{closure#0} with closure args [ i8, @@ -19,7 +19,7 @@ note: no external requirements --> $DIR/nested-closures-regions.rs:8:5 | LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: main::{closure#0} with closure args [ i8, diff --git a/tests/ui/closures/closure-move-sync.stderr b/tests/ui/closures/closure-move-sync.stderr index 6cade0c09dd7e..47e677eee4bb2 100644 --- a/tests/ui/closures/closure-move-sync.stderr +++ b/tests/ui/closures/closure-move-sync.stderr @@ -10,13 +10,17 @@ LL | | LL | | }); | |_____^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `std::sync::mpsc::Receiver<()>`, which is required by `{closure@$DIR/closure-move-sync.rs:6:27: 6:29}: Send` + = help: the trait `Sync` is not implemented for `std::sync::mpsc::Receiver<()>`, which is required by `{closure@$DIR/closure-move-sync.rs:6:27: 9:6}: Send` = note: required for `&std::sync::mpsc::Receiver<()>` to implement `Send` note: required because it's used within this closure --> $DIR/closure-move-sync.rs:6:27 | -LL | let t = thread::spawn(|| { - | ^^ +LL | let t = thread::spawn(|| { + | ___________________________^ +LL | | recv.recv().unwrap(); +LL | | +LL | | }); + | |_____^ note: required by a bound in `spawn` --> $SRC_DIR/std/src/thread/mod.rs:LL:COL diff --git a/tests/ui/closures/closure-no-fn-1.stderr b/tests/ui/closures/closure-no-fn-1.stderr index 8fab92e9b151d..b10798ba49d13 100644 --- a/tests/ui/closures/closure-no-fn-1.stderr +++ b/tests/ui/closures/closure-no-fn-1.stderr @@ -7,7 +7,7 @@ LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; | expected due to this | = note: expected fn pointer `fn(u8) -> u8` - found closure `{closure@$DIR/closure-no-fn-1.rs:6:29: 6:36}` + found closure `{closure@$DIR/closure-no-fn-1.rs:6:29: 6:50}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-1.rs:6:39 | diff --git a/tests/ui/closures/closure-no-fn-2.stderr b/tests/ui/closures/closure-no-fn-2.stderr index 06682fcc244a3..6d841c28b9350 100644 --- a/tests/ui/closures/closure-no-fn-2.stderr +++ b/tests/ui/closures/closure-no-fn-2.stderr @@ -7,7 +7,7 @@ LL | let bar: fn() -> u8 = || { b }; | expected due to this | = note: expected fn pointer `fn() -> u8` - found closure `{closure@$DIR/closure-no-fn-2.rs:6:27: 6:29}` + found closure `{closure@$DIR/closure-no-fn-2.rs:6:27: 6:35}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-2.rs:6:32 | diff --git a/tests/ui/closures/closure-no-fn-3.stderr b/tests/ui/closures/closure-no-fn-3.stderr index 7711347c5683e..68079e9f0d2ee 100644 --- a/tests/ui/closures/closure-no-fn-3.stderr +++ b/tests/ui/closures/closure-no-fn-3.stderr @@ -1,4 +1,4 @@ -error[E0605]: non-primitive cast: `{closure@$DIR/closure-no-fn-3.rs:6:28: 6:30}` as `fn() -> u8` +error[E0605]: non-primitive cast: `{closure@$DIR/closure-no-fn-3.rs:6:28: 6:36}` as `fn() -> u8` --> $DIR/closure-no-fn-3.rs:6:27 | LL | let baz: fn() -> u8 = (|| { b }) as fn() -> u8; diff --git a/tests/ui/closures/closure-no-fn-4.stderr b/tests/ui/closures/closure-no-fn-4.stderr index c86731b127d3c..89914e9b13dc3 100644 --- a/tests/ui/closures/closure-no-fn-4.stderr +++ b/tests/ui/closures/closure-no-fn-4.stderr @@ -12,7 +12,7 @@ LL | | }; | |_____- `match` arms have incompatible types | = note: expected fn pointer `fn(usize) -> usize` - found closure `{closure@$DIR/closure-no-fn-4.rs:5:18: 5:21}` + found closure `{closure@$DIR/closure-no-fn-4.rs:5:18: 5:27}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-4.rs:5:26 | diff --git a/tests/ui/closures/closure-no-fn-5.stderr b/tests/ui/closures/closure-no-fn-5.stderr index ffe01fac4966d..7496966f6c0b1 100644 --- a/tests/ui/closures/closure-no-fn-5.stderr +++ b/tests/ui/closures/closure-no-fn-5.stderr @@ -7,7 +7,7 @@ LL | let bar: fn() -> u8 = || { a; b; c; d; e }; | expected due to this | = note: expected fn pointer `fn() -> u8` - found closure `{closure@$DIR/closure-no-fn-5.rs:10:27: 10:29}` + found closure `{closure@$DIR/closure-no-fn-5.rs:10:27: 10:47}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-5.rs:10:32 | diff --git a/tests/ui/closures/closure-reform-bad.stderr b/tests/ui/closures/closure-reform-bad.stderr index 426930666065d..0fb988b6e1e2b 100644 --- a/tests/ui/closures/closure-reform-bad.stderr +++ b/tests/ui/closures/closure-reform-bad.stderr @@ -2,14 +2,14 @@ error[E0308]: mismatched types --> $DIR/closure-reform-bad.rs:11:15 | LL | let f = |s: &str| println!("{}{}", s, string); - | --------- the found closure + | ------------------------------------- the found closure LL | call_bare(f) | --------- ^ expected fn pointer, found closure | | | arguments to this function are incorrect | = note: expected fn pointer `for<'a> fn(&'a str)` - found closure `{closure@$DIR/closure-reform-bad.rs:10:13: 10:22}` + found closure `{closure@$DIR/closure-reform-bad.rs:10:13: 10:50}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-reform-bad.rs:10:43 | diff --git a/tests/ui/closures/closure-wrong-kind.stderr b/tests/ui/closures/closure-wrong-kind.stderr index 705cc948668fc..ee2312fe7b6f2 100644 --- a/tests/ui/closures/closure-wrong-kind.stderr +++ b/tests/ui/closures/closure-wrong-kind.stderr @@ -2,8 +2,9 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closur --> $DIR/closure-wrong-kind.rs:10:19 | LL | let closure = |_| foo(x); - | ^^^ - closure is `FnOnce` because it moves the variable `x` out of its environment - | | + | ^^^^^^^^-^ + | | | + | | closure is `FnOnce` because it moves the variable `x` out of its environment | this closure implements `FnOnce`, not `Fn` LL | bar(closure); | --- ------- the requirement to implement `Fn` derives from here diff --git a/tests/ui/closures/closure_cap_coerce_many_fail.stderr b/tests/ui/closures/closure_cap_coerce_many_fail.stderr index 958439e7dd061..0b83ad784c8c9 100644 --- a/tests/ui/closures/closure_cap_coerce_many_fail.stderr +++ b/tests/ui/closures/closure_cap_coerce_many_fail.stderr @@ -12,7 +12,7 @@ LL | | }; | |_____- `match` arms have incompatible types | = note: expected fn item `fn(i32, i32) -> i32 {add}` - found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:22}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:43}` error[E0308]: `match` arms have incompatible types --> $DIR/closure_cap_coerce_many_fail.rs:18:16 @@ -23,15 +23,15 @@ LL | | "+" => |a, b| (a + b) as i32, | | --------------------- | | | | | the expected closure - | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22}` + | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:37}` LL | | "-" => |a, b| (a - b + cap) as i32, | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22}` - found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:22}` + = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:37}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:43}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object @@ -44,15 +44,15 @@ LL | | "+" => |a, b| (a + b + cap) as i32, | | --------------------------- | | | | | the expected closure - | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22}` + | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:43}` LL | | "-" => |a, b| (a - b) as i32, | | ^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22}` - found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:22}` + = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:43}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:37}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object @@ -65,15 +65,15 @@ LL | | "+" => |a, b| (a + b + cap) as i32, | | --------------------------- | | | | | the expected closure - | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22}` + | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:43}` LL | | "-" => |a, b| (a - b + cap) as i32, | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22}` - found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:22}` + = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:43}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:43}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr index eaa0d32e75dff..7ad8ef9e4cdfc 100644 --- a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr +++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr @@ -8,7 +8,7 @@ LL | | x.to_string(); LL | | }); | |______^ implementation of `Foo` is not general enough | - = note: `Wrap<{closure@$DIR/obligation-with-leaking-placeholders.rs:18:15: 18:18}>` must implement `Foo<'0>`, for any lifetime `'0`... + = note: `Wrap<{closure@$DIR/obligation-with-leaking-placeholders.rs:18:15: 22:6}>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but it actually implements `Foo<'1>`, for some specific lifetime `'1` error: aborting due to 1 previous error diff --git a/tests/ui/closures/issue-25439.stderr b/tests/ui/closures/issue-25439.stderr index 19a26396a5d94..fee249afd5093 100644 --- a/tests/ui/closures/issue-25439.stderr +++ b/tests/ui/closures/issue-25439.stderr @@ -2,7 +2,7 @@ error[E0644]: closure/coroutine type that references itself --> $DIR/issue-25439.rs:8:9 | LL | fix(|_, x| x); - | ^^^^^^ cyclic type of infinite size + | ^^^^^^^^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, diff --git a/tests/ui/closures/issue-90871.stderr b/tests/ui/closures/issue-90871.stderr index ef1cb213f73be..2f7cff49d7330 100644 --- a/tests/ui/closures/issue-90871.stderr +++ b/tests/ui/closures/issue-90871.stderr @@ -14,7 +14,7 @@ LL | type_ascribe!(2, n([u8; || 1])) | ^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/issue-90871.rs:4:29: 4:31}` + found closure `{closure@$DIR/issue-90871.rs:4:29: 4:33}` help: use parentheses to call this closure | LL | type_ascribe!(2, n([u8; (|| 1)()])) diff --git a/tests/ui/closures/multiple-fn-bounds.stderr b/tests/ui/closures/multiple-fn-bounds.stderr index 861b39b4d076e..d392efbfd6a43 100644 --- a/tests/ui/closures/multiple-fn-bounds.stderr +++ b/tests/ui/closures/multiple-fn-bounds.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/multiple-fn-bounds.rs:10:5 | LL | foo(move |x| v); - | ^^^^--------^^^ + | ^^^^----------^ | | | | | found signature defined here | expected due to this diff --git a/tests/ui/closures/print/closure-print-generic-1.stderr b/tests/ui/closures/print/closure-print-generic-1.stderr index 41cad279f7b9f..04bf28182a49e 100644 --- a/tests/ui/closures/print/closure-print-generic-1.stderr +++ b/tests/ui/closures/print/closure-print-generic-1.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `c` --> $DIR/closure-print-generic-1.rs:17:5 | LL | let c = to_fn_once(move || { - | - move occurs because `c` has type `{closure@$DIR/closure-print-generic-1.rs:12:24: 12:31}`, which does not implement the `Copy` trait + | - move occurs because `c` has type `{closure@$DIR/closure-print-generic-1.rs:12:24: 14:6}`, which does not implement the `Copy` trait ... LL | c(); | --- `c` moved due to this call diff --git a/tests/ui/closures/print/closure-print-generic-2.stderr b/tests/ui/closures/print/closure-print-generic-2.stderr index 0a604a7d6cf02..f3837a518f2cb 100644 --- a/tests/ui/closures/print/closure-print-generic-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-2.stderr @@ -2,14 +2,14 @@ error[E0308]: mismatched types --> $DIR/closure-print-generic-2.rs:6:22 | LL | let c = || println!("{} {}", t, x); - | -- the found closure + | -------------------------- the found closure LL | let c1: () = c; | -- ^ expected `()`, found closure | | | expected due to this | = note: expected unit type `()` - found closure `{closure@$DIR/closure-print-generic-2.rs:5:17: 5:19}` + found closure `{closure@$DIR/closure-print-generic-2.rs:5:17: 5:43}` help: use parentheses to call this closure | LL | let c1: () = c(); diff --git a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr index b71cfc503339c..6f4f3a0ffdb01 100644 --- a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/closure-print-generic-trim-off-verbose-2.rs:9:23 | LL | let c = || println!("{} {}", t, x); - | -- the found closure + | -------------------------- the found closure LL | let c1 : () = c; | -- ^ expected `()`, found closure | | diff --git a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr index 88f4dc9b92ab4..d06f4f755b65d 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/closure-print-generic-verbose-2.rs:9:23 | LL | let c = || println!("{} {}", t, x); - | -- the found closure + | -------------------------- the found closure LL | let c1 : () = c; | -- ^ expected `()`, found closure | | diff --git a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr index e0cce8c4b3143..cd894fc5ffc31 100644 --- a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr +++ b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr @@ -18,8 +18,9 @@ LL | fn func(_f: impl Fn()) -> usize { | --------- change this to accept `FnMut` instead of `Fn` ... LL | func(|| x = ()) - | ---- -- ^^^^^^ cannot assign - | | | + | ---- ---^^^^^^ + | | | | + | | | cannot assign | | in this closure | expects `Fn` instead of `FnMut` diff --git a/tests/ui/codegen/overflow-during-mono.stderr b/tests/ui/codegen/overflow-during-mono.stderr index f7a3e2df3dbaa..848ff137cb543 100644 --- a/tests/ui/codegen/overflow-during-mono.stderr +++ b/tests/ui/codegen/overflow-during-mono.stderr @@ -1,10 +1,10 @@ -error[E0275]: overflow evaluating the requirement `{closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: Sized` +error[E0275]: overflow evaluating the requirement `{closure@$DIR/overflow-during-mono.rs:13:41: 13:51}: Sized` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`) - = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` + = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>` to implement `Iterator` = note: 31 redundant requirements hidden - = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` - = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `IntoIterator` + = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>` to implement `Iterator` + = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:51}>` to implement `IntoIterator` error: aborting due to 1 previous error diff --git a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr index 646044ae41abc..2a4d9d2de0ccc 100644 --- a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -32,7 +32,7 @@ LL | let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure@coerce-expect-unsized-ascribed.rs:14:39}>` | = note: expected struct `Box u8>` - found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:14:39: 14:42}>` + found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:14:39: 14:52}>` error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:15:27 @@ -86,7 +86,7 @@ LL | let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _); | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&{closure@coerce-expect-unsized-ascribed.rs:22:30}` | = note: expected reference `&dyn Fn(i32) -> u8` - found reference `&{closure@$DIR/coerce-expect-unsized-ascribed.rs:22:30: 22:33}` + found reference `&{closure@$DIR/coerce-expect-unsized-ascribed.rs:22:30: 22:43}` error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:23:27 @@ -122,7 +122,7 @@ LL | let _ = type_ascribe!(Box::new(|x| (x as u8)), Box _>); | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure@coerce-expect-unsized-ascribed.rs:27:36}>` | = note: expected struct `Box u8>` - found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:27:36: 27:39}>` + found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:27:36: 27:49}>` error: aborting due to 14 previous errors diff --git a/tests/ui/confuse-field-and-method/issue-33784.stderr b/tests/ui/confuse-field-and-method/issue-33784.stderr index 8acd1f8ff1ee9..036698708f862 100644 --- a/tests/ui/confuse-field-and-method/issue-33784.stderr +++ b/tests/ui/confuse-field-and-method/issue-33784.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `closure` found for reference `&Obj<{closure@$DIR/issue-33784.rs:25:43: 25:45}>` in the current scope +error[E0599]: no method named `closure` found for reference `&Obj<{closure@$DIR/issue-33784.rs:25:43: 25:48}>` in the current scope --> $DIR/issue-33784.rs:27:7 | LL | p.closure(); @@ -13,7 +13,7 @@ help: there is a method `clone` with a similar name LL | p.clone(); | ~~~~~ -error[E0599]: no method named `fn_ptr` found for reference `&&Obj<{closure@$DIR/issue-33784.rs:25:43: 25:45}>` in the current scope +error[E0599]: no method named `fn_ptr` found for reference `&&Obj<{closure@$DIR/issue-33784.rs:25:43: 25:48}>` in the current scope --> $DIR/issue-33784.rs:29:7 | LL | q.fn_ptr(); diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr index 694f5a5c1a9da..af5f62093e9e1 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr @@ -16,11 +16,11 @@ help: use parentheses to call this function LL | check(main()); | ++ -error[E0277]: `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}` can't be used as a const parameter type +error[E0277]: `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:16}` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:8:11 | LL | check(|| {}); - | ----- ^^^^^ the trait `UnsizedConstParamTy` is not implemented for closure `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}` + | ----- ^^^^^ the trait `UnsizedConstParamTy` is not implemented for closure `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:16}` | | | required by a bound introduced by this call | diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr index db93bcca60fb3..161d82faf5d44 100644 --- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr @@ -19,11 +19,11 @@ LL + #[derive(ConstParamTy)] LL | struct Foo(u8); | -error[E0284]: type annotations needed: cannot normalize `foo::{constant#0}` +error[E0284]: type annotations needed: cannot normalize `foo::{constant#1}` --> $DIR/unify-op-with-fn-call.rs:20:25 | LL | fn foo(a: Evaluatable<{ N + N }>) { - | ^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo::{constant#0}` + | ^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo::{constant#1}` error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/unify-op-with-fn-call.rs:20:17 @@ -49,23 +49,23 @@ LL + #[derive(ConstParamTy)] LL | struct Foo(u8); | -error[E0284]: type annotations needed: cannot normalize `foo2::{constant#0}` +error[E0284]: type annotations needed: cannot normalize `foo2::{constant#1}` --> $DIR/unify-op-with-fn-call.rs:29:28 | LL | fn foo2(a: Evaluatable2<{ N + N }>) { - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2::{constant#0}` + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2::{constant#1}` -error[E0284]: type annotations needed: cannot normalize `foo::{constant#0}` +error[E0284]: type annotations needed: cannot normalize `foo::{constant#1}` --> $DIR/unify-op-with-fn-call.rs:21:11 | LL | bar::<{ std::ops::Add::add(N, N) }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo::{constant#0}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo::{constant#1}` -error[E0284]: type annotations needed: cannot normalize `foo2::{constant#0}` +error[E0284]: type annotations needed: cannot normalize `foo2::{constant#1}` --> $DIR/unify-op-with-fn-call.rs:30:12 | LL | bar2::<{ std::ops::Add::add(N, N) }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2::{constant#0}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2::{constant#1}` error: aborting due to 8 previous errors diff --git a/tests/ui/const-generics/nested-type.full.stderr b/tests/ui/const-generics/nested-type.full.stderr index 04dc84ea3cf5a..ebd94826e035a 100644 --- a/tests/ui/const-generics/nested-type.full.stderr +++ b/tests/ui/const-generics/nested-type.full.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17>::value` in constants +error[E0015]: cannot call non-const fn `Foo::Foo::<17>::value` in constants --> $DIR/nested-type.rs:15:5 | LL | Foo::<17>::value() diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index 0da2b30e3f1a9..f7b56535ac81e 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17>::value` in constants +error[E0015]: cannot call non-const fn `Foo::Foo::<17>::value` in constants --> $DIR/nested-type.rs:15:5 | LL | Foo::<17>::value() diff --git a/tests/ui/consts/const-size_of-cycle.stderr b/tests/ui/consts/const-size_of-cycle.stderr index cd0ea55642545..d01539326f902 100644 --- a/tests/ui/consts/const-size_of-cycle.stderr +++ b/tests/ui/consts/const-size_of-cycle.stderr @@ -4,7 +4,7 @@ error[E0391]: cycle detected when evaluating type-level constant LL | bytes: [u8; std::mem::size_of::()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`... +note: ...which requires const-evaluating + checking `Foo::{constant#0}`... --> $DIR/const-size_of-cycle.rs:4:17 | LL | bytes: [u8; std::mem::size_of::()] diff --git a/tests/ui/consts/issue-44415.stderr b/tests/ui/consts/issue-44415.stderr index 641945fce9fd4..89c4570f698ba 100644 --- a/tests/ui/consts/issue-44415.stderr +++ b/tests/ui/consts/issue-44415.stderr @@ -4,7 +4,7 @@ error[E0391]: cycle detected when evaluating type-level constant LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`... +note: ...which requires const-evaluating + checking `Foo::{constant#0}`... --> $DIR/issue-44415.rs:6:17 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], diff --git a/tests/ui/coroutine/clone-impl-static.stderr b/tests/ui/coroutine/clone-impl-static.stderr index 43920326d5dfd..c10a7d13bfa8a 100644 --- a/tests/ui/coroutine/clone-impl-static.stderr +++ b/tests/ui/coroutine/clone-impl-static.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:8:5: 8:19}: Copy` is not satisfied +error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:8:5: 10:6}: Copy` is not satisfied --> $DIR/clone-impl-static.rs:11:16 | LL | check_copy(&gen); - | ---------- ^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:8:5: 8:19}` + | ---------- ^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:8:5: 10:6}` | | | required by a bound introduced by this call | @@ -12,11 +12,11 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:8:5: 8:19}: Clone` is not satisfied +error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:8:5: 10:6}: Clone` is not satisfied --> $DIR/clone-impl-static.rs:13:17 | LL | check_clone(&gen); - | ----------- ^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:8:5: 8:19}` + | ----------- ^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:8:5: 10:6}` | | | required by a bound introduced by this call | diff --git a/tests/ui/coroutine/clone-impl.stderr b/tests/ui/coroutine/clone-impl.stderr index 5330d3bbd39d5..f1d3b55abe936 100644 --- a/tests/ui/coroutine/clone-impl.stderr +++ b/tests/ui/coroutine/clone-impl.stderr @@ -1,11 +1,15 @@ -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}` +error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}` --> $DIR/clone-impl.rs:49:5 | -LL | move || { - | ------- within this `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}` -... -LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}: Copy` +LL | / move || { +LL | | let v = vec!['a']; +LL | | yield; +LL | | drop(v); +LL | | drop(clonable_0); +LL | | }; + | |_____- within this `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}` +LL | check_copy(&gen_clone_0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}: Copy` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:47:14 @@ -18,14 +22,18 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}` +error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}` --> $DIR/clone-impl.rs:49:5 | -LL | move || { - | ------- within this `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}` -... -LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:43:5: 43:12}: Copy` +LL | / move || { +LL | | let v = vec!['a']; +LL | | yield; +LL | | drop(v); +LL | | drop(clonable_0); +LL | | }; + | |_____- within this `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}` +LL | check_copy(&gen_clone_0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:43:5: 48:6}: Copy` | note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/clone-impl.rs:45:9 @@ -40,14 +48,19 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}` +error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}` --> $DIR/clone-impl.rs:70:5 | -LL | move || { - | ------- within this `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}` -... -LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}: Copy` +LL | / move || { +LL | | let v = vec!['a']; +LL | | /* +LL | | let n = NonClone; +... | +LL | | drop(clonable_1); +LL | | }; + | |_____- within this `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}` +LL | check_copy(&gen_clone_1); + | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}: Copy` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:68:14 @@ -60,14 +73,19 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}` +error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}` --> $DIR/clone-impl.rs:70:5 | -LL | move || { - | ------- within this `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}` -... -LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:58:5: 58:12}: Copy` +LL | / move || { +LL | | let v = vec!['a']; +LL | | /* +LL | | let n = NonClone; +... | +LL | | drop(clonable_1); +LL | | }; + | |_____- within this `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}` +LL | check_copy(&gen_clone_1); + | ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}`, the trait `Copy` is not implemented for `Vec`, which is required by `{coroutine@$DIR/clone-impl.rs:58:5: 69:6}: Copy` | note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/clone-impl.rs:64:9 @@ -83,14 +101,16 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}` +error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}` --> $DIR/clone-impl.rs:83:5 | -LL | move || { - | ------- within this `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}` -... -LL | check_copy(&gen_non_clone); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}`, the trait `Copy` is not implemented for `NonClone`, which is required by `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}: Copy` +LL | / move || { +LL | | yield; +LL | | drop(non_clonable); +LL | | }; + | |_____- within this `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}` +LL | check_copy(&gen_non_clone); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}`, the trait `Copy` is not implemented for `NonClone`, which is required by `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}: Copy` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:81:14 @@ -108,14 +128,17 @@ LL + #[derive(Copy)] LL | struct NonClone; | -error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}` +error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}` --> $DIR/clone-impl.rs:85:5 | -LL | move || { - | ------- within this `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}` +LL | / move || { +LL | | yield; +LL | | drop(non_clonable); +LL | | }; + | |_____- within this `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}` ... -LL | check_clone(&gen_non_clone); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}`, the trait `Clone` is not implemented for `NonClone`, which is required by `{coroutine@$DIR/clone-impl.rs:79:5: 79:12}: Clone` +LL | check_clone(&gen_non_clone); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}`, the trait `Clone` is not implemented for `NonClone`, which is required by `{coroutine@$DIR/clone-impl.rs:79:5: 82:6}: Clone` | note: captured value does not implement `Clone` --> $DIR/clone-impl.rs:81:14 diff --git a/tests/ui/coroutine/clone-rpit.next.stderr b/tests/ui/coroutine/clone-rpit.next.stderr index c223f1f211ac6..e333ada0b73d4 100644 --- a/tests/ui/coroutine/clone-rpit.next.stderr +++ b/tests/ui/coroutine/clone-rpit.next.stderr @@ -7,33 +7,45 @@ LL | pub fn foo<'a, 'b>() -> impl Clone { note: ...which requires coroutine witness types for `foo::{closure#0}`... --> $DIR/clone-rpit.rs:15:5 | -LL | move |_: ()| { - | ^^^^^^^^^^^^ +LL | / move |_: ()| { +LL | | let () = yield (); +LL | | } + | |_____^ note: ...which requires promoting constants in MIR for `foo::{closure#0}`... --> $DIR/clone-rpit.rs:15:5 | -LL | move |_: ()| { - | ^^^^^^^^^^^^ +LL | / move |_: ()| { +LL | | let () = yield (); +LL | | } + | |_____^ note: ...which requires checking if `foo::{closure#0}` contains FFI-unwind calls... --> $DIR/clone-rpit.rs:15:5 | -LL | move |_: ()| { - | ^^^^^^^^^^^^ +LL | / move |_: ()| { +LL | | let () = yield (); +LL | | } + | |_____^ note: ...which requires building MIR for `foo::{closure#0}`... --> $DIR/clone-rpit.rs:15:5 | -LL | move |_: ()| { - | ^^^^^^^^^^^^ +LL | / move |_: ()| { +LL | | let () = yield (); +LL | | } + | |_____^ note: ...which requires match-checking `foo::{closure#0}`... --> $DIR/clone-rpit.rs:15:5 | -LL | move |_: ()| { - | ^^^^^^^^^^^^ +LL | / move |_: ()| { +LL | | let () = yield (); +LL | | } + | |_____^ note: ...which requires type-checking `foo::{closure#0}`... --> $DIR/clone-rpit.rs:15:5 | -LL | move |_: ()| { - | ^^^^^^^^^^^^ +LL | / move |_: ()| { +LL | | let () = yield (); +LL | | } + | |_____^ = note: ...which again requires type-checking `foo`, completing the cycle note: cycle used when computing type of opaque `foo::{opaque#0}` --> $DIR/clone-rpit.rs:13:25 diff --git a/tests/ui/coroutine/coroutine-with-nll.stderr b/tests/ui/coroutine/coroutine-with-nll.stderr index ee3a8f45f44a7..9281634fef63a 100644 --- a/tests/ui/coroutine/coroutine-with-nll.stderr +++ b/tests/ui/coroutine/coroutine-with-nll.stderr @@ -1,14 +1,17 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/coroutine-with-nll.rs:8:17 | -LL | || { - | -- within this coroutine -... -LL | let b = &mut true; - | ^^^^^^^^^ -LL | -LL | yield (); - | -------- possible yield occurs here +LL | / || { +LL | | // The reference in `_a` is a Legal with NLL since it ends before the yield +LL | | let _a = &mut true; +LL | | let b = &mut true; + | | ^^^^^^^^^ +LL | | +LL | | yield (); + | | -------- possible yield occurs here +LL | | println!("{}", b); +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr index 32799148ae1da..56d1aaa6fd174 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@$DIR/coroutine-yielding-or-returning-itself.rs:15:47: 19:6} as Coroutine>::Return == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:47: 19:6}` --> $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@$DIR/coroutine-yielding-or-returning-itself.rs:28:46: 32:6} as Coroutine>::Yield == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:46: 32:6}` --> $DIR/coroutine-yielding-or-returning-itself.rs:28:46 | LL | want_cyclic_coroutine_yield(#[coroutine] || { diff --git a/tests/ui/coroutine/drop-tracking-parent-expression.stderr b/tests/ui/coroutine/drop-tracking-parent-expression.stderr index 5f8d8495e4f14..1550b294d82b8 100644 --- a/tests/ui/coroutine/drop-tracking-parent-expression.stderr +++ b/tests/ui/coroutine/drop-tracking-parent-expression.stderr @@ -13,7 +13,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `derived_drop::Client`, which is required by `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}: Send` + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 22:14}`, the trait `Send` is not implemented for `derived_drop::Client`, which is required by `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 22:14}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-tracking-parent-expression.rs:21:22 | @@ -53,7 +53,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `significant_drop::Client`, which is required by `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}: Send` + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 22:14}`, the trait `Send` is not implemented for `significant_drop::Client`, which is required by `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 22:14}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-tracking-parent-expression.rs:21:22 | @@ -93,7 +93,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `insignificant_dtor::Client`, which is required by `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}: Send` + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 22:14}`, the trait `Send` is not implemented for `insignificant_dtor::Client`, which is required by `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 22:14}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-tracking-parent-expression.rs:21:22 | diff --git a/tests/ui/coroutine/drop-yield-twice.stderr b/tests/ui/coroutine/drop-yield-twice.stderr index 362c6e943ade0..ca5810457efec 100644 --- a/tests/ui/coroutine/drop-yield-twice.stderr +++ b/tests/ui/coroutine/drop-yield-twice.stderr @@ -9,7 +9,7 @@ LL | | yield; LL | | }) | |______^ coroutine is not `Send` | - = help: within `{coroutine@$DIR/drop-yield-twice.rs:7:30: 7:32}`, the trait `Send` is not implemented for `Foo`, which is required by `{coroutine@$DIR/drop-yield-twice.rs:7:30: 7:32}: Send` + = help: within `{coroutine@$DIR/drop-yield-twice.rs:7:30: 12:6}`, the trait `Send` is not implemented for `Foo`, which is required by `{coroutine@$DIR/drop-yield-twice.rs:7:30: 12:6}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/drop-yield-twice.rs:9:9 | diff --git a/tests/ui/coroutine/issue-105084.stderr b/tests/ui/coroutine/issue-105084.stderr index 6b1701f0c2abc..5a1d0a5d5efb7 100644 --- a/tests/ui/coroutine/issue-105084.stderr +++ b/tests/ui/coroutine/issue-105084.stderr @@ -2,7 +2,7 @@ error[E0382]: borrow of moved value: `g` --> $DIR/issue-105084.rs:38:14 | LL | let mut g = #[coroutine] - | ----- move occurs because `g` has type `{coroutine@$DIR/issue-105084.rs:15:5: 15:7}`, which does not implement the `Copy` trait + | ----- move occurs because `g` has type `{coroutine@$DIR/issue-105084.rs:15:5: 24:6}`, which does not implement the `Copy` trait ... LL | let mut h = copy(g); | - value moved here @@ -22,14 +22,20 @@ help: consider cloning the value if the performance cost is acceptable LL | let mut h = copy(g.clone()); | ++++++++ -error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:15:5: 15:7}` +error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:15:5: 24:6}` --> $DIR/issue-105084.rs:32:17 | -LL | || { - | -- within this `{coroutine@$DIR/issue-105084.rs:15:5: 15:7}` +LL | / || { +LL | | // This is desuraged as 4 stages: +LL | | // - allocate a `*mut u8` with `exchange_malloc`; +LL | | // - create a Box that is ignored for trait computations; +... | +LL | | drop(t); +LL | | }; + | |_____- within this `{coroutine@$DIR/issue-105084.rs:15:5: 24:6}` ... -LL | let mut h = copy(g); - | ^^^^^^^ within `{coroutine@$DIR/issue-105084.rs:15:5: 15:7}`, the trait `Copy` is not implemented for `Box<(i32, ())>`, which is required by `{coroutine@$DIR/issue-105084.rs:15:5: 15:7}: Copy` +LL | let mut h = copy(g); + | ^^^^^^^ within `{coroutine@$DIR/issue-105084.rs:15:5: 24:6}`, the trait `Copy` is not implemented for `Box<(i32, ())>`, which is required by `{coroutine@$DIR/issue-105084.rs:15:5: 24:6}: Copy` | note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/issue-105084.rs:22:22 diff --git a/tests/ui/coroutine/issue-48048.stderr b/tests/ui/coroutine/issue-48048.stderr index 8231dbef7f626..098a58d60b5cf 100644 --- a/tests/ui/coroutine/issue-48048.stderr +++ b/tests/ui/coroutine/issue-48048.stderr @@ -1,13 +1,17 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/issue-48048.rs:9:9 | -LL | #[coroutine] || { - | -- within this coroutine -... -LL | x.0({ - | ^^^ -LL | yield; - | ----- possible yield occurs here +LL | #[coroutine] || { + | __________________- +LL | | let x = x; +LL | | +LL | | x.0({ + | | ^^^ +LL | | yield; + | | ----- possible yield occurs here +LL | | }); +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/issue-68112.stderr b/tests/ui/coroutine/issue-68112.stderr index bcfcb5ec6e608..135ce4052fc7a 100644 --- a/tests/ui/coroutine/issue-68112.stderr +++ b/tests/ui/coroutine/issue-68112.stderr @@ -4,7 +4,7 @@ error: coroutine cannot be sent between threads safely LL | require_send(send_gen); | ^^^^^^^^^^^^^^^^^^^^^^ coroutine is not `Send` | - = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{coroutine@$DIR/issue-68112.rs:33:33: 33:35}: Send` + = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{coroutine@$DIR/issue-68112.rs:33:33: 39:6}: Send` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: coroutine is not `Send` as this value is used across a yield --> $DIR/issue-68112.rs:36:9 @@ -26,14 +26,18 @@ error[E0277]: `RefCell` cannot be shared between threads safely LL | require_send(send_gen); | ^^^^^^^^^^^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{coroutine@$DIR/issue-68112.rs:60:33: 60:35}: Send` + = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{coroutine@$DIR/issue-68112.rs:60:33: 63:6}: Send` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc>` to implement `Send` note: required because it's used within this coroutine --> $DIR/issue-68112.rs:49:18 | -LL | #[coroutine] || { - | ^^ +LL | #[coroutine] || { + | __________________^ +LL | | yield; +LL | | t +LL | | } + | |_____^ note: required because it appears within the type `impl Coroutine>>` --> $DIR/issue-68112.rs:46:30 | @@ -47,8 +51,12 @@ LL | fn make_non_send_coroutine2() -> impl Coroutine>> note: required because it's used within this coroutine --> $DIR/issue-68112.rs:60:33 | -LL | let send_gen = #[coroutine] || { - | ^^ +LL | let send_gen = #[coroutine] || { + | _________________________________^ +LL | | let _non_send_gen = make_non_send_coroutine2(); +LL | | yield; +LL | | }; + | |_____^ note: required by a bound in `require_send` --> $DIR/issue-68112.rs:22:25 | diff --git a/tests/ui/coroutine/issue-88653.stderr b/tests/ui/coroutine/issue-88653.stderr index 8a23ad17b8b37..87b2b8a8423b7 100644 --- a/tests/ui/coroutine/issue-88653.stderr +++ b/tests/ui/coroutine/issue-88653.stderr @@ -1,11 +1,16 @@ error[E0631]: type mismatch in coroutine arguments --> $DIR/issue-88653.rs:8:22 | -LL | fn foo(bar: bool) -> impl Coroutine<(bool,)> { - | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this +LL | fn foo(bar: bool) -> impl Coroutine<(bool,)> { + | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this ... -LL | |bar| { - | ----- found signature defined here +LL | / |bar| { +LL | | +LL | | if bar { +LL | | yield bar; +LL | | } +LL | | } + | |_____- found signature defined here | = note: expected coroutine signature `fn((bool,)) -> _` found coroutine signature `fn(bool) -> _` diff --git a/tests/ui/coroutine/not-send-sync.stderr b/tests/ui/coroutine/not-send-sync.stderr index 0f9cbdec1300e..98e1d8ed6d7c5 100644 --- a/tests/ui/coroutine/not-send-sync.stderr +++ b/tests/ui/coroutine/not-send-sync.stderr @@ -9,7 +9,7 @@ LL | | drop(a); LL | | }); | |______^ coroutine is not `Sync` | - = help: within `{coroutine@$DIR/not-send-sync.rs:14:30: 14:32}`, the trait `Sync` is not implemented for `NotSync`, which is required by `{coroutine@$DIR/not-send-sync.rs:14:30: 14:32}: Sync` + = help: within `{coroutine@$DIR/not-send-sync.rs:14:30: 19:6}`, the trait `Sync` is not implemented for `NotSync`, which is required by `{coroutine@$DIR/not-send-sync.rs:14:30: 19:6}: Sync` note: coroutine is not `Sync` as this value is used across a yield --> $DIR/not-send-sync.rs:17:9 | @@ -34,7 +34,7 @@ LL | | drop(a); LL | | }); | |______^ coroutine is not `Send` | - = help: within `{coroutine@$DIR/not-send-sync.rs:21:30: 21:32}`, the trait `Send` is not implemented for `NotSend`, which is required by `{coroutine@$DIR/not-send-sync.rs:21:30: 21:32}: Send` + = help: within `{coroutine@$DIR/not-send-sync.rs:21:30: 26:6}`, the trait `Send` is not implemented for `NotSend`, which is required by `{coroutine@$DIR/not-send-sync.rs:21:30: 26:6}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/not-send-sync.rs:24:9 | diff --git a/tests/ui/coroutine/parent-expression.stderr b/tests/ui/coroutine/parent-expression.stderr index 2d817f1bfd9cb..e6106827c87b4 100644 --- a/tests/ui/coroutine/parent-expression.stderr +++ b/tests/ui/coroutine/parent-expression.stderr @@ -13,7 +13,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `derived_drop::Client`, which is required by `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}: Send` + = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 22:14}`, the trait `Send` is not implemented for `derived_drop::Client`, which is required by `{coroutine@$DIR/parent-expression.rs:17:34: 22:14}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/parent-expression.rs:21:22 | @@ -53,7 +53,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `significant_drop::Client`, which is required by `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}: Send` + = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 22:14}`, the trait `Send` is not implemented for `significant_drop::Client`, which is required by `{coroutine@$DIR/parent-expression.rs:17:34: 22:14}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/parent-expression.rs:21:22 | @@ -93,7 +93,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `insignificant_dtor::Client`, which is required by `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}: Send` + = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 22:14}`, the trait `Send` is not implemented for `insignificant_dtor::Client`, which is required by `{coroutine@$DIR/parent-expression.rs:17:34: 22:14}: Send` note: coroutine is not `Send` as this value is used across a yield --> $DIR/parent-expression.rs:21:22 | diff --git a/tests/ui/coroutine/pattern-borrow.stderr b/tests/ui/coroutine/pattern-borrow.stderr index a3954b0b8ad68..cc73f44af9346 100644 --- a/tests/ui/coroutine/pattern-borrow.stderr +++ b/tests/ui/coroutine/pattern-borrow.stderr @@ -1,12 +1,16 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/pattern-borrow.rs:9:24 | -LL | #[coroutine] move || { - | ------- within this coroutine -LL | if let Test::A(ref _a) = test { - | ^^^^^^ -LL | yield (); - | -------- possible yield occurs here +LL | #[coroutine] move || { + | __________________- +LL | | if let Test::A(ref _a) = test { + | | ^^^^^^ +LL | | yield (); + | | -------- possible yield occurs here +LL | | _a.use_ref(); +LL | | } +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr index 934ab08cf178d..c70bd331c453f 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr @@ -10,7 +10,7 @@ note: coroutine is not `Send` as this value is used across a yield --> $DIR/coroutine-print-verbose-1.rs:35:9 | LL | let _non_send_gen = make_non_send_coroutine(); - | ------------- has type `Opaque(DefId(0:34 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine::{opaque#0}), [])` which is not `Send` + | ------------- has type `Opaque(DefId(0:31 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later note: required by a bound in `require_send` @@ -31,14 +31,18 @@ LL | require_send(send_gen); note: required because it's used within this coroutine --> $DIR/coroutine-print-verbose-1.rs:42:18 | -LL | #[coroutine] || { - | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ coroutine_print_verbose_1[75fb]::make_gen2::{opaque#0}), [Arc>])` +LL | #[coroutine] || { + | __________________^ +LL | | yield; +LL | | t +LL | | } + | |_____^ +note: required because it appears within the type `Opaque(DefId(0:34 ~ coroutine_print_verbose_1[75fb]::make_gen2::{opaque#0}), [Arc>])` --> $DIR/coroutine-print-verbose-1.rs:41:30 | LL | pub fn make_gen2(t: T) -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine2::{opaque#0}), [])` +note: required because it appears within the type `Opaque(DefId(0:35 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine2::{opaque#0}), [])` --> $DIR/coroutine-print-verbose-1.rs:47:34 | LL | fn make_non_send_coroutine2() -> impl Coroutine>> { @@ -46,8 +50,12 @@ LL | fn make_non_send_coroutine2() -> impl Coroutine>> note: required because it's used within this coroutine --> $DIR/coroutine-print-verbose-1.rs:52:33 | -LL | let send_gen = #[coroutine] || { - | ^^ +LL | let send_gen = #[coroutine] || { + | _________________________________^ +LL | | let _non_send_gen = make_non_send_coroutine2(); +LL | | yield; +LL | | }; + | |_____^ note: required by a bound in `require_send` --> $DIR/coroutine-print-verbose-1.rs:26:25 | diff --git a/tests/ui/coroutine/ref-upvar-not-send.stderr b/tests/ui/coroutine/ref-upvar-not-send.stderr index 4c7deab3f4c4d..1ab2c88643937 100644 --- a/tests/ui/coroutine/ref-upvar-not-send.stderr +++ b/tests/ui/coroutine/ref-upvar-not-send.stderr @@ -10,7 +10,7 @@ LL | | let _x = x; LL | | }); | |_____^ coroutine is not `Send` | - = help: the trait `Sync` is not implemented for `*mut ()`, which is required by `{coroutine@$DIR/ref-upvar-not-send.rs:15:30: 15:37}: Send` + = help: the trait `Sync` is not implemented for `*mut ()`, which is required by `{coroutine@$DIR/ref-upvar-not-send.rs:15:30: 20:6}: Send` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` --> $DIR/ref-upvar-not-send.rs:19:18 | @@ -34,7 +34,7 @@ LL | | let _y = y; LL | | }); | |_____^ coroutine is not `Send` | - = help: within `{coroutine@$DIR/ref-upvar-not-send.rs:23:30: 23:37}`, the trait `Send` is not implemented for `*mut ()`, which is required by `{coroutine@$DIR/ref-upvar-not-send.rs:23:30: 23:37}: Send` + = help: within `{coroutine@$DIR/ref-upvar-not-send.rs:23:30: 28:6}`, the trait `Send` is not implemented for `*mut ()`, which is required by `{coroutine@$DIR/ref-upvar-not-send.rs:23:30: 28:6}: Send` note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` --> $DIR/ref-upvar-not-send.rs:27:18 | diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 646abaf4f7bde..23d6d7ae0e4f4 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@$DIR/resume-arg-late-bound.rs:11:28: 14:6}` 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/static-not-unpin.current.stderr b/tests/ui/coroutine/static-not-unpin.current.stderr index 7d6260ac569e8..f913bcf4a990b 100644 --- a/tests/ui/coroutine/static-not-unpin.current.stderr +++ b/tests/ui/coroutine/static-not-unpin.current.stderr @@ -1,8 +1,8 @@ -error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:15:5: 15:14}` cannot be unpinned +error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:15:5: 17:6}` cannot be unpinned --> $DIR/static-not-unpin.rs:18:18 | LL | assert_unpin(coroutine); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:15:5: 15:14}` + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:15:5: 17:6}` | | | required by a bound introduced by this call | diff --git a/tests/ui/coroutine/static-not-unpin.next.stderr b/tests/ui/coroutine/static-not-unpin.next.stderr index 7d6260ac569e8..f913bcf4a990b 100644 --- a/tests/ui/coroutine/static-not-unpin.next.stderr +++ b/tests/ui/coroutine/static-not-unpin.next.stderr @@ -1,8 +1,8 @@ -error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:15:5: 15:14}` cannot be unpinned +error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:15:5: 17:6}` cannot be unpinned --> $DIR/static-not-unpin.rs:18:18 | LL | assert_unpin(coroutine); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:15:5: 15:14}` + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:15:5: 17:6}` | | | required by a bound introduced by this call | diff --git a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr index 0892719603752..5f153482e94c2 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@$DIR/type-mismatch-signature-deduction.rs:8:5: 16:6} as Coroutine>::Return == i32` --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Coroutine { diff --git a/tests/ui/coroutine/yield-in-args.stderr b/tests/ui/coroutine/yield-in-args.stderr index 1cc3c83deb3b8..3227193f74ee0 100644 --- a/tests/ui/coroutine/yield-in-args.stderr +++ b/tests/ui/coroutine/yield-in-args.stderr @@ -1,11 +1,12 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-in-args.rs:9:13 | -LL | || { - | -- within this coroutine -LL | let b = true; -LL | foo(&b, yield); - | ^^ ----- possible yield occurs here +LL | / || { +LL | | let b = true; +LL | | foo(&b, yield); + | | ^^ ----- possible yield occurs here +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/yield-while-iterating.stderr b/tests/ui/coroutine/yield-while-iterating.stderr index a92237e44c16b..f328c05dba0f4 100644 --- a/tests/ui/coroutine/yield-while-iterating.stderr +++ b/tests/ui/coroutine/yield-while-iterating.stderr @@ -1,12 +1,15 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-while-iterating.rs:13:18 | -LL | let _b =#[coroutine] move || { - | ------- within this coroutine -LL | for p in &x { - | ^^ -LL | yield(); - | ------- possible yield occurs here +LL | let _b =#[coroutine] move || { + | ___________________________- +LL | | for p in &x { + | | ^^ +LL | | yield(); + | | ------- possible yield occurs here +LL | | } +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/yield-while-local-borrowed.stderr b/tests/ui/coroutine/yield-while-local-borrowed.stderr index b42ca3ba46106..daf9ca2c5d541 100644 --- a/tests/ui/coroutine/yield-while-local-borrowed.stderr +++ b/tests/ui/coroutine/yield-while-local-borrowed.stderr @@ -1,13 +1,16 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-while-local-borrowed.rs:13:17 | -LL | let mut b = #[coroutine] move || { - | ------- within this coroutine -LL | let a = &mut 3; - | ^^^^^^ -LL | -LL | yield (); - | -------- possible yield occurs here +LL | let mut b = #[coroutine] move || { + | ______________________________- +LL | | let a = &mut 3; + | | ^^^^^^ +LL | | +LL | | yield (); + | | -------- possible yield occurs here +LL | | println!("{}", a); +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | @@ -17,14 +20,19 @@ LL | let mut b = #[coroutine] static move || { error[E0626]: borrow may still be in use when coroutine yields --> $DIR/yield-while-local-borrowed.rs:40:21 | -LL | let mut b = #[coroutine] move || { - | ------- within this coroutine -... -LL | let b = &a; - | ^^ -LL | -LL | yield (); - | -------- possible yield occurs here +LL | let mut b = #[coroutine] move || { + | ______________________________- +LL | | let a = 3; +LL | | { +LL | | let b = &a; + | | ^^ +LL | | +LL | | yield (); + | | -------- possible yield occurs here +LL | | println!("{}", b); +LL | | } +LL | | }; + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/deprecation/deprecation-lint.stderr b/tests/ui/deprecation/deprecation-lint.stderr index 2098073409da5..0de11b1d1140f 100644 --- a/tests/ui/deprecation/deprecation-lint.stderr +++ b/tests/ui/deprecation/deprecation-lint.stderr @@ -298,7 +298,7 @@ error: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ -error: use of deprecated function `this_crate::test_fn_closure_body::{closure#0}::bar` +error: use of deprecated function `this_crate::test_fn_closure_body::bar` --> $DIR/deprecation-lint.rs:317:13 | LL | bar(); diff --git a/tests/ui/error-codes/E0057.stderr b/tests/ui/error-codes/E0057.stderr index ef6e2908b939f..b8a42313e4d66 100644 --- a/tests/ui/error-codes/E0057.stderr +++ b/tests/ui/error-codes/E0057.stderr @@ -8,7 +8,7 @@ note: closure defined here --> $DIR/E0057.rs:2:13 | LL | let f = |x| x * 3; - | ^^^ + | ^^^^^^^^^ help: provide the argument | LL | let a = f(/* x */); @@ -24,7 +24,7 @@ note: closure defined here --> $DIR/E0057.rs:2:13 | LL | let f = |x| x * 3; - | ^^^ + | ^^^^^^^^^ help: remove the extra argument | LL - let c = f(2, 3); diff --git a/tests/ui/error-codes/E0767.stderr b/tests/ui/error-codes/E0767.stderr index 4b09008f9a0f9..cfa4298d46ebb 100644 --- a/tests/ui/error-codes/E0767.stderr +++ b/tests/ui/error-codes/E0767.stderr @@ -19,7 +19,7 @@ LL | | } | |_________^ expected `()`, found closure | = note: expected unit type `()` - found closure `{closure@$DIR/E0767.rs:3:9: 3:11}` + found closure `{closure@$DIR/E0767.rs:3:9: 6:10}` error: aborting due to 2 previous errors diff --git a/tests/ui/fn/fn-closure-mutable-capture.stderr b/tests/ui/fn/fn-closure-mutable-capture.stderr index 5a2f92250e020..bee65acbd856d 100644 --- a/tests/ui/fn/fn-closure-mutable-capture.stderr +++ b/tests/ui/fn/fn-closure-mutable-capture.stderr @@ -5,8 +5,9 @@ LL | pub fn bar(_f: F) {} | - change this to accept `FnMut` instead of `Fn` ... LL | bar(move || x = 1); - | --- ------- ^^^^^ cannot assign - | | | + | --- --------^^^^^ + | | | | + | | | cannot assign | | in this closure | expects `Fn` instead of `FnMut` diff --git a/tests/ui/functions-closures/fn-help-with-err.stderr b/tests/ui/functions-closures/fn-help-with-err.stderr index e5fe4611434ea..d557f93a9aabb 100644 --- a/tests/ui/functions-closures/fn-help-with-err.stderr +++ b/tests/ui/functions-closures/fn-help-with-err.stderr @@ -4,7 +4,7 @@ error[E0425]: cannot find value `oops` in this scope LL | let arc = std::sync::Arc::new(oops); | ^^^^ not found in this scope -error[E0599]: no method named `bar` found for struct `Arc<{closure@$DIR/fn-help-with-err.rs:18:36: 18:38}>` in the current scope +error[E0599]: no method named `bar` found for struct `Arc<{closure@$DIR/fn-help-with-err.rs:18:36: 18:42}>` in the current scope --> $DIR/fn-help-with-err.rs:19:10 | LL | arc2.bar(); diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr index ae364de8cc061..740c89c4b9ce8 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr @@ -8,9 +8,9 @@ LL | let filter = map.filterx(|x: &_| true); | ^^^^^^^ method cannot be called due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Map: Stream` - `&'a mut &mut Map: Stream` - `&'a mut Map: Stream` + `&'a mut &Map: Stream` + `&'a mut &mut Map: Stream` + `&'a mut Map: Stream` --> $DIR/hrtb-doesnt-borrow-self-1.rs:98:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr index eeb4e12fa8b31..69d650a8b62bb 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr @@ -8,9 +8,9 @@ LL | let count = filter.countx(); | ^^^^^^ method cannot be called due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` - `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` - `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:42}>: Stream` + `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:42}>: Stream` + `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:42}>: Stream` --> $DIR/hrtb-doesnt-borrow-self-2.rs:98:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr index 74610b55dc373..0e37a0ea71444 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr @@ -44,7 +44,7 @@ LL | | }, LL | | }, | |_________^ expected `Unit3`, found `Unit4` | -note: required for `L<{closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19}>` to implement `for<'r> T0<'r, (&'r u8,)>` +note: required for `L<{closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 45:14}>` to implement `for<'r> T0<'r, (&'r u8,)>` --> $DIR/issue-62203-hrtb-ice.rs:17:16 | LL | impl<'a, A, T> T0<'a, A> for L diff --git a/tests/ui/impl-trait/auto-trait-leak2.stderr b/tests/ui/impl-trait/auto-trait-leak2.stderr index 1fcde0372fc96..879328ed0c51f 100644 --- a/tests/ui/impl-trait/auto-trait-leak2.stderr +++ b/tests/ui/impl-trait/auto-trait-leak2.stderr @@ -14,7 +14,7 @@ note: required because it's used within this closure --> $DIR/auto-trait-leak2.rs:10:5 | LL | move |x| p.set(x) - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` --> $DIR/auto-trait-leak2.rs:5:16 | @@ -42,7 +42,7 @@ note: required because it's used within this closure --> $DIR/auto-trait-leak2.rs:38:5 | LL | move |x| p.set(x) - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` --> $DIR/auto-trait-leak2.rs:33:15 | diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr index 4e453c108d4bb..1e3090df44d42 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Debug` captures lifetime that does not appea LL | fn a() -> impl Fn(&u8) -> impl Debug { | ---------- opaque type defined here LL | |x| x - | --- ^ + | ----^ | | | hidden type `&u8` captures the anonymous lifetime as defined here diff --git a/tests/ui/impl-trait/issue-99073.stderr b/tests/ui/impl-trait/issue-99073.stderr index 3c32f1794a0e0..a94d563ae05c2 100644 --- a/tests/ui/impl-trait/issue-99073.stderr +++ b/tests/ui/impl-trait/issue-99073.stderr @@ -10,7 +10,7 @@ error: concrete type differs from previous defining opaque type use --> $DIR/issue-99073.rs:6:13 | LL | move || f(fix(&f)) - | ^^^^^^^ expected `{closure@$DIR/issue-99073.rs:6:3: 6:10}`, got `G` + | ^^^^^^^ expected `{closure@$DIR/issue-99073.rs:6:3: 6:21}`, got `G` | note: previous use here --> $DIR/issue-99073.rs:5:36 diff --git a/tests/ui/impl-trait/issues/issue-74282.stderr b/tests/ui/impl-trait/issues/issue-74282.stderr index f8e85f7ae0008..81a72920daa97 100644 --- a/tests/ui/impl-trait/issues/issue-74282.stderr +++ b/tests/ui/impl-trait/issues/issue-74282.stderr @@ -14,7 +14,7 @@ LL | | }) | |_____^ expected opaque type, found closure | = note: expected opaque type `Closure` - found closure `{closure@$DIR/issue-74282.rs:8:15: 8:17}` + found closure `{closure@$DIR/issue-74282.rs:8:15: 11:6}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object note: tuple struct defined here diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 273f51ddbe35c..3943ce116c74e 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -104,7 +104,7 @@ error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | -- ---------------- opaque type defined here | | - | hidden type `{closure@$DIR/must_outlive_least_region_or_bound.rs:42:5: 42:13}` captures the lifetime `'b` as defined here + | hidden type `{closure@$DIR/must_outlive_least_region_or_bound.rs:42:5: 42:31}` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr index 96db2030a405c..f954cde56d509 100644 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr @@ -32,7 +32,7 @@ LL | | } | |_____^ types differ | = note: expected opaque type `impl Coroutine` - found coroutine `{coroutine@$DIR/recursive-coroutine-boxed.rs:14:18: 14:20}` + found coroutine `{coroutine@$DIR/recursive-coroutine-boxed.rs:14:18: 22:6}` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr index 9814187e179ef..157b20b417b81 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr @@ -1,10 +1,14 @@ error[E0733]: recursion in a coroutine requires boxing --> $DIR/recursive-coroutine-indirect.rs:11:18 | -LL | #[coroutine] move || { - | ^^^^^^^ -LL | let x = coroutine_hold(); - | - recursive call here +LL | #[coroutine] move || { + | __________________^ +LL | | let x = coroutine_hold(); + | | - recursive call here +LL | | yield; +LL | | x; +LL | | } + | |_____^ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr index 9814187e179ef..157b20b417b81 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr @@ -1,10 +1,14 @@ error[E0733]: recursion in a coroutine requires boxing --> $DIR/recursive-coroutine-indirect.rs:11:18 | -LL | #[coroutine] move || { - | ^^^^^^^ -LL | let x = coroutine_hold(); - | - recursive call here +LL | #[coroutine] move || { + | __________________^ +LL | | let x = coroutine_hold(); + | | - recursive call here +LL | | yield; +LL | | x; +LL | | } + | |_____^ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr index 2d2731e4368f5..eb64020c9774f 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr @@ -55,7 +55,7 @@ LL | / move || { LL | | x; | | - closure captures itself here LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:34:5: 34:12}` + | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:34:5: 36:6}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:39:29 @@ -67,7 +67,7 @@ LL | / move || { LL | | &x; | | - closure captures itself here LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:42:5: 42:12}` + | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:42:5: 44:6}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:47:21 @@ -76,7 +76,7 @@ LL | fn closure_sig() -> impl Sized { | ^^^^^^^^^^ recursive opaque type LL | LL | || closure_sig() - | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:49:5: 49:7}` + | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:49:5: 49:21}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:52:23 @@ -85,7 +85,7 @@ LL | fn coroutine_sig() -> impl Sized { | ^^^^^^^^^^ recursive opaque type LL | LL | || coroutine_sig() - | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7}` + | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:23}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:57:27 @@ -98,7 +98,7 @@ LL | | yield; LL | | x; | | - coroutine captures itself here LL | | } - | |_____- returning here with type `{coroutine@$DIR/recursive-impl-trait-type-indirect.rs:62:5: 62:12}` + | |_____- returning here with type `{coroutine@$DIR/recursive-impl-trait-type-indirect.rs:62:5: 65:6}` error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:68:35 diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 4be244068d226..6b60221f4f0a0 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@$DIR/static-return-lifetime-infered.rs:11:27: 11:30}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@$DIR/static-return-lifetime-infered.rs:11:27: 11:34}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/inference/hint-closure-signature-119266.stderr b/tests/ui/inference/hint-closure-signature-119266.stderr index f0b957906afbc..21b71179d910a 100644 --- a/tests/ui/inference/hint-closure-signature-119266.stderr +++ b/tests/ui/inference/hint-closure-signature-119266.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/hint-closure-signature-119266.rs:5:22 | LL | let x = |a: u8, b: (usize, u32), c: fn() -> char| -> String { "I love beans.".to_string() }; - | --------------------------------------------------- the found closure + | ----------------------------------------------------------------------------------- the found closure ... LL | let x: fn(i32) = x; | ------- ^ incorrect number of function parameters @@ -10,7 +10,7 @@ LL | let x: fn(i32) = x; | expected due to this | = note: expected fn pointer `fn(i32)` - found closure `{closure@$DIR/hint-closure-signature-119266.rs:2:13: 2:64}` + found closure `{closure@$DIR/hint-closure-signature-119266.rs:2:13: 2:96}` = note: closure has signature: `fn(u8, (usize, u32), fn() -> char) -> String` error: aborting due to 1 previous error diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/interior-mutability/interior-mutability.stderr index 29b250c1b07c2..6dcfce826abc6 100644 --- a/tests/ui/interior-mutability/interior-mutability.stderr +++ b/tests/ui/interior-mutability/interior-mutability.stderr @@ -6,7 +6,7 @@ LL | catch_unwind(|| { x.set(23); }); | | | required by a bound introduced by this call | - = help: within `Cell`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell`, which is required by `{closure@$DIR/interior-mutability.rs:5:18: 5:20}: UnwindSafe` + = help: within `Cell`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell`, which is required by `{closure@$DIR/interior-mutability.rs:5:18: 5:35}: UnwindSafe` note: required because it appears within the type `Cell` --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell` to implement `UnwindSafe` @@ -14,7 +14,7 @@ note: required because it's used within this closure --> $DIR/interior-mutability.rs:5:18 | LL | catch_unwind(|| { x.set(23); }); - | ^^ + | ^^^^^^^^^^^^^^^^^ note: required by a bound in `std::panic::catch_unwind` --> $SRC_DIR/std/src/panic.rs:LL:COL diff --git a/tests/ui/intrinsics/const-eval-select-bad.stderr b/tests/ui/intrinsics/const-eval-select-bad.stderr index 50092edda4f73..f9f30e2b8ddfa 100644 --- a/tests/ui/intrinsics/const-eval-select-bad.stderr +++ b/tests/ui/intrinsics/const-eval-select-bad.stderr @@ -4,7 +4,7 @@ error: this argument must be a function item LL | const_eval_select((), || {}, || {}); | ^^^^^ | - = note: expected a function item, found {closure@$DIR/const-eval-select-bad.rs:7:27: 7:29} + = note: expected a function item, found {closure@$DIR/const-eval-select-bad.rs:7:27: 7:32} = help: consult the documentation on `const_eval_select` for more information error: this argument must be a function item @@ -13,7 +13,7 @@ error: this argument must be a function item LL | const_eval_select((), || {}, || {}); | ^^^^^ | - = note: expected a function item, found {closure@$DIR/const-eval-select-bad.rs:7:34: 7:36} + = note: expected a function item, found {closure@$DIR/const-eval-select-bad.rs:7:34: 7:39} = help: consult the documentation on `const_eval_select` for more information error[E0277]: expected a `FnOnce()` closure, found `{integer}` diff --git a/tests/ui/issues/issue-12127.stderr b/tests/ui/issues/issue-12127.stderr index 2a6233547ee8c..28ce9e86985b4 100644 --- a/tests/ui/issues/issue-12127.stderr +++ b/tests/ui/issues/issue-12127.stderr @@ -11,7 +11,7 @@ note: this value implements `FnOnce`, which causes it to be moved when called | LL | f(); | ^ - = note: move occurs because `f` has type `{closure@$DIR/issue-12127.rs:8:24: 8:30}`, which does not implement the `Copy` trait + = note: move occurs because `f` has type `{closure@$DIR/issue-12127.rs:8:24: 8:41}`, which does not implement the `Copy` trait error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-21600.stderr b/tests/ui/issues/issue-21600.stderr index f79059344245c..879df6a709f9b 100644 --- a/tests/ui/issues/issue-21600.stderr +++ b/tests/ui/issues/issue-21600.stderr @@ -5,26 +5,31 @@ LL | fn call_it(f: F) where F: Fn() { f(); } | - change this to accept `FnMut` instead of `Fn` ... LL | call_it(|| x.gen_mut()); - | ------- -- ^ cannot borrow as mutable - | | | + | ------- ---^---------- + | | | | + | | | cannot borrow as mutable | | in this closure | expects `Fn` instead of `FnMut` error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/issue-21600.rs:14:17 | -LL | fn call_it(f: F) where F: Fn() { f(); } - | - change this to accept `FnMut` instead of `Fn` +LL | fn call_it(f: F) where F: Fn() { f(); } + | - change this to accept `FnMut` instead of `Fn` ... -LL | call_it(|| { - | ------- -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | call_it(|| x.gen()); -LL | call_it(|| x.gen_mut()); - | ^^ - mutable borrow occurs due to use of `x` in closure - | | - | cannot borrow as mutable +LL | call_it(|| { + | _____-------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | call_it(|| x.gen()); +LL | | call_it(|| x.gen_mut()); + | | ^^ - mutable borrow occurs due to use of `x` in closure + | | | + | | cannot borrow as mutable +LL | | +LL | | +LL | | }); + | |_____- in this closure error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-22638.stderr b/tests/ui/issues/issue-22638.stderr index 96f1794486838..814d24504bd60 100644 --- a/tests/ui/issues/issue-22638.stderr +++ b/tests/ui/issues/issue-22638.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `A::matches::<{closure@$DIR/issue-22638.rs:42:23: 42:25}>` +error: reached the recursion limit while instantiating `A::matches::<{closure@$DIR/issue-22638.rs:42:23: 44:10}>` --> $DIR/issue-22638.rs:54:9 | LL | a.matches(f) diff --git a/tests/ui/issues/issue-24036.stderr b/tests/ui/issues/issue-24036.stderr index 184383b736942..b96670d18ff4b 100644 --- a/tests/ui/issues/issue-24036.stderr +++ b/tests/ui/issues/issue-24036.stderr @@ -2,12 +2,12 @@ error[E0308]: mismatched types --> $DIR/issue-24036.rs:3:9 | LL | let mut x = |c| c + 1; - | --- the expected closure + | --------- the expected closure LL | x = |c| c + 1; | ^^^^^^^^^ expected closure, found a different closure | - = note: expected closure `{closure@$DIR/issue-24036.rs:2:17: 2:20}` - found closure `{closure@$DIR/issue-24036.rs:3:9: 3:12}` + = note: expected closure `{closure@$DIR/issue-24036.rs:2:17: 2:26}` + found closure `{closure@$DIR/issue-24036.rs:3:9: 3:18}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object diff --git a/tests/ui/issues/issue-34349.stderr b/tests/ui/issues/issue-34349.stderr index 6a6188f10c8f8..c21de52d8d99d 100644 --- a/tests/ui/issues/issue-34349.stderr +++ b/tests/ui/issues/issue-34349.stderr @@ -1,15 +1,18 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut` --> $DIR/issue-34349.rs:16:17 | -LL | let diary = || { - | ^^ this closure implements `FnMut`, not `Fn` -LL | farewell.push_str("!!!"); - | -------- closure is `FnMut` because it mutates the variable `farewell` here -... -LL | apply(diary); - | ----- ----- the requirement to implement `Fn` derives from here - | | - | required by a bound introduced by this call +LL | let diary = || { + | _________________^ +LL | | farewell.push_str("!!!"); + | | -------- closure is `FnMut` because it mutates the variable `farewell` here +LL | | println!("Then I screamed {}.", farewell); +LL | | }; + | |_____^ this closure implements `FnMut`, not `Fn` +LL | +LL | apply(diary); + | ----- ----- the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call | note: required by a bound in `apply` --> $DIR/issue-34349.rs:11:32 diff --git a/tests/ui/issues/issue-4335.stderr b/tests/ui/issues/issue-4335.stderr index 14b5cfa9f9ac4..9fc34c129db58 100644 --- a/tests/ui/issues/issue-4335.stderr +++ b/tests/ui/issues/issue-4335.stderr @@ -4,8 +4,9 @@ error[E0507]: cannot move out of `*v`, as `v` is a captured variable in an `FnMu LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { | - captured outer variable LL | id(Box::new(|| *v)) - | -- ^^ move occurs because `*v` has type `T`, which does not implement the `Copy` trait - | | + | ---^^ + | | | + | | move occurs because `*v` has type `T`, which does not implement the `Copy` trait | captured by this `FnMut` closure | help: if `T` implemented `Clone`, you could clone the value diff --git a/tests/ui/issues/issue-48838.stderr b/tests/ui/issues/issue-48838.stderr index 504ea3e80103a..f66bb5d63815c 100644 --- a/tests/ui/issues/issue-48838.stderr +++ b/tests/ui/issues/issue-48838.stderr @@ -5,7 +5,7 @@ LL | Square = |x| x, | ^^^^^ expected `isize`, found closure | = note: expected type `isize` - found closure `{closure@$DIR/issue-48838.rs:2:14: 2:17}` + found closure `{closure@$DIR/issue-48838.rs:2:14: 2:19}` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-50600.stderr b/tests/ui/issues/issue-50600.stderr index e3ae7f144c35b..183632ac9c961 100644 --- a/tests/ui/issues/issue-50600.stderr +++ b/tests/ui/issues/issue-50600.stderr @@ -5,7 +5,7 @@ LL | fn([u8; |x: u8| {}]), | ^^^^^^^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/issue-50600.rs:2:13: 2:20}` + found closure `{closure@$DIR/issue-50600.rs:2:13: 2:23}` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-50688.stderr b/tests/ui/issues/issue-50688.stderr index 873f179f56d94..be1c232b96be5 100644 --- a/tests/ui/issues/issue-50688.stderr +++ b/tests/ui/issues/issue-50688.stderr @@ -5,7 +5,7 @@ LL | [1; || {}]; | ^^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/issue-50688.rs:2:9: 2:11}` + found closure `{closure@$DIR/issue-50688.rs:2:9: 2:14}` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-51154.stderr b/tests/ui/issues/issue-51154.stderr index b7451ea28ee97..95331fb981ee8 100644 --- a/tests/ui/issues/issue-51154.stderr +++ b/tests/ui/issues/issue-51154.stderr @@ -9,7 +9,7 @@ LL | let _: Box = Box::new(|| ()); | arguments to this function are incorrect | = note: expected type parameter `F` - found closure `{closure@$DIR/issue-51154.rs:2:30: 2:32}` + found closure `{closure@$DIR/issue-51154.rs:2:30: 2:35}` = help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F` note: associated function defined here --> $SRC_DIR/alloc/src/boxed.rs:LL:COL diff --git a/tests/ui/kindck/kindck-nonsendable-1.stderr b/tests/ui/kindck/kindck-nonsendable-1.stderr index 8cc931bc48ed3..6aa5756df21fd 100644 --- a/tests/ui/kindck/kindck-nonsendable-1.stderr +++ b/tests/ui/kindck/kindck-nonsendable-1.stderr @@ -2,18 +2,18 @@ error[E0277]: `Rc` cannot be sent between threads safely --> $DIR/kindck-nonsendable-1.rs:9:9 | LL | bar(move|| foo(x)); - | --- ------^^^^^^^ + | --- ^^^^^^^^^^^^^ | | | | | `Rc` cannot be sent between threads safely - | | within this `{closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15}` + | | within this `{closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22}` | required by a bound introduced by this call | - = help: within `{closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15}`, the trait `Send` is not implemented for `Rc`, which is required by `{closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15}: Send` + = help: within `{closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22}`, the trait `Send` is not implemented for `Rc`, which is required by `{closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22}: Send` note: required because it's used within this closure --> $DIR/kindck-nonsendable-1.rs:9:9 | LL | bar(move|| foo(x)); - | ^^^^^^ + | ^^^^^^^^^^^^^ note: required by a bound in `bar` --> $DIR/kindck-nonsendable-1.rs:5:21 | diff --git a/tests/ui/lint/lint_map_unit_fn.stderr b/tests/ui/lint/lint_map_unit_fn.stderr index fbf689c54219e..7816f68702279 100644 --- a/tests/ui/lint/lint_map_unit_fn.stderr +++ b/tests/ui/lint/lint_map_unit_fn.stderr @@ -25,17 +25,15 @@ error: `Iterator::map` call that discard the iterator's values --> $DIR/lint_map_unit_fn.rs:11:18 | LL | x.iter_mut().map(|items| { - | ^ ------- - | | | - | ____________________|___this function returns `()`, which is likely not what you wanted - | | __________________| - | | | + | __________________^ - + | _|______________________| LL | | | LL | | | items.sort(); LL | | | }); | | | -^ after this call to map, the resulting iterator is `impl Iterator`, which means the only information carried by the iterator is the number of items | | |_____|| - | |_______| + | | | + | |_______this function returns `()`, which is likely not what you wanted | called `Iterator::map` with callable that returns `()` | = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated @@ -47,14 +45,16 @@ LL | x.iter_mut().for_each(|items| { error: `Iterator::map` call that discard the iterator's values --> $DIR/lint_map_unit_fn.rs:18:18 | -LL | let f = |items: &mut Vec| { - | --------------------- this function returns `()`, which is likely not what you wanted -... -LL | x.iter_mut().map(f); - | ^^^^-^ - | | | - | | called `Iterator::map` with callable that returns `()` - | after this call to map, the resulting iterator is `impl Iterator`, which means the only information carried by the iterator is the number of items +LL | let f = |items: &mut Vec| { + | _____________- +LL | | items.sort(); +LL | | }; + | |_____- this function returns `()`, which is likely not what you wanted +LL | x.iter_mut().map(f); + | ^^^^-^ + | | | + | | called `Iterator::map` with callable that returns `()` + | after this call to map, the resulting iterator is `impl Iterator`, which means the only information carried by the iterator is the number of items | = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated help: you might have meant to use `Iterator::for_each` diff --git a/tests/ui/lint/non-local-defs/consts.stderr b/tests/ui/lint/non-local-defs/consts.stderr index ed7bd56fe4a54..46a7e9ea9f63b 100644 --- a/tests/ui/lint/non-local-defs/consts.stderr +++ b/tests/ui/lint/non-local-defs/consts.stderr @@ -71,18 +71,13 @@ LL | impl Test { warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/consts.rs:52:9 | -LL | const { - | ___________- -LL | | impl Test { - | | ^^^^^---- - | | | - | | `Test` is not local -LL | | -LL | | fn hoo() {} -... | -LL | | 1 -LL | | }; - | |_____- move the `impl` block outside of this inline constant `` and up 2 bodies +LL | fn main() { + | --------- move the `impl` block outside of this function `main` and up 2 bodies +... +LL | impl Test { + | ^^^^^---- + | | + | `Test` is not local | = note: methods and associated constants are still usable outside the current expression, only `impl Local` and `impl dyn Local` can ever be private, and only if the type is nested in the same item as the `impl` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue @@ -101,39 +96,20 @@ LL | impl Test { = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue -warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item - --> $DIR/consts.rs:74:9 - | -LL | let _a = || { - | -- move the `impl` block outside of this closure `` and up 2 bodies -LL | impl Uto9 for Test {} - | ^^^^^----^^^^^---- - | | | - | | `Test` is not local - | `Uto9` is not local - | - = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type - = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` - = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue - warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/consts.rs:81:9 | -LL | type A = [u32; { - | ____________________- -LL | | impl Uto10 for Test {} - | | ^^^^^-----^^^^^---- - | | | | - | | | `Test` is not local - | | `Uto10` is not local -LL | | -... | -LL | | }]; - | |_____- move the `impl` block outside of this constant expression `` and up 2 bodies +LL | type A = [u32; { + | ------ move the `impl` block outside of this type alias `A` and up 2 bodies +LL | impl Uto10 for Test {} + | ^^^^^-----^^^^^---- + | | | + | | `Test` is not local + | `Uto10` is not local | = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue -warning: 8 warnings emitted +warning: 7 warnings emitted diff --git a/tests/ui/lint/non-local-defs/exhaustive.stderr b/tests/ui/lint/non-local-defs/exhaustive.stderr index 6d8c2ec0bc7cf..9c2f587d029fc 100644 --- a/tests/ui/lint/non-local-defs/exhaustive.stderr +++ b/tests/ui/lint/non-local-defs/exhaustive.stderr @@ -177,8 +177,9 @@ LL | impl Trait for fn() -> Test {} warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/exhaustive.rs:52:9 | -LL | let _a = || { - | -- move the `impl` block outside of this closure `` and up 2 bodies +LL | fn main() { + | --------- move the `impl` block outside of this function `main` and up 2 bodies +... LL | impl Trait for Test {} | ^^^^^-----^^^^^---- | | | diff --git a/tests/ui/lint/non-local-defs/weird-exprs.stderr b/tests/ui/lint/non-local-defs/weird-exprs.stderr index 49aba904ebb0e..0c407c0cad943 100644 --- a/tests/ui/lint/non-local-defs/weird-exprs.stderr +++ b/tests/ui/lint/non-local-defs/weird-exprs.stderr @@ -1,17 +1,13 @@ warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/weird-exprs.rs:10:5 | -LL | type A = [u32; { - | ________________- -LL | | impl Uto for *mut Test {} - | | ^^^^^---^^^^^--------- - | | | | - | | | `*mut Test` is not local - | | `Uto` is not local -LL | | -... | -LL | | }]; - | |_- move the `impl` block outside of this constant expression `` +LL | type A = [u32; { + | ------ move the `impl` block outside of this type alias `A` +LL | impl Uto for *mut Test {} + | ^^^^^---^^^^^--------- + | | | + | | `*mut Test` is not local + | `Uto` is not local | = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` @@ -25,17 +21,13 @@ LL | #![warn(non_local_definitions)] warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/weird-exprs.rs:18:9 | -LL | Discr = { - | _____________- -LL | | impl Uto for Test {} - | | ^^^^^---^^^^^---- - | | | | - | | | `Test` is not local - | | `Uto` is not local -LL | | -... | -LL | | } - | |_____- move the `impl` block outside of this constant expression `` +LL | Discr = { + | ----- move the `impl` block outside of this variant `Discr` +LL | impl Uto for Test {} + | ^^^^^---^^^^^---- + | | | + | | `Test` is not local + | `Uto` is not local | = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` @@ -44,18 +36,13 @@ LL | | } warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/weird-exprs.rs:27:9 | -LL | let _array = [0i32; { - | _________________________- -LL | | impl Test { - | | ^^^^^---- - | | | - | | `Test` is not local -LL | | -LL | | fn bar() {} -... | -LL | | 1 -LL | | }]; - | |_____- move the `impl` block outside of this constant expression `` and up 2 bodies +LL | fn main() { + | --------- move the `impl` block outside of this function `main` and up 2 bodies +LL | let _array = [0i32; { +LL | impl Test { + | ^^^^^---- + | | + | `Test` is not local | = note: methods and associated constants are still usable outside the current expression, only `impl Local` and `impl dyn Local` can ever be private, and only if the type is nested in the same item as the `impl` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue @@ -63,17 +50,13 @@ LL | | }]; warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/weird-exprs.rs:36:9 | -LL | type A = [u32; { - | ____________________- -LL | | impl Uto for &Test {} - | | ^^^^^---^^^^^----- - | | | | - | | | `&'_ Test` is not local - | | `Uto` is not local -LL | | -... | -LL | | }]; - | |_____- move the `impl` block outside of this constant expression `` and up 2 bodies +LL | type A = [u32; { + | ------ move the `impl` block outside of this type alias `A` and up 2 bodies +LL | impl Uto for &Test {} + | ^^^^^---^^^^^----- + | | | + | | `&'_ Test` is not local + | `Uto` is not local | = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` @@ -82,8 +65,7 @@ LL | | }]; warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/weird-exprs.rs:43:9 | -LL | fn a(_: [u32; { - | ___________________- +LL | / fn a(_: [u32; { LL | | impl Uto for &(Test,) {} | | ^^^^^---^^^^^-------- | | | | @@ -92,7 +74,7 @@ LL | | impl Uto for &(Test,) {} LL | | ... | LL | | }]) {} - | |_____- move the `impl` block outside of this constant expression `` and up 2 bodies + | |_______- move the `impl` block outside of this function `a` and up 2 bodies | = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` @@ -101,8 +83,7 @@ LL | | }]) {} warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/weird-exprs.rs:50:9 | -LL | fn b() -> [u32; { - | _____________________- +LL | / fn b() -> [u32; { LL | | impl Uto for &(Test,Test) {} | | ^^^^^---^^^^^------------ | | | | @@ -111,7 +92,7 @@ LL | | impl Uto for &(Test,Test) {} LL | | ... | LL | | }] { todo!() } - | |_____- move the `impl` block outside of this constant expression `` and up 2 bodies + | |______- move the `impl` block outside of this function `b` and up 2 bodies | = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` diff --git a/tests/ui/lint/trivial_casts.stderr b/tests/ui/lint/trivial_casts.stderr index 5e2115574585b..bde7d6fa8a16d 100644 --- a/tests/ui/lint/trivial_casts.stderr +++ b/tests/ui/lint/trivial_casts.stderr @@ -128,7 +128,7 @@ LL | let _ = &baz as &dyn Fn(i32); | = help: cast can be replaced by coercion; this might require a temporary variable -error: trivial cast: `&{closure@$DIR/trivial_casts.rs:72:13: 72:22}` as `&dyn Fn(i32)` +error: trivial cast: `&{closure@$DIR/trivial_casts.rs:72:13: 72:25}` as `&dyn Fn(i32)` --> $DIR/trivial_casts.rs:73:13 | LL | let _ = &x as &dyn Fn(i32); diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index b737c0ab11fd4..8268a38f6a5d9 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -46,15 +46,15 @@ help: consider further restricting this bound LL | F: for<'a> FnOnce(>::Type) + Output<'_>, | ++++++++++++ -error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` +error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:44} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:44}` --> $DIR/filter-relevant-fn-bounds.rs:21:34 | LL | wrapper.do_something_wrapper(|value| ()); - | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` + | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:44} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:44}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` + = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:44}` help: this trait has no implementations, consider adding one --> $DIR/filter-relevant-fn-bounds.rs:1:1 | diff --git a/tests/ui/methods/method-missing-call.stderr b/tests/ui/methods/method-missing-call.stderr index bc508461b690c..60e51bb0eed96 100644 --- a/tests/ui/methods/method-missing-call.stderr +++ b/tests/ui/methods/method-missing-call.stderr @@ -9,7 +9,7 @@ help: use parentheses to call the method LL | .get_x(); | ++ -error[E0615]: attempted to take value of method `filter_map` on type `Filter, {closure@$DIR/method-missing-call.rs:27:20: 27:23}>, {closure@$DIR/method-missing-call.rs:28:23: 28:28}>` +error[E0615]: attempted to take value of method `filter_map` on type `Filter, {closure@$DIR/method-missing-call.rs:27:20: 27:25}>, {closure@$DIR/method-missing-call.rs:28:23: 28:35}>` --> $DIR/method-missing-call.rs:29:16 | LL | .filter_map; diff --git a/tests/ui/mismatched_types/E0631.stderr b/tests/ui/mismatched_types/E0631.stderr index dcd66c28e3cfb..5e67eba6fd0a2 100644 --- a/tests/ui/mismatched_types/E0631.stderr +++ b/tests/ui/mismatched_types/E0631.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:7:5 | LL | foo(|_: isize| {}); - | ^^^^----------^^^^ + | ^^^^-------------^ | | | | | found signature defined here | expected due to this @@ -19,7 +19,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:8:5 | LL | bar(|_: isize| {}); - | ^^^^----------^^^^ + | ^^^^-------------^ | | | | | found signature defined here | expected due to this diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr index e52e095e9f729..924fc0889d040 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-arg-type-mismatch-issue-45727.rs:3:24 | LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); - | ^^^^ -------- found signature defined here + | ^^^^ ------------------------ found signature defined here | | | expected due to this | @@ -19,7 +19,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-arg-type-mismatch-issue-45727.rs:4:24 | LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); - | ^^^^ ----------- found signature defined here + | ^^^^ --------------------------- found signature defined here | | | expected due to this | diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr index abc5d150a3f9c..11560235ffbd4 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-arg-type-mismatch.rs:3:14 | LL | a.iter().map(|_: (u32, u32)| 45); - | ^^^ --------------- found signature defined here + | ^^^ ------------------ found signature defined here | | | expected due to this | @@ -19,7 +19,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-arg-type-mismatch.rs:4:14 | LL | a.iter().map(|_: &(u16, u16)| 45); - | ^^^ ---------------- found signature defined here + | ^^^ ------------------- found signature defined here | | | expected due to this | @@ -32,7 +32,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-arg-type-mismatch.rs:5:14 | LL | a.iter().map(|_: (u16, u16)| 45); - | ^^^ --------------- found signature defined here + | ^^^ ------------------ found signature defined here | | | expected due to this | diff --git a/tests/ui/mismatched_types/closure-ref-114180.stderr b/tests/ui/mismatched_types/closure-ref-114180.stderr index 27649822e694f..9ed9ea47b0ec5 100644 --- a/tests/ui/mismatched_types/closure-ref-114180.stderr +++ b/tests/ui/mismatched_types/closure-ref-114180.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-ref-114180.rs:6:15 | LL | let compare = |(a,), (e,)| todo!(); - | ------------ found signature defined here + | -------------------- found signature defined here LL | v.sort_by(compare); | ------- ^^^^^^^ expected due to this | | diff --git a/tests/ui/mismatched_types/issue-36053-2.stderr b/tests/ui/mismatched_types/issue-36053-2.stderr index ffaa276b62e4b..87abd85905ad2 100644 --- a/tests/ui/mismatched_types/issue-36053-2.stderr +++ b/tests/ui/mismatched_types/issue-36053-2.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/issue-36053-2.rs:7:32 | LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); - | ^^^^^^ --------- found signature defined here + | ^^^^^^ -------------- found signature defined here | | | expected due to this | @@ -19,17 +19,17 @@ error[E0599]: the method `count` exists for struct `Filter>, {cl --> $DIR/issue-36053-2.rs:7:55 | LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); - | --------- ^^^^^ method cannot be called due to unsatisfied trait bounds + | -------------- ^^^^^ method cannot be called due to unsatisfied trait bounds | | | doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool` or `_: FnMut<(&&str,)>` | = note: the following trait bounds were not satisfied: - `<{closure@$DIR/issue-36053-2.rs:7:39: 7:48} as FnOnce<(&&str,)>>::Output = bool` - which is required by `Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` - `{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnMut<(&&str,)>` - which is required by `Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` - `Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` - which is required by `&mut Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` + `<{closure@$DIR/issue-36053-2.rs:7:39: 7:53} as FnOnce<(&&str,)>>::Output = bool` + which is required by `Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:53}>: Iterator` + `{closure@$DIR/issue-36053-2.rs:7:39: 7:53}: FnMut<(&&str,)>` + which is required by `Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:53}>: Iterator` + `Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:53}>: Iterator` + which is required by `&mut Filter>, {closure@$DIR/issue-36053-2.rs:7:39: 7:53}>: Iterator` error: aborting due to 2 previous errors diff --git a/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index d92d5dbd16fad..b428f43265a74 100644 --- a/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/unboxed-closures-vtable-mismatch.rs:16:24 | LL | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); - | ----------------------------- found signature defined here + | -------------------------------------------------- found signature defined here LL | LL | let z = call_it(3, f); | ------- ^ expected due to this diff --git a/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr index 523134a9425f4..8b57222b55234 100644 --- a/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr +++ b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr @@ -4,8 +4,9 @@ error[E0507]: cannot move out of `i`, a captured variable in an `Fn` closure LL | let i = Box::new(3); | - captured outer variable LL | let _f = to_fn(|| test(i)); - | -- ^ move occurs because `i` has type `Box`, which does not implement the `Copy` trait - | | + | --------^- + | | | + | | move occurs because `i` has type `Box`, which does not implement the `Copy` trait | captured by this `Fn` closure | help: consider cloning the value if the performance cost is acceptable diff --git a/tests/ui/never_type/fallback-closure-wrap.fallback.stderr b/tests/ui/never_type/fallback-closure-wrap.fallback.stderr index aa4a2760ffdc6..42d1eb58d92e7 100644 --- a/tests/ui/never_type/fallback-closure-wrap.fallback.stderr +++ b/tests/ui/never_type/fallback-closure-wrap.fallback.stderr @@ -10,7 +10,7 @@ LL | | }) as Box); | = note: expected unit type `()` found type `!` - = note: required for the cast from `Box<{closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47}>` to `Box` + = note: required for the cast from `Box<{closure@$DIR/fallback-closure-wrap.rs:18:40: 21:6}>` to `Box` error: aborting due to 1 previous error diff --git a/tests/ui/nll/closure-captures.stderr b/tests/ui/nll/closure-captures.stderr index 828974c517e60..f0f95e334f84b 100644 --- a/tests/ui/nll/closure-captures.stderr +++ b/tests/ui/nll/closure-captures.stderr @@ -45,32 +45,36 @@ LL | fn two_closures(mut x: i32) { error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/closure-captures.rs:27:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | || - | ^^ cannot borrow as mutable -LL | x = 1;} - | - mutable borrow occurs due to use of `x` in closure +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | || + | | ^^ cannot borrow as mutable +LL | | x = 1;} + | |__________-_____- in this closure + | | + | mutable borrow occurs due to use of `x` in closure error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/closure-captures.rs:31:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | || - | ^^ cannot borrow as mutable -LL | x = 1;}); - | - mutable borrow occurs due to use of `x` in closure +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | || + | | ^^ cannot borrow as mutable +LL | | x = 1;}); + | |_____-_____- in this closure + | | + | mutable borrow occurs due to use of `x` in closure error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/closure-captures.rs:39:10 @@ -86,17 +90,19 @@ LL | fn two_closures_ref(mut x: i32) { error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/closure-captures.rs:38:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | || - | ^^ cannot borrow as mutable -LL | x = 1;} - | - mutable borrow occurs due to use of `x` in closure +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | || + | | ^^ cannot borrow as mutable +LL | | x = 1;} + | |__________-_____- in this closure + | | + | mutable borrow occurs due to use of `x` in closure error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/closure-captures.rs:43:5 @@ -112,47 +118,53 @@ LL | fn two_closures_ref(mut x: i32) { error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/closure-captures.rs:42:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | || - | ^^ cannot borrow as mutable -LL | x = 1;}); - | - mutable borrow occurs due to use of `x` in closure +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | || + | | ^^ cannot borrow as mutable +LL | | x = 1;}); + | |_____-_____- in this closure + | | + | mutable borrow occurs due to use of `x` in closure error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/closure-captures.rs:48:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(|| { - | ------ -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | || - | ^^ cannot borrow as mutable -LL | *x = 1;}); - | -- mutable borrow occurs due to use of `x` in closure +LL | fn_ref(|| { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | || + | | ^^ cannot borrow as mutable +LL | | *x = 1;}); + | |_________--_____- in this closure + | | + | mutable borrow occurs due to use of `x` in closure error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/closure-captures.rs:51:9 | -LL | fn fn_ref(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn fn_ref(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | fn_ref(move || { - | ------ ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | || - | ^^ cannot borrow as mutable -LL | *x = 1;}); - | -- mutable borrow occurs due to use of `x` in closure +LL | fn_ref(move || { + | _____------_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | || + | | ^^ cannot borrow as mutable +LL | | *x = 1;}); + | |_________--_____- in this closure + | | + | mutable borrow occurs due to use of `x` in closure error: aborting due to 12 previous errors diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr index a7a59dccf2234..d725c1b1670ed 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/escape-argument-callee.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); - | ^^^^^^ + | ^^^^^^^^^^^^^ | = note: defining type: test::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/escape-argument.stderr b/tests/ui/nll/closure-requirements/escape-argument.stderr index 7fd1cd8c3e422..a0ffa71b7a795 100644 --- a/tests/ui/nll/closure-requirements/escape-argument.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/escape-argument.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); - | ^^^^^^ + | ^^^^^^^^^^^^^ | = note: defining type: test::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr b/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr index 8e47ab780f210..7170ba6897b2d 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/escape-upvar-nested.rs:21:32 | LL | let mut closure1 = || p = &y; - | ^^ + | ^^^^^^^^^ | = note: defining type: test::{closure#0}::{closure#0} with closure args [ i16, @@ -15,8 +15,12 @@ LL | let mut closure1 = || p = &y; note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 | -LL | let mut closure = || { - | ^^ +LL | let mut closure = || { + | ___________________________^ +LL | | let mut closure1 = || p = &y; +LL | | closure1(); +LL | | }; + | |_________^ | = note: defining type: test::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr b/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr index c428150aa2f4c..60153e6cb09c6 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/escape-upvar-ref.rs:23:27 | LL | let mut closure = || p = &y; - | ^^ + | ^^^^^^^^^ | = note: defining type: test::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index f37ce967a1ba3..4ee19ce0c5f08 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -1,8 +1,12 @@ note: no external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:43:9 | -LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / |_outlives1, _outlives2, _outlives3, x, y| { +LL | | // Only works if 'x: 'y: +LL | | let p = x.get(); +LL | | demand_y(x, y, p) +LL | | }, + | |_________^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr index e2d0b105ab14d..6f898d941823b 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -1,8 +1,13 @@ note: external requirements --> $DIR/propagate-approximated-ref.rs:43:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | _______________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index d7933a39eaacf..10239817cc2f4 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -1,8 +1,12 @@ note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15 | -LL | foo(cell, |cell_a, cell_x| { - | ^^^^^^^^^^^^^^^^ +LL | foo(cell, |cell_a, cell_x| { + | _______________^ +LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure +LL | | +LL | | }) + | |_____^ | = note: defining type: case1::{closure#0} with closure args [ i32, @@ -31,8 +35,11 @@ LL | fn case1() { note: external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15 | -LL | foo(cell, |cell_a, cell_x| { - | ^^^^^^^^^^^^^^^^ +LL | foo(cell, |cell_a, cell_x| { + | _______________^ +LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error +LL | | }) + | |_____^ | = note: defining type: case2::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index ca7d187ac573b..aaa6cf96bfb58 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -1,8 +1,14 @@ note: external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | ^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { + | _______________________________________________^ +LL | | +LL | | +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index d11a64272a9ce..3b85098d74537 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -1,8 +1,14 @@ note: external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | _______________________________________________^ +LL | | +LL | | +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr index 4787577a6e1a6..6e02278e58113 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -1,8 +1,13 @@ note: external requirements --> $DIR/propagate-approximated-val.rs:36:45 | -LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { + | _____________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(outlives1, outlives2, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: test::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 49c65d77ddded..06af7183f8973 100644 --- a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -1,8 +1,12 @@ note: external requirements --> $DIR/propagate-despite-same-free-region.rs:42:9 | -LL | |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / |_outlives1, _outlives2, x, y| { +LL | | // Only works if 'x: 'y: +LL | | let p = x.get(); +LL | | demand_y(x, y, p) +LL | | }, + | |_________^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 669b56a0be70c..d59e059b87d6d 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -1,8 +1,13 @@ note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:35:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | ^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { + | _______________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 75f476ac5f188..9d90197eccc54 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -1,8 +1,13 @@ note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:39:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | _______________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 28c5c43a6ace8..4d625909e687f 100644 --- a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -1,8 +1,15 @@ note: external requirements --> $DIR/propagate-from-trait-match.rs:32:36 | -LL | establish_relationships(value, |value| { - | ^^^^^^^ +LL | establish_relationships(value, |value| { + | ____________________________________^ +LL | | // This function call requires that +LL | | // +LL | | // (a) T: Trait<'a> +... | +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::<'?1, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr index bc5c04a27a3e6..f3f6496ae5fa6 100644 --- a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/return-wrong-bound-region.rs:11:16 | LL | expect_sig(|a, b| b); // ought to return `a` - | ^^^^^^ + | ^^^^^^^^ | = note: defining type: test::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr b/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr index fbaec8a6008a1..8290a67e6df50 100644 --- a/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr +++ b/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr @@ -4,8 +4,9 @@ error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` LL | let x = (vec![22], vec![44]); | - captured outer variable LL | expect_fn(|| drop(x.0)); - | -- ^^^ move occurs because `x.0` has type `Vec`, which does not implement the `Copy` trait - | | + | --------^^^- + | | | + | | move occurs because `x.0` has type `Vec`, which does not implement the `Copy` trait | captured by this `Fn` closure | help: consider cloning the value if the performance cost is acceptable diff --git a/tests/ui/nll/issue-54556-stephaneyfx.stderr b/tests/ui/nll/issue-54556-stephaneyfx.stderr index 2296407535b7a..e0cb104dcca36 100644 --- a/tests/ui/nll/issue-54556-stephaneyfx.stderr +++ b/tests/ui/nll/issue-54556-stephaneyfx.stderr @@ -12,7 +12,7 @@ LL | } | - | | | `stmt` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Map, {closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:19}>` + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Map, {closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23}>` | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped diff --git a/tests/ui/nll/issue-55850.stderr b/tests/ui/nll/issue-55850.stderr index 5a9c779919790..4ffac5737460b 100644 --- a/tests/ui/nll/issue-55850.stderr +++ b/tests/ui/nll/issue-55850.stderr @@ -10,11 +10,14 @@ LL | yield &s[..] error[E0626]: borrow may still be in use when coroutine yields --> $DIR/issue-55850.rs:28:16 | -LL | GenIter(#[coroutine] move || { - | ------- within this coroutine -LL | let mut s = String::new(); -LL | yield &s[..] - | -------^---- possible yield occurs here +LL | GenIter(#[coroutine] move || { + | __________________________- +LL | | let mut s = String::new(); +LL | | yield &s[..] + | | -------^---- possible yield occurs here +LL | | +LL | | }) + | |_____- within this coroutine | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 4f93fb4eaea34..81b8e9c1d05e9 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:25:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_region::<'?1, T>::{closure#0} with closure args [ i32, @@ -40,7 +40,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:34:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: correct_region::<'?1, T>::{closure#0} with closure args [ i32, @@ -64,7 +64,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:42:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: wrong_region::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -102,7 +102,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:52:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr index dda60398198e7..053b3d7a05a2a 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure args [ i32, @@ -55,7 +55,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:56:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -108,7 +108,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -133,7 +133,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 52040663e005c..cf7ebabc6ec22 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:37:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure args [ i32, @@ -40,7 +40,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:47:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -78,7 +78,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:60:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -103,7 +103,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:69:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -128,7 +128,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:81:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: one_region::<'?1, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index 97be61b77a87f..86280b0839938 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:36:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure args [ i32, @@ -25,7 +25,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -48,7 +48,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:64:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -71,7 +71,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:73:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -94,7 +94,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:85:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: one_region::<'?1, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index c157e89ff8f31..08ed058fb8d2d 100644 --- a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:38:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -38,7 +38,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, @@ -74,7 +74,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, @@ -99,7 +99,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive1::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, @@ -124,7 +124,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:79:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive2::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, @@ -149,7 +149,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: two_regions::<'?1, T>::{closure#0} with closure args [ i32, @@ -190,7 +190,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: two_regions_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, @@ -215,7 +215,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:109:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: one_region::<'?1, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index e58764354c032..c046828183cc6 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:24:24 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: defining type: generic::::{closure#0} with closure args [ i16, @@ -24,7 +24,7 @@ note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: defining type: generic_fail::::{closure#0} with closure args [ i16, diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 3468c5ad37298..fe231bd4f4d79 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23 | LL | with_signature(x, |y| y) - | ^^^ + | ^^^^^ | = note: defining type: no_region::<'?1, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index cef4a0f1e9377..36ecc3ce2114e 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -1,8 +1,15 @@ note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | // See `correct_region`, which explains the point of this +LL | | // test. The only difference is that, in the case of this +LL | | // function, there is no where clause *anywhere*, and hence we +... | +LL | | +LL | | }) + | |_____^ | = note: defining type: no_region::::{closure#0} with closure args [ i32, @@ -38,8 +45,15 @@ LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) { note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:42:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | // Key point of this test: +LL | | // +LL | | // The *closure* is being type-checked with all of its free +... | +LL | | require(&x, &y) +LL | | }) + | |_____^ | = note: defining type: correct_region::<'?1, T>::{closure#0} with closure args [ i32, @@ -62,8 +76,13 @@ LL | | T: 'a, note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:63:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | // See `correct_region` +LL | | require(&x, &y) +LL | | +LL | | }) + | |_____^ | = note: defining type: wrong_region::<'?1, T>::{closure#0} with closure args [ i32, @@ -101,8 +120,12 @@ LL | T: 'b + 'a, note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:76:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | // See `correct_region` +LL | | require(&x, &y) +LL | | }) + | |_____^ | = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure args [ i32, diff --git a/tests/ui/no-send-res-ports.stderr b/tests/ui/no-send-res-ports.stderr index c71d8ecba371c..92eb3687e1068 100644 --- a/tests/ui/no-send-res-ports.stderr +++ b/tests/ui/no-send-res-ports.stderr @@ -2,18 +2,19 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely --> $DIR/no-send-res-ports.rs:25:19 | LL | thread::spawn(move|| { - | ------------- ^----- - | | | - | _____|_____________within this `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}` + | _____-------------_^ | | | | | required by a bound introduced by this call LL | | LL | | let y = x; LL | | println!("{:?}", y); LL | | }); - | |_____^ `Rc<()>` cannot be sent between threads safely + | | ^ + | | | + | |_____`Rc<()>` cannot be sent between threads safely + | within this `{closure@$DIR/no-send-res-ports.rs:25:19: 29:6}` | - = help: within `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}`, the trait `Send` is not implemented for `Rc<()>`, which is required by `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}: Send` + = help: within `{closure@$DIR/no-send-res-ports.rs:25:19: 29:6}`, the trait `Send` is not implemented for `Rc<()>`, which is required by `{closure@$DIR/no-send-res-ports.rs:25:19: 29:6}: Send` note: required because it appears within the type `Port<()>` --> $DIR/no-send-res-ports.rs:5:8 | @@ -27,8 +28,13 @@ LL | struct Foo { note: required because it's used within this closure --> $DIR/no-send-res-ports.rs:25:19 | -LL | thread::spawn(move|| { - | ^^^^^^ +LL | thread::spawn(move|| { + | ___________________^ +LL | | +LL | | let y = x; +LL | | println!("{:?}", y); +LL | | }); + | |_____^ note: required by a bound in `spawn` --> $SRC_DIR/std/src/thread/mod.rs:LL:COL diff --git a/tests/ui/not-clone-closure.stderr b/tests/ui/not-clone-closure.stderr index 9b557b1558290..cdc98ab59647f 100644 --- a/tests/ui/not-clone-closure.stderr +++ b/tests/ui/not-clone-closure.stderr @@ -1,17 +1,23 @@ -error[E0277]: the trait bound `S: Clone` is not satisfied in `{closure@$DIR/not-clone-closure.rs:7:17: 7:24}` +error[E0277]: the trait bound `S: Clone` is not satisfied in `{closure@$DIR/not-clone-closure.rs:7:17: 9:6}` --> $DIR/not-clone-closure.rs:11:23 | -LL | let hello = move || { - | ------- within this `{closure@$DIR/not-clone-closure.rs:7:17: 7:24}` -... -LL | let hello = hello.clone(); - | ^^^^^ within `{closure@$DIR/not-clone-closure.rs:7:17: 7:24}`, the trait `Clone` is not implemented for `S`, which is required by `{closure@$DIR/not-clone-closure.rs:7:17: 7:24}: Clone` +LL | let hello = move || { + | _________________- +LL | | println!("Hello {}", a.0); +LL | | }; + | |_____- within this `{closure@$DIR/not-clone-closure.rs:7:17: 9:6}` +LL | +LL | let hello = hello.clone(); + | ^^^^^ within `{closure@$DIR/not-clone-closure.rs:7:17: 9:6}`, the trait `Clone` is not implemented for `S`, which is required by `{closure@$DIR/not-clone-closure.rs:7:17: 9:6}: Clone` | note: required because it's used within this closure --> $DIR/not-clone-closure.rs:7:17 | -LL | let hello = move || { - | ^^^^^^^ +LL | let hello = move || { + | _________________^ +LL | | println!("Hello {}", a.0); +LL | | }; + | |_____^ help: consider annotating `S` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/on-unimplemented/parent-label.stderr b/tests/ui/on-unimplemented/parent-label.stderr index 101a41512d280..298f985844f59 100644 --- a/tests/ui/on-unimplemented/parent-label.stderr +++ b/tests/ui/on-unimplemented/parent-label.stderr @@ -1,12 +1,17 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/parent-label.rs:14:11 | -LL | let x = || { - | -- in this scope -LL | f(Foo {}); - | - ^^^^^^ the trait `Trait` is not implemented for `Foo` - | | - | required by a bound introduced by this call +LL | let x = || { + | _____________- +LL | | f(Foo {}); + | | - ^^^^^^ the trait `Trait` is not implemented for `Foo` + | | | + | | required by a bound introduced by this call +LL | | let y = || { +LL | | f(Foo {}); +LL | | }; +LL | | }; + | |_____- in this scope | help: this trait has no implementations, consider adding one --> $DIR/parent-label.rs:6:1 @@ -22,12 +27,14 @@ LL | fn f(x: T) {} error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/parent-label.rs:16:15 | -LL | let y = || { - | -- in this scope -LL | f(Foo {}); - | - ^^^^^^ the trait `Trait` is not implemented for `Foo` - | | - | required by a bound introduced by this call +LL | let y = || { + | _________________- +LL | | f(Foo {}); + | | - ^^^^^^ the trait `Trait` is not implemented for `Foo` + | | | + | | required by a bound introduced by this call +LL | | }; + | |_________- in this scope | help: this trait has no implementations, consider adding one --> $DIR/parent-label.rs:6:1 diff --git a/tests/ui/parser/expr-as-stmt.stderr b/tests/ui/parser/expr-as-stmt.stderr index 76a83aa0161bb..39d44dad66bc3 100644 --- a/tests/ui/parser/expr-as-stmt.stderr +++ b/tests/ui/parser/expr-as-stmt.stderr @@ -217,7 +217,7 @@ LL | { true } || { true } | ^^^^^^^^^^^ expected `bool`, found closure | = note: expected type `bool` - found closure `{closure@$DIR/expr-as-stmt.rs:51:14: 51:16}` + found closure `{closure@$DIR/expr-as-stmt.rs:51:14: 51:25}` help: parentheses are required to parse this as an expression | LL | ({ true }) || { true } diff --git a/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr b/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr index aee31d08fe0ec..8272d8c533cd4 100644 --- a/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr +++ b/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr @@ -30,7 +30,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/recover-fn-trait-from-fn-kw.rs:10:5 | LL | foo2(|_: ()| {}); - | ^^^^^-------^^^^ + | ^^^^^----------^ | | | | | found signature defined here | expected due to this diff --git a/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr b/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr index c715486e2da9c..6a2bd922b42e0 100644 --- a/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr +++ b/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr @@ -24,7 +24,7 @@ LL | | }.hi() { | |__________^ expected `bool`, found closure | = note: expected type `bool` - found closure `{closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 12:13}` + found closure `{closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 14:11}` help: use parentheses to call this closure | LL ~ while (|| Foo { diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures.stderr b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures.stderr index eba65a61803d0..2dda87b4f1e75 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures.stderr +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures.stderr @@ -1,16 +1,21 @@ error[E0525]: expected a closure that implements the `FnMut` trait, but this closure only implements `FnOnce` --> $DIR/move-ref-patterns-closure-captures.rs:9:14 | -LL | let c1 = || { - | ^^ this closure implements `FnOnce`, not `FnMut` -... -LL | drop::(_x1); - | --- closure is `FnOnce` because it moves the variable `_x1` out of its environment -... -LL | accept_fn_mut(&c1); - | ------------- --- the requirement to implement `FnMut` derives from here - | | - | required by a bound introduced by this call +LL | let c1 = || { + | ______________^ +LL | | +LL | | +LL | | drop::<&U>(_x0); +LL | | drop::(_x1); + | | --- closure is `FnOnce` because it moves the variable `_x1` out of its environment +LL | | drop::<&mut U>(_x2); +LL | | }; + | |_____^ this closure implements `FnOnce`, not `FnMut` +LL | accept_fn_once(&c1); +LL | accept_fn_mut(&c1); + | ------------- --- the requirement to implement `FnMut` derives from here + | | + | required by a bound introduced by this call | note: required by a bound in `accept_fn_mut` --> $DIR/move-ref-patterns-closure-captures.rs:4:31 @@ -21,16 +26,21 @@ LL | fn accept_fn_mut(_: &impl FnMut()) {} error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/move-ref-patterns-closure-captures.rs:9:14 | -LL | let c1 = || { - | ^^ this closure implements `FnOnce`, not `Fn` -... -LL | drop::(_x1); - | --- closure is `FnOnce` because it moves the variable `_x1` out of its environment +LL | let c1 = || { + | ______________^ +LL | | +LL | | +LL | | drop::<&U>(_x0); +LL | | drop::(_x1); + | | --- closure is `FnOnce` because it moves the variable `_x1` out of its environment +LL | | drop::<&mut U>(_x2); +LL | | }; + | |_____^ this closure implements `FnOnce`, not `Fn` ... -LL | accept_fn(&c1); - | --------- --- the requirement to implement `Fn` derives from here - | | - | required by a bound introduced by this call +LL | accept_fn(&c1); + | --------- --- the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call | note: required by a bound in `accept_fn` --> $DIR/move-ref-patterns-closure-captures.rs:5:27 @@ -41,16 +51,19 @@ LL | fn accept_fn(_: &impl Fn()) {} error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut` --> $DIR/move-ref-patterns-closure-captures.rs:20:14 | -LL | let c2 = || { - | ^^ this closure implements `FnMut`, not `Fn` -... -LL | drop::<&mut U>(_x2); - | --- closure is `FnMut` because it mutates the variable `_x2` here -... -LL | accept_fn(&c2); - | --------- --- the requirement to implement `Fn` derives from here - | | - | required by a bound introduced by this call +LL | let c2 = || { + | ______________^ +LL | | +LL | | drop::<&U>(_x0); +LL | | drop::<&mut U>(_x2); + | | --- closure is `FnMut` because it mutates the variable `_x2` here +LL | | }; + | |_____^ this closure implements `FnMut`, not `Fn` +LL | accept_fn_mut(&c2); +LL | accept_fn(&c2); + | --------- --- the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call | note: required by a bound in `accept_fn` --> $DIR/move-ref-patterns-closure-captures.rs:5:27 diff --git a/tests/ui/polymorphization/const_parameters/closures.stderr b/tests/ui/polymorphization/const_parameters/closures.stderr index 4e927f7732fa1..22abc8b7e826c 100644 --- a/tests/ui/polymorphization/const_parameters/closures.stderr +++ b/tests/ui/polymorphization/const_parameters/closures.stderr @@ -14,7 +14,7 @@ LL | pub fn unused() -> usize { | -------------- generic parameter `T` is unused LL | LL | let add_one = |x: usize| x + 1; - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: item has unused generic parameters --> $DIR/closures.rs:17:8 @@ -29,7 +29,7 @@ LL | pub fn used_parent() -> usize { | -------------- generic parameter `T` is unused LL | let x: usize = T; LL | let add_one = |x: usize| x + 1; - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: item has unused generic parameters --> $DIR/closures.rs:48:13 @@ -38,7 +38,7 @@ LL | pub fn unused_upvar() -> usize { | -------------- generic parameter `T` is unused LL | let x: usize = T; LL | let y = || x; - | ^^ + | ^^^^ error: aborting due to 4 previous errors; 1 warning emitted diff --git a/tests/ui/polymorphization/coroutine.stderr b/tests/ui/polymorphization/coroutine.stderr index 07e29184226d9..bb5ae82f0d4a0 100644 --- a/tests/ui/polymorphization/coroutine.stderr +++ b/tests/ui/polymorphization/coroutine.stderr @@ -10,20 +10,28 @@ LL | #![feature(generic_const_exprs, coroutines, coroutine_trait, rustc_attrs)] error: item has unused generic parameters --> $DIR/coroutine.rs:36:5 | -LL | pub fn unused_type() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { - | - generic parameter `T` is unused -LL | #[coroutine] -LL | || { - | ^^ +LL | pub fn unused_type() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { + | - generic parameter `T` is unused +LL | #[coroutine] +LL | / || { +LL | | +LL | | yield 1; +LL | | 2 +LL | | } + | |_____^ error: item has unused generic parameters --> $DIR/coroutine.rs:64:5 | -LL | pub fn unused_const() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { - | ------------ generic parameter `T` is unused -LL | #[coroutine] -LL | || { - | ^^ +LL | pub fn unused_const() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { + | ------------ generic parameter `T` is unused +LL | #[coroutine] +LL | / || { +LL | | +LL | | yield 1; +LL | | 2 +LL | | } + | |_____^ error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/polymorphization/lifetimes.stderr b/tests/ui/polymorphization/lifetimes.stderr index 4773dd4fa2ef1..2020256717c4d 100644 --- a/tests/ui/polymorphization/lifetimes.stderr +++ b/tests/ui/polymorphization/lifetimes.stderr @@ -11,7 +11,7 @@ LL | pub fn used<'a, T: Default>(_: &'a u32) -> u32 { | - generic parameter `T` is unused LL | let _: T = Default::default(); LL | let add_one = |x: u32| x + 1; - | ^^^^^^^^ + | ^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/polymorphization/predicates.stderr b/tests/ui/polymorphization/predicates.stderr index a3b2f75b12d4a..44b4e34d75d40 100644 --- a/tests/ui/polymorphization/predicates.stderr +++ b/tests/ui/polymorphization/predicates.stderr @@ -25,7 +25,7 @@ LL | impl<'a, I, T: 'a, E> Iterator for Foo<'a, I, E> | generic parameter `I` is unused ... LL | self.find(|_| true) - | ^^^ + | ^^^^^^^^ error: item has unused generic parameters --> $DIR/predicates.rs:59:4 diff --git a/tests/ui/polymorphization/type_parameters/closures.stderr b/tests/ui/polymorphization/type_parameters/closures.stderr index 5c3b46c6041b3..41d4e90f35716 100644 --- a/tests/ui/polymorphization/type_parameters/closures.stderr +++ b/tests/ui/polymorphization/type_parameters/closures.stderr @@ -5,7 +5,7 @@ LL | pub fn unused() -> u32 { | - generic parameter `T` is unused ... LL | let add_one = |x: u32| x + 1; - | ^^^^^^^^ + | ^^^^^^^^^^^^^^ error: item has unused generic parameters --> $DIR/closures.rs:16:8 @@ -20,7 +20,7 @@ LL | pub fn used_parent() -> u32 { | - generic parameter `T` is unused LL | let _: T = Default::default(); LL | let add_one = |x: u32| x + 1; - | ^^^^^^^^ + | ^^^^^^^^^^^^^^ error: item has unused generic parameters --> $DIR/closures.rs:94:23 @@ -32,7 +32,7 @@ LL | pub fn unused_all() -> u32 { | - generic parameter `G` is unused LL | LL | let add_one = |x: u32| x + 1; - | ^^^^^^^^ + | ^^^^^^^^^^^^^^ error: item has unused generic parameters --> $DIR/closures.rs:92:12 @@ -46,11 +46,16 @@ LL | pub fn unused_all() -> u32 { error: item has unused generic parameters --> $DIR/closures.rs:115:23 | -LL | impl Foo { - | - generic parameter `F` is unused +LL | impl Foo { + | - generic parameter `F` is unused ... -LL | let add_one = |x: u32| { - | ^^^^^^^^ +LL | let add_one = |x: u32| { + | _______________________^ +LL | | +LL | | let _: G = Default::default(); +LL | | x + 1 +LL | | }; + | |_________^ error: item has unused generic parameters --> $DIR/closures.rs:113:12 @@ -64,11 +69,16 @@ LL | pub fn used_fn() -> u32 { error: item has unused generic parameters --> $DIR/closures.rs:128:23 | -LL | pub fn used_impl() -> u32 { - | - generic parameter `G` is unused +LL | pub fn used_impl() -> u32 { + | - generic parameter `G` is unused LL | -LL | let add_one = |x: u32| { - | ^^^^^^^^ +LL | let add_one = |x: u32| { + | _______________________^ +LL | | +LL | | let _: F = Default::default(); +LL | | x + 1 +LL | | }; + | |_________^ error: item has unused generic parameters --> $DIR/closures.rs:126:12 diff --git a/tests/ui/polymorphization/unsized_cast.stderr b/tests/ui/polymorphization/unsized_cast.stderr index 27f88d2817464..ec4ff88c5ae1f 100644 --- a/tests/ui/polymorphization/unsized_cast.stderr +++ b/tests/ui/polymorphization/unsized_cast.stderr @@ -5,7 +5,7 @@ LL | fn foo() { | - generic parameter `T` is unused LL | let _: T = Default::default(); LL | (|| Box::new(|| {}) as Box)(); - | ^^ + | ^^^^^ error: item has unused generic parameters --> $DIR/unsized_cast.rs:11:6 @@ -14,7 +14,7 @@ LL | fn foo() { | - generic parameter `T` is unused LL | let _: T = Default::default(); LL | (|| Box::new(|| {}) as Box)(); - | ^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: item has unused generic parameters --> $DIR/unsized_cast.rs:22:15 @@ -23,16 +23,22 @@ LL | fn foo2() { | - generic parameter `T` is unused ... LL | call(&|| {}, ()); - | ^^ + | ^^^^^ error: item has unused generic parameters --> $DIR/unsized_cast.rs:19:6 | -LL | fn foo2() { - | - generic parameter `T` is unused -LL | let _: T = Default::default(); -LL | (|| { - | ^^ +LL | fn foo2() { + | - generic parameter `T` is unused +LL | let _: T = Default::default(); +LL | (|| { + | ______^ +LL | | +LL | | let call: extern "rust-call" fn(_, _) = Fn::call; +LL | | call(&|| {}, ()); +LL | | +LL | | })(); + | |_____^ error: aborting due to 4 previous errors diff --git a/tests/ui/print_type_sizes/coroutine.stdout b/tests/ui/print_type_sizes/coroutine.stdout index 339bbddfc2a93..22f057c98e090 100644 --- a/tests/ui/print_type_sizes/coroutine.stdout +++ b/tests/ui/print_type_sizes/coroutine.stdout @@ -1,4 +1,4 @@ -print-type-size type: `{coroutine@$DIR/coroutine.rs:11:5: 11:14}`: 8193 bytes, alignment: 1 bytes +print-type-size type: `{coroutine@$DIR/coroutine.rs:11:5: 14:6}`: 8193 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 8192 bytes print-type-size upvar `.array`: 8192 bytes diff --git a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout index 4ce1ce46f6e82..9a60620639312 100644 --- a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout @@ -1,4 +1,4 @@ -print-type-size type: `{coroutine@$DIR/coroutine_discr_placement.rs:13:5: 13:7}`: 8 bytes, alignment: 4 bytes +print-type-size type: `{coroutine@$DIR/coroutine_discr_placement.rs:13:5: 24:6}`: 8 bytes, alignment: 4 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Suspend0`: 7 bytes diff --git a/tests/ui/recursion/issue-23302-1.stderr b/tests/ui/recursion/issue-23302-1.stderr index 234060ab5c897..c01dfe351b100 100644 --- a/tests/ui/recursion/issue-23302-1.stderr +++ b/tests/ui/recursion/issue-23302-1.stderr @@ -1,15 +1,15 @@ -error[E0391]: cycle detected when simplifying constant for the type system `X::A::{constant#0}` +error[E0391]: cycle detected when simplifying constant for the type system `X::{constant#0}` --> $DIR/issue-23302-1.rs:4:9 | LL | A = X::A as isize, | ^^^^^^^^^^^^^ | -note: ...which requires const-evaluating + checking `X::A::{constant#0}`... +note: ...which requires const-evaluating + checking `X::{constant#0}`... --> $DIR/issue-23302-1.rs:4:9 | LL | A = X::A as isize, | ^^^^^^^^^^^^^ - = note: ...which again requires simplifying constant for the type system `X::A::{constant#0}`, completing the cycle + = note: ...which again requires simplifying constant for the type system `X::{constant#0}`, completing the cycle note: cycle used when checking that `X` is well-formed --> $DIR/issue-23302-1.rs:3:1 | diff --git a/tests/ui/recursion/issue-23302-2.stderr b/tests/ui/recursion/issue-23302-2.stderr index 9bd95239c8335..20d07e3c5bdec 100644 --- a/tests/ui/recursion/issue-23302-2.stderr +++ b/tests/ui/recursion/issue-23302-2.stderr @@ -1,15 +1,15 @@ -error[E0391]: cycle detected when simplifying constant for the type system `Y::A::{constant#0}` +error[E0391]: cycle detected when simplifying constant for the type system `Y::{constant#0}` --> $DIR/issue-23302-2.rs:4:9 | LL | A = Y::B as isize, | ^^^^^^^^^^^^^ | -note: ...which requires const-evaluating + checking `Y::A::{constant#0}`... +note: ...which requires const-evaluating + checking `Y::{constant#0}`... --> $DIR/issue-23302-2.rs:4:9 | LL | A = Y::B as isize, | ^^^^^^^^^^^^^ - = note: ...which again requires simplifying constant for the type system `Y::A::{constant#0}`, completing the cycle + = note: ...which again requires simplifying constant for the type system `Y::{constant#0}`, completing the cycle note: cycle used when checking that `Y` is well-formed --> $DIR/issue-23302-2.rs:3:1 | diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index fb66436dbbdd7..2236f71cc5eea 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -10,12 +10,12 @@ LL | func(&mut iter.map(|x| x + 1)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:14:24: 14:27}>: Iterator` +error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:14:24: 14:33}>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `&mut Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:14:24: 14:27}>` to implement `Iterator` + = note: required for `&mut Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:14:24: 14:33}>` to implement `Iterator` = note: 65 redundant requirements hidden - = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>, {closure@$DIR/issue-83150.rs:14:24: 14:27}>` to implement `Iterator` + = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>, {closure@$DIR/issue-83150.rs:14:24: 14:33}>` to implement `Iterator` error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr index 7db6a77c77bf6..116773cc23d79 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr @@ -4,11 +4,11 @@ error[E0284]: type annotations needed: cannot normalize `process::{constant#0 LL | fn process(input: [(); T::make(2)]) -> [(); T::make(2)] { | ^^^^^^^^^^^^^^^^ cannot normalize `process::{constant#0}` -error[E0284]: type annotations needed: cannot normalize `Struct::field::{constant#0}` +error[E0284]: type annotations needed: cannot normalize `Struct::{constant#1}` --> $DIR/const-trait-bounds.rs:20:12 | LL | field: [u32; T::make(P)], - | ^^^^^^^^^^^^^^^^^ cannot normalize `Struct::field::{constant#0}` + | ^^^^^^^^^^^^^^^^^ cannot normalize `Struct::{constant#1}` error[E0284]: type annotations needed: cannot normalize `process::{constant#1}` --> $DIR/const-trait-bounds.rs:13:5 diff --git a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr index f37dc320fa315..7c7407ea599d0 100644 --- a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -35,14 +35,17 @@ LL | fn test4(f: &mut Test) { error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | -LL | let mut f = move |g: Box, b: isize| { - | ----- captured outer variable +LL | let mut f = move |g: Box, b: isize| { + | ----- captured outer variable ... -LL | f(Box::new(|a| { - | --- captured by this `FnMut` closure -LL | -LL | foo(f); - | ^ move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait +LL | f(Box::new(|a| { + | ________________- +LL | | +LL | | foo(f); + | | ^ move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 54:6}`, which does not implement the `Copy` trait +LL | | +LL | | }), 3); + | |_____- captured by this `FnMut` closure | help: consider cloning the value if the performance cost is acceptable | diff --git a/tests/ui/span/move-closure.stderr b/tests/ui/span/move-closure.stderr index 2e9cef32e7e67..1147d95384c2c 100644 --- a/tests/ui/span/move-closure.stderr +++ b/tests/ui/span/move-closure.stderr @@ -7,7 +7,7 @@ LL | let x: () = move || (); | expected due to this | = note: expected unit type `()` - found closure `{closure@$DIR/move-closure.rs:5:17: 5:24}` + found closure `{closure@$DIR/move-closure.rs:5:17: 5:27}` help: use parentheses to call this closure | LL | let x: () = (move || ())(); diff --git a/tests/ui/static/issue-24446.stderr b/tests/ui/static/issue-24446.stderr index 9c206e5ef3c42..ec04a65ef6cd7 100644 --- a/tests/ui/static/issue-24446.stderr +++ b/tests/ui/static/issue-24446.stderr @@ -45,7 +45,7 @@ LL | | }; | |_____^ expected `dyn Fn`, found closure | = note: expected trait object `(dyn Fn() -> u32 + 'static)` - found closure `{closure@$DIR/issue-24446.rs:2:35: 2:44}` + found closure `{closure@$DIR/issue-24446.rs:2:35: 8:6}` error: aborting due to 4 previous errors diff --git a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 05e087fd9f9a6..47f6ee6de6a9a 100644 --- a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -17,15 +17,15 @@ help: use parentheses to call this function LL | bar(foo()); | ++ -error[E0277]: `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future +error[E0277]: `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36}` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 | LL | bar(async_closure); - | --- ^^^^^^^^^^^^^ `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future + | --- ^^^^^^^^^^^^^ `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36}` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` + = help: the trait `Future` is not implemented for `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36}` note: required by a bound in `bar` --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16 | diff --git a/tests/ui/suggestions/call-boxed.stderr b/tests/ui/suggestions/call-boxed.stderr index 08fa1a698d6d0..da32190f5f9d5 100644 --- a/tests/ui/suggestions/call-boxed.stderr +++ b/tests/ui/suggestions/call-boxed.stderr @@ -4,12 +4,12 @@ error[E0308]: mismatched types LL | let mut x = 1i32; | ---- expected due to this value LL | let y = Box::new(|| 1); - | -- the found closure + | ---- the found closure LL | x = y; | ^ expected `i32`, found `Box<{closure@call-boxed.rs:3:22}>` | = note: expected type `i32` - found struct `Box<{closure@$DIR/call-boxed.rs:3:22: 3:24}>` + found struct `Box<{closure@$DIR/call-boxed.rs:3:22: 3:26}>` help: use parentheses to call this closure | LL | x = y(); diff --git a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr index edda2cbc735a2..3015012a8adba 100644 --- a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr +++ b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr @@ -1,16 +1,22 @@ error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:28:21 | -LL | let x = X(Y); - | - captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -LL | let X(_t) = x; - | -- ^ - | | - | data moved here - | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; + | | -- ^ + | | | + | | data moved here + | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +LL | | +LL | | +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -20,17 +26,23 @@ LL | let X(_t) = &x; error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:31:34 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | if let Either::One(_t) = e { } - | -- ^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +LL | | if let Either::One(_t) = e { } + | | -- ^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -40,17 +52,24 @@ LL | if let Either::One(_t) = &e { } error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:34:37 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | while let Either::One(_t) = e { } - | -- ^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | while let Either::One(_t) = e { } + | | -- ^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -60,20 +79,27 @@ LL | while let Either::One(_t) = &e { } error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:37:15 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | match e { - | ^ -... -LL | Either::One(_t) - | -- - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match e { + | | ^ +... | +LL | | Either::One(_t) + | | -- + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -83,20 +109,27 @@ LL | match &e { error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:43:15 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | match e { - | ^ -... -LL | Either::One(_t) => (), - | -- - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match e { + | | ^ +... | +LL | | Either::One(_t) => (), + | | -- + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -106,17 +139,24 @@ LL | match &e { error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:51:25 | -LL | let x = X(Y); - | - captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | let X(mut _t) = x; - | ------ ^ - | | - | data moved here - | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | let X(mut _t) = x; + | | ------ ^ + | | | + | | data moved here + | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -126,17 +166,24 @@ LL | let X(mut _t) = &x; error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:54:38 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | if let Either::One(mut _t) = em { } - | ------ ^^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | if let Either::One(mut _t) = em { } + | | ------ ^^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -146,17 +193,24 @@ LL | if let Either::One(mut _t) = &em { } error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:57:41 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | while let Either::One(mut _t) = em { } - | ------ ^^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | while let Either::One(mut _t) = em { } + | | ------ ^^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -166,20 +220,27 @@ LL | while let Either::One(mut _t) = &em { } error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:60:15 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | match em { - | ^^ -... -LL | Either::One(mut _t) - | ------ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match em { + | | ^^ +... | +LL | | Either::One(mut _t) + | | ------ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -189,20 +250,27 @@ LL | match &em { error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure --> $DIR/move-into-closure.rs:66:15 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fn(|| { - | -- captured by this `Fn` closure -... -LL | match em { - | ^^ -... -LL | Either::One(mut _t) => (), - | ------ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fn(|| { + | ________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match em { + | | ^^ +... | +LL | | Either::One(mut _t) => (), + | | ------ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `Fn` closure | help: consider borrowing here | @@ -212,16 +280,22 @@ LL | match &em { error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:85:21 | -LL | let x = X(Y); - | - captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -LL | let X(_t) = x; - | -- ^ - | | - | data moved here - | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; + | | -- ^ + | | | + | | data moved here + | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +LL | | +LL | | +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -231,17 +305,23 @@ LL | let X(_t) = &x; error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:88:34 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | if let Either::One(_t) = e { } - | -- ^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +LL | | if let Either::One(_t) = e { } + | | -- ^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -251,17 +331,24 @@ LL | if let Either::One(_t) = &e { } error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:91:37 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | while let Either::One(_t) = e { } - | -- ^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | while let Either::One(_t) = e { } + | | -- ^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -271,20 +358,27 @@ LL | while let Either::One(_t) = &e { } error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:94:15 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | match e { - | ^ -... -LL | Either::One(_t) - | -- - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match e { + | | ^ +... | +LL | | Either::One(_t) + | | -- + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -294,20 +388,27 @@ LL | match &e { error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:100:15 | -LL | let e = Either::One(X(Y)); - | - captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | match e { - | ^ -... -LL | Either::One(_t) => (), - | -- - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match e { + | | ^ +... | +LL | | Either::One(_t) => (), + | | -- + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -317,17 +418,24 @@ LL | match &e { error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:108:25 | -LL | let x = X(Y); - | - captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | let X(mut _t) = x; - | ------ ^ - | | - | data moved here - | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | let X(mut _t) = x; + | | ------ ^ + | | | + | | data moved here + | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -337,17 +445,24 @@ LL | let X(mut _t) = &x; error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:111:38 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | if let Either::One(mut _t) = em { } - | ------ ^^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | if let Either::One(mut _t) = em { } + | | ------ ^^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -357,17 +472,24 @@ LL | if let Either::One(mut _t) = &em { } error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:114:41 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | while let Either::One(mut _t) = em { } - | ------ ^^ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | while let Either::One(mut _t) = em { } + | | ------ ^^ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -377,20 +499,27 @@ LL | while let Either::One(mut _t) = &em { } error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:117:15 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | match em { - | ^^ -... -LL | Either::One(mut _t) - | ------ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match em { + | | ^^ +... | +LL | | Either::One(mut _t) + | | ------ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -400,20 +529,27 @@ LL | match &em { error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:123:15 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | match em { - | ^^ -... -LL | Either::One(mut _t) => (), - | ------ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match em { + | | ^^ +... | +LL | | Either::One(mut _t) => (), + | | ------ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | @@ -423,20 +559,27 @@ LL | match &em { error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure --> $DIR/move-into-closure.rs:130:15 | -LL | let mut em = Either::One(X(Y)); - | ------ captured outer variable -... -LL | consume_fnmut(|| { - | -- captured by this `FnMut` closure -... -LL | match em { - | ^^ -... -LL | Either::One(mut _t) => (), - | ------ - | | - | data moved here - | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | ___________________- +LL | | let X(_t) = x; +LL | | +LL | | +... | +LL | | match em { + | | ^^ +... | +LL | | Either::One(mut _t) => (), + | | ------ + | | | + | | data moved here + | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait +... | +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: consider borrowing here | diff --git a/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 75a3ae1a83e2f..ae3c2635c4488 100644 --- a/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -16,11 +16,11 @@ help: use parentheses to call this function LL | bar(foo()); | ++ -error[E0277]: the trait bound `{closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21}: T` is not satisfied +error[E0277]: the trait bound `{closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23}: T` is not satisfied --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9 | LL | bar(closure); - | --- ^^^^^^^ the trait `T` is not implemented for closure `{closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21}` + | --- ^^^^^^^ the trait `T` is not implemented for closure `{closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23}` | | | required by a bound introduced by this call | diff --git a/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 1af86860ce1a6..fcdb9fde10349 100644 --- a/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -269,14 +269,14 @@ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:46:20 | LL | let closure = || 42; - | -- the found closure + | ----- the found closure LL | let _: usize = closure; | ----- ^^^^^^^ expected `usize`, found closure | | | expected due to this | = note: expected type `usize` - found closure `{closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:21}` + found closure `{closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24}` help: use parentheses to call this closure | LL | let _: usize = closure(); diff --git a/tests/ui/suggestions/issue-84973-blacklist.stderr b/tests/ui/suggestions/issue-84973-blacklist.stderr index 4fd063e46926a..0644c052b4503 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.stderr +++ b/tests/ui/suggestions/issue-84973-blacklist.stderr @@ -36,11 +36,11 @@ LL + #[derive(Clone)] LL | struct S; | -error[E0277]: `{static coroutine@$DIR/issue-84973-blacklist.rs:17:26: 17:35}` cannot be unpinned +error[E0277]: `{static coroutine@$DIR/issue-84973-blacklist.rs:17:26: 17:46}` cannot be unpinned --> $DIR/issue-84973-blacklist.rs:17:26 | LL | f_unpin(#[coroutine] static || { yield; }); - | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/issue-84973-blacklist.rs:17:26: 17:35}` + | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/issue-84973-blacklist.rs:17:26: 17:46}` | | | required by a bound introduced by this call | diff --git a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr index f0acf1dbb963c..40b708141986b 100644 --- a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr +++ b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr @@ -1,13 +1,16 @@ error[E0631]: type mismatch in closure arguments --> $DIR/late-bound-in-borrow-closure-sugg.rs:26:24 | -LL | let closure = |trader : Trader| { - | ----------------- found signature defined here +LL | let closure = |trader : Trader| { + | ___________________- +LL | | println!("Woooosh!"); +LL | | }; + | |_____- found signature defined here ... -LL | trader.set_closure(closure); - | ----------- ^^^^^^^ expected due to this - | | - | required by a bound introduced by this call +LL | trader.set_closure(closure); + | ----------- ^^^^^^^ expected due to this + | | + | required by a bound introduced by this call | = note: expected closure signature `for<'a, 'b> fn(&'a mut Trader<'b>) -> _` found closure signature `fn(Trader<'_>) -> _` diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index 3a1f685f16b79..5bb03ccbb3626 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure@$DIR/explicit-lifetime-suggestion-in-proper-span-issue-121267.rs:9:21: 9:24}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure@$DIR/explicit-lifetime-suggestion-in-proper-span-issue-121267.rs:9:21: 9:33}>` captures lifetime `'_` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 64af17c830e2e..57d1e51d00264 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -12,7 +12,7 @@ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not ap LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() | ------ ------------- opaque type defined here | | - | hidden type `{closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12}` captures the anonymous lifetime defined here + | hidden type `{closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6}` captures the anonymous lifetime defined here ... LL | / move || { LL | | diff --git a/tests/ui/suggestions/option-content-move2.stderr b/tests/ui/suggestions/option-content-move2.stderr index be97cba17b900..66b233f2cd476 100644 --- a/tests/ui/suggestions/option-content-move2.stderr +++ b/tests/ui/suggestions/option-content-move2.stderr @@ -1,36 +1,42 @@ error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure --> $DIR/option-content-move2.rs:11:9 | -LL | let mut var = None; - | ------- captured outer variable -LL | func(|| { - | -- captured by this `FnMut` closure -LL | // Shouldn't suggest `move ||.as_ref()` here -LL | move || { - | ^^^^^^^ `var` is moved here -LL | -LL | var = Some(NotCopyable); - | --- - | | - | variable moved due to use in closure - | move occurs because `var` has type `Option`, which does not implement the `Copy` trait +LL | let mut var = None; + | ------- captured outer variable +LL | func(|| { + | __________- +LL | | // Shouldn't suggest `move ||.as_ref()` here +LL | | move || { + | | ^^^^^^^ `var` is moved here +LL | | +LL | | var = Some(NotCopyable); + | | --- + | | | + | | variable moved due to use in closure + | | move occurs because `var` has type `Option`, which does not implement the `Copy` trait +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure --> $DIR/option-content-move2.rs:21:9 | -LL | let mut var = None; - | ------- captured outer variable -LL | func(|| { - | -- captured by this `FnMut` closure -LL | // Shouldn't suggest `move ||.as_ref()` nor to `clone()` here -LL | move || { - | ^^^^^^^ `var` is moved here -LL | -LL | var = Some(NotCopyableButCloneable); - | --- - | | - | variable moved due to use in closure - | move occurs because `var` has type `Option`, which does not implement the `Copy` trait +LL | let mut var = None; + | ------- captured outer variable +LL | func(|| { + | __________- +LL | | // Shouldn't suggest `move ||.as_ref()` nor to `clone()` here +LL | | move || { + | | ^^^^^^^ `var` is moved here +LL | | +LL | | var = Some(NotCopyableButCloneable); + | | --- + | | | + | | variable moved due to use in closure + | | move occurs because `var` has type `Option`, which does not implement the `Copy` trait +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/option-content-move3.stderr b/tests/ui/suggestions/option-content-move3.stderr index a20dcce1ee310..3a2b930d70aa0 100644 --- a/tests/ui/suggestions/option-content-move3.stderr +++ b/tests/ui/suggestions/option-content-move3.stderr @@ -1,13 +1,15 @@ error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure --> $DIR/option-content-move3.rs:13:21 | -LL | let var = NotCopyable; - | --- captured outer variable +LL | let var = NotCopyable; + | --- captured outer variable ... -LL | move || { - | ------- captured by this `FnMut` closure -LL | let x = var; - | ^^^ move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait +LL | / move || { +LL | | let x = var; + | | ^^^ move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait +LL | | println!("{x:?}"); +LL | | } + | |_________- captured by this `FnMut` closure | note: if `NotCopyable` implemented `Clone`, you could clone the value --> $DIR/option-content-move3.rs:2:1 @@ -25,18 +27,22 @@ LL | let x = &var; error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure --> $DIR/option-content-move3.rs:12:9 | -LL | let var = NotCopyable; - | --- captured outer variable -LL | func(|| { - | -- captured by this `FnMut` closure -LL | // Shouldn't suggest `move ||.as_ref()` here -LL | move || { - | ^^^^^^^ `var` is moved here -LL | let x = var; - | --- - | | - | variable moved due to use in closure - | move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait +LL | let var = NotCopyable; + | --- captured outer variable +LL | func(|| { + | __________- +LL | | // Shouldn't suggest `move ||.as_ref()` here +LL | | move || { + | | ^^^^^^^ `var` is moved here +LL | | let x = var; + | | --- + | | | + | | variable moved due to use in closure + | | move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait +LL | | println!("{x:?}"); +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | note: if `NotCopyable` implemented `Clone`, you could clone the value --> $DIR/option-content-move3.rs:2:1 @@ -50,13 +56,15 @@ LL | let x = var; error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure --> $DIR/option-content-move3.rs:24:21 | -LL | let var = NotCopyableButCloneable; - | --- captured outer variable +LL | let var = NotCopyableButCloneable; + | --- captured outer variable ... -LL | move || { - | ------- captured by this `FnMut` closure -LL | let x = var; - | ^^^ move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait +LL | / move || { +LL | | let x = var; + | | ^^^ move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait +LL | | println!("{x:?}"); +LL | | } + | |_________- captured by this `FnMut` closure | help: consider borrowing here | @@ -66,18 +74,22 @@ LL | let x = &var; error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure --> $DIR/option-content-move3.rs:23:9 | -LL | let var = NotCopyableButCloneable; - | --- captured outer variable -LL | func(|| { - | -- captured by this `FnMut` closure -LL | // Shouldn't suggest `move ||.as_ref()` here -LL | move || { - | ^^^^^^^ `var` is moved here -LL | let x = var; - | --- - | | - | variable moved due to use in closure - | move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait +LL | let var = NotCopyableButCloneable; + | --- captured outer variable +LL | func(|| { + | __________- +LL | | // Shouldn't suggest `move ||.as_ref()` here +LL | | move || { + | | ^^^^^^^ `var` is moved here +LL | | let x = var; + | | --- + | | | + | | variable moved due to use in closure + | | move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait +LL | | println!("{x:?}"); +LL | | } +LL | | }); + | |_____- captured by this `FnMut` closure | help: clone the value before moving it into the closure | diff --git a/tests/ui/suggestions/return-closures.stderr b/tests/ui/suggestions/return-closures.stderr index ef1f50b8a6ce8..5766562eb484b 100644 --- a/tests/ui/suggestions/return-closures.stderr +++ b/tests/ui/suggestions/return-closures.stderr @@ -8,7 +8,7 @@ LL | |x: &i32| 1i32 | ^^^^^^^^^^^^^^ expected `()`, found closure | = note: expected unit type `()` - found closure `{closure@$DIR/return-closures.rs:3:5: 3:14}` + found closure `{closure@$DIR/return-closures.rs:3:5: 3:19}` error[E0308]: mismatched types --> $DIR/return-closures.rs:9:5 @@ -20,7 +20,7 @@ LL | || i | ^^^^ expected `()`, found closure | = note: expected unit type `()` - found closure `{closure@$DIR/return-closures.rs:9:5: 9:7}` + found closure `{closure@$DIR/return-closures.rs:9:5: 9:9}` error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/sugg-else-for-closure.stderr b/tests/ui/suggestions/sugg-else-for-closure.stderr index fda5ac4e4f07a..7dcfa7e6a1407 100644 --- a/tests/ui/suggestions/sugg-else-for-closure.stderr +++ b/tests/ui/suggestions/sugg-else-for-closure.stderr @@ -7,8 +7,8 @@ LL | let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap()); | arguments to this method are incorrect | = note: expected reference `&str` - found closure `{closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28}` -help: the return type of this call is `{closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28}` due to the type of the argument passed + found closure `{closure@$DIR/sugg-else-for-closure.rs:6:26: 6:57}` +help: the return type of this call is `{closure@$DIR/sugg-else-for-closure.rs:6:26: 6:57}` due to the type of the argument passed --> $DIR/sugg-else-for-closure.rs:6:14 | LL | let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap()); diff --git a/tests/ui/suggestions/suggest-box.stderr b/tests/ui/suggestions/suggest-box.stderr index 58f8774fe9ddd..159895e50bb36 100644 --- a/tests/ui/suggestions/suggest-box.stderr +++ b/tests/ui/suggestions/suggest-box.stderr @@ -11,7 +11,7 @@ LL | | }; | |_____^ expected `Box Result<(), ()>>`, found closure | = note: expected struct `Box Result<(), ()>>` - found closure `{closure@$DIR/suggest-box.rs:4:47: 4:49}` + found closure `{closure@$DIR/suggest-box.rs:4:47: 7:6}` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html help: store this in the heap by calling `Box::new` | diff --git a/tests/ui/suggestions/types/into-inference-needs-type.stderr b/tests/ui/suggestions/types/into-inference-needs-type.stderr index dd688f9028982..aa3f4cbb5e9d4 100644 --- a/tests/ui/suggestions/types/into-inference-needs-type.stderr +++ b/tests/ui/suggestions/types/into-inference-needs-type.stderr @@ -4,8 +4,8 @@ error[E0283]: type annotations needed LL | .into()?; | ^^^^ | - = note: cannot satisfy `_: From, {closure@$DIR/into-inference-needs-type.rs:10:14: 10:17}>, fn(Option<&str>) -> Option> {Option::>::Some}>>` - = note: required for `FilterMap, {closure@$DIR/into-inference-needs-type.rs:10:14: 10:17}>, fn(Option<&str>) -> Option> {Option::>::Some}>` to implement `Into<_>` + = note: cannot satisfy `_: From, {closure@$DIR/into-inference-needs-type.rs:10:14: 10:37}>, fn(Option<&str>) -> Option> {Option::>::Some}>>` + = note: required for `FilterMap, {closure@$DIR/into-inference-needs-type.rs:10:14: 10:37}>, fn(Option<&str>) -> Option> {Option::>::Some}>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = , _>, _> as Into>::into(vec diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr index 6623678fd0c2d..8e15134f6ff4e 100644 --- a/tests/ui/suggestions/unnamable-types.stderr +++ b/tests/ui/suggestions/unnamable-types.stderr @@ -55,7 +55,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@$DIR/unnamable-types.rs:37:24: 37:56}` cannot be named --> $DIR/unnamable-types.rs:37:24 | LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; diff --git a/tests/ui/symbol-names/impl1.legacy.stderr b/tests/ui/symbol-names/impl1.legacy.stderr index 3d438df92b85d..d6609646d999f 100644 --- a/tests/ui/symbol-names/impl1.legacy.stderr +++ b/tests/ui/symbol-names/impl1.legacy.stderr @@ -46,25 +46,25 @@ error: def-path(bar::::baz) LL | #[rustc_def_path] | ^^^^^^^^^^^^^^^^^ -error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17) +error: symbol-name(_ZN180_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..Bar$GT$6method17) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method::) +error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::Bar>::method::) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method) +error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::Bar>::method) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) +error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::Bar>::method) --> $DIR/impl1.rs:69:13 | LL | #[rustc_def_path] diff --git a/tests/ui/symbol-names/impl1.v0.stderr b/tests/ui/symbol-names/impl1.v0.stderr index a7cc5fc8ed211..90e86b49468eb 100644 --- a/tests/ui/symbol-names/impl1.v0.stderr +++ b/tests/ui/symbol-names/impl1.v0.stderr @@ -46,25 +46,25 @@ error: def-path(bar::::baz) LL | #[rustc_def_path] | ^^^^^^^^^^^^^^^^^ -error: symbol-name(_RNvXNCNvCsCRATE_HASH_5impl14mains_0ARDNtB_3Foop5AssocFG_KCRL0_hvEuNtB_9AutoTraitEL_j3_NtB_3Bar6method) +error: symbol-name(_RNvXNvCsCRATE_HASH_5impl14mainARDNtB_3Foop5AssocFG_KCRL0_hvEuNtB_9AutoTraitEL_j3_NtB_3Bar6method) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<[&dyn impl1[d5591eb39db23cbb]::Foo extern "C" fn(&'a u8, ...)> + impl1[d5591eb39db23cbb]::AutoTrait; 3usize] as impl1[d5591eb39db23cbb]::main::{closure#1}::Bar>::method) +error: demangling(<[&dyn impl1[d5591eb39db23cbb]::Foo extern "C" fn(&'a u8, ...)> + impl1[d5591eb39db23cbb]::AutoTrait; 3usize] as impl1[d5591eb39db23cbb]::main::Bar>::method) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) +error: demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::Bar>::method) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) +error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::Bar>::method) --> $DIR/impl1.rs:69:13 | LL | #[rustc_def_path] diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index c2f09371cf7fc..2923f0d4a8e1e 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -24,7 +24,7 @@ LL | impl> Iterator for IteratorOfWrapped { | | | unsatisfied trait bound introduced here = note: 256 redundant requirements hidden - = note: required for `IteratorOfWrapped<(), Map>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>` to implement `Iterator` + = note: required for `IteratorOfWrapped<(), Map>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52}>>` to implement `Iterator` error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/traits/issue-99875.stderr b/tests/ui/traits/issue-99875.stderr index 29e87571561d8..ad8b64a8b8add 100644 --- a/tests/ui/traits/issue-99875.stderr +++ b/tests/ui/traits/issue-99875.stderr @@ -16,11 +16,11 @@ help: the trait `Trait` is implemented for fn pointer `fn(Argument) -> Return`, LL | takes(function as fn(Argument) -> Return); | +++++++++++++++++++++++++ -error[E0277]: the trait bound `{closure@$DIR/issue-99875.rs:14:11: 14:34}: Trait` is not satisfied +error[E0277]: the trait bound `{closure@$DIR/issue-99875.rs:14:11: 14:46}: Trait` is not satisfied --> $DIR/issue-99875.rs:14:11 | LL | takes(|_: Argument| -> Return { todo!() }); - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for closure `{closure@$DIR/issue-99875.rs:14:11: 14:34}` + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for closure `{closure@$DIR/issue-99875.rs:14:11: 14:46}` | | | required by a bound introduced by this call | diff --git a/tests/ui/traits/next-solver/coroutine.fail.stderr b/tests/ui/traits/next-solver/coroutine.fail.stderr index 8c263e8644bd0..e95f91c67ac6e 100644 --- a/tests/ui/traits/next-solver/coroutine.fail.stderr +++ b/tests/ui/traits/next-solver/coroutine.fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `{coroutine@$DIR/coroutine.rs:20:9: 20:11}: Coroutine` is not satisfied +error[E0277]: the trait bound `{coroutine@$DIR/coroutine.rs:20:9: 23:10}: Coroutine` is not satisfied --> $DIR/coroutine.rs:20:9 | LL | needs_coroutine( @@ -8,7 +8,7 @@ LL | / || { LL | | LL | | yield (); LL | | }, - | |_________^ the trait `Coroutine` is not implemented for `{coroutine@$DIR/coroutine.rs:20:9: 20:11}` + | |_________^ the trait `Coroutine` is not implemented for `{coroutine@$DIR/coroutine.rs:20:9: 23:10}` | note: required by a bound in `needs_coroutine` --> $DIR/coroutine.rs:14:28 diff --git a/tests/ui/try-trait/try-on-option-diagnostics.stderr b/tests/ui/try-trait/try-on-option-diagnostics.stderr index 9ee540c79fdda..c10a43f3819a7 100644 --- a/tests/ui/try-trait/try-on-option-diagnostics.stderr +++ b/tests/ui/try-trait/try-on-option-diagnostics.stderr @@ -12,11 +12,14 @@ LL | x?; error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:14:10 | -LL | let a_closure = || { - | -- this function should return `Result` or `Option` to accept `?` -LL | let x: Option = None; -LL | x?; - | ^ cannot use the `?` operator in a closure that returns `{integer}` +LL | let a_closure = || { + | _____________________- +LL | | let x: Option = None; +LL | | x?; + | | ^ cannot use the `?` operator in a closure that returns `{integer}` +LL | | 22 +LL | | }; + | |_____- this function should return `Result` or `Option` to accept `?` | = help: the trait `FromResidual>` is not implemented for `{integer}` diff --git a/tests/ui/tuple/wrong_argument_ice-4.stderr b/tests/ui/tuple/wrong_argument_ice-4.stderr index 10191faf7bf03..eea02e38e6b6b 100644 --- a/tests/ui/tuple/wrong_argument_ice-4.stderr +++ b/tests/ui/tuple/wrong_argument_ice-4.stderr @@ -6,13 +6,13 @@ LL | (|| {})(|| { LL | | LL | | let b = 1; LL | | }); - | |_____- unexpected argument of type `{closure@$DIR/wrong_argument_ice-4.rs:2:13: 2:15}` + | |_____- unexpected argument of type `{closure@$DIR/wrong_argument_ice-4.rs:2:13: 5:6}` | note: closure defined here --> $DIR/wrong_argument_ice-4.rs:2:6 | LL | (|| {})(|| { - | ^^ + | ^^^^^ help: remove the extra argument | LL - (|| {})(|| { diff --git a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr index 084008d8b2a42..50d7bf776608c 100644 --- a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr +++ b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr @@ -1,46 +1,46 @@ -error[E0391]: cycle detected when simplifying constant for the type system `Alpha::V3::{constant#0}` +error[E0391]: cycle detected when simplifying constant for the type system `Alpha::{constant#2}` --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ | -note: ...which requires const-evaluating + checking `Alpha::V3::{constant#0}`... +note: ...which requires const-evaluating + checking `Alpha::{constant#2}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires caching mir of `Alpha::V3::{constant#0}` for CTFE... +note: ...which requires caching mir of `Alpha::{constant#2}` for CTFE... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires elaborating drops for `Alpha::V3::{constant#0}`... +note: ...which requires elaborating drops for `Alpha::{constant#2}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires borrow-checking `Alpha::V3::{constant#0}`... +note: ...which requires borrow-checking `Alpha::{constant#2}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `Alpha::V3::{constant#0}`... +note: ...which requires promoting constants in MIR for `Alpha::{constant#2}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `Alpha::V3::{constant#0}`... +note: ...which requires const checking `Alpha::{constant#2}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `Alpha::V3::{constant#0}`... +note: ...which requires building MIR for `Alpha::{constant#2}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Alpha`... - = note: ...which again requires simplifying constant for the type system `Alpha::V3::{constant#0}`, completing the cycle + = note: ...which again requires simplifying constant for the type system `Alpha::{constant#2}`, completing the cycle note: cycle used when checking that `Alpha` is well-formed --> $DIR/self-in-enum-definition.rs:2:1 | diff --git a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr index 121f765e66726..0f0b6a10aea7a 100644 --- a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr +++ b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr @@ -53,7 +53,7 @@ error: item does not constrain `Bug::{opaque#0}`, but has it in its signature --> $DIR/issue-53092-2.rs:6:61 | LL | const CONST_BUG: Bug = unsafe { std::mem::transmute(|_: u8| ()) }; - | ^^^^^^^ + | ^^^^^^^^^^ | = note: consider moving the opaque type's declaration and defining uses into a separate module note: this opaque type is in the signature diff --git a/tests/ui/type-alias-impl-trait/issue-63279.stderr b/tests/ui/type-alias-impl-trait/issue-63279.stderr index 97158ee297da2..8b5ac07cf8cb4 100644 --- a/tests/ui/type-alias-impl-trait/issue-63279.stderr +++ b/tests/ui/type-alias-impl-trait/issue-63279.stderr @@ -23,7 +23,7 @@ LL | || -> Closure { || () } | ^^^^^ expected `()`, found closure | = note: expected unit type `()` - found closure `{closure@$DIR/issue-63279.rs:7:21: 7:23}` + found closure `{closure@$DIR/issue-63279.rs:7:21: 7:26}` help: use parentheses to call this closure | LL | || -> Closure { (|| ())() } @@ -36,7 +36,7 @@ LL | || -> Closure { || () } | ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure | = note: expected unit type `()` - found closure `{closure@$DIR/issue-63279.rs:7:5: 7:18}` + found closure `{closure@$DIR/issue-63279.rs:7:5: 7:28}` help: use parentheses to call this closure | LL | (|| -> Closure { || () })() diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr index 4c2020becbe32..03474afe70427 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@$DIR/issue-94429.rs:18:9: 20:10} as Coroutine>::Yield == ()` --> $DIR/issue-94429.rs:15:26 | LL | fn run(&mut self) -> Self::Coro { diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr index e8925b9b489fa..2e5c8c38b84cb 100644 --- a/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr +++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr @@ -2,7 +2,7 @@ error: concrete type differs from previous defining opaque type use --> $DIR/recursive-fn-tait.rs:14:5 | LL | move |x: usize| m(n(x)) - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `{closure@$DIR/recursive-fn-tait.rs:7:5: 7:16}`, got `{closure@$DIR/recursive-fn-tait.rs:14:5: 14:20}` + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `{closure@$DIR/recursive-fn-tait.rs:7:5: 7:23}`, got `{closure@$DIR/recursive-fn-tait.rs:14:5: 14:28}` | note: previous use here --> $DIR/recursive-fn-tait.rs:7:5 diff --git a/tests/ui/type/type-check/point-at-inference-issue-116155.stderr b/tests/ui/type/type-check/point-at-inference-issue-116155.stderr index 703694abe594d..55e6cce8f5190 100644 --- a/tests/ui/type/type-check/point-at-inference-issue-116155.stderr +++ b/tests/ui/type/type-check/point-at-inference-issue-116155.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/point-at-inference-issue-116155.rs:15:23 | LL | s.constrain(c); - | - - this argument has type `{closure@$DIR/point-at-inference-issue-116155.rs:13:13: 13:15}`... + | - - this argument has type `{closure@$DIR/point-at-inference-issue-116155.rs:13:13: 13:20}`... | | | ... which causes `s` to have type `S` LL | let _: S = s; diff --git a/tests/ui/typeck/bad-index-modulo-higher-ranked-regions.stderr b/tests/ui/typeck/bad-index-modulo-higher-ranked-regions.stderr index 93c370fd893e3..b855f814dae3e 100644 --- a/tests/ui/typeck/bad-index-modulo-higher-ranked-regions.stderr +++ b/tests/ui/typeck/bad-index-modulo-higher-ranked-regions.stderr @@ -1,4 +1,4 @@ -error[E0608]: cannot index into a value of type `Map<[usize; 1], {closure@$DIR/bad-index-modulo-higher-ranked-regions.rs:23:32: 23:45}>` +error[E0608]: cannot index into a value of type `Map<[usize; 1], {closure@$DIR/bad-index-modulo-higher-ranked-regions.rs:23:32: 23:53}>` --> $DIR/bad-index-modulo-higher-ranked-regions.rs:23:55 | LL | Map { inner: [0_usize], f: |_, i: usize| 1_usize }[0]; diff --git a/tests/ui/typeck/cyclic_type_ice.stderr b/tests/ui/typeck/cyclic_type_ice.stderr index 36715b4ee5d1f..1518b1bb25e8c 100644 --- a/tests/ui/typeck/cyclic_type_ice.stderr +++ b/tests/ui/typeck/cyclic_type_ice.stderr @@ -19,7 +19,7 @@ note: closure defined here --> $DIR/cyclic_type_ice.rs:2:13 | LL | let f = |_, _| (); - | ^^^^^^ + | ^^^^^^^^^ help: provide the argument | LL | f(/* */, /* */); diff --git a/tests/ui/typeck/issue-31173.stderr b/tests/ui/typeck/issue-31173.stderr index 9598bc61352fd..a65a9cb2acd3c 100644 --- a/tests/ui/typeck/issue-31173.stderr +++ b/tests/ui/typeck/issue-31173.stderr @@ -37,10 +37,10 @@ LL | | .collect(); | | = note: the following trait bounds were not satisfied: - `, {closure@$DIR/issue-31173.rs:7:21: 7:25}> as Iterator>::Item = &_` - which is required by `Cloned, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator` - `Cloned, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator` - which is required by `&mut Cloned, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator` + `, {closure@$DIR/issue-31173.rs:7:21: 10:10}> as Iterator>::Item = &_` + which is required by `Cloned, {closure@$DIR/issue-31173.rs:7:21: 10:10}>>: Iterator` + `Cloned, {closure@$DIR/issue-31173.rs:7:21: 10:10}>>: Iterator` + which is required by `&mut Cloned, {closure@$DIR/issue-31173.rs:7:21: 10:10}>>: Iterator` error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/return_type_containing_closure.stderr b/tests/ui/typeck/return_type_containing_closure.stderr index 3f14650a82cce..40d00b0449318 100644 --- a/tests/ui/typeck/return_type_containing_closure.stderr +++ b/tests/ui/typeck/return_type_containing_closure.stderr @@ -5,7 +5,7 @@ LL | vec!['a'].iter().map(|c| c) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Map, ...>` | = note: expected unit type `()` - found struct `Map, {closure@$DIR/return_type_containing_closure.rs:3:26: 3:29}>` + found struct `Map, {closure@$DIR/return_type_containing_closure.rs:3:26: 3:31}>` help: consider using a semicolon here | LL | vec!['a'].iter().map(|c| c); diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 9d295f88da5aa..818d1ca72cd5e 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -663,7 +663,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | type F: std::ops::Fn(_); | ^ not allowed in type signatures -error[E0015]: cannot call non-const fn ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}>` in constants +error[E0015]: cannot call non-const fn ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:43}>` in constants --> $DIR/typeck_type_placeholder_item.rs:230:22 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); @@ -675,7 +675,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0015]: cannot call non-const fn `, {closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}> as Iterator>::map::` in constants +error[E0015]: cannot call non-const fn `, {closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:43}> as Iterator>::map::` in constants --> $DIR/typeck_type_placeholder_item.rs:230:45 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); diff --git a/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr b/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr index cf4391311d03d..0aac74902c387 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr +++ b/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr @@ -4,8 +4,9 @@ error[E0507]: cannot move out of `x`, a captured variable in an `Fn` closure LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn(|| drop(x)); - | -- ^ move occurs because `x` has type `Box`, which does not implement the `Copy` trait - | | + | --------^- + | | | + | | move occurs because `x` has type `Box`, which does not implement the `Copy` trait | captured by this `Fn` closure | help: consider cloning the value if the performance cost is acceptable @@ -19,8 +20,9 @@ error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn_mut(|| drop(x)); - | -- ^ move occurs because `x` has type `Box`, which does not implement the `Copy` trait - | | + | --------^- + | | | + | | move occurs because `x` has type `Box`, which does not implement the `Copy` trait | captured by this `FnMut` closure | help: consider cloning the value if the performance cost is acceptable @@ -34,8 +36,9 @@ error[E0507]: cannot move out of `x`, a captured variable in an `Fn` closure LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn(move || drop(x)); - | ------- ^ move occurs because `x` has type `Box`, which does not implement the `Copy` trait - | | + | -------------^- + | | | + | | move occurs because `x` has type `Box`, which does not implement the `Copy` trait | captured by this `Fn` closure error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure @@ -44,8 +47,9 @@ error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn_mut(move || drop(x)); - | ------- ^ move occurs because `x` has type `Box`, which does not implement the `Copy` trait - | | + | -------------^- + | | | + | | move occurs because `x` has type `Box`, which does not implement the `Copy` trait | captured by this `FnMut` closure error: aborting due to 4 previous errors diff --git a/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr b/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr index 563167f3c0b06..48230e64f7dbd 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr +++ b/tests/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr @@ -2,7 +2,7 @@ error[E0644]: closure/coroutine type that references itself --> $DIR/unboxed-closure-no-cyclic-sig.rs:8:7 | LL | g(|_| { }); - | ^^^ cyclic type of infinite size + | ^^^^^^^^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, diff --git a/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr b/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr index cc81ce9bc3609..f21552d695202 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr @@ -2,8 +2,9 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closur --> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:14:13 | LL | let c = || drop(y.0); - | ^^ --- closure is `FnOnce` because it moves the variable `y` out of its environment - | | + | ^^^^^^^^---^ + | | | + | | closure is `FnOnce` because it moves the variable `y` out of its environment | this closure implements `FnOnce`, not `Fn` LL | foo(c); | --- - the requirement to implement `Fn` derives from here diff --git a/tests/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr b/tests/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr index 80caddb2a11e1..8ba4e138f3ab5 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr @@ -34,15 +34,17 @@ LL | let mut n = 0; error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 | -LL | fn to_fn>(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn>(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... -LL | let mut f = to_fn(move || { - | ----- ------- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | n += 1; - | ^^^^^^ cannot assign +LL | let mut f = to_fn(move || { + | _________________-----_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | n += 1; + | | ^^^^^^ cannot assign +LL | | }); + | |_____- in this closure error: aborting due to 4 previous errors diff --git a/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr b/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr index cbe42861d5ee2..51dc1f0c5aa14 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr @@ -1,15 +1,18 @@ error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:11:9 | -LL | fn call(f: F) where F : Fn() { - | - change this to accept `FnMut` instead of `Fn` +LL | fn call(f: F) where F : Fn() { + | - change this to accept `FnMut` instead of `Fn` ... -LL | call(|| { - | ---- -- in this closure - | | - | expects `Fn` instead of `FnMut` -LL | counter += 1; - | ^^^^^^^^^^^^ cannot assign +LL | call(|| { + | _____----_- + | | | + | | expects `Fn` instead of `FnMut` +LL | | counter += 1; + | | ^^^^^^^^^^^^ cannot assign +LL | | +LL | | }); + | |_____- in this closure error: aborting due to 1 previous error diff --git a/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr b/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr index 4d5e6f4796500..788d7f3dd3fed 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `call` found for closure `{closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:29}` in the current scope +error[E0599]: no method named `call` found for closure `{closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:31}` in the current scope --> $DIR/unboxed-closures-static-call-wrong-trait.rs:7:10 | LL | mut_.call((0, )); From d1b810a9eda097fbb005a4891ac601574a21736c Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 14:30:55 -0700 Subject: [PATCH 03/17] Create defs for generators --- compiler/rustc_ast_lowering/src/expr.rs | 30 ++++++++++++----- .../async-closures/def-path.stderr | 2 +- .../higher-ranked-return.stderr | 2 +- .../async-closures/is-not-fn.stderr | 4 +-- .../move-consuming-capture.stderr | 2 +- .../async-closures/not-lending.stderr | 4 +-- .../async-closures/wrong-fn-kind.stderr | 33 ++++++++++--------- .../ui/async-await/async-is-unwindsafe.stderr | 25 +++++++------- tests/ui/async-await/issue-86507.stderr | 2 +- 9 files changed, 61 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 54d2a3a41b00a..cbf46e21ed84b 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -375,7 +375,27 @@ impl<'hir> LoweringContext<'_, 'hir> { c.value.span, ); } - ExprKind::Closure(_) => { + ExprKind::Closure(box Closure { coroutine_kind, .. }) => { + let closure_def = self.create_def( + self.current_def_id_parent, + e.id, + kw::Empty, + DefKind::Closure, + e.span, + ); + if let Some(coroutine_kind) = coroutine_kind { + self.with_def_id_parent(closure_def, |this| { + this.create_def( + this.current_def_id_parent, + coroutine_kind.closure_id(), + kw::Empty, + DefKind::Closure, + e.span, + ); + }) + } + } + ExprKind::Gen(..) => { self.create_def( self.current_def_id_parent, e.id, @@ -649,13 +669,7 @@ impl<'hir> LoweringContext<'_, 'hir> { coroutine_source: hir::CoroutineSource, body: impl FnOnce(&mut Self) -> hir::Expr<'hir>, ) -> hir::ExprKind<'hir> { - let closure_def_id = self.create_def( - self.current_def_id_parent, - closure_node_id, - kw::Empty, - DefKind::Closure, - span, - ); + let closure_def_id = self.local_def_id(closure_node_id); let coroutine_kind = hir::CoroutineKind::Desugared(desugaring_kind, coroutine_source); // The `async` desugaring takes a resume argument and maintains a `task_context`, diff --git a/tests/ui/async-await/async-closures/def-path.stderr b/tests/ui/async-await/async-closures/def-path.stderr index 0a1e30c1253f3..47be240e09e93 100644 --- a/tests/ui/async-await/async-closures/def-path.stderr +++ b/tests/ui/async-await/async-closures/def-path.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/def-path.rs:9:9 | LL | let x = async || {}; - | -- the expected `async` closure body + | ----------- the expected `async` closure body LL | LL | let () = x(); | ^^ --- this expression has type `{static main::{closure#0}::{closure#0} upvar_tys=?16t witness=?6t}` diff --git a/tests/ui/async-await/async-closures/higher-ranked-return.stderr b/tests/ui/async-await/async-closures/higher-ranked-return.stderr index 268631f67cddf..f45b05b70e9c6 100644 --- a/tests/ui/async-await/async-closures/higher-ranked-return.stderr +++ b/tests/ui/async-await/async-closures/higher-ranked-return.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let x = async move |x: &str| -> &str { | ________________________________-________----_^ | | | | - | | | return type of async closure `{async closure body@$DIR/higher-ranked-return.rs:13:46: 15:10}` contains a lifetime `'2` + | | | return type of async closure `{async closure body@$DIR/higher-ranked-return.rs:13:17: 15:10}` contains a lifetime `'2` | | let's call the lifetime of this reference `'1` LL | | x LL | | }; diff --git a/tests/ui/async-await/async-closures/is-not-fn.stderr b/tests/ui/async-await/async-closures/is-not-fn.stderr index 130746ece675f..6b6bb3d48e0b2 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:14: 7:25}` --> $DIR/is-not-fn.rs:7:14 | LL | needs_fn(async || {}); @@ -7,7 +7,7 @@ LL | needs_fn(async || {}); | required by a bound introduced by this call | = note: expected unit type `()` - found `async` closure body `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` + found `async` closure body `{async closure body@$DIR/is-not-fn.rs:7:14: 7:25}` note: required by a bound in `needs_fn` --> $DIR/is-not-fn.rs:6:25 | diff --git a/tests/ui/async-await/async-closures/move-consuming-capture.stderr b/tests/ui/async-await/async-closures/move-consuming-capture.stderr index 4ce71ec49d612..0f0f0dab4cb4e 100644 --- a/tests/ui/async-await/async-closures/move-consuming-capture.stderr +++ b/tests/ui/async-await/async-closures/move-consuming-capture.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/move-consuming-capture.rs:17:9 | LL | let x = async move || { - | - move occurs because `x` has type `{async closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait + | - move occurs because `x` has type `{async closure@$DIR/move-consuming-capture.rs:13:17: 15:10}`, which does not implement the `Copy` trait ... LL | x().await; | --- `x` moved due to this method call diff --git a/tests/ui/async-await/async-closures/not-lending.stderr b/tests/ui/async-await/async-closures/not-lending.stderr index 1713e49b551e6..a4d7dbfe6a125 100644 --- a/tests/ui/async-await/async-closures/not-lending.stderr +++ b/tests/ui/async-await/async-closures/not-lending.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let x = async move || -> &String { &s }; | ------------------------ ^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of async closure `{async closure body@$DIR/not-lending.rs:14:42: 14:48}` contains a lifetime `'2` + | | return type of async closure `{async closure body@$DIR/not-lending.rs:14:17: 14:48}` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure @@ -15,7 +15,7 @@ error: lifetime may not live long enough LL | let x = async move || { &s }; | ------------- ^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of async closure `{async closure body@$DIR/not-lending.rs:18:31: 18:37}` contains a lifetime `'2` + | | return type of async closure `{async closure body@$DIR/not-lending.rs:18:17: 18:37}` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/async-await/async-closures/wrong-fn-kind.stderr b/tests/ui/async-await/async-closures/wrong-fn-kind.stderr index 4b626c1bed6c3..756845dadfbdc 100644 --- a/tests/ui/async-await/async-closures/wrong-fn-kind.stderr +++ b/tests/ui/async-await/async-closures/wrong-fn-kind.stderr @@ -2,16 +2,17 @@ error[E0525]: expected a closure that implements the `async Fn` trait, but this --> $DIR/wrong-fn-kind.rs:17:20 | LL | needs_async_fn(move || async move { - | -------------- -^^^^^^ - | | | - | _____|______________this closure implements `async FnOnce`, not `async Fn` + | _____--------------_^ | | | | | required by a bound introduced by this call LL | | LL | | println!("{x}"); | | - closure is `async FnOnce` because it moves the variable `x` out of its environment LL | | }); - | |_____- the requirement to implement `async Fn` derives from here + | | ^ + | | | + | |_____this closure implements `async FnOnce`, not `async Fn` + | the requirement to implement `async Fn` derives from here | note: required by a bound in `needs_async_fn` --> $DIR/wrong-fn-kind.rs:5:27 @@ -22,18 +23,20 @@ LL | fn needs_async_fn(_: impl async Fn()) {} error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/wrong-fn-kind.rs:9:20 | -LL | fn needs_async_fn(_: impl async Fn()) {} - | --------------- change this to accept `FnMut` instead of `Fn` +LL | fn needs_async_fn(_: impl async Fn()) {} + | --------------- change this to accept `FnMut` instead of `Fn` ... -LL | needs_async_fn(async || { - | -------------- ^^^^^^^^ - | | | - | | cannot borrow as mutable - | | in this closure - | expects `Fn` instead of `FnMut` -LL | -LL | x += 1; - | - mutable borrow occurs due to use of `x` in closure +LL | needs_async_fn(async || { + | -------------- -^^^^^^^ + | | | + | _____|______________cannot borrow as mutable + | | | + | | expects `Fn` instead of `FnMut` +LL | | +LL | | x += 1; + | | - mutable borrow occurs due to use of `x` in closure +LL | | }); + | |_____- in this closure error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/async-is-unwindsafe.stderr b/tests/ui/async-await/async-is-unwindsafe.stderr index 9c5e8f0252cf9..85fdcda3b8c12 100644 --- a/tests/ui/async-await/async-is-unwindsafe.stderr +++ b/tests/ui/async-await/async-is-unwindsafe.stderr @@ -1,19 +1,20 @@ error[E0277]: the type `&mut Context<'_>` may not be safely transferred across an unwind boundary --> $DIR/async-is-unwindsafe.rs:12:5 | -LL | is_unwindsafe(async { - | ^ ----- within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 12:24}` - | _____| - | | -LL | | -LL | | use std::ptr::null; -LL | | use std::task::{Context, RawWaker, RawWakerVTable, Waker}; -... | -LL | | drop(cx_ref); -LL | | }); - | |______^ `&mut Context<'_>` may not be safely transferred across an unwind boundary +LL | is_unwindsafe(async { + | ______^ - + | | ___________________| +LL | || +LL | || use std::ptr::null; +LL | || use std::task::{Context, RawWaker, RawWakerVTable, Waker}; +... || +LL | || drop(cx_ref); +LL | || }); + | ||_____-^ `&mut Context<'_>` may not be safely transferred across an unwind boundary + | |_____| + | within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}` | - = help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 12:24}`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`, which is required by `{async block@$DIR/async-is-unwindsafe.rs:12:19: 12:24}: UnwindSafe` + = help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`, which is required by `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}: UnwindSafe` = note: `UnwindSafe` is implemented for `&Context<'_>`, but not for `&mut Context<'_>` note: future does not implement `UnwindSafe` as this value is used across an await --> $DIR/async-is-unwindsafe.rs:25:18 diff --git a/tests/ui/async-await/issue-86507.stderr b/tests/ui/async-await/issue-86507.stderr index f4cd7c42706c8..0398e57ef780f 100644 --- a/tests/ui/async-await/issue-86507.stderr +++ b/tests/ui/async-await/issue-86507.stderr @@ -13,7 +13,7 @@ note: captured value is not `Send` because `&` references cannot be sent unless | LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` + = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` help: consider further restricting this bound | LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) From 7e9fbf70ab6eb619f2f15489cedb45698141e772 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 14:34:50 -0700 Subject: [PATCH 04/17] Create def for implicit closure in async fn --- compiler/rustc_ast_lowering/src/item.rs | 7 +++ .../async-await/async-await-let-else.stderr | 10 ++--- ...block-control-flow-static-semantics.stderr | 8 ++-- tests/ui/async-await/coroutine-desc.stderr | 12 ++--- .../async-await/coroutine-not-future.stderr | 10 ++--- .../issue-67252-unnamed-future.stderr | 2 +- tests/ui/async-await/issue-68112.stderr | 20 +++++---- .../issue-70935-complex-spans.stderr | 44 ++++++++++++------- ...sue-74072-lifetime-name-annotations.stderr | 4 +- tests/ui/async-await/issue-84841.stderr | 3 +- .../ui/async-await/issues/issue-67893.stderr | 5 +-- .../partial-drop-partial-reinit.stderr | 5 +-- .../async-closure-gate.afn.stderr | 4 +- .../async-closure-gate.nofeat.stderr | 4 +- .../async-await/try-on-option-in-async.stderr | 17 +++---- 15 files changed, 87 insertions(+), 68 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 7af3945d3f99d..9494b1477d53e 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1160,6 +1160,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let (Some(coroutine_kind), Some(body)) = (coroutine_kind, body) else { return self.lower_fn_body_block(span, decl, body); }; + self.create_def( + self.current_def_id_parent, + coroutine_kind.closure_id(), + kw::Empty, + DefKind::Closure, + span, + ); self.lower_body(|this| { let (parameters, expr) = this.lower_coroutine_body_with_moved_arguments( decl, diff --git a/tests/ui/async-await/async-await-let-else.stderr b/tests/ui/async-await/async-await-let-else.stderr index 0952be2abe53b..993325f485794 100644 --- a/tests/ui/async-await/async-await-let-else.stderr +++ b/tests/ui/async-await/async-await-let-else.stderr @@ -31,18 +31,16 @@ LL | is_send(foo2(Some(true))); | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>`, which is required by `impl Future: Send` note: required because it's used within this `async` fn body - --> $DIR/async-await-let-else.rs:24:29 + --> $DIR/async-await-let-else.rs:24:1 | -LL | async fn bar2(_: T) -> ! { - | _____________________________^ +LL | / async fn bar2(_: T) -> ! { LL | | panic!() LL | | } | |_^ note: required because it's used within this `async` fn body - --> $DIR/async-await-let-else.rs:18:32 + --> $DIR/async-await-let-else.rs:18:1 | -LL | async fn foo2(x: Option) { - | ________________________________^ +LL | / async fn foo2(x: Option) { LL | | let Some(_) = x else { LL | | bar2(Rc::new(())).await LL | | }; 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 3bc467cc84de9..1a41e465429b8 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 @@ -27,13 +27,13 @@ LL | | 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@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6}` 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 = █ | ^^^^^^ expected `()`, found `u8` | - = note: required for the cast from `&{async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 23:22}` to `&dyn Future` + = note: required for the cast from `&{async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6}` to `&dyn Future` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:12:43 @@ -43,13 +43,13 @@ 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@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6}` 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 = █ | ^^^^^^ expected `()`, found `u8` | - = note: required for the cast from `&{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 14:22}` to `&dyn Future` + = note: required for the cast from `&{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6}` to `&dyn Future` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:49:44 diff --git a/tests/ui/async-await/coroutine-desc.stderr b/tests/ui/async-await/coroutine-desc.stderr index e1d7898478e0a..831efb2aa98d7 100644 --- a/tests/ui/async-await/coroutine-desc.stderr +++ b/tests/ui/async-await/coroutine-desc.stderr @@ -8,8 +8,8 @@ LL | fun(async {}, async {}); | | expected all arguments to be this `async` block type because they need to match the type of this parameter | arguments to this function are incorrect | - = note: expected `async` block `{async block@$DIR/coroutine-desc.rs:10:9: 10:14}` - found `async` block `{async block@$DIR/coroutine-desc.rs:10:19: 10:24}` + = note: expected `async` block `{async block@$DIR/coroutine-desc.rs:10:9: 10:17}` + found `async` block `{async block@$DIR/coroutine-desc.rs:10:19: 10:27}` = note: no two async blocks, even if identical, have the same type = help: consider pinning your async block and casting it to a trait object note: function defined here @@ -46,13 +46,13 @@ error[E0308]: mismatched types | LL | fun((async || {})(), (async || {})()); | --- --------------- ^^^^^^^^^^^^^^^ expected `async` closure body, found a different `async` closure body - | | | | - | | | the expected `async` closure body + | | || + | | |the expected `async` closure body | | expected all arguments to be this `async` closure body type because they need to match the type of this parameter | arguments to this function are incorrect | - = note: expected `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:19: 14:21}` - found `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:36: 14:38}` + = note: expected `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:10: 14:21}` + found `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:27: 14:38}` = note: no two async blocks, even if identical, have the same type = help: consider pinning your async block and casting it to a trait object note: function defined here diff --git a/tests/ui/async-await/coroutine-not-future.stderr b/tests/ui/async-await/coroutine-not-future.stderr index 72921a72a9569..6660f7ffaa472 100644 --- a/tests/ui/async-await/coroutine-not-future.stderr +++ b/tests/ui/async-await/coroutine-not-future.stderr @@ -26,11 +26,11 @@ note: required by a bound in `takes_coroutine` LL | fn takes_coroutine(_g: impl Coroutine) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_coroutine` -error[E0277]: the trait bound `{async block@$DIR/coroutine-not-future.rs:39:21: 39:26}: Coroutine<_>` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/coroutine-not-future.rs:39:21: 39:29}: Coroutine<_>` is not satisfied --> $DIR/coroutine-not-future.rs:39:21 | LL | takes_coroutine(async {}); - | --------------- ^^^^^^^^ the trait `Coroutine<_>` is not implemented for `{async block@$DIR/coroutine-not-future.rs:39:21: 39:26}` + | --------------- ^^^^^^^^ the trait `Coroutine<_>` is not implemented for `{async block@$DIR/coroutine-not-future.rs:39:21: 39:29}` | | | required by a bound introduced by this call | @@ -55,7 +55,7 @@ note: required by a bound in `takes_future` LL | fn takes_future(_f: impl Future) {} | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future` -error[E0277]: `{coroutine@$DIR/coroutine-not-future.rs:47:9: 47:14}` is not a future +error[E0277]: `{coroutine@$DIR/coroutine-not-future.rs:47:9: 50:10}` is not a future --> $DIR/coroutine-not-future.rs:47:9 | LL | takes_future( @@ -65,9 +65,9 @@ LL | / |ctx| { LL | | LL | | ctx = yield (); LL | | }, - | |_________^ `{coroutine@$DIR/coroutine-not-future.rs:47:9: 47:14}` is not a future + | |_________^ `{coroutine@$DIR/coroutine-not-future.rs:47:9: 50:10}` is not a future | - = help: the trait `Future` is not implemented for `{coroutine@$DIR/coroutine-not-future.rs:47:9: 47:14}` + = help: the trait `Future` is not implemented for `{coroutine@$DIR/coroutine-not-future.rs:47:9: 50:10}` note: required by a bound in `takes_future` --> $DIR/coroutine-not-future.rs:18:26 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.stderr b/tests/ui/async-await/issue-67252-unnamed-future.stderr index 2ed4028470284..51c06b9c8afef 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.stderr @@ -8,7 +8,7 @@ LL | | let _a = a; LL | | }); | |______^ future created by async block is not `Send` | - = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 18:16}`, the trait `Send` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 18:16}: Send` + = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 22:6}`, the trait `Send` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 22:6}: Send` note: future is not `Send` as this value is used across an await --> $DIR/issue-67252-unnamed-future.rs:20:17 | diff --git a/tests/ui/async-await/issue-68112.stderr b/tests/ui/async-await/issue-68112.stderr index ca60079f3ef5e..711d99ddfd819 100644 --- a/tests/ui/async-await/issue-68112.stderr +++ b/tests/ui/async-await/issue-68112.stderr @@ -4,7 +4,7 @@ error: future cannot be sent between threads safely LL | require_send(send_fut); | ^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | - = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{async block@$DIR/issue-68112.rs:29:20: 29:25}: Send` + = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{async block@$DIR/issue-68112.rs:29:20: 33:6}: Send` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: future is not `Send` as it awaits another future which is not `Send` --> $DIR/issue-68112.rs:31:17 @@ -23,7 +23,7 @@ error: future cannot be sent between threads safely LL | require_send(send_fut); | ^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | - = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{async block@$DIR/issue-68112.rs:39:20: 39:25}: Send` + = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{async block@$DIR/issue-68112.rs:39:20: 42:6}: Send` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: future is not `Send` as it awaits another future which is not `Send` --> $DIR/issue-68112.rs:40:17 @@ -42,14 +42,13 @@ error[E0277]: `RefCell` cannot be shared between threads safely LL | require_send(send_fut); | ^^^^^^^^^^^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{async block@$DIR/issue-68112.rs:57:20: 57:25}: Send` + = help: the trait `Sync` is not implemented for `RefCell`, which is required by `{async block@$DIR/issue-68112.rs:57:20: 61:6}: Send` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc>` to implement `Send` note: required because it's used within this `async` fn body - --> $DIR/issue-68112.rs:47:31 + --> $DIR/issue-68112.rs:47:1 | -LL | async fn ready2(t: T) -> T { - | _______________________________^ +LL | / async fn ready2(t: T) -> T { LL | | t LL | | } | |_^ @@ -61,8 +60,13 @@ LL | fn make_non_send_future2() -> impl Future>> { note: required because it's used within this `async` block --> $DIR/issue-68112.rs:57:20 | -LL | let send_fut = async { - | ^^^^^ +LL | let send_fut = async { + | ____________________^ +LL | | let non_send_fut = make_non_send_future2(); +LL | | let _ = non_send_fut.await; +LL | | ready(0).await; +LL | | }; + | |_____^ note: required by a bound in `require_send` --> $DIR/issue-68112.rs:11:25 | diff --git a/tests/ui/async-await/issue-70935-complex-spans.stderr b/tests/ui/async-await/issue-70935-complex-spans.stderr index 1ca0b339c16ad..c704d6917ffb1 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.stderr @@ -4,7 +4,7 @@ error[E0277]: `*mut ()` cannot be shared between threads safely LL | fn foo(x: NotSync) -> impl Future + Send { | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely | - = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:18:5: 18:15}: Send` + = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:18:5: 22:6}: Send` note: required because it appears within the type `PhantomData<*mut ()>` --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `NotSync` @@ -16,20 +16,26 @@ LL | struct NotSync(PhantomData<*mut ()>); note: required because it's used within this closure --> $DIR/issue-70935-complex-spans.rs:19:13 | -LL | baz(|| async { - | ^^ +LL | baz(|| async { + | _____________^ +LL | | foo(x.clone()); +LL | | }).await; + | |_________^ note: required because it's used within this `async` fn body - --> $DIR/issue-70935-complex-spans.rs:12:67 + --> $DIR/issue-70935-complex-spans.rs:12:1 | -LL | async fn baz(_c: impl FnMut() -> T) where T: Future { - | ___________________________________________________________________^ +LL | / async fn baz(_c: impl FnMut() -> T) where T: Future { LL | | } | |_^ note: required because it's used within this `async` block --> $DIR/issue-70935-complex-spans.rs:18:5 | -LL | async move { - | ^^^^^^^^^^ +LL | / async move { +LL | | baz(|| async { +LL | | foo(x.clone()); +LL | | }).await; +LL | | } + | |_____^ error[E0277]: `*mut ()` cannot be shared between threads safely --> $DIR/issue-70935-complex-spans.rs:15:23 @@ -37,7 +43,7 @@ error[E0277]: `*mut ()` cannot be shared between threads safely LL | fn foo(x: NotSync) -> impl Future + Send { | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely | - = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:18:5: 18:15}: Send` + = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:18:5: 22:6}: Send` note: required because it appears within the type `PhantomData<*mut ()>` --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `NotSync` @@ -49,20 +55,26 @@ LL | struct NotSync(PhantomData<*mut ()>); note: required because it's used within this closure --> $DIR/issue-70935-complex-spans.rs:19:13 | -LL | baz(|| async { - | ^^ +LL | baz(|| async { + | _____________^ +LL | | foo(x.clone()); +LL | | }).await; + | |_________^ note: required because it's used within this `async` fn body - --> $DIR/issue-70935-complex-spans.rs:12:67 + --> $DIR/issue-70935-complex-spans.rs:12:1 | -LL | async fn baz(_c: impl FnMut() -> T) where T: Future { - | ___________________________________________________________________^ +LL | / async fn baz(_c: impl FnMut() -> T) where T: Future { LL | | } | |_^ note: required because it's used within this `async` block --> $DIR/issue-70935-complex-spans.rs:18:5 | -LL | async move { - | ^^^^^^^^^^ +LL | / async move { +LL | | baz(|| async { +LL | | foo(x.clone()); +LL | | }).await; +LL | | } + | |_____^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr b/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr index 9d963686dea0e..f027f66a002f9 100644 --- a/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr +++ b/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr @@ -29,7 +29,7 @@ error: lifetime may not live long enough LL | (async move || { | ______-------------_^ | | | | - | | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:14:20: 20:6}` contains a lifetime `'2` + | | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:14:6: 20:6}` contains a lifetime `'2` | | lifetime `'1` represents this closure's body LL | | LL | | @@ -78,7 +78,7 @@ error: lifetime may not live long enough LL | (async move || -> &i32 { | ______---------------------_^ | | | | - | | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:24:28: 30:6}` contains a lifetime `'2` + | | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:24:6: 30:6}` contains a lifetime `'2` | | lifetime `'1` represents this closure's body LL | | LL | | diff --git a/tests/ui/async-await/issue-84841.stderr b/tests/ui/async-await/issue-84841.stderr index 1e22373ba6ea1..0109c8208832f 100644 --- a/tests/ui/async-await/issue-84841.stderr +++ b/tests/ui/async-await/issue-84841.stderr @@ -9,8 +9,7 @@ LL | test()?; error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/issue-84841.rs:9:11 | -LL | async fn foo() { - | ________________- +LL | / async fn foo() { LL | | // Adding an .await here avoids the ICE LL | | test()?; | | ^ cannot use the `?` operator in an async function that returns `()` diff --git a/tests/ui/async-await/issues/issue-67893.stderr b/tests/ui/async-await/issues/issue-67893.stderr index 0c28aea44bb94..b231b4152e611 100644 --- a/tests/ui/async-await/issues/issue-67893.stderr +++ b/tests/ui/async-await/issues/issue-67893.stderr @@ -13,10 +13,9 @@ LL | pub async fn run() { | = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`, which is required by `impl Future: Send` note: required because it's used within this `async` fn body - --> $DIR/auxiliary/issue_67893.rs:9:20 + --> $DIR/auxiliary/issue_67893.rs:9:1 | -LL | pub async fn run() { - | ____________________^ +LL | / pub async fn run() { LL | | let x: Arc> = make_arc(); LL | | f(*x.lock().unwrap()).await; LL | | } diff --git a/tests/ui/async-await/partial-drop-partial-reinit.stderr b/tests/ui/async-await/partial-drop-partial-reinit.stderr index 0bd7d50b94164..b05a23b32b91a 100644 --- a/tests/ui/async-await/partial-drop-partial-reinit.stderr +++ b/tests/ui/async-await/partial-drop-partial-reinit.stderr @@ -12,10 +12,9 @@ LL | async fn foo() { = help: within `impl Future`, the trait `Send` is not implemented for `NotSend`, which is required by `impl Future: Send` = note: required because it appears within the type `(NotSend,)` note: required because it's used within this `async` fn body - --> $DIR/partial-drop-partial-reinit.rs:27:16 + --> $DIR/partial-drop-partial-reinit.rs:27:1 | -LL | async fn foo() { - | ________________^ +LL | / async fn foo() { LL | | LL | | LL | | let mut x = (NotSend {},); diff --git a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr index 8344b7a07dc6f..640d946421a5f 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr +++ b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr @@ -72,7 +72,7 @@ LL | | } | |_____^ expected `()`, found `async` block | = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:27:5: 27:10}` + found `async` block `{async block@$DIR/async-closure-gate.rs:27:5: 32:6}` error[E0308]: mismatched types --> $DIR/async-closure-gate.rs:44:5 @@ -89,7 +89,7 @@ LL | | } | |_____^ expected `()`, found `async` block | = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:44:5: 44:10}` + found `async` block `{async block@$DIR/async-closure-gate.rs:44:5: 51:6}` error: aborting due to 8 previous errors diff --git a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr index 8344b7a07dc6f..640d946421a5f 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr +++ b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr @@ -72,7 +72,7 @@ LL | | } | |_____^ expected `()`, found `async` block | = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:27:5: 27:10}` + found `async` block `{async block@$DIR/async-closure-gate.rs:27:5: 32:6}` error[E0308]: mismatched types --> $DIR/async-closure-gate.rs:44:5 @@ -89,7 +89,7 @@ LL | | } | |_____^ expected `()`, found `async` block | = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:44:5: 44:10}` + found `async` block `{async block@$DIR/async-closure-gate.rs:44:5: 51:6}` error: aborting due to 8 previous errors diff --git a/tests/ui/async-await/try-on-option-in-async.stderr b/tests/ui/async-await/try-on-option-in-async.stderr index 65f63093728dd..b26acbc44bff8 100644 --- a/tests/ui/async-await/try-on-option-in-async.stderr +++ b/tests/ui/async-await/try-on-option-in-async.stderr @@ -1,11 +1,13 @@ error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-in-async.rs:8:10 | -LL | async { - | ----- this function should return `Result` or `Option` to accept `?` -LL | let x: Option = None; -LL | x?; - | ^ cannot use the `?` operator in an async block that returns `{integer}` +LL | / async { +LL | | let x: Option = None; +LL | | x?; + | | ^ cannot use the `?` operator in an async block that returns `{integer}` +LL | | 22 +LL | | } + | |_____- this function should return `Result` or `Option` to accept `?` | = help: the trait `FromResidual>` is not implemented for `{integer}` @@ -13,7 +15,7 @@ error[E0277]: the `?` operator can only be used in an async closure that returns --> $DIR/try-on-option-in-async.rs:17:10 | LL | let async_closure = async || { - | __________________________________- + | _________________________- LL | | let x: Option = None; LL | | x?; | | ^ cannot use the `?` operator in an async closure that returns `u32` @@ -26,8 +28,7 @@ LL | | }; error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-in-async.rs:26:6 | -LL | async fn an_async_function() -> u32 { - | _____________________________________- +LL | / async fn an_async_function() -> u32 { LL | | let x: Option = None; LL | | x?; | | ^ cannot use the `?` operator in an async function that returns `u32` From 6c70fc30e512632a3864f553500b7e474df724a2 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 14:37:24 -0700 Subject: [PATCH 05/17] Bless tests --- tests/ui/coroutine/clone-impl-async.stderr | 24 +++++++++---------- tests/ui/coroutine/gen_block_is_coro.stderr | 12 +++++----- .../coroutine/gen_block_is_no_future.stderr | 6 ++--- .../self_referential_gen_block.stderr | 17 +++++++------ .../issue-90014-tait.stderr | 2 +- tests/ui/impl-trait/issue-55872-3.stderr | 4 ++-- .../ui/impl-trait/issues/issue-78722-2.stderr | 4 ++-- tests/ui/impl-trait/issues/issue-78722.stderr | 2 +- tests/ui/impl-trait/issues/issue-86800.stderr | 10 ++++---- .../ui/impl-trait/nested-return-type4.stderr | 2 +- .../issue-76168-hr-outlives-3.stderr | 8 ++++--- .../mismatch-sugg-for-shorthand-field.stderr | 4 ++-- .../pattern/non-structural-match-types.stderr | 4 ++-- .../expected-boxed-future-isnt-pinned.stderr | 2 +- tests/ui/traits/next-solver/async.fail.stderr | 2 +- .../const_generic_type.no_infer.stderr | 5 ++-- .../hkl_forbidden4.stderr | 7 ++++-- .../indirect-recursion-issue-112047.stderr | 4 +++- 18 files changed, 64 insertions(+), 55 deletions(-) diff --git a/tests/ui/coroutine/clone-impl-async.stderr b/tests/ui/coroutine/clone-impl-async.stderr index b5074911aa917..d172dff3abd22 100644 --- a/tests/ui/coroutine/clone-impl-async.stderr +++ b/tests/ui/coroutine/clone-impl-async.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:12:27: 12:32}: Copy` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:12:27: 16:6}: Copy` is not satisfied --> $DIR/clone-impl-async.rs:17:16 | LL | check_copy(&inner_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/clone-impl-async.rs:12:27: 12:32}` + | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/clone-impl-async.rs:12:27: 16:6}` | | | required by a bound introduced by this call | @@ -12,11 +12,11 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:12:27: 12:32}: Clone` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:12:27: 16:6}: Clone` is not satisfied --> $DIR/clone-impl-async.rs:19:17 | LL | check_clone(&inner_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `{async block@$DIR/clone-impl-async.rs:12:27: 12:32}` + | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `{async block@$DIR/clone-impl-async.rs:12:27: 16:6}` | | | required by a bound introduced by this call | @@ -26,11 +26,11 @@ note: required by a bound in `check_clone` LL | fn check_clone(_x: &T) {} | ^^^^^ required by this bound in `check_clone` -error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:23:27: 23:37}: Copy` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:23:27: 25:6}: Copy` is not satisfied --> $DIR/clone-impl-async.rs:26:16 | LL | check_copy(&outer_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/clone-impl-async.rs:23:27: 23:37}` + | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/clone-impl-async.rs:23:27: 25:6}` | | | required by a bound introduced by this call | @@ -40,11 +40,11 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:23:27: 23:37}: Clone` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:23:27: 25:6}: Clone` is not satisfied --> $DIR/clone-impl-async.rs:28:17 | LL | check_clone(&outer_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `{async block@$DIR/clone-impl-async.rs:23:27: 23:37}` + | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `{async block@$DIR/clone-impl-async.rs:23:27: 25:6}` | | | required by a bound introduced by this call | @@ -54,11 +54,11 @@ note: required by a bound in `check_clone` LL | fn check_clone(_x: &T) {} | ^^^^^ required by this bound in `check_clone` -error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:31:28: 31:38}: Copy` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:31:28: 31:41}: Copy` is not satisfied --> $DIR/clone-impl-async.rs:32:16 | LL | check_copy(&maybe_copy_clone); - | ---------- ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/clone-impl-async.rs:31:28: 31:38}` + | ---------- ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/clone-impl-async.rs:31:28: 31:41}` | | | required by a bound introduced by this call | @@ -68,11 +68,11 @@ note: required by a bound in `check_copy` LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` -error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:31:28: 31:38}: Clone` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/clone-impl-async.rs:31:28: 31:41}: Clone` is not satisfied --> $DIR/clone-impl-async.rs:34:17 | LL | check_clone(&maybe_copy_clone); - | ----------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `{async block@$DIR/clone-impl-async.rs:31:28: 31:38}` + | ----------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `{async block@$DIR/clone-impl-async.rs:31:28: 31:41}` | | | required by a bound introduced by this call | diff --git a/tests/ui/coroutine/gen_block_is_coro.stderr b/tests/ui/coroutine/gen_block_is_coro.stderr index afcdce1d58dfc..83a674fa53ce3 100644 --- a/tests/ui/coroutine/gen_block_is_coro.stderr +++ b/tests/ui/coroutine/gen_block_is_coro.stderr @@ -1,20 +1,20 @@ -error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}: Coroutine` is not satisfied +error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:21}: Coroutine` is not satisfied --> $DIR/gen_block_is_coro.rs:6:13 | LL | fn foo() -> impl Coroutine { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:21}` -error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:8}: Coroutine` is not satisfied +error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:21}: Coroutine` is not satisfied --> $DIR/gen_block_is_coro.rs:10:13 | LL | fn bar() -> impl Coroutine { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:8}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:21}` -error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:8}: Coroutine` is not satisfied +error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:21}: Coroutine` is not satisfied --> $DIR/gen_block_is_coro.rs:14:13 | LL | fn baz() -> impl Coroutine { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:8}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:21}` error: aborting due to 3 previous errors diff --git a/tests/ui/coroutine/gen_block_is_no_future.stderr b/tests/ui/coroutine/gen_block_is_no_future.stderr index bf0985a76a28e..fb2f2ba559775 100644 --- a/tests/ui/coroutine/gen_block_is_no_future.stderr +++ b/tests/ui/coroutine/gen_block_is_no_future.stderr @@ -1,10 +1,10 @@ -error[E0277]: `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` is not a future +error[E0277]: `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` is not a future --> $DIR/gen_block_is_no_future.rs:4:13 | LL | fn foo() -> impl std::future::Future { - | ^^^^^^^^^^^^^^^^^^^^^^^^ `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` is not a future + | ^^^^^^^^^^^^^^^^^^^^^^^^ `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` is not a future | - = help: the trait `Future` is not implemented for `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` + = help: the trait `Future` is not implemented for `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/self_referential_gen_block.stderr b/tests/ui/coroutine/self_referential_gen_block.stderr index 2f53e7c84a10b..e5b5460edd356 100644 --- a/tests/ui/coroutine/self_referential_gen_block.stderr +++ b/tests/ui/coroutine/self_referential_gen_block.stderr @@ -1,13 +1,16 @@ error[E0626]: borrow may still be in use when `gen` block yields --> $DIR/self_referential_gen_block.rs:9:21 | -LL | let mut x = gen { - | --- within this `gen` block -LL | let y = 42; -LL | let z = &y; - | ^^ -LL | yield 43; - | -------- possible yield occurs here +LL | let mut x = gen { + | _____________________- +LL | | let y = 42; +LL | | let z = &y; + | | ^^ +LL | | yield 43; + | | -------- possible yield occurs here +LL | | panic!("{z}"); +LL | | }; + | |_________- within this `gen` block error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/issue-90014-tait.stderr b/tests/ui/generic-associated-types/issue-90014-tait.stderr index 09c2903ab0281..e4bcc92bf6e02 100644 --- a/tests/ui/generic-associated-types/issue-90014-tait.stderr +++ b/tests/ui/generic-associated-types/issue-90014-tait.stderr @@ -10,7 +10,7 @@ LL | async { () } | ^^^^^^^^^^^^ expected future, found `async` block | = note: expected opaque type `Foo<'_>::Fut<'a>` - found `async` block `{async block@$DIR/issue-90014-tait.rs:18:9: 18:14}` + found `async` block `{async block@$DIR/issue-90014-tait.rs:18:9: 18:21}` note: this item must have the opaque type in its signature in order to be able to register hidden types --> $DIR/issue-90014-tait.rs:17:8 | diff --git a/tests/ui/impl-trait/issue-55872-3.stderr b/tests/ui/impl-trait/issue-55872-3.stderr index f892da2a5353b..9af0fad9cdb94 100644 --- a/tests/ui/impl-trait/issue-55872-3.stderr +++ b/tests/ui/impl-trait/issue-55872-3.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `{async block@$DIR/issue-55872-3.rs:15:9: 15:14}: Copy` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/issue-55872-3.rs:15:9: 15:17}: Copy` is not satisfied --> $DIR/issue-55872-3.rs:13:20 | LL | fn foo() -> Self::E { - | ^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/issue-55872-3.rs:15:9: 15:14}` + | ^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/issue-55872-3.rs:15:9: 15:17}` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr index dc5579c1c829e..91dad1b5e673d 100644 --- a/tests/ui/impl-trait/issues/issue-78722-2.stderr +++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:13:13: 13:18}` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:13:13: 13:21}` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722-2.rs:11:30 | LL | fn concrete_use() -> F { @@ -16,7 +16,7 @@ LL | let f: F = async { 1 }; | expected due to this | = note: expected opaque type `F` - found `async` block `{async block@$DIR/issue-78722-2.rs:16:20: 16:25}` + found `async` block `{async block@$DIR/issue-78722-2.rs:16:20: 16:31}` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index 3642000597f92..0bb24fae822b5 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:10:13: 10:18}` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `{async block@$DIR/issue-78722.rs:10:13: 10:21}` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:8:30 | LL | fn concrete_use() -> F { diff --git a/tests/ui/impl-trait/issues/issue-86800.stderr b/tests/ui/impl-trait/issues/issue-86800.stderr index 095f648143ca7..f03797fa7cd08 100644 --- a/tests/ui/impl-trait/issues/issue-86800.stderr +++ b/tests/ui/impl-trait/issues/issue-86800.stderr @@ -25,13 +25,13 @@ LL | type TransactionFuture<'__, O> = impl '__ + Future $DIR/issue-86800.rs:44:5 + --> $DIR/issue-86800.rs:40:5 | -LL | / { -LL | | +LL | / async fn do_transaction( LL | | -LL | | let mut conn = Connection {}; -LL | | let mut transaction = TestTransaction { conn: &mut conn }; +LL | | &self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> +LL | | ) -> TransactionResult +... | LL | | f(&mut transaction).await LL | | } | |_____^ diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index f1e3b97be0283..14d51a1b06424 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@$DIR/nested-return-type4.rs:4:5: 4:31}` captures the lifetime `'s` as defined here LL | async move { let _s = s; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr index e8c3ab00226e1..0555269fbd995 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr @@ -50,11 +50,13 @@ LL | | for<'a> >::Output: Future + 'a = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:14:1 + --> $DIR/issue-76168-hr-outlives-3.rs:6:1 | -LL | / { +LL | / async fn wrapper(f: F) +LL | | LL | | -LL | | let mut i = 41; +LL | | +... | LL | | &mut i; LL | | } | |_^ expected an `FnOnce(&'a mut i32)` closure, found `i32` diff --git a/tests/ui/mismatched_types/mismatch-sugg-for-shorthand-field.stderr b/tests/ui/mismatched_types/mismatch-sugg-for-shorthand-field.stderr index 225d7503a02a4..1baf95d2bf781 100644 --- a/tests/ui/mismatched_types/mismatch-sugg-for-shorthand-field.stderr +++ b/tests/ui/mismatched_types/mismatch-sugg-for-shorthand-field.stderr @@ -52,13 +52,13 @@ error[E0308]: mismatched types --> $DIR/mismatch-sugg-for-shorthand-field.rs:57:20 | LL | let a = async { 42 }; - | ----- the found `async` block + | ------------ the found `async` block ... LL | let s = Demo { a }; | ^ expected `Pin>`, found `async` block | = note: expected struct `Pin + Send + 'static)>>` - found `async` block `{async block@$DIR/mismatch-sugg-for-shorthand-field.rs:53:13: 53:18}` + found `async` block `{async block@$DIR/mismatch-sugg-for-shorthand-field.rs:53:13: 53:25}` help: you need to pin and box this expression | LL | let s = Demo { a: Box::pin(a) }; diff --git a/tests/ui/pattern/non-structural-match-types.stderr b/tests/ui/pattern/non-structural-match-types.stderr index 9075cf40ddae9..cec57c866b100 100644 --- a/tests/ui/pattern/non-structural-match-types.stderr +++ b/tests/ui/pattern/non-structural-match-types.stderr @@ -1,10 +1,10 @@ -error: `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns +error: `{closure@$DIR/non-structural-match-types.rs:9:17: 9:22}` cannot be used in patterns --> $DIR/non-structural-match-types.rs:9:9 | LL | const { || {} } => {} | ^^^^^^^^^^^^^^^ -error: `{async block@$DIR/non-structural-match-types.rs:12:17: 12:22}` cannot be used in patterns +error: `{async block@$DIR/non-structural-match-types.rs:12:17: 12:25}` cannot be used in patterns --> $DIR/non-structural-match-types.rs:12:9 | LL | const { async {} } => {} diff --git a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 42bc094859a97..60ab392f55de8 100644 --- a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -79,7 +79,7 @@ LL | | } | |_____^ expected `Pin>`, found `async` block | = note: expected struct `Pin + Send + 'static)>>` - found `async` block `{async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 28:10}` + found `async` block `{async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6}` help: you need to pin and box this expression | LL ~ Box::pin(async { diff --git a/tests/ui/traits/next-solver/async.fail.stderr b/tests/ui/traits/next-solver/async.fail.stderr index e47da338736f4..5c98e75392aa4 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@$DIR/async.rs:12:17: 12:25}` 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/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index 55a5a3d20006b..407def09469f5 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -12,10 +12,9 @@ LL | type Bar = impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^^^^^^ error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/const_generic_type.rs:8:38 + --> $DIR/const_generic_type.rs:8:1 | -LL | async fn test() { - | ______________________________________^ +LL | / async fn test() { LL | | LL | | LL | | diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr index 0c2772683a918..20afd687d507f 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr @@ -12,10 +12,13 @@ LL | type FutNothing<'a> = impl 'a + Future; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature - --> $DIR/hkl_forbidden4.rs:23:1 + --> $DIR/hkl_forbidden4.rs:19:1 | -LL | / { +LL | / async fn call(_f: F) LL | | +LL | | where +LL | | for<'any> F: FnMut(&'any mut ()) -> FutNothing<'any>, +... | LL | | LL | | } | |_^ diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr index 6cbffaaed4d35..b62186103c7cb 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr @@ -2,7 +2,9 @@ error[E0733]: recursion in an async block requires boxing --> $DIR/indirect-recursion-issue-112047.rs:22:9 | LL | async move { recur(self).await; } - | ^^^^^^^^^^ ----------------- recursive call here + | ^^^^^^^^^^^^^-----------------^^^ + | | + | recursive call here | note: which leads to this async fn --> $DIR/indirect-recursion-issue-112047.rs:14:1 From a146e1d0f856fe13c4e7716c6d8a7fdab6ad0cb4 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 15:05:14 -0700 Subject: [PATCH 06/17] Remove extraneous with_def_id_parent call --- compiler/rustc_ast_lowering/src/expr.rs | 53 ++++++++++++------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index cbf46e21ed84b..f0a48e7b665ce 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -208,34 +208,31 @@ impl<'hir> LoweringContext<'_, 'hir> { body, fn_decl_span, fn_arg_span, - }) => { - let closure_def = self.local_def_id(e.id); - self.with_def_id_parent(closure_def, |this| match coroutine_kind { - Some(coroutine_kind) => this.lower_expr_coroutine_closure( - binder, - *capture_clause, - e.id, - hir_id, - *coroutine_kind, - fn_decl, - body, - *fn_decl_span, - *fn_arg_span, - ), - None => this.lower_expr_closure( - binder, - *capture_clause, - e.id, - hir_id, - *constness, - *movability, - fn_decl, - body, - *fn_decl_span, - *fn_arg_span, - ), - }) - } + }) => match coroutine_kind { + Some(coroutine_kind) => self.lower_expr_coroutine_closure( + binder, + *capture_clause, + e.id, + hir_id, + *coroutine_kind, + fn_decl, + body, + *fn_decl_span, + *fn_arg_span, + ), + None => self.lower_expr_closure( + binder, + *capture_clause, + e.id, + hir_id, + *constness, + *movability, + fn_decl, + body, + *fn_decl_span, + *fn_arg_span, + ), + }, ExprKind::Gen(capture_clause, block, genblock_kind, decl_span) => { let desugaring_kind = match genblock_kind { GenBlockKind::Async => hir::CoroutineDesugaring::Async, From a36ce9b30f8574efd41f616def04ef1a9ca84235 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 15:44:10 -0700 Subject: [PATCH 07/17] Visit closures and opaque types in rustc_dump_def_parents --- .../rustc_hir_analysis/src/collect/dump.rs | 29 +++++++---- tests/ui/attributes/dump_def_parents.rs | 3 +- tests/ui/attributes/dump_def_parents.stderr | 50 +++++++++++++++++-- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/dump.rs b/compiler/rustc_hir_analysis/src/collect/dump.rs index c73d3a5390d93..314c0af67c47b 100644 --- a/compiler/rustc_hir_analysis/src/collect/dump.rs +++ b/compiler/rustc_hir_analysis/src/collect/dump.rs @@ -1,7 +1,7 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; use rustc_hir::intravisit; -use rustc_middle::hir::nested_filter::OnlyBodies; +use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; use rustc_span::sym; @@ -47,31 +47,42 @@ pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) { pub(crate) fn def_parents(tcx: TyCtxt<'_>) { for did in tcx.hir().body_owners() { if tcx.has_attr(did, sym::rustc_dump_def_parents) { - struct AnonConstFinder<'tcx> { + struct ExprDefFinder<'tcx> { tcx: TyCtxt<'tcx>, - anon_consts: Vec, + defs: Vec, } - impl<'tcx> intravisit::Visitor<'tcx> for AnonConstFinder<'tcx> { - type NestedFilter = OnlyBodies; + impl<'tcx> intravisit::Visitor<'tcx> for ExprDefFinder<'tcx> { + type NestedFilter = nested_filter::All; fn nested_visit_map(&mut self) -> Self::Map { self.tcx.hir() } fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) { - self.anon_consts.push(c.def_id); + self.defs.push(c.def_id); intravisit::walk_anon_const(self, c) } + + fn visit_expr(&mut self, ex: &'tcx rustc_hir::Expr<'tcx>) -> Self::Result { + match &ex.kind { + rustc_hir::ExprKind::Closure(closure) => self.defs.push(closure.def_id), + _ => {} + } + intravisit::walk_expr(self, ex) + } } // Look for any anon consts inside of this body owner as there is no way to apply // the `rustc_dump_def_parents` attribute to the anon const so it would not be possible // to see what its def parent is. - let mut anon_ct_finder = AnonConstFinder { tcx, anon_consts: vec![] }; - intravisit::walk_expr(&mut anon_ct_finder, tcx.hir().body_owned_by(did).value); + let mut expr_def_finder = ExprDefFinder { tcx, defs: vec![] }; + tcx.hir() + .fn_decl_by_hir_id(tcx.local_def_id_to_hir_id(did)) + .map(|decl| intravisit::walk_fn_decl(&mut expr_def_finder, decl)); + intravisit::walk_expr(&mut expr_def_finder, tcx.hir().body_owned_by(did).value); - for did in [did].into_iter().chain(anon_ct_finder.anon_consts) { + for did in [did].into_iter().chain(expr_def_finder.defs) { let span = tcx.def_span(did); let mut diag = tcx.dcx().struct_span_err( diff --git a/tests/ui/attributes/dump_def_parents.rs b/tests/ui/attributes/dump_def_parents.rs index de0c88bb6c39a..0b4e6f04c9d85 100644 --- a/tests/ui/attributes/dump_def_parents.rs +++ b/tests/ui/attributes/dump_def_parents.rs @@ -10,9 +10,10 @@ fn bar() { qux::< { //~^ ERROR: rustc_dump_def_parents: DefId - fn inhibits_dump() { + fn doesnt_inhibit_dump() { qux::< { + //~^ ERROR: rustc_dump_def_parents: DefId "hi"; 1 }, diff --git a/tests/ui/attributes/dump_def_parents.stderr b/tests/ui/attributes/dump_def_parents.stderr index 966d9e7ff1408..9480c90944de9 100644 --- a/tests/ui/attributes/dump_def_parents.stderr +++ b/tests/ui/attributes/dump_def_parents.stderr @@ -42,7 +42,7 @@ error: rustc_dump_def_parents: DefId(..) | LL | / { LL | | -LL | | fn inhibits_dump() { +LL | | fn doesnt_inhibit_dump() { LL | | qux::< ... | LL | | 1 @@ -88,7 +88,49 @@ LL | | fn main() {} | |____________^ error: rustc_dump_def_parents: DefId(..) - --> $DIR/dump_def_parents.rs:22:31 + --> $DIR/dump_def_parents.rs:15:33 + | +LL | / ... { +LL | | ... +LL | | ... "hi"; +LL | | ... 1 +LL | | ... }, + | |_______________________^ + | +note: DefId(..) + --> $DIR/dump_def_parents.rs:13:25 + | +LL | fn doesnt_inhibit_dump() { + | ^^^^^^^^^^^^^^^^^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:6:9 + | +LL | fn baz() { + | ^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:5:5 + | +LL | fn foo() { + | ^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:4:1 + | +LL | fn bar() { + | ^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:2:1 + | +LL | / #![feature(rustc_attrs)] +LL | | +LL | | fn bar() { +LL | | fn foo() { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: rustc_dump_def_parents: DefId(..) + --> $DIR/dump_def_parents.rs:23:31 | LL | qux::<{ 1 + 1 }>(); | ^^^^^^^^^ @@ -98,7 +140,7 @@ note: DefId(..) | LL | / { LL | | -LL | | fn inhibits_dump() { +LL | | fn doesnt_inhibit_dump() { LL | | qux::< ... | LL | | 1 @@ -142,5 +184,5 @@ LL | | LL | | fn main() {} | |____________^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors From 60ddcf161602d1807d07a304ed3e36d6f2a540b7 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 16:04:46 -0700 Subject: [PATCH 08/17] Use current_def_id_parent in more places --- compiler/rustc_ast_lowering/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 880a488e9664e..8ad2ff2f2d8cc 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -828,7 +828,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { LifetimeRes::Fresh { param, kind, .. } => { // Late resolution delegates to us the creation of the `LocalDefId`. let _def_id = self.create_def( - self.current_hir_id_owner.def_id, // FIXME: should this use self.current_def_id_parent? + self.current_def_id_parent, param, kw::UnderscoreLifetime, DefKind::LifetimeParam, @@ -1412,7 +1412,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ); self.create_def( - self.current_hir_id_owner.def_id, // FIXME: should this use self.current_def_id_parent? + self.current_def_id_parent, *def_node_id, ident.name, DefKind::TyParam, @@ -1620,7 +1620,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>], ) -> hir::TyKind<'hir> { let opaque_ty_def_id = self.create_def( - self.current_hir_id_owner.def_id, // FIXME: should this use self.current_def_id_parent? + self.current_def_id_parent, opaque_ty_node_id, kw::Empty, DefKind::OpaqueTy, From 79a3e7a9426d86f87fcd8f9fe6f27c3071e15747 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 8 Aug 2024 16:43:56 -0700 Subject: [PATCH 09/17] Show nested items in rustc_dump_def_parents --- .../rustc_hir_analysis/src/collect/dump.rs | 13 ++++--- compiler/rustc_passes/src/hir_id_validator.rs | 5 +-- tests/ui/attributes/dump_def_parents.rs | 1 + tests/ui/attributes/dump_def_parents.stderr | 35 ++++++++++++++++++- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/dump.rs b/compiler/rustc_hir_analysis/src/collect/dump.rs index 314c0af67c47b..6cbfcf76616b9 100644 --- a/compiler/rustc_hir_analysis/src/collect/dump.rs +++ b/compiler/rustc_hir_analysis/src/collect/dump.rs @@ -59,6 +59,11 @@ pub(crate) fn def_parents(tcx: TyCtxt<'_>) { self.tcx.hir() } + fn visit_item(&mut self, i: &'tcx rustc_hir::Item<'tcx>) -> Self::Result { + self.defs.push(i.owner_id.def_id); + intravisit::walk_item(self, i) + } + fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) { self.defs.push(c.def_id); intravisit::walk_anon_const(self, c) @@ -76,13 +81,13 @@ pub(crate) fn def_parents(tcx: TyCtxt<'_>) { // Look for any anon consts inside of this body owner as there is no way to apply // the `rustc_dump_def_parents` attribute to the anon const so it would not be possible // to see what its def parent is. - let mut expr_def_finder = ExprDefFinder { tcx, defs: vec![] }; + let mut def_finder = ExprDefFinder { tcx, defs: vec![] }; tcx.hir() .fn_decl_by_hir_id(tcx.local_def_id_to_hir_id(did)) - .map(|decl| intravisit::walk_fn_decl(&mut expr_def_finder, decl)); - intravisit::walk_expr(&mut expr_def_finder, tcx.hir().body_owned_by(did).value); + .map(|decl| intravisit::walk_fn_decl(&mut def_finder, decl)); + intravisit::walk_expr(&mut def_finder, tcx.hir().body_owned_by(did).value); - for did in [did].into_iter().chain(expr_def_finder.defs) { + for did in [did].into_iter().chain(def_finder.defs) { let span = tcx.def_span(did); let mut diag = tcx.dcx().struct_span_err( diff --git a/compiler/rustc_passes/src/hir_id_validator.rs b/compiler/rustc_passes/src/hir_id_validator.rs index 51a69809c7a57..3b5a43e06b82c 100644 --- a/compiler/rustc_passes/src/hir_id_validator.rs +++ b/compiler/rustc_passes/src/hir_id_validator.rs @@ -91,11 +91,12 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> { if def_parent_hir_id.owner != owner { self.error(|| { format!( - "inconsistent Def parent at `{:?}` for `{:?}`:\nexpected={:?}\nfound={:?}", + "inconsistent Def parent at `{:?}` for `{:?}`:\nexpected={:?}\nfound={:?} ({:?})", self.tcx.def_span(id), id, owner, - def_parent_hir_id + def_parent_hir_id, + def_parent, ) }); } diff --git a/tests/ui/attributes/dump_def_parents.rs b/tests/ui/attributes/dump_def_parents.rs index 0b4e6f04c9d85..36ea45c9070e2 100644 --- a/tests/ui/attributes/dump_def_parents.rs +++ b/tests/ui/attributes/dump_def_parents.rs @@ -11,6 +11,7 @@ fn bar() { { //~^ ERROR: rustc_dump_def_parents: DefId fn doesnt_inhibit_dump() { + //~^ ERROR: rustc_dump_def_parents: DefId qux::< { //~^ ERROR: rustc_dump_def_parents: DefId diff --git a/tests/ui/attributes/dump_def_parents.stderr b/tests/ui/attributes/dump_def_parents.stderr index 9480c90944de9..ab799b74a23b9 100644 --- a/tests/ui/attributes/dump_def_parents.stderr +++ b/tests/ui/attributes/dump_def_parents.stderr @@ -87,6 +87,39 @@ LL | | LL | | fn main() {} | |____________^ +error: rustc_dump_def_parents: DefId(..) + --> $DIR/dump_def_parents.rs:13:25 + | +LL | fn doesnt_inhibit_dump() { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: DefId(..) + --> $DIR/dump_def_parents.rs:6:9 + | +LL | fn baz() { + | ^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:5:5 + | +LL | fn foo() { + | ^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:4:1 + | +LL | fn bar() { + | ^^^^^^^^ +note: DefId(..) + --> $DIR/dump_def_parents.rs:2:1 + | +LL | / #![feature(rustc_attrs)] +LL | | +LL | | fn bar() { +LL | | fn foo() { +... | +LL | | +LL | | fn main() {} + | |____________^ + error: rustc_dump_def_parents: DefId(..) --> $DIR/dump_def_parents.rs:15:33 | @@ -184,5 +217,5 @@ LL | | LL | | fn main() {} | |____________^ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors From 134314a7b853e1bec0c6d444d753a695f17878d0 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 9 Aug 2024 20:43:30 -0700 Subject: [PATCH 10/17] wip: rm `ItemKind::OpaqueTy` --- compiler/rustc_ast_lowering/src/lib.rs | 27 +++---- .../src/diagnostics/region_name.rs | 10 +-- .../src/region_infer/opaque_types.rs | 4 +- compiler/rustc_hir/src/hir.rs | 14 ++-- compiler/rustc_hir/src/intravisit.rs | 31 ++++++-- compiler/rustc_hir/src/target.rs | 5 -- .../rustc_hir_analysis/src/check/check.rs | 16 ++-- .../src/check/compare_impl_item/refine.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 40 +++------- .../src/collect/generics_of.rs | 55 ++++++------- .../src/collect/item_bounds.rs | 19 ++--- .../src/collect/predicates_of.rs | 2 +- .../src/collect/resolve_bound_vars.rs | 77 ++++++++----------- .../rustc_hir_analysis/src/collect/type_of.rs | 59 ++++++-------- .../src/hir_ty_lowering/mod.rs | 29 +++---- compiler/rustc_hir_pretty/src/lib.rs | 15 ++-- .../src/fn_ctxt/suggestions.rs | 5 +- compiler/rustc_lint/src/async_fn_in_trait.rs | 7 +- .../rustc_lint/src/impl_trait_overcaptures.rs | 2 +- .../src/opaque_hidden_inferred_bound.rs | 6 +- compiler/rustc_lint/src/types.rs | 1 - compiler/rustc_middle/src/hir/map/mod.rs | 28 +++++-- compiler/rustc_middle/src/ty/context.rs | 11 +-- compiler/rustc_middle/src/ty/diagnostics.rs | 5 +- compiler/rustc_middle/src/ty/sty.rs | 2 + compiler/rustc_passes/src/check_attr.rs | 2 - compiler/rustc_passes/src/dead.rs | 4 - compiler/rustc_passes/src/hir_stats.rs | 1 - compiler/rustc_passes/src/reachable.rs | 1 - compiler/rustc_privacy/src/lib.rs | 19 +++-- .../nice_region_error/static_impl_trait.rs | 9 +-- .../error_reporting/infer/note_and_explain.rs | 2 +- .../src/error_reporting/infer/region.rs | 11 +-- .../src/error_reporting/infer/suggest.rs | 8 +- .../src/error_reporting/traits/suggestions.rs | 18 +++-- compiler/rustc_ty_utils/src/assoc.rs | 15 ++-- compiler/rustc_ty_utils/src/opaque_types.rs | 1 + src/librustdoc/clean/mod.rs | 12 +-- src/librustdoc/html/render/span_map.rs | 1 - src/librustdoc/visit_ast.rs | 10 --- .../clippy_utils/src/check_proc_macro.rs | 2 +- 41 files changed, 256 insertions(+), 332 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 8ad2ff2f2d8cc..d43a075e5bcc7 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1619,6 +1619,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { opaque_ty_span: Span, lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>], ) -> hir::TyKind<'hir> { + let opaque_ty_hir_id = self.next_id(); let opaque_ty_def_id = self.create_def( self.current_def_id_parent, opaque_ty_node_id, @@ -1627,6 +1628,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { opaque_ty_span, ); debug!(?opaque_ty_def_id); + self.children.push((opaque_ty_def_id, hir::MaybeOwner::NonOwner(opaque_ty_hir_id))); // Map from captured (old) lifetime to synthetic (new) lifetime. // Used to resolve lifetimes in the bounds of the opaque. @@ -1699,7 +1701,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - self.with_hir_id_owner(opaque_ty_node_id, |this| { + let opaque_ty_def = self.with_def_id_parent(opaque_ty_def_id, |this| { // Install the remapping from old to new (if any). This makes sure that // any lifetimes that would have resolved to the def-id of captured // lifetimes are remapped to the new *synthetic* lifetimes of the opaque. @@ -1737,7 +1739,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let lifetime_mapping = self.arena.alloc_slice(&synthesized_lifetime_args); - let opaque_ty_item = hir::OpaqueTy { + trace!("registering opaque type with id {:#?}", opaque_ty_def_id); + let opaque_ty_def = hir::OpaqueTy { + hir_id: opaque_ty_hir_id, + def_id: opaque_ty_def_id, generics: this.arena.alloc(hir::Generics { params: generic_params, predicates: &[], @@ -1749,19 +1754,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { origin, lifetime_mapping, in_trait, - }; - - // Generate an `type Foo = impl Trait;` declaration. - trace!("registering opaque type with id {:#?}", opaque_ty_def_id); - let opaque_ty_item = hir::Item { - owner_id: hir::OwnerId { def_id: opaque_ty_def_id }, - ident: Ident::empty(), - kind: hir::ItemKind::OpaqueTy(this.arena.alloc(opaque_ty_item)), - vis_span: this.lower_span(span.shrink_to_lo()), span: this.lower_span(opaque_ty_span), }; - - hir::OwnerNode::Item(this.arena.alloc(opaque_ty_item)) + this.arena.alloc(opaque_ty_def) }); let generic_args = self.arena.alloc_from_iter( @@ -1774,11 +1769,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { // Foo = impl Trait` is, internally, created as a child of the // async fn, so the *type parameters* are inherited. It's // only the lifetime parameters that we must supply. - hir::TyKind::OpaqueDef( - hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } }, - generic_args, - in_trait, - ) + hir::TyKind::OpaqueDef(opaque_ty_def, generic_args, in_trait) } fn lower_precise_capturing_args( diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 12aedf6fe088b..f8b728e4024f8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -829,20 +829,14 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { /// /// [`OpaqueDef`]: hir::TyKind::OpaqueDef fn get_future_inner_return_ty(&self, hir_ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> { - let hir = self.infcx.tcx.hir(); - - let hir::TyKind::OpaqueDef(id, _, _) = hir_ty.kind else { + let hir::TyKind::OpaqueDef(opaque_ty, _, _) = hir_ty.kind else { span_bug!( hir_ty.span, "lowered return type of async fn is not OpaqueDef: {:?}", hir_ty ); }; - let opaque_ty = hir.item(id); - if let hir::ItemKind::OpaqueTy(hir::OpaqueTy { - bounds: [hir::GenericBound::Trait(trait_ref, _)], - .. - }) = opaque_ty.kind + if let hir::OpaqueTy { bounds: [hir::GenericBound::Trait(trait_ref, _)], .. } = opaque_ty && let Some(segment) = trait_ref.trait_ref.path.segments.last() && let Some(args) = segment.args && let [constraint] = args.constraints diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 1073ea4069483..cc03c642b1c01 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -328,8 +328,8 @@ fn check_opaque_type_well_formed<'tcx>( ) -> Result, ErrorGuaranteed> { // Only check this for TAIT. RPIT already supports `tests/ui/impl-trait/nested-return-type2.rs` // on stable and we'd break that. - let opaque_ty_hir = tcx.hir().expect_item(def_id); - let OpaqueTyOrigin::TyAlias { .. } = opaque_ty_hir.expect_opaque_ty().origin else { + let opaque_ty_hir = tcx.hir().expect_opaque_ty(def_id); + let OpaqueTyOrigin::TyAlias { .. } = opaque_ty_hir.origin else { return Ok(definition_ty); }; let param_env = tcx.param_env(def_id); diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 33e8432596be1..1ddc814e8f997 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2727,6 +2727,8 @@ pub struct BareFnTy<'hir> { #[derive(Debug, Clone, Copy, HashStable_Generic)] pub struct OpaqueTy<'hir> { + pub hir_id: HirId, + pub def_id: LocalDefId, pub generics: &'hir Generics<'hir>, pub bounds: GenericBounds<'hir>, pub origin: OpaqueTyOrigin, @@ -2744,6 +2746,7 @@ pub struct OpaqueTy<'hir> { /// originating from a trait method. This makes it so that the opaque is /// lowered as an associated type. pub in_trait: bool, + pub span: Span, } #[derive(Debug, Clone, Copy, HashStable_Generic)] @@ -2835,7 +2838,7 @@ pub enum TyKind<'hir> { /// possibly parameters) that are actually bound on the `impl Trait`. /// /// The last parameter specifies whether this opaque appears in a trait definition. - OpaqueDef(ItemId, &'hir [GenericArg<'hir>], bool), + OpaqueDef(&'hir OpaqueTy<'hir>, &'hir [GenericArg<'hir>], bool), /// A trait object type `Bound1 + Bound2 + Bound3` /// where `Bound` is a trait or a lifetime. TraitObject( @@ -3302,8 +3305,6 @@ impl<'hir> Item<'hir> { expect_ty_alias, (&'hir Ty<'hir>, &'hir Generics<'hir>), ItemKind::TyAlias(ty, generics), (ty, generics); - expect_opaque_ty, &OpaqueTy<'hir>, ItemKind::OpaqueTy(ty), ty; - expect_enum, (&EnumDef<'hir>, &'hir Generics<'hir>), ItemKind::Enum(def, generics), (def, generics); expect_struct, (&VariantData<'hir>, &'hir Generics<'hir>), @@ -3416,8 +3417,6 @@ pub enum ItemKind<'hir> { GlobalAsm(&'hir InlineAsm<'hir>), /// A type alias, e.g., `type Foo = Bar`. TyAlias(&'hir Ty<'hir>, &'hir Generics<'hir>), - /// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;`. - OpaqueTy(&'hir OpaqueTy<'hir>), /// An enum definition, e.g., `enum Foo {C, D}`. Enum(EnumDef<'hir>, &'hir Generics<'hir>), /// A struct definition, e.g., `struct Foo {x: A}`. @@ -3461,7 +3460,6 @@ impl ItemKind<'_> { ItemKind::Fn(_, ref generics, _) | ItemKind::TyAlias(_, ref generics) | ItemKind::Const(_, ref generics, _) - | ItemKind::OpaqueTy(OpaqueTy { ref generics, .. }) | ItemKind::Enum(_, ref generics) | ItemKind::Struct(_, ref generics) | ItemKind::Union(_, ref generics) @@ -3484,7 +3482,6 @@ impl ItemKind<'_> { ItemKind::ForeignMod { .. } => "extern block", ItemKind::GlobalAsm(..) => "global asm item", ItemKind::TyAlias(..) => "type alias", - ItemKind::OpaqueTy(..) => "opaque type", ItemKind::Enum(..) => "enum", ItemKind::Struct(..) => "struct", ItemKind::Union(..) => "union", @@ -3769,6 +3766,7 @@ pub enum Node<'hir> { Ty(&'hir Ty<'hir>), AssocItemConstraint(&'hir AssocItemConstraint<'hir>), TraitRef(&'hir TraitRef<'hir>), + OpaqueTy(&'hir OpaqueTy<'hir>), Pat(&'hir Pat<'hir>), PatField(&'hir PatField<'hir>), Arm(&'hir Arm<'hir>), @@ -3834,6 +3832,7 @@ impl<'hir> Node<'hir> { | Node::Crate(..) | Node::Ty(..) | Node::TraitRef(..) + | Node::OpaqueTy(..) | Node::Infer(..) | Node::WhereBoundPredicate(..) | Node::ArrayLenInfer(..) @@ -4013,6 +4012,7 @@ impl<'hir> Node<'hir> { expect_ty, &'hir Ty<'hir>, Node::Ty(n), n; expect_assoc_item_constraint, &'hir AssocItemConstraint<'hir>, Node::AssocItemConstraint(n), n; expect_trait_ref, &'hir TraitRef<'hir>, Node::TraitRef(n), n; + expect_opaque_ty, &'hir OpaqueTy<'hir>, Node::OpaqueTy(n), n; expect_pat, &'hir Pat<'hir>, Node::Pat(n), n; expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n; expect_arm, &'hir Arm<'hir>, Node::Arm(n), n; diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index dd501f8417e64..1ae0462bcca48 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -111,6 +111,7 @@ impl<'a> FnKind<'a> { pub trait Map<'hir> { /// Retrieves the `Node` corresponding to `id`. fn hir_node(&self, hir_id: HirId) -> Node<'hir>; + fn hir_node_by_def_id(&self, def_id: LocalDefId) -> Node<'hir>; fn body(&self, id: BodyId) -> &'hir Body<'hir>; fn item(&self, id: ItemId) -> &'hir Item<'hir>; fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>; @@ -123,6 +124,9 @@ impl<'hir> Map<'hir> for ! { fn hir_node(&self, _: HirId) -> Node<'hir> { *self; } + fn hir_node_by_def_id(&self, _: LocalDefId) -> Node<'hir> { + *self; + } fn body(&self, _: BodyId) -> &'hir Body<'hir> { *self; } @@ -290,6 +294,13 @@ pub trait Visitor<'v>: Sized { Self::Result::output() } + #[track_caller] + fn visit_nested_opaque_ty(&mut self, opaq: &'v OpaqueTy<'v>) -> Self::Result { + // FIXME: should guard with INTRA/INTER? then hir id validator has to be changed + try_visit!(self.visit_opaque_ty(opaq)); + Self::Result::output() + } + fn visit_param(&mut self, param: &'v Param<'v>) -> Self::Result { walk_param(self, param) } @@ -423,6 +434,9 @@ pub trait Visitor<'v>: Sized { fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef<'v>) -> Self::Result { walk_poly_trait_ref(self, t) } + fn visit_opaque_ty(&mut self, opaq: &'v OpaqueTy<'v>) -> Self::Result { + walk_opaque_ty(self, opaq) + } fn visit_variant_data(&mut self, s: &'v VariantData<'v>) -> Self::Result { walk_struct_def(self, s) } @@ -536,11 +550,6 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V:: try_visit!(visitor.visit_ty(ty)); try_visit!(visitor.visit_generics(generics)); } - ItemKind::OpaqueTy(&OpaqueTy { generics, bounds, .. }) => { - try_visit!(visitor.visit_id(item.hir_id())); - try_visit!(walk_generics(visitor, generics)); - walk_list!(visitor, visit_param_bound, bounds); - } ItemKind::Enum(ref enum_definition, ref generics) => { try_visit!(visitor.visit_generics(generics)); // `visit_enum_def()` takes care of visiting the `Item`'s `HirId`. @@ -894,8 +903,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Resul TyKind::Path(ref qpath) => { try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span)); } - TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => { - try_visit!(visitor.visit_nested_item(item_id)); + TyKind::OpaqueDef(def_id, lifetimes, _in_trait) => { + try_visit!(visitor.visit_nested_opaque_ty(def_id)); walk_list!(visitor, visit_generic_arg, lifetimes); } TyKind::Array(ref ty, ref length) => { @@ -1185,6 +1194,14 @@ pub fn walk_poly_trait_ref<'v, V: Visitor<'v>>( visitor.visit_trait_ref(&trait_ref.trait_ref) } +pub fn walk_opaque_ty<'v, V: Visitor<'v>>(visitor: &mut V, opaq: &'v OpaqueTy<'v>) -> V::Result { + let &OpaqueTy { hir_id, generics, bounds, .. } = opaq; + try_visit!(visitor.visit_id(hir_id)); + try_visit!(walk_generics(visitor, generics)); + walk_list!(visitor, visit_param_bound, bounds); + V::Result::output() +} + pub fn walk_struct_def<'v, V: Visitor<'v>>( visitor: &mut V, struct_definition: &'v VariantData<'v>, diff --git a/compiler/rustc_hir/src/target.rs b/compiler/rustc_hir/src/target.rs index f43008eda1181..8058a24d91f21 100644 --- a/compiler/rustc_hir/src/target.rs +++ b/compiler/rustc_hir/src/target.rs @@ -34,7 +34,6 @@ pub enum Target { ForeignMod, GlobalAsm, TyAlias, - OpaqueTy, Enum, Variant, Struct, @@ -79,7 +78,6 @@ impl Target { | Target::ForeignMod | Target::GlobalAsm | Target::TyAlias - | Target::OpaqueTy | Target::Enum | Target::Variant | Target::Struct @@ -114,7 +112,6 @@ impl Target { ItemKind::ForeignMod { .. } => Target::ForeignMod, ItemKind::GlobalAsm(..) => Target::GlobalAsm, ItemKind::TyAlias(..) => Target::TyAlias, - ItemKind::OpaqueTy(..) => Target::OpaqueTy, ItemKind::Enum(..) => Target::Enum, ItemKind::Struct(..) => Target::Struct, ItemKind::Union(..) => Target::Union, @@ -137,7 +134,6 @@ impl Target { DefKind::ForeignMod => Target::ForeignMod, DefKind::GlobalAsm => Target::GlobalAsm, DefKind::TyAlias => Target::TyAlias, - DefKind::OpaqueTy => Target::OpaqueTy, DefKind::Enum => Target::Enum, DefKind::Struct => Target::Struct, DefKind::Union => Target::Union, @@ -191,7 +187,6 @@ impl Target { Target::ForeignMod => "foreign module", Target::GlobalAsm => "global asm", Target::TyAlias => "type alias", - Target::OpaqueTy => "opaque type", Target::Enum => "enum", Target::Variant => "enum variant", Target::Struct => "struct", diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 2e778fd375961..b82e1ab43de2d 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -251,10 +251,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) { /// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo` /// projections that would result in "inheriting lifetimes". fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) { - let item = tcx.hir().expect_item(def_id); - let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else { - tcx.dcx().span_bug(item.span, "expected opaque item"); - }; + let hir::OpaqueTy { origin, .. } = tcx.hir().expect_opaque_ty(def_id); // HACK(jynelson): trying to infer the type of `impl trait` breaks documenting // `async-std` (and `pub async fn` in general). @@ -264,16 +261,16 @@ fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) { return; } - let span = tcx.def_span(item.owner_id.def_id); + let span = tcx.def_span(def_id); - if tcx.type_of(item.owner_id.def_id).instantiate_identity().references_error() { + if tcx.type_of(def_id).instantiate_identity().references_error() { return; } - if check_opaque_for_cycles(tcx, item.owner_id.def_id, span).is_err() { + if check_opaque_for_cycles(tcx, def_id, span).is_err() { return; } - let _ = check_opaque_meets_bounds(tcx, item.owner_id.def_id, span, origin); + let _ = check_opaque_meets_bounds(tcx, def_id, span, origin); } /// Checks that an opaque type does not contain cycles. @@ -480,8 +477,7 @@ fn sanity_check_found_hidden_type<'tcx>( /// 2. Checking that all lifetimes that are implicitly captured are mentioned. /// 3. Asserting that all parameters mentioned in the captures list are invariant. fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDefId) { - let hir::OpaqueTy { bounds, .. } = - *tcx.hir_node_by_def_id(opaque_def_id).expect_item().expect_opaque_ty(); + let hir::OpaqueTy { bounds, .. } = *tcx.hir_node_by_def_id(opaque_def_id).expect_opaque_ty(); let Some(precise_capturing_args) = bounds.iter().find_map(|bound| match *bound { hir::GenericBound::Use(bounds, ..) => Some(bounds), _ => None, diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 80daaa60324a3..ca86470c06ce6 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -92,7 +92,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( // it's a refinement to a TAIT. if !tcx.hir().get_if_local(impl_opaque.def_id).is_some_and(|node| { matches!( - node.expect_item().expect_opaque_ty().origin, + node.expect_opaque_ty().origin, hir::OpaqueTyOrigin::AsyncFn(def_id) | hir::OpaqueTyOrigin::FnReturn(def_id) if def_id == impl_m.def_id.expect_local() ) diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 47ff748547a90..41a51b4c570f6 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -259,8 +259,8 @@ fn reject_placeholder_type_signatures_in_item<'tcx>( | hir::ItemKind::Trait(_, _, generics, ..) | hir::ItemKind::Impl(hir::Impl { generics, .. }) | hir::ItemKind::Struct(_, generics) => (generics, true), - hir::ItemKind::OpaqueTy(hir::OpaqueTy { generics, .. }) - | hir::ItemKind::TyAlias(_, generics) => (generics, false), + // FIXME: how to handle opaque types since no longer items + hir::ItemKind::TyAlias(_, generics) => (generics, false), // `static`, `fn` and `const` are handled elsewhere to suggest appropriate type. _ => return, }; @@ -729,18 +729,8 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { } } - // Don't call `type_of` on opaque types, since that depends on type - // checking function bodies. `check_item_type` ensures that it's called - // instead. - hir::ItemKind::OpaqueTy(..) => { - tcx.ensure().generics_of(def_id); - tcx.ensure().predicates_of(def_id); - tcx.ensure().explicit_item_bounds(def_id); - tcx.ensure().explicit_item_super_predicates(def_id); - tcx.ensure().item_bounds(def_id); - tcx.ensure().item_super_predicates(def_id); - } - + // FIXME: ok to ignore opaque tys in collection? + // hir::ItemKind::TyAlias(..) => { tcx.ensure().generics_of(def_id); tcx.ensure().type_of(def_id); @@ -1880,12 +1870,8 @@ fn coroutine_for_closure(tcx: TyCtxt<'_>, def_id: LocalDefId) -> DefId { } fn is_type_alias_impl_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool { - match tcx.hir_node_by_def_id(def_id) { - Node::Item(hir::Item { kind: hir::ItemKind::OpaqueTy(opaque), .. }) => { - matches!(opaque.origin, hir::OpaqueTyOrigin::TyAlias { .. }) - } - _ => bug!("tried getting opaque_ty_origin for non-opaque: {:?}", def_id), - } + let opaque = tcx.hir().expect_opaque_ty(def_id); + matches!(opaque.origin, hir::OpaqueTyOrigin::TyAlias { .. }) } fn rendered_precise_capturing_args<'tcx>( @@ -1898,12 +1884,10 @@ fn rendered_precise_capturing_args<'tcx>( return tcx.rendered_precise_capturing_args(opaque_def_id); } - tcx.hir_node_by_def_id(def_id).expect_item().expect_opaque_ty().bounds.iter().find_map( - |bound| match bound { - hir::GenericBound::Use(args, ..) => { - Some(&*tcx.arena.alloc_from_iter(args.iter().map(|arg| arg.name()))) - } - _ => None, - }, - ) + tcx.hir_node_by_def_id(def_id).expect_opaque_ty().bounds.iter().find_map(|bound| match bound { + hir::GenericBound::Use(args, ..) => { + Some(&*tcx.arena.alloc_from_iter(args.iter().map(|arg| arg.name()))) + } + _ => None, + }) } diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 60e2c2eb30e56..db73ef415f5a0 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -199,34 +199,34 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { | Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => { Some(tcx.typeck_root_def_id(def_id.to_def_id())) } - Node::Item(item) => match item.kind { - ItemKind::OpaqueTy(&hir::OpaqueTy { - origin: - hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id), - in_trait, - .. - }) => { - if in_trait { - assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn)) - } else { - assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn)) - } - Some(fn_def_id.to_def_id()) + Node::OpaqueTy(&hir::OpaqueTy { + origin: + hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id), + in_trait, + .. + }) => { + if in_trait { + assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn)) + } else { + assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn)) } - ItemKind::OpaqueTy(&hir::OpaqueTy { - origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty }, - .. - }) => { - if in_assoc_ty { - assert!(matches!(tcx.def_kind(parent), DefKind::AssocTy)); - } else { - assert!(matches!(tcx.def_kind(parent), DefKind::TyAlias)); - } - debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent); - // Opaque types are always nested within another item, and - // inherit the generics of the item. - Some(parent.to_def_id()) + Some(fn_def_id.to_def_id()) + } + Node::OpaqueTy(&hir::OpaqueTy { + origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty }, + .. + }) => { + if in_assoc_ty { + assert!(matches!(tcx.def_kind(parent), DefKind::AssocTy)); + } else { + assert!(matches!(tcx.def_kind(parent), DefKind::TyAlias)); } + debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent); + // Opaque types are always nested within another item, and + // inherit the generics of the item. + Some(parent.to_def_id()) + } + Node::Item(item) => match item.kind { ItemKind::Fn(sig, _, _) => { // For a delegation item inherit generics from callee. if let Some(sig_id) = sig.decl.opt_delegation_sig_id() @@ -274,13 +274,14 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { ItemKind::TyAlias(..) | ItemKind::Enum(..) | ItemKind::Struct(..) - | ItemKind::OpaqueTy(..) | ItemKind::Union(..) => (None, Defaults::Allowed), ItemKind::Const(..) => (None, Defaults::Deny), _ => (None, Defaults::FutureCompatDisallowed), } } + Node::OpaqueTy(..) => (None, Defaults::Allowed), + // GATs Node::TraitItem(item) if matches!(item.kind, TraitItemKind::Type(..)) => { (None, Defaults::Deny) diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 6bff99ea65f0b..b4fda63475a4f 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -105,8 +105,7 @@ pub(super) fn explicit_item_bounds_with_filter( // RPITIT's bounds are the same as opaque type bounds, but with // a projection self type. Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => { - let item = tcx.hir_node_by_def_id(opaque_def_id.expect_local()).expect_item(); - let opaque_ty = item.expect_opaque_ty(); + let opaque_ty = tcx.hir_node_by_def_id(opaque_def_id.expect_local()).expect_opaque_ty(); return ty::EarlyBinder::bind(opaque_type_bounds( tcx, opaque_def_id.expect_local(), @@ -116,7 +115,7 @@ pub(super) fn explicit_item_bounds_with_filter( def_id.to_def_id(), ty::GenericArgs::identity_for_item(tcx, def_id), ), - item.span, + opaque_ty.span, filter, )); } @@ -159,11 +158,7 @@ pub(super) fn explicit_item_bounds_with_filter( span, .. }) => associated_type_bounds(tcx, def_id, bounds, *span, filter), - hir::Node::Item(hir::Item { - kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait: false, .. }), - span, - .. - }) => { + hir::Node::OpaqueTy(hir::OpaqueTy { bounds, in_trait: false, span, .. }) => { let args = GenericArgs::identity_for_item(tcx, def_id); let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args); opaque_type_bounds(tcx, def_id, bounds, item_ty, *span, filter) @@ -171,11 +166,7 @@ pub(super) fn explicit_item_bounds_with_filter( // Since RPITITs are lowered as projections in `::lower_ty`, when we're // asking for the item bounds of the *opaques* in a trait's default method signature, we // need to map these projections back to opaques. - hir::Node::Item(hir::Item { - kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait: true, origin, .. }), - span, - .. - }) => { + hir::Node::OpaqueTy(hir::OpaqueTy { bounds, in_trait: true, origin, span, .. }) => { let (hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id)) = *origin else { @@ -190,7 +181,7 @@ pub(super) fn explicit_item_bounds_with_filter( ) } hir::Node::Item(hir::Item { kind: hir::ItemKind::TyAlias(..), .. }) => &[], - _ => bug!("item_bounds called on {:?}", def_id), + node => bug!("item_bounds called on {def_id:?} => {node:?}"), }; ty::EarlyBinder::bind(bounds) } diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index a5a56cb845d79..2a9cf392d4f8b 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -313,7 +313,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen // Opaque types duplicate some of their generic parameters. // We create bi-directional Outlives predicates between the original // and the duplicated parameter, to ensure that they do not get out of sync. - if let Node::Item(&Item { kind: ItemKind::OpaqueTy(..), .. }) = node { + if let Node::OpaqueTy(..) = node { let opaque_ty_node = tcx.parent_hir_node(hir_id); let Node::Ty(&hir::Ty { kind: TyKind::OpaqueDef(_, lifetimes, _), .. }) = opaque_ty_node else { diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index e11d3c9c48b4e..a32f58c166a79 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -485,6 +485,37 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { } } + fn visit_opaque_ty(&mut self, opaq: &'tcx rustc_hir::OpaqueTy<'tcx>) -> Self::Result { + let (hir::OpaqueTyOrigin::FnReturn(parent) + | hir::OpaqueTyOrigin::AsyncFn(parent) + | hir::OpaqueTyOrigin::TyAlias { parent, .. }) = opaq.origin; + + // We want to start our early-bound indices at the end of the parent scope, + // not including any parent `impl Trait`s. + let mut bound_vars = FxIndexMap::default(); + debug!(?opaq.generics.params); + for param in opaq.generics.params { + let (def_id, reg) = ResolvedArg::early(param); + bound_vars.insert(def_id, reg); + } + + let scope = Scope::Root { opt_parent_item: Some(parent) }; + let hir_id = self.tcx.local_def_id_to_hir_id(opaq.def_id); + self.with(scope, |this| { + let scope = Scope::Binder { + hir_id, + bound_vars, + s: this.scope, + scope_type: BinderScopeType::Normal, + where_bound_origin: None, + }; + this.with(scope, |this| { + let scope = Scope::TraitRefBoundary { s: this.scope }; + this.with(scope, |this| intravisit::walk_opaque_ty(this, opaq)) + }); + }) + } + #[instrument(level = "debug", skip(self))] fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { match &item.kind { @@ -512,38 +543,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { // These sorts of items have no lifetime parameters at all. intravisit::walk_item(self, item); } - hir::ItemKind::OpaqueTy(&hir::OpaqueTy { - origin: - hir::OpaqueTyOrigin::FnReturn(parent) - | hir::OpaqueTyOrigin::AsyncFn(parent) - | hir::OpaqueTyOrigin::TyAlias { parent, .. }, - generics, - .. - }) => { - // We want to start our early-bound indices at the end of the parent scope, - // not including any parent `impl Trait`s. - let mut bound_vars = FxIndexMap::default(); - debug!(?generics.params); - for param in generics.params { - let (def_id, reg) = ResolvedArg::early(param); - bound_vars.insert(def_id, reg); - } - - let scope = Scope::Root { opt_parent_item: Some(parent) }; - self.with(scope, |this| { - let scope = Scope::Binder { - hir_id: item.hir_id(), - bound_vars, - s: this.scope, - scope_type: BinderScopeType::Normal, - where_bound_origin: None, - }; - this.with(scope, |this| { - let scope = Scope::TraitRefBoundary { s: this.scope }; - this.with(scope, |this| intravisit::walk_item(this, item)) - }); - }) - } hir::ItemKind::TyAlias(_, generics) | hir::ItemKind::Const(_, generics, _) | hir::ItemKind::Enum(_, generics) @@ -690,17 +689,12 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { }; self.with(scope, |this| this.visit_ty(mt.ty)); } - hir::TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => { + hir::TyKind::OpaqueDef(opaque_ty, lifetimes, _in_trait) => { // Resolve the lifetimes in the bounds to the lifetime defs in the generics. // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to // `type MyAnonTy<'b> = impl MyTrait<'b>;` // ^ ^ this gets resolved in the scope of // the opaque_ty generics - let opaque_ty = self.tcx.hir().item(item_id); - match &opaque_ty.kind { - hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin: _, .. }) => {} - i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i), - }; // Resolve the lifetimes that are applied to the opaque type. // These are resolved in the current scope. @@ -724,9 +718,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { { // Opaques do not declare their own lifetimes, so if a lifetime comes from an opaque // it must be a reified late-bound lifetime from a trait goal. - hir::Node::Item(hir::Item { - kind: hir::ItemKind::OpaqueTy { .. }, .. - }) => "higher-ranked lifetime from outer `impl Trait`", + hir::Node::OpaqueTy(_) => "higher-ranked lifetime from outer `impl Trait`", // Other items are fine. hir::Node::Item(_) | hir::Node::TraitItem(_) | hir::Node::ImplItem(_) => { continue; @@ -742,8 +734,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { let (span, label) = if lifetime.ident.span == self.tcx.def_span(lifetime_def_id) { - let opaque_span = self.tcx.def_span(item_id.owner_id); - (opaque_span, Some(opaque_span)) + (opaque_ty.span, Some(opaque_ty.span)) } else { (lifetime.ident.span, None) }; diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 8cb4ba6c6691d..020a0a31bb59a 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -528,10 +528,6 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ let args = ty::GenericArgs::identity_for_item(tcx, def_id); Ty::new_adt(tcx, def, args) } - ItemKind::OpaqueTy(..) => tcx.type_of_opaque(def_id).map_or_else( - |CyclePlaceholder(guar)| Ty::new_error(tcx, guar), - |ty| ty.instantiate_identity(), - ), ItemKind::Trait(..) | ItemKind::TraitAlias(..) | ItemKind::Macro(..) @@ -544,6 +540,11 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ } }, + Node::OpaqueTy(..) => tcx.type_of_opaque(def_id).map_or_else( + |CyclePlaceholder(guar)| Ty::new_error(tcx, guar), + |ty| ty.instantiate_identity(), + ), + Node::ForeignItem(foreign_item) => match foreign_item.kind { ForeignItemKind::Fn(..) => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); @@ -604,38 +605,26 @@ pub(super) fn type_of_opaque( if let Some(def_id) = def_id.as_local() { use rustc_hir::*; - Ok(ty::EarlyBinder::bind(match tcx.hir_node_by_def_id(def_id) { - Node::Item(item) => match item.kind { - ItemKind::OpaqueTy(OpaqueTy { - origin: hir::OpaqueTyOrigin::TyAlias { in_assoc_ty: false, .. }, - .. - }) => opaque::find_opaque_ty_constraints_for_tait(tcx, def_id), - ItemKind::OpaqueTy(OpaqueTy { - origin: hir::OpaqueTyOrigin::TyAlias { in_assoc_ty: true, .. }, - .. - }) => opaque::find_opaque_ty_constraints_for_impl_trait_in_assoc_type(tcx, def_id), - // Opaque types desugared from `impl Trait`. - ItemKind::OpaqueTy(&OpaqueTy { - origin: - hir::OpaqueTyOrigin::FnReturn(owner) | hir::OpaqueTyOrigin::AsyncFn(owner), - in_trait, - .. - }) => { - if in_trait && !tcx.defaultness(owner).has_value() { - span_bug!( - tcx.def_span(def_id), - "tried to get type of this RPITIT with no definition" - ); - } - opaque::find_opaque_ty_constraints_for_rpit(tcx, def_id, owner) - } - _ => { - span_bug!(item.span, "type_of_opaque: unexpected item type: {:?}", item.kind); + Ok(ty::EarlyBinder::bind(match tcx.hir_node_by_def_id(def_id).expect_opaque_ty() { + OpaqueTy { + origin: hir::OpaqueTyOrigin::TyAlias { in_assoc_ty: false, .. }, .. + } => opaque::find_opaque_ty_constraints_for_tait(tcx, def_id), + OpaqueTy { origin: hir::OpaqueTyOrigin::TyAlias { in_assoc_ty: true, .. }, .. } => { + opaque::find_opaque_ty_constraints_for_impl_trait_in_assoc_type(tcx, def_id) + } + // Opaque types desugared from `impl Trait`. + &OpaqueTy { + origin: hir::OpaqueTyOrigin::FnReturn(owner) | hir::OpaqueTyOrigin::AsyncFn(owner), + in_trait, + .. + } => { + if in_trait && !tcx.defaultness(owner).has_value() { + span_bug!( + tcx.def_span(def_id), + "tried to get type of this RPITIT with no definition" + ); } - }, - - x => { - bug!("unexpected sort of node in type_of_opaque(): {:?}", x); + opaque::find_opaque_ty_constraints_for_rpit(tcx, def_id, owner) } })) } else { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index d865357b82900..6fe4cd16555ca 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2083,24 +2083,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself)); self.lower_path(opt_self_ty, path, hir_ty.hir_id, false) } - &hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => { - let opaque_ty = tcx.hir().item(item_id); - - match opaque_ty.kind { - hir::ItemKind::OpaqueTy(&hir::OpaqueTy { .. }) => { - let local_def_id = item_id.owner_id.def_id; - // If this is an RPITIT and we are using the new RPITIT lowering scheme, we - // generate the def_id of an associated type for the trait and return as - // type a projection. - let def_id = if in_trait { - tcx.associated_type_for_impl_trait_in_trait(local_def_id).to_def_id() - } else { - local_def_id.to_def_id() - }; - self.lower_opaque_ty(def_id, lifetimes, in_trait) - } - ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i), - } + &hir::TyKind::OpaqueDef(opaque_ty, lifetimes, in_trait) => { + let local_def_id = opaque_ty.def_id; + // If this is an RPITIT and we are using the new RPITIT lowering scheme, we + // generate the def_id of an associated type for the trait and return as + // type a projection. + let def_id = if in_trait { + tcx.associated_type_for_impl_trait_in_trait(local_def_id).to_def_id() + } else { + local_def_id.to_def_id() + }; + self.lower_opaque_ty(def_id, lifetimes, in_trait) } hir::TyKind::Path(hir::QPath::TypeRelative(qself, segment)) => { debug!(?qself, ?segment); diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 089cee2fa0dec..673fe07434edb 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -95,6 +95,7 @@ impl<'a> State<'a> { Node::Ty(a) => self.print_type(a), Node::AssocItemConstraint(a) => self.print_assoc_item_constraint(a), Node::TraitRef(a) => self.print_trait_ref(a), + Node::OpaqueTy(o) => self.print_opaque_ty(o), Node::Pat(a) => self.print_pat(a), Node::PatField(a) => self.print_patfield(a), Node::Arm(a) => self.print_arm(a), @@ -572,11 +573,6 @@ impl<'a> State<'a> { state.print_type(ty); }); } - hir::ItemKind::OpaqueTy(opaque_ty) => { - self.print_item_type(item, opaque_ty.generics, |state| { - state.print_bounds("= impl", opaque_ty.bounds) - }); - } hir::ItemKind::Enum(ref enum_definition, params) => { self.print_enum_def(enum_definition, params, item.ident.name, item.span); } @@ -669,6 +665,15 @@ impl<'a> State<'a> { self.print_path(t.path, false); } + fn print_opaque_ty(&mut self, o: &hir::OpaqueTy<'_>) { + self.head("opaque"); + self.print_generic_params(o.generics.params); + self.print_where_clause(o.generics); + self.word("{"); + self.print_bounds("impl", o.bounds); + self.word("}"); + } + fn print_formal_generic_params(&mut self, generic_params: &[hir::GenericParam<'_>]) { if !generic_params.is_empty() { self.word("for"); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 6b4edcd95d993..a50485ec08401 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -849,11 +849,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } hir::FnRetTy::Return(hir_ty) => { - if let hir::TyKind::OpaqueDef(item_id, ..) = hir_ty.kind + if let hir::TyKind::OpaqueDef(op_ty, ..) = hir_ty.kind // FIXME: account for RPITIT. - && let hir::Node::Item(hir::Item { - kind: hir::ItemKind::OpaqueTy(op_ty), .. - }) = self.tcx.hir_node(item_id.hir_id()) && let [hir::GenericBound::Trait(trait_ref, _)] = op_ty.bounds && let Some(hir::PathSegment { args: Some(generic_args), .. }) = trait_ref.trait_ref.path.segments.last() diff --git a/compiler/rustc_lint/src/async_fn_in_trait.rs b/compiler/rustc_lint/src/async_fn_in_trait.rs index d904020730019..63a8a949e9699 100644 --- a/compiler/rustc_lint/src/async_fn_in_trait.rs +++ b/compiler/rustc_lint/src/async_fn_in_trait.rs @@ -104,8 +104,9 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait { return; } - let hir::FnRetTy::Return(hir::Ty { kind: hir::TyKind::OpaqueDef(def, ..), .. }) = - sig.decl.output + let hir::FnRetTy::Return(hir::Ty { + kind: hir::TyKind::OpaqueDef(opaq_def, ..), .. + }) = sig.decl.output else { // This should never happen, but let's not ICE. return; @@ -114,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait { cx.tcx, sig, body, - def.owner_id.def_id, + opaq_def.def_id, " + Send", ); cx.tcx.emit_node_span_lint( diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index e914169f4c373..1caef25cf2eee 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -206,7 +206,7 @@ impl<'tcx> TypeVisitor> for VisitOpaqueTypes<'tcx> { && self.seen.insert(opaque_def_id) // If it's owned by this function && let opaque = - self.tcx.hir_node_by_def_id(opaque_def_id).expect_item().expect_opaque_ty() + self.tcx.hir_node_by_def_id(opaque_def_id).expect_opaque_ty() && let hir::OpaqueTyOrigin::FnReturn(parent_def_id) = opaque.origin && parent_def_id == self.parent_def_id { diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index e0ba6a912f120..bc75b4dcbd4f3 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -68,11 +68,11 @@ declare_lint! { declare_lint_pass!(OpaqueHiddenInferredBound => [OPAQUE_HIDDEN_INFERRED_BOUND]); impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { - fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { - let hir::ItemKind::OpaqueTy(opaque) = &item.kind else { + fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'tcx>) { + let hir::TyKind::OpaqueDef(opaque, _, _) = &ty.kind else { return; }; - let def_id = item.owner_id.def_id.to_def_id(); + let def_id = opaque.def_id.to_def_id(); let infcx = &cx.tcx.infer_ctxt().build(); // For every projection predicate in the opaque type's explicit bounds, // check that the type that we're assigning actually satisfies the bounds diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 5b17c0d718a44..1522a02991543 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1789,7 +1789,6 @@ impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDefinitions { hir::ItemKind::Impl(..) | hir::ItemKind::TraitAlias(..) | hir::ItemKind::Trait(..) - | hir::ItemKind::OpaqueTy(..) | hir::ItemKind::GlobalAsm(..) | hir::ItemKind::ForeignMod { .. } | hir::ItemKind::Mod(..) diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 4c243e6330b91..d46acca2839f9 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -739,6 +739,19 @@ impl<'hir> Map<'hir> { } } + #[track_caller] + pub fn expect_opaque_ty(self, id: LocalDefId) -> &'hir OpaqueTy<'hir> { + match self.tcx.hir_node_by_def_id(id) { + Node::OpaqueTy(opaq) => opaq, + _ => { + bug!( + "expected opaque type definition, found {}", + self.node_to_string(self.tcx.local_def_id_to_hir_id(id)) + ) + } + } + } + pub fn expect_expr(self, id: HirId) -> &'hir Expr<'hir> { match self.tcx.hir_node(id) { Node::Expr(expr) => expr, @@ -928,6 +941,7 @@ impl<'hir> Map<'hir> { Node::Ty(ty) => ty.span, Node::AssocItemConstraint(constraint) => constraint.span, Node::TraitRef(tr) => tr.path.span, + Node::OpaqueTy(op) => op.span, Node::Pat(pat) => pat.span, Node::PatField(field) => field.span, Node::Arm(arm) => arm.span, @@ -1011,6 +1025,10 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> { self.tcx.hir_node(hir_id) } + fn hir_node_by_def_id(&self, def_id: LocalDefId) -> Node<'hir> { + self.tcx.hir_node_by_def_id(def_id) + } + fn body(&self, id: BodyId) -> &'hir Body<'hir> { (*self).body(id) } @@ -1144,13 +1162,6 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String { ItemKind::ForeignMod { .. } => "foreign mod", ItemKind::GlobalAsm(..) => "global asm", ItemKind::TyAlias(..) => "ty", - ItemKind::OpaqueTy(opaque) => { - if opaque.in_trait { - "opaque type in trait" - } else { - "opaque type" - } - } ItemKind::Enum(..) => "enum", ItemKind::Struct(..) => "struct", ItemKind::Union(..) => "union", @@ -1196,6 +1207,9 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String { Node::Ty(_) => node_str("type"), Node::AssocItemConstraint(_) => node_str("assoc item constraint"), Node::TraitRef(_) => node_str("trait ref"), + Node::OpaqueTy(opaque) => { + node_str(if opaque.in_trait { "opaque type in trait" } else { "opaque type" }) + } Node::Pat(_) => node_str("pat"), Node::PatField(_) => node_str("pattern field"), Node::Param(_) => node_str("param"), diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8f8fd09c9e4d9..ffa7153d79ed8 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -56,7 +56,7 @@ pub use rustc_type_ir::lift::Lift; use rustc_type_ir::solve::SolverMode; use rustc_type_ir::TyKind::*; use rustc_type_ir::{search_graph, CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo}; -use tracing::{debug, instrument}; +use tracing::{debug, trace}; use crate::arena::Arena; use crate::dep_graph::{DepGraph, DepKindStruct}; @@ -2072,9 +2072,11 @@ impl<'tcx> TyCtxt<'tcx> { } /// Returns the origin of the opaque type `def_id`. - #[instrument(skip(self), level = "trace", ret)] + #[track_caller] pub fn opaque_type_origin(self, def_id: LocalDefId) -> hir::OpaqueTyOrigin { - self.hir().expect_item(def_id).expect_opaque_ty().origin + let origin = self.hir().expect_opaque_ty(def_id).origin; + trace!("opaque_type_origin({def_id:?}) => {origin:?}"); + origin } } @@ -3032,8 +3034,7 @@ impl<'tcx> TyCtxt<'tcx> { loop { let parent = self.local_parent(opaque_lifetime_param_def_id); - let hir::OpaqueTy { lifetime_mapping, .. } = - self.hir_node_by_def_id(parent).expect_item().expect_opaque_ty(); + let hir::OpaqueTy { lifetime_mapping, .. } = self.hir().expect_opaque_ty(parent); let Some((lifetime, _)) = lifetime_mapping .iter() diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 5acc0b7ac7ff1..69bccffaed0fe 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -510,10 +510,9 @@ impl<'v> hir::intravisit::Visitor<'v> for TraitObjectVisitor<'v> { ) => { self.0.push(ty); } - hir::TyKind::OpaqueDef(item_id, _, _) => { + hir::TyKind::OpaqueDef(opaq, _, _) => { self.0.push(ty); - let item = self.1.item(item_id); - hir::intravisit::walk_item(self, item); + hir::intravisit::walk_opaque_ty(self, opaq); } _ => {} } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 8c97de1c59b26..87d55ee989fa9 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -21,6 +21,7 @@ use rustc_target::spec::abi; use rustc_type_ir::visit::TypeVisitableExt; use rustc_type_ir::TyKind::*; use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind}; +use tracing::instrument; use ty::util::{AsyncDropGlueMorphology, IntTypeExt}; use super::GenericParamDefKind; @@ -500,6 +501,7 @@ impl<'tcx> Ty<'tcx> { } #[inline] + #[instrument(level = "debug", skip(tcx))] pub fn new_opaque(tcx: TyCtxt<'tcx>, def_id: DefId, args: GenericArgsRef<'tcx>) -> Ty<'tcx> { Ty::new_alias(tcx, ty::Opaque, AliasTy::new_from_args(tcx, def_id, args)) } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index cf7d724ab63ae..9d15094f1f229 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -835,7 +835,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | Target::Mod | Target::GlobalAsm | Target::TyAlias - | Target::OpaqueTy | Target::Enum | Target::Variant | Target::Struct @@ -1340,7 +1339,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { ) { let article = match target { Target::ExternCrate - | Target::OpaqueTy | Target::Enum | Target::Impl | Target::Expression diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 7ae5c9040042c..ea0dc9e1a7ede 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -656,10 +656,6 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { } fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) { - if let TyKind::OpaqueDef(item_id, _, _) = ty.kind { - let item = self.tcx.hir().item(item_id); - intravisit::walk_item(self, item); - } intravisit::walk_ty(self, ty); } diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 38e8c3cd12de4..638aac9441ef7 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -232,7 +232,6 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { ForeignMod, GlobalAsm, TyAlias, - OpaqueTy, Enum, Struct, Union, diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index dee8ba7e87dfd..1068993d861dc 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -236,7 +236,6 @@ impl<'tcx> ReachableContext<'tcx> { // worklist, as determined by the privacy pass hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) - | hir::ItemKind::OpaqueTy(..) | hir::ItemKind::TyAlias(..) | hir::ItemKind::Macro(..) | hir::ItemKind::Mod(..) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index d1d1e5e901f29..e758ffc1ce8db 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -632,22 +632,21 @@ impl<'tcx> EmbargoVisitor<'tcx> { } impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { - fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { - if self.impl_trait_pass - && let hir::ItemKind::OpaqueTy(opaque) = item.kind - && !opaque.in_trait - { + fn visit_opaque_ty(&mut self, opaque: &'tcx rustc_hir::OpaqueTy<'tcx>) -> Self::Result { + if self.impl_trait_pass && !opaque.in_trait { // FIXME: This is some serious pessimization intended to workaround deficiencies // in the reachability pass (`middle/reachable.rs`). Types are marked as link-time // reachable if they are returned via `impl Trait`, even from private functions. let pub_ev = EffectiveVisibility::from_vis(ty::Visibility::Public); - self.reach_through_impl_trait(item.owner_id.def_id, pub_ev) - .generics() - .predicates() - .ty(); + self.reach_through_impl_trait(opaque.def_id, pub_ev).generics().predicates().ty(); return; } + // Visit nested items. + intravisit::walk_opaque_ty(self, opaque) + } + + fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { // Update levels of nested things and mark all items // in interfaces of reachable items as reachable. let item_ev = self.get(item.owner_id.def_id); @@ -657,7 +656,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { | hir::ItemKind::ExternCrate(..) | hir::ItemKind::GlobalAsm(..) => {} // The interface is empty, and all nested items are processed by `visit_item`. - hir::ItemKind::Mod(..) | hir::ItemKind::OpaqueTy(..) => {} + hir::ItemKind::Mod(..) => {} hir::ItemKind::Macro(macro_def, _) => { if let Some(item_ev) = item_ev { self.update_reachability_from_macro(item.owner_id.def_id, macro_def, item_ev); diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs index dc775b824da47..962f73eef07cd 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs @@ -283,14 +283,9 @@ pub fn suggest_new_region_bound( } match fn_return.kind { // FIXME(precise_captures): Suggest adding to `use<...>` list instead. - TyKind::OpaqueDef(item_id, _, _) => { - let item = tcx.hir().item(item_id); - let ItemKind::OpaqueTy(opaque) = &item.kind else { - return; - }; - + TyKind::OpaqueDef(opaque, _, _) => { // Get the identity type for this RPIT - let did = item_id.owner_id.to_def_id(); + let did = opaque.def_id.to_def_id(); let ty = Ty::new_opaque(tcx, did, ty::GenericArgs::identity_for_item(tcx, did)); if let Some(span) = opaque.bounds.iter().find_map(|arg| match arg { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs index 864510bb65047..4391319fa0c44 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs @@ -706,7 +706,7 @@ fn foo(&self) -> Self::T { String::new() } if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *proj_ty.self_ty().kind() { let opaque_local_def_id = def_id.as_local(); let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id { - tcx.hir().expect_item(opaque_local_def_id).expect_opaque_ty() + tcx.hir().expect_opaque_ty(opaque_local_def_id) } else { return false; }; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 3cee8ff5f4c07..f458e4da58a45 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -813,14 +813,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { lifetime: Region<'tcx>, add_lt_suggs: &mut Vec<(Span, String)>, ) -> String { - struct LifetimeReplaceVisitor<'tcx, 'a> { - tcx: TyCtxt<'tcx>, + struct LifetimeReplaceVisitor<'a> { needle: hir::LifetimeName, new_lt: &'a str, add_lt_suggs: &'a mut Vec<(Span, String)>, } - impl<'hir, 'tcx> hir::intravisit::Visitor<'hir> for LifetimeReplaceVisitor<'tcx, '_> { + impl<'hir> hir::intravisit::Visitor<'hir> for LifetimeReplaceVisitor<'_> { fn visit_lifetime(&mut self, lt: &'hir hir::Lifetime) { if lt.res == self.needle { let (pos, span) = lt.suggestion_position(); @@ -839,10 +838,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } fn visit_ty(&mut self, ty: &'hir hir::Ty<'hir>) { - let hir::TyKind::OpaqueDef(item_id, _, _) = ty.kind else { + let hir::TyKind::OpaqueDef(opaque_ty, _, _) = ty.kind else { return hir::intravisit::walk_ty(self, ty); }; - let opaque_ty = self.tcx.hir().item(item_id).expect_opaque_ty(); if let Some(&(_, b)) = opaque_ty.lifetime_mapping.iter().find(|&(a, _)| a.res == self.needle) { @@ -887,7 +885,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; let mut visitor = LifetimeReplaceVisitor { - tcx: self.tcx, needle: hir::LifetimeName::Param(lifetime_def_id), add_lt_suggs, new_lt: &new_lt, @@ -1281,7 +1278,7 @@ fn suggest_precise_capturing<'tcx>( diag: &mut Diag<'_>, ) { let hir::OpaqueTy { bounds, origin, .. } = - tcx.hir_node_by_def_id(opaque_def_id).expect_item().expect_opaque_ty(); + tcx.hir_node_by_def_id(opaque_def_id).expect_opaque_ty(); let hir::OpaqueTyOrigin::FnReturn(fn_def_id) = *origin else { return; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs index ee159aa0b77a6..116412e4433d5 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs @@ -729,12 +729,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let exp_local_id = exp_def_id.as_local()?; match ( - &self.tcx.hir().expect_item(last_local_id).kind, - &self.tcx.hir().expect_item(exp_local_id).kind, + &self.tcx.hir().expect_opaque_ty(last_local_id), + &self.tcx.hir().expect_opaque_ty(exp_local_id), ) { ( - hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: last_bounds, .. }), - hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: exp_bounds, .. }), + hir::OpaqueTy { bounds: last_bounds, .. }, + hir::OpaqueTy { bounds: exp_bounds, .. }, ) if std::iter::zip(*last_bounds, *exp_bounds).all(|(left, right)| match ( left, right, ) { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 0d15ef55e24e7..a0c2b784c645c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -354,12 +354,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { | hir::ItemKind::Fn(_, generics, _) | hir::ItemKind::TyAlias(_, generics) | hir::ItemKind::Const(_, generics, _) - | hir::ItemKind::TraitAlias(generics, _) - | hir::ItemKind::OpaqueTy(hir::OpaqueTy { generics, .. }), + | hir::ItemKind::TraitAlias(generics, _), .. }) | hir::Node::TraitItem(hir::TraitItem { generics, .. }) | hir::Node::ImplItem(hir::ImplItem { generics, .. }) + | hir::Node::OpaqueTy(hir::OpaqueTy { generics, .. }) if param_ty => { // We skip the 0'th arg (self) because we do not want @@ -420,10 +420,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { | hir::ItemKind::Fn(_, generics, _) | hir::ItemKind::TyAlias(_, generics) | hir::ItemKind::Const(_, generics, _) - | hir::ItemKind::TraitAlias(generics, _) - | hir::ItemKind::OpaqueTy(hir::OpaqueTy { generics, .. }), + | hir::ItemKind::TraitAlias(generics, _), .. - }) if !param_ty => { + }) + | hir::Node::OpaqueTy(hir::OpaqueTy { generics, .. }) + if !param_ty => + { // Missing generic type parameter bound. if suggest_arbitrary_trait_bound( self.tcx, @@ -4508,7 +4510,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // ... whose signature is `async` (i.e. this is an AFIT) let (sig, body) = item.expect_fn(); - let hir::FnRetTy::Return(hir::Ty { kind: hir::TyKind::OpaqueDef(def, ..), .. }) = + let hir::FnRetTy::Return(hir::Ty { kind: hir::TyKind::OpaqueDef(opaq_def, ..), .. }) = sig.decl.output else { // This should never happen, but let's not ICE. @@ -4517,7 +4519,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // Check that this is *not* a nested `impl Future` RPIT in an async fn // (i.e. `async fn foo() -> impl Future`) - if def.owner_id.to_def_id() != opaque_def_id { + if opaq_def.def_id.to_def_id() != opaque_def_id { return; } @@ -5081,7 +5083,7 @@ pub fn suggest_desugaring_async_fn_to_impl_future_in_trait<'tcx>( }; let async_span = tcx.sess.source_map().span_extend_while_whitespace(async_span); - let future = tcx.hir_node_by_def_id(opaque_def_id).expect_item().expect_opaque_ty(); + let future = tcx.hir_node_by_def_id(opaque_def_id).expect_opaque_ty(); let [hir::GenericBound::Trait(trait_ref, _)] = future.bounds else { // `async fn` should always lower to a single bound... but don't ICE. return None; diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 6726db8bb54df..78706137f8d1c 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -316,19 +316,16 @@ fn associated_types_for_impl_traits_in_associated_fn( match tcx.def_kind(parent_def_id) { DefKind::Trait => { - struct RPITVisitor<'tcx> { + struct RPITVisitor { rpits: FxIndexSet, - tcx: TyCtxt<'tcx>, } - impl<'tcx> Visitor<'tcx> for RPITVisitor<'tcx> { + impl<'tcx> Visitor<'tcx> for RPITVisitor { fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) { - if let hir::TyKind::OpaqueDef(item_id, _, _) = ty.kind - && self.rpits.insert(item_id.owner_id.def_id) + if let hir::TyKind::OpaqueDef(opaq, _, _) = ty.kind + && self.rpits.insert(opaq.def_id) { - let opaque_item = - self.tcx.hir().expect_item(item_id.owner_id.def_id).expect_opaque_ty(); - for bound in opaque_item.bounds { + for bound in opaq.bounds { intravisit::walk_param_bound(self, bound); } } @@ -336,7 +333,7 @@ fn associated_types_for_impl_traits_in_associated_fn( } } - let mut visitor = RPITVisitor { tcx, rpits: FxIndexSet::default() }; + let mut visitor = RPITVisitor { rpits: FxIndexSet::default() }; if let Some(output) = tcx.hir().get_fn_output(fn_def_id) { visitor.visit_fn_ret_ty(output); diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 6680b451b7cc7..dc5b318a7d394 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -132,6 +132,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> { TaitInBodyFinder { collector: self }.visit_expr(body); } + #[instrument(level = "debug", skip(self))] fn visit_opaque_ty(&mut self, alias_ty: ty::AliasTy<'tcx>) { if !self.seen.insert(alias_ty.def_id.expect_local()) { return; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index cffadc7c10a91..ae292c360050a 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1841,13 +1841,8 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T Array(Box::new(clean_ty(ty, cx)), length.into()) } TyKind::Tup(tys) => Tuple(tys.iter().map(|ty| clean_ty(ty, cx)).collect()), - TyKind::OpaqueDef(item_id, _, _) => { - let item = cx.tcx.hir().item(item_id); - if let hir::ItemKind::OpaqueTy(ref ty) = item.kind { - ImplTrait(ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect()) - } else { - unreachable!() - } + TyKind::OpaqueDef(ty, _, _) => { + ImplTrait(ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect()) } TyKind::Path(_) => clean_qpath(ty, cx), TyKind::TraitObject(bounds, ref lifetime, _) => { @@ -2749,9 +2744,6 @@ fn clean_maybe_renamed_item<'tcx>( type_: clean_ty(ty, cx), kind: ConstantKind::Local { body: body_id, def_id }, })), - // clean_ty changes types which reference an OpaqueTy item to instead be - // an ImplTrait, so it's ok to return nothing here. - ItemKind::OpaqueTy(_) => return vec![], ItemKind::TyAlias(hir_ty, generics) => { *cx.current_type_aliases.entry(def_id).or_insert(0) += 1; let rustdoc_ty = clean_ty(hir_ty, cx); diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index 5b53277c059a9..e24a41826c9e3 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -243,7 +243,6 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> { | ItemKind::ExternCrate(_) | ItemKind::ForeignMod { .. } | ItemKind::GlobalAsm(_) - | ItemKind::OpaqueTy(_) // We already have "visit_mod" above so no need to check it here. | ItemKind::Mod(_) => {} } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index d7a4a0d88ac3e..95875ca685d1f 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -504,21 +504,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) | hir::ItemKind::TyAlias(..) - | hir::ItemKind::OpaqueTy(hir::OpaqueTy { - origin: hir::OpaqueTyOrigin::TyAlias { .. }, - .. - }) | hir::ItemKind::Static(..) | hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) => { self.add_to_current_mod(item, renamed, import_id); } - hir::ItemKind::OpaqueTy(hir::OpaqueTy { - origin: hir::OpaqueTyOrigin::AsyncFn(_) | hir::OpaqueTyOrigin::FnReturn(_), - .. - }) => { - // return-position impl traits are never nameable, and should never be documented. - } hir::ItemKind::Const(..) => { // Underscore constants do not correspond to a nameable item and // so are never useful in documentation. diff --git a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs index 7f2234b310b42..5beeab8bbfa58 100644 --- a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs +++ b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs @@ -222,7 +222,7 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) { ItemKind::Const(..) => (Pat::Str("const"), Pat::Str(";")), ItemKind::Fn(sig, ..) => (fn_header_search_pat(sig.header), Pat::Str("")), ItemKind::ForeignMod { .. } => (Pat::Str("extern"), Pat::Str("}")), - ItemKind::TyAlias(..) | ItemKind::OpaqueTy(_) => (Pat::Str("type"), Pat::Str(";")), + ItemKind::TyAlias(..) => (Pat::Str("type"), Pat::Str(";")), ItemKind::Enum(..) => (Pat::Str("enum"), Pat::Str("}")), ItemKind::Struct(VariantData::Struct { .. }, _) => (Pat::Str("struct"), Pat::Str("}")), ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")), From d29f44a58c6f456d5965f164c779ffcd077aa306 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 13:21:43 -0700 Subject: [PATCH 11/17] Handle opaques in NodeCollector --- compiler/rustc_ast_lowering/src/index.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index 23729124e21a9..23a2765b9b854 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -228,6 +228,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { }); } + fn visit_opaque_ty(&mut self, opaq: &'hir OpaqueTy<'hir>) { + self.insert(opaq.span, opaq.hir_id, Node::OpaqueTy(opaq)); + + self.with_parent(opaq.hir_id, |this| { + intravisit::walk_opaque_ty(this, opaq); + }); + } + fn visit_anon_const(&mut self, constant: &'hir AnonConst) { // FIXME: use real span? self.insert(DUMMY_SP, constant.hir_id, Node::AnonConst(constant)); From ca48eee15ed050bdd7721cfe1387fda917e0e45e Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 13:27:50 -0700 Subject: [PATCH 12/17] Fix nested behavior --- compiler/rustc_ast_lowering/src/index.rs | 4 ++++ compiler/rustc_hir/src/intravisit.rs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index 23a2765b9b854..a1a14b1f21d6f 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -146,6 +146,10 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { self.visit_body(body); } + fn visit_nested_opaque_ty(&mut self, opaq: &'hir OpaqueTy<'hir>) -> Self::Result { + self.visit_opaque_ty(opaq) + } + fn visit_param(&mut self, param: &'hir Param<'hir>) { let node = Node::Param(param); self.insert(param.pat.span, param.hir_id, node); diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 1ae0462bcca48..2a6cf409c9f61 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -296,8 +296,9 @@ pub trait Visitor<'v>: Sized { #[track_caller] fn visit_nested_opaque_ty(&mut self, opaq: &'v OpaqueTy<'v>) -> Self::Result { - // FIXME: should guard with INTRA/INTER? then hir id validator has to be changed - try_visit!(self.visit_opaque_ty(opaq)); + if Self::NestedFilter::INTER { + try_visit!(self.visit_opaque_ty(opaq)); + } Self::Result::output() } From c8cefb2a5e9923ec9630c45cd226df25ec3c8d77 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 13:55:45 -0700 Subject: [PATCH 13/17] INTRA not INTER --- compiler/rustc_hir/src/intravisit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 2a6cf409c9f61..8969b759398da 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -296,7 +296,7 @@ pub trait Visitor<'v>: Sized { #[track_caller] fn visit_nested_opaque_ty(&mut self, opaq: &'v OpaqueTy<'v>) -> Self::Result { - if Self::NestedFilter::INTER { + if Self::NestedFilter::INTRA { try_visit!(self.visit_opaque_ty(opaq)); } Self::Result::output() From d7b0b0ed243b1c3262ef02ad536e76d0f71f73e8 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 14:27:43 -0700 Subject: [PATCH 14/17] Fix bound vars ICE --- compiler/rustc_hir/src/intravisit.rs | 4 ++-- .../rustc_hir_analysis/src/collect/resolve_bound_vars.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 8969b759398da..592f19855f917 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -904,8 +904,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Resul TyKind::Path(ref qpath) => { try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span)); } - TyKind::OpaqueDef(def_id, lifetimes, _in_trait) => { - try_visit!(visitor.visit_nested_opaque_ty(def_id)); + TyKind::OpaqueDef(opaq, lifetimes, _in_trait) => { + try_visit!(visitor.visit_nested_opaque_ty(opaq)); walk_list!(visitor, visit_generic_arg, lifetimes); } TyKind::Array(ref ty, ref length) => { diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index a32f58c166a79..3c43e14abdc7f 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -485,7 +485,8 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { } } - fn visit_opaque_ty(&mut self, opaq: &'tcx rustc_hir::OpaqueTy<'tcx>) -> Self::Result { + #[instrument(level = "debug", skip(self))] + fn visit_opaque_ty(&mut self, opaq: &'tcx rustc_hir::OpaqueTy<'tcx>) { let (hir::OpaqueTyOrigin::FnReturn(parent) | hir::OpaqueTyOrigin::AsyncFn(parent) | hir::OpaqueTyOrigin::TyAlias { parent, .. }) = opaq.origin; @@ -690,6 +691,8 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { self.with(scope, |this| this.visit_ty(mt.ty)); } hir::TyKind::OpaqueDef(opaque_ty, lifetimes, _in_trait) => { + self.visit_opaque_ty(opaque_ty); + // Resolve the lifetimes in the bounds to the lifetime defs in the generics. // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to // `type MyAnonTy<'b> = impl MyTrait<'b>;` From 96f38fcace977cebedc1897031b811b3996e8a6f Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 15:38:25 -0700 Subject: [PATCH 15/17] Fix generics ICE --- compiler/rustc_hir/src/hir.rs | 1 + compiler/rustc_hir_analysis/src/collect/generics_of.rs | 1 + compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 1ddc814e8f997..010aea21bd107 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3953,6 +3953,7 @@ impl<'hir> Node<'hir> { | Node::TraitItem(TraitItem { generics, .. }) | Node::ImplItem(ImplItem { generics, .. }) => Some(generics), Node::Item(item) => item.kind.generics(), + Node::OpaqueTy(opaq) => Some(opaq.generics), _ => None, } } diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index db73ef415f5a0..18667542e1b15 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -22,6 +22,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { if let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id }) = tcx.opt_rpitit_info(def_id.to_def_id()) { + debug!("RPITIT fn_def_id={fn_def_id:?} opaque_def_id={opaque_def_id:?}"); let trait_def_id = tcx.parent(fn_def_id); let opaque_ty_generics = tcx.generics_of(opaque_def_id); let opaque_ty_parent_count = opaque_ty_generics.parent_count; diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 6fe4cd16555ca..5cc232d311176 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2247,7 +2247,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { span_bug!( tcx.def_span(param.def_id), "only expected lifetime for opaque's own generics, got {:?}", - param.kind + param ); }; let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else { From dcb9e9abe2e89eeaa36bf43eca3573bfd73736d8 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 21:11:53 -0700 Subject: [PATCH 16/17] Fix dead code analysis for opaque types We need to recurse into them since they may contain anon consts with code inside, e.g. --- compiler/rustc_passes/src/dead.rs | 2 ++ compiler/rustc_passes/src/reachable.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index ea0dc9e1a7ede..244fb0174121d 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -41,6 +41,7 @@ fn should_explore(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { | Node::TraitItem(..) | Node::Variant(..) | Node::AnonConst(..) + | Node::OpaqueTy(..) ) } @@ -494,6 +495,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { Node::ForeignItem(foreign_item) => { intravisit::walk_foreign_item(self, foreign_item); } + Node::OpaqueTy(opaq) => intravisit::walk_opaque_ty(self, opaq), _ => {} } self.repr_has_repr_simd = had_repr_simd; diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index 1068993d861dc..7145915340a31 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -286,7 +286,8 @@ impl<'tcx> ReachableContext<'tcx> { | Node::Field(_) | Node::Ty(_) | Node::Crate(_) - | Node::Synthetic => {} + | Node::Synthetic + | Node::OpaqueTy(..) => {} _ => { bug!( "found unexpected node kind in worklist: {} ({:?})", From 6d13474c35b0d36ffee7154f3eca49bc954a79c5 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 10 Aug 2024 21:13:16 -0700 Subject: [PATCH 17/17] [do not merge] Bless impl-trait tests (incorrect!) Note that the new test output is in most cases incorrect or undesirable. This should be fixed before merging. The purpose of this commit is merely to see what changes occurred. --- .../ret-impl-trait-fg.stderr | 10 + tests/ui/impl-trait/auto-trait-leak.stderr | 34 +-- .../capture-lifetime-not-in-hir.stderr | 31 ++- .../impl-fn-predefined-lifetimes.stderr | 11 +- .../impl-trait/implicit-capture-late.stderr | 8 +- .../in-assoc-type-unconstrained.stderr | 18 +- ...e-visibilities-during-object-safety.stderr | 54 ++--- .../in-trait/span-bug-issue-121457.stderr | 16 +- tests/ui/impl-trait/issue-99073-2.stderr | 14 +- tests/ui/impl-trait/issue-99073.stderr | 14 +- .../ui/impl-trait/issues/issue-78722-2.stderr | 12 +- tests/ui/impl-trait/issues/issue-86800.stderr | 55 +---- .../must_outlive_least_region_or_bound.stderr | 112 +++++----- tests/ui/impl-trait/nested-rpit-hrtb.stderr | 18 +- ...type-err-cause-on-impl-trait-return.stderr | 54 ++--- .../precise-capturing/bad-params.stderr | 12 +- .../forgot-to-capture-lifetime.stderr | 11 +- .../forgot-to-capture-type.stderr | 22 +- .../precise-capturing/ordering.stderr | 41 ++-- .../precise-capturing/redundant.rpitit.stderr | 27 ++- .../precise-capturing/rpitit.stderr | 10 +- ...s-impl-trait-declaration-too-subtle.stderr | 31 +-- .../impl-trait/rpit/non-defining-use.stderr | 14 +- .../transmute/in-defining-scope.stderr | 36 +-- ...o_tait_defining_each_other2.current.stderr | 23 +- tests/ui/impl-trait/where-allowed.stderr | 112 +++++----- tests/ui/lint/dead-code/impl-trait.stderr | 22 +- tests/ui/pattern/usefulness/impl-trait.stderr | 56 ++--- .../const-impl-trait.stderr | 74 ++---- .../higher-ranked-regions-basic.stderr | 48 ++-- .../impl-trait-missing-lifetime-gated.stderr | 32 +-- .../impl-trait-missing-lifetime.stderr | 12 +- .../auto-trait-leakage3.stderr | 21 +- .../const_generic_type.no_infer.stderr | 42 +--- .../constrain_inputs.stderr | 28 +-- .../declared_but_not_defined_in_scope.stderr | 10 +- ...ifferent_defining_uses_never_type-2.stderr | 14 +- .../failed-to-normalize-ice-99945.stderr | 28 +-- .../generic_duplicate_param_use.stderr | 24 +- .../generic_nondefining_use.stderr | 18 +- .../generic_underconstrained.stderr | 22 +- .../generic_underconstrained2.stderr | 44 ++-- .../hkl_forbidden4.stderr | 66 ++---- ...iled-to-resolve-instance-for-110696.stderr | 28 +-- .../implied_lifetime_wf_check4_static.stderr | 16 +- .../in-assoc-ty-early-bound2.stderr | 10 +- .../in-where-clause.stderr | 42 ++-- .../inference-cycle.stderr | 21 +- .../type-alias-impl-trait/issue-109054.stderr | 15 +- .../issue-53092-2.stderr | 66 +----- .../issue-84660-unsoundness.current.stderr | 15 +- .../issue-84660-unsoundness.next.stderr | 18 +- .../nested-impl-trait-in-tait.stderr | 18 +- .../nested-in-anon-const.stderr | 10 +- tests/ui/type-alias-impl-trait/nested.stderr | 15 +- .../nested_type_alias_impl_trait.stderr | 15 +- .../normalize-hidden-types.current.stderr | 38 +--- .../type-alias-impl-trait/reveal_local.stderr | 21 +- ...alias-impl-trait-with-cycle-error-4.stderr | 14 +- .../ui/type-alias-impl-trait/variance.stderr | 210 +----------------- 60 files changed, 577 insertions(+), 1356 deletions(-) create mode 100644 tests/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.stderr diff --git a/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.stderr b/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.stderr new file mode 100644 index 0000000000000..32bf081aa6c6c --- /dev/null +++ b/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.stderr @@ -0,0 +1,10 @@ +warning: trait `Trait` is never used + --> $DIR/ret-impl-trait-fg.rs:8:7 + | +LL | trait Trait<'a, 'b> { } + | ^^^^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr index cc9939f2d57f9..0bc771300f66b 100644 --- a/tests/ui/impl-trait/auto-trait-leak.stderr +++ b/tests/ui/impl-trait/auto-trait-leak.stderr @@ -1,22 +1,30 @@ -error: cannot check whether the hidden type of opaque type satisfies auto traits - --> $DIR/auto-trait-leak.rs:18:10 +error[E0391]: cycle detected when type-checking `cycle1` + --> $DIR/auto-trait-leak.rs:12:5 | -LL | send(cycle1().clone()); - | ---- ^^^^^^^^^^^^^^^^ - | | - | required by a bound introduced by this call +LL | send(cycle2().clone()); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which requires evaluating trait selection obligation `cycle2::{opaque#0}: core::marker::Send`... +note: ...which requires computing type of opaque `cycle2::{opaque#0}`... + --> $DIR/auto-trait-leak.rs:17:16 + | +LL | fn cycle2() -> impl Clone { + | ^^^^^^^^^^ +note: ...which requires type-checking `cycle2`... + --> $DIR/auto-trait-leak.rs:18:5 | - = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule -note: opaque type is declared here +LL | send(cycle1().clone()); + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires evaluating trait selection obligation `cycle1::{opaque#0}: core::marker::Send`... +note: ...which requires computing type of opaque `cycle1::{opaque#0}`... --> $DIR/auto-trait-leak.rs:11:16 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^ -note: required by a bound in `send` - --> $DIR/auto-trait-leak.rs:4:12 - | -LL | fn send(_: T) {} - | ^^^^ required by this bound in `send` + = note: ...which again requires type-checking `cycle1`, completing the cycle + = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr b/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr index 9d52001b02460..b0b9c30705e45 100644 --- a/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr +++ b/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr @@ -1,14 +1,27 @@ -error: [o, o] - --> $DIR/capture-lifetime-not-in-hir.rs:8:29 +error[E0391]: cycle detected when computing generics of `foo2` + --> $DIR/capture-lifetime-not-in-hir.rs:14:1 | -LL | fn foo<'a, T: Bar<'a>>() -> impl Into { - | ^^^^^^^^^^^^^^^^^^^ - -error: [o, o, o] - --> $DIR/capture-lifetime-not-in-hir.rs:14:30 +LL | fn foo2<'a, T: Bar<'a>>() -> impl Into + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires looking up a named region... + --> $DIR/capture-lifetime-not-in-hir.rs:14:1 + | +LL | fn foo2<'a, T: Bar<'a>>() -> impl Into + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires resolving lifetimes... + --> $DIR/capture-lifetime-not-in-hir.rs:14:1 + | +LL | fn foo2<'a, T: Bar<'a>>() -> impl Into + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing generics of `foo2`, completing the cycle +note: cycle used when checking that `foo2` is well-formed + --> $DIR/capture-lifetime-not-in-hir.rs:14:1 | LL | fn foo2<'a, T: Bar<'a>>() -> impl Into + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: aborting due to 2 previous errors +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr index c2386e8c88be0..894bc56413a67 100644 --- a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr +++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr @@ -7,13 +7,6 @@ LL | LL | |x| x | ^ -error[E0720]: cannot resolve opaque type - --> $DIR/impl-fn-predefined-lifetimes.rs:4:35 - | -LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { - | ^^^^^^^^^^^^^^^ cannot resolve opaque type - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0720, E0792. -For more information about an error, try `rustc --explain E0720`. +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/implicit-capture-late.stderr b/tests/ui/impl-trait/implicit-capture-late.stderr index 080750f849767..80044d15f7dd5 100644 --- a/tests/ui/impl-trait/implicit-capture-late.stderr +++ b/tests/ui/impl-trait/implicit-capture-late.stderr @@ -10,12 +10,6 @@ note: lifetime declared here LL | fn foo(x: Vec) -> Box Deref> { | ^^ -error: [o] - --> $DIR/implicit-capture-late.rs:10:55 - | -LL | fn foo(x: Vec) -> Box Deref> { - | ^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr index 75cbe43eeb4a1..0ca118189a1a6 100644 --- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -12,14 +12,6 @@ note: required by a bound in `compare_ty::Trait::Ty` LL | type Ty: IntoIterator; | ^^^^^^^^^ required by this bound in `Trait::Ty` -error: unconstrained opaque type - --> $DIR/in-assoc-type-unconstrained.rs:8:26 - | -LL | type Ty = Option; - | ^^^^^^^^^^ - | - = note: `Ty` must be used in combination with a concrete type within the same impl - error[E0053]: method `method` has an incompatible type for trait --> $DIR/in-assoc-type-unconstrained.rs:22:24 | @@ -46,15 +38,7 @@ help: change the output type to match the trait LL | fn method() -> <() as compare_method::Trait>::Ty {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: unconstrained opaque type - --> $DIR/in-assoc-type-unconstrained.rs:20:19 - | -LL | type Ty = impl Sized; - | ^^^^^^^^^^ - | - = note: `Ty` must be used in combination with a concrete type within the same impl - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0053, E0271. For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr index 90285d512ef03..de269c66f4ef7 100644 --- a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr @@ -1,18 +1,8 @@ -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:22 - | -LL | MyTrait::foo(&self) - | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | | - | required by a bound introduced by this call - | - = help: the trait `MyTrait` is implemented for `Outer` - error[E0038]: the trait `MyTrait` cannot be made into an object - --> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9 + --> $DIR/cycle-effective-visibilities-during-object-safety.rs:16:6 | -LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^ `MyTrait` cannot be made into an object +LL | impl dyn MyTrait { + | ^^^^^^^^^^^ `MyTrait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit --> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22 @@ -24,19 +14,11 @@ LL | fn foo(&self) -> impl Marker; = help: consider moving `foo` to another trait = help: only type `Outer` implements the trait, consider using it directly instead -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9 - | -LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | - = help: the trait `MyTrait` is implemented for `Outer` - error[E0038]: the trait `MyTrait` cannot be made into an object - --> $DIR/cycle-effective-visibilities-during-object-safety.rs:16:6 + --> $DIR/cycle-effective-visibilities-during-object-safety.rs:18:15 | -LL | impl dyn MyTrait { - | ^^^^^^^^^^^ `MyTrait` cannot be made into an object +LL | fn other(&self) -> impl Marker { + | ^^^^ `MyTrait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit --> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22 @@ -48,11 +30,21 @@ LL | fn foo(&self) -> impl Marker; = help: consider moving `foo` to another trait = help: only type `Outer` implements the trait, consider using it directly instead +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:22 + | +LL | MyTrait::foo(&self) + | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | | + | required by a bound introduced by this call + | + = help: the trait `MyTrait` is implemented for `Outer` + error[E0038]: the trait `MyTrait` cannot be made into an object - --> $DIR/cycle-effective-visibilities-during-object-safety.rs:18:15 + --> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9 | -LL | fn other(&self) -> impl Marker { - | ^^^^ `MyTrait` cannot be made into an object +LL | MyTrait::foo(&self) + | ^^^^^^^^^^^^ `MyTrait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit --> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22 @@ -64,6 +56,14 @@ LL | fn foo(&self) -> impl Marker; = help: consider moving `foo` to another trait = help: only type `Outer` implements the trait, consider using it directly instead +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9 + | +LL | MyTrait::foo(&self) + | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | + = help: the trait `MyTrait` is implemented for `Outer` + error: aborting due to 5 previous errors Some errors have detailed explanations: E0038, E0277. diff --git a/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr b/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr index 67c4df0f3a9eb..6d32f7b4c2ac7 100644 --- a/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr +++ b/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr @@ -24,14 +24,6 @@ LL | Self: 'a; LL | type Item = u32; | ^ lifetimes do not match type in trait -error[E0277]: `()` is not an iterator - --> $DIR/span-bug-issue-121457.rs:13:23 - | -LL | fn iter(&self) -> impl for<'missing> Iterator> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator - | - = help: the trait `Iterator` is not implemented for `()` - warning: impl trait in impl method signature does not match trait method signature --> $DIR/span-bug-issue-121457.rs:13:51 | @@ -49,6 +41,14 @@ help: replace the return type so that it matches the trait LL | fn iter(&self) -> impl Iterator {} | ~~~~~~~~~~~~~ +error[E0277]: `()` is not an iterator + --> $DIR/span-bug-issue-121457.rs:13:23 + | +LL | fn iter(&self) -> impl for<'missing> Iterator> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator + | + = help: the trait `Iterator` is not implemented for `()` + error: aborting due to 4 previous errors; 1 warning emitted Some errors have detailed explanations: E0195, E0277, E0582. diff --git a/tests/ui/impl-trait/issue-99073-2.stderr b/tests/ui/impl-trait/issue-99073-2.stderr index 06b2b84569f69..519530b539625 100644 --- a/tests/ui/impl-trait/issue-99073-2.stderr +++ b/tests/ui/impl-trait/issue-99073-2.stderr @@ -7,18 +7,6 @@ LL | let f = || { LL | let i: u32 = test::(-1, false); | ^^^^^^^^^^^^^^^^^^^^^^ -error: concrete type differs from previous defining opaque type use - --> $DIR/issue-99073-2.rs:9:22 - | -LL | let i: u32 = test::(-1, false); - | ^^^^^^^^^^^^^^^^^^^^^^ expected `T`, got `u32` - | -note: previous use here - --> $DIR/issue-99073-2.rs:7:45 - | -LL | fn test(t: T, recurse: bool) -> impl Display { - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/issue-99073.stderr b/tests/ui/impl-trait/issue-99073.stderr index a94d563ae05c2..36a3ffedf2f5d 100644 --- a/tests/ui/impl-trait/issue-99073.stderr +++ b/tests/ui/impl-trait/issue-99073.stderr @@ -6,18 +6,6 @@ LL | fn fix(f: F) -> impl Fn() { LL | move || f(fix(&f)) | ^^^^^^^^^^ -error: concrete type differs from previous defining opaque type use - --> $DIR/issue-99073.rs:6:13 - | -LL | move || f(fix(&f)) - | ^^^^^^^ expected `{closure@$DIR/issue-99073.rs:6:3: 6:21}`, got `G` - | -note: previous use here - --> $DIR/issue-99073.rs:5:36 - | -LL | fn fix(f: F) -> impl Fn() { - | ^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr index 91dad1b5e673d..56a626f2c8f64 100644 --- a/tests/ui/impl-trait/issues/issue-78722-2.stderr +++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr @@ -1,9 +1,3 @@ -error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:13:13: 13:21}` to be a future that resolves to `u8`, but it resolves to `()` - --> $DIR/issue-78722-2.rs:11:30 - | -LL | fn concrete_use() -> F { - | ^ expected `()`, found `u8` - error[E0308]: mismatched types --> $DIR/issue-78722-2.rs:16:20 | @@ -18,6 +12,12 @@ LL | let f: F = async { 1 }; = note: expected opaque type `F` found `async` block `{async block@$DIR/issue-78722-2.rs:16:20: 16:31}` +error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:13:13: 13:21}` to be a future that resolves to `u8`, but it resolves to `()` + --> $DIR/issue-78722-2.rs:11:30 + | +LL | fn concrete_use() -> F { + | ^ expected `()`, found `u8` + error: aborting due to 2 previous errors Some errors have detailed explanations: E0271, E0308. diff --git a/tests/ui/impl-trait/issues/issue-86800.stderr b/tests/ui/impl-trait/issues/issue-86800.stderr index f03797fa7cd08..30cfd363760ef 100644 --- a/tests/ui/impl-trait/issues/issue-86800.stderr +++ b/tests/ui/impl-trait/issues/issue-86800.stderr @@ -1,56 +1,3 @@ -error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature - --> $DIR/issue-86800.rs:28:4 - | -LL | fn execute_transaction_fut<'f, F, O>( - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/issue-86800.rs:25:34 - | -LL | type TransactionFuture<'__, O> = impl '__ + Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature - --> $DIR/issue-86800.rs:40:14 - | -LL | async fn do_transaction( - | ^^^^^^^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/issue-86800.rs:25:34 - | -LL | type TransactionFuture<'__, O> = impl '__ + Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature - --> $DIR/issue-86800.rs:40:5 - | -LL | / async fn do_transaction( -LL | | -LL | | &self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> -LL | | ) -> TransactionResult -... | -LL | | f(&mut transaction).await -LL | | } - | |_____^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/issue-86800.rs:25:34 - | -LL | type TransactionFuture<'__, O> = impl '__ + Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: unconstrained opaque type - --> $DIR/issue-86800.rs:25:34 - | -LL | type TransactionFuture<'__, O> = impl '__ + Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `TransactionFuture` must be used in combination with a concrete type within the same module - error[E0792]: expected generic lifetime parameter, found `'_` --> $DIR/issue-86800.rs:35:5 | @@ -75,6 +22,6 @@ LL | | f(&mut transaction).await LL | | } | |_____^ -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 3943ce116c74e..63defe58b5181 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -66,6 +66,62 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | | | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` +error: lifetime may not live long enough + --> $DIR/must_outlive_least_region_or_bound.rs:18:41 + | +LL | fn elided3(x: &i32) -> Box { Box::new(x) } + | - ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` + | | + | let's call the lifetime of this reference `'1` + | +help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound + | +LL | fn elided3(x: &i32) -> Box { Box::new(x) } + | ++++ + +error: lifetime may not live long enough + --> $DIR/must_outlive_least_region_or_bound.rs:21:50 + | +LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } + | -- lifetime `'a` defined here ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | +help: to declare that the trait object captures data from argument `x`, you can add an explicit `'a` lifetime bound + | +LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } + | ++++ + +error: lifetime may not live long enough + --> $DIR/must_outlive_least_region_or_bound.rs:24:51 + | +LL | fn elided4(x: &i32) -> Box { Box::new(x) } + | - ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` + | | + | let's call the lifetime of this reference `'1` + | +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` + | +LL | fn elided4(x: &i32) -> Box { Box::new(x) } + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn elided4(x: &'static i32) -> Box { Box::new(x) } + | ~~~~~~~~~~~~ + +error: lifetime may not live long enough + --> $DIR/must_outlive_least_region_or_bound.rs:27:60 + | +LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } + | -- lifetime `'a` defined here ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` + | +LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn explicit4<'a>(x: &'static i32) -> Box { Box::new(x) } + | ~~~~~~~~~~~~ + error: lifetime may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:30:55 | @@ -127,62 +183,6 @@ help: consider adding an explicit lifetime bound LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { | +++++++++ -error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:18:41 - | -LL | fn elided3(x: &i32) -> Box { Box::new(x) } - | - ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` - | | - | let's call the lifetime of this reference `'1` - | -help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound - | -LL | fn elided3(x: &i32) -> Box { Box::new(x) } - | ++++ - -error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:21:50 - | -LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } - | -- lifetime `'a` defined here ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - | -help: to declare that the trait object captures data from argument `x`, you can add an explicit `'a` lifetime bound - | -LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } - | ++++ - -error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:24:51 - | -LL | fn elided4(x: &i32) -> Box { Box::new(x) } - | - ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` - | | - | let's call the lifetime of this reference `'1` - | -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` - | -LL | fn elided4(x: &i32) -> Box { Box::new(x) } - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn elided4(x: &'static i32) -> Box { Box::new(x) } - | ~~~~~~~~~~~~ - -error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:27:60 - | -LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } - | -- lifetime `'a` defined here ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - | -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` - | -LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn explicit4<'a>(x: &'static i32) -> Box { Box::new(x) } - | ~~~~~~~~~~~~ - error: aborting due to 13 previous errors Some errors have detailed explanations: E0310, E0621, E0700. diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.stderr b/tests/ui/impl-trait/nested-rpit-hrtb.stderr index d98de650d0d88..055d738746dfc 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.stderr +++ b/tests/ui/impl-trait/nested-rpit-hrtb.stderr @@ -86,15 +86,6 @@ LL | fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = help: the trait `Qux<'_>` is implemented for `()` = help: for that trait implementation, expected `()`, found `&'a ()` -error: implementation of `Bar` is not general enough - --> $DIR/nested-rpit-hrtb.rs:49:93 - | -LL | fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'b> {} - | ^^ implementation of `Bar` is not general enough - | - = note: `()` must implement `Bar<'a>` - = note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0` - error[E0277]: the trait bound `for<'a, 'b> &'a (): Qux<'b>` is not satisfied --> $DIR/nested-rpit-hrtb.rs:60:64 | @@ -104,6 +95,15 @@ LL | fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> = help: the trait `Qux<'_>` is implemented for `()` = help: for that trait implementation, expected `()`, found `&'a ()` +error: implementation of `Bar` is not general enough + --> $DIR/nested-rpit-hrtb.rs:49:93 + | +LL | fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'b> {} + | ^^ implementation of `Bar` is not general enough + | + = note: `()` must implement `Bar<'a>` + = note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0` + error: aborting due to 9 previous errors Some errors have detailed explanations: E0261, E0277, E0657. diff --git a/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr b/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr index 54849c112f5a0..58832f21b521c 100644 --- a/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr +++ b/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr @@ -138,33 +138,6 @@ help: change the type of the numeric literal from `u32` to `i32` LL | 1 => 1i32, | ~~~ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9 - | -LL | / if let Some(42) = Some(42) { -LL | | 0i32 - | | ---- expected because of this -LL | | } else { -LL | | 1u32 - | | ^^^^ expected `i32`, found `u32` -LL | | } - | |_____- `if` and `else` have incompatible types - | -help: you could change the return type to be a boxed trait object - | -LL | fn apt() -> Box { - | ~~~~~~~ + -help: if you change the return type to expect trait objects, box the returned expressions - | -LL ~ Box::new(0i32) -LL | } else { -LL ~ Box::new(1u32) - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL | 1i32 - | ~~~ - error[E0746]: return type cannot have an unboxed trait object --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13 | @@ -221,6 +194,33 @@ LL | } else { LL ~ Box::new(1u32) | +error[E0308]: `if` and `else` have incompatible types + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9 + | +LL | / if let Some(42) = Some(42) { +LL | | 0i32 + | | ---- expected because of this +LL | | } else { +LL | | 1u32 + | | ^^^^ expected `i32`, found `u32` +LL | | } + | |_____- `if` and `else` have incompatible types + | +help: you could change the return type to be a boxed trait object + | +LL | fn apt() -> Box { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ Box::new(0i32) +LL | } else { +LL ~ Box::new(1u32) + | +help: change the type of the numeric literal from `u32` to `i32` + | +LL | 1i32 + | ~~~ + error: aborting due to 12 previous errors Some errors have detailed explanations: E0308, E0746. diff --git a/tests/ui/impl-trait/precise-capturing/bad-params.stderr b/tests/ui/impl-trait/precise-capturing/bad-params.stderr index e104f115aa3f2..f6973a7e7f117 100644 --- a/tests/ui/impl-trait/precise-capturing/bad-params.stderr +++ b/tests/ui/impl-trait/precise-capturing/bad-params.stderr @@ -17,6 +17,12 @@ LL | fn missing_self() -> impl Sized + use {} | | | `Self` not allowed in a function +error: expected type or const parameter in `use<...>` precise captures list, found function + --> $DIR/bad-params.rs:15:32 + | +LL | fn hello() -> impl Sized + use {} + | ^^^^^ + error: `Self` can't be captured in `use<...>` precise captures list, since it is an alias --> $DIR/bad-params.rs:11:48 | @@ -25,12 +31,6 @@ LL | impl MyType { LL | fn self_is_not_param() -> impl Sized + use {} | ^^^^ -error: expected type or const parameter in `use<...>` precise captures list, found function - --> $DIR/bad-params.rs:15:32 - | -LL | fn hello() -> impl Sized + use {} - | ^^^^^ - error: aborting due to 4 previous errors Some errors have detailed explanations: E0411, E0412. diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr index 979c0ca6d7b6e..11c4e8dd93eb6 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr @@ -1,12 +1,3 @@ -error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list - --> $DIR/forgot-to-capture-lifetime.rs:3:52 - | -LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x } - | -- -----------^^------------ - | | | - | | lifetime captured due to being mentioned in the bounds of the `impl Trait` - | this lifetime parameter is captured - error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds --> $DIR/forgot-to-capture-lifetime.rs:6:62 | @@ -21,6 +12,6 @@ help: add `'a` to the `use<...>` bound to explicitly capture it LL | fn lifetime_in_hidden<'a>(x: &'a ()) -> impl Sized + use<'a> { x } | ++ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr index 89bd4df443106..f30539aed3902 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr @@ -6,25 +6,5 @@ LL | fn bar() -> impl Sized + use<>; | = note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope -error: `impl Trait` must mention all type parameters in scope in `use<...>` - --> $DIR/forgot-to-capture-type.rs:3:23 - | -LL | fn type_param() -> impl Sized + use<> {} - | - ^^^^^^^^^^^^^^^^^^ - | | - | type parameter is implicitly captured by this `impl Trait` - | - = note: currently, all type parameters are required to be mentioned in the precise captures list - -error: `impl Trait` must mention the `Self` type of the trait in `use<...>` - --> $DIR/forgot-to-capture-type.rs:7:17 - | -LL | trait Foo { - | --------- `Self` type parameter is implicitly captured by this `impl Trait` -LL | fn bar() -> impl Sized + use<>; - | ^^^^^^^^^^^^^^^^^^ - | - = note: currently, all type parameters are required to be mentioned in the precise captures list - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/precise-capturing/ordering.stderr b/tests/ui/impl-trait/precise-capturing/ordering.stderr index ecd47159059b4..f66d7ae3193e7 100644 --- a/tests/ui/impl-trait/precise-capturing/ordering.stderr +++ b/tests/ui/impl-trait/precise-capturing/ordering.stderr @@ -1,28 +1,27 @@ -error: cannot capture parameter `'a` twice - --> $DIR/ordering.rs:3:33 +error[E0391]: cycle detected when computing generics of `ordering` + --> $DIR/ordering.rs:12:1 | -LL | fn lt<'a>() -> impl Sized + use<'a, 'a> {} - | ^^ -- parameter captured again here - -error: cannot capture parameter `T` twice - --> $DIR/ordering.rs:6:32 +LL | fn ordering<'a, T>() -> impl Sized + use {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | fn ty() -> impl Sized + use {} - | ^ - parameter captured again here - -error: cannot capture parameter `N` twice - --> $DIR/ordering.rs:9:45 +note: ...which requires looking up a named region... + --> $DIR/ordering.rs:12:1 | -LL | fn ct() -> impl Sized + use {} - | ^ - parameter captured again here - -error: lifetime parameter `'a` must be listed before non-lifetime parameters - --> $DIR/ordering.rs:12:45 +LL | fn ordering<'a, T>() -> impl Sized + use {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires resolving lifetimes... + --> $DIR/ordering.rs:12:1 + | +LL | fn ordering<'a, T>() -> impl Sized + use {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing generics of `ordering`, completing the cycle +note: cycle used when checking that `ordering` is well-formed + --> $DIR/ordering.rs:12:1 | LL | fn ordering<'a, T>() -> impl Sized + use {} - | - ^^ - | | - | move the lifetime before this parameter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: aborting due to 4 previous errors +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr b/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr index 9aa73353126cd..5299923b4fa49 100644 --- a/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr +++ b/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr @@ -14,5 +14,30 @@ LL | fn in_trait() -> impl Sized + use<'a> {} | = note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope -error: aborting due to 2 previous errors +error[E0391]: cycle detected when computing generics of `Test::in_trait` + --> $DIR/redundant.rs:18:5 + | +LL | fn in_trait() -> impl Sized + use<'a, Self>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires looking up a named region... + --> $DIR/redundant.rs:18:5 + | +LL | fn in_trait() -> impl Sized + use<'a, Self>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires resolving lifetimes... + --> $DIR/redundant.rs:18:5 + | +LL | fn in_trait() -> impl Sized + use<'a, Self>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing generics of `Test::in_trait`, completing the cycle +note: cycle used when computing generics of `Test::in_trait::{opaque#0}` + --> $DIR/redundant.rs:18:22 + | +LL | fn in_trait() -> impl Sized + use<'a, Self>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/precise-capturing/rpitit.stderr b/tests/ui/impl-trait/precise-capturing/rpitit.stderr index 45eceef2f494b..3ff5ed70455ef 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit.stderr +++ b/tests/ui/impl-trait/precise-capturing/rpitit.stderr @@ -6,14 +6,6 @@ LL | fn hello() -> impl PartialEq + use; | = note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope -error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list - --> $DIR/rpitit.rs:11:19 - | -LL | trait Foo<'a> { - | -- this lifetime parameter is captured -LL | fn hello() -> impl PartialEq + use; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait` - error: lifetime may not live long enough --> $DIR/rpitit.rs:15:5 | @@ -46,5 +38,5 @@ LL | | ); help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index 3692cc77b0fb4..175b5366cd56b 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -1,24 +1,3 @@ -error: item does not constrain `a::Foo::{opaque#0}`, but has it in its signature - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12 - | -LL | fn eq(&self, _other: &(Foo, i32)) -> bool { - | ^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: unconstrained opaque type - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - error[E0053]: method `eq` has an incompatible type for trait --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:30 | @@ -35,14 +14,6 @@ help: change the parameter type to match the trait LL | fn eq(&self, _other: &(a::Bar, i32)) -> bool { | ~~~~~~~~~~~~~~ -error: unconstrained opaque type - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:19:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - error[E0053]: method `eq` has an incompatible type for trait --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:30 | @@ -64,6 +35,6 @@ help: change the parameter type to match the trait LL | fn eq(&self, _other: &(b::Foo, i32)) -> bool { | ~~~~~~~~~~~~~~ -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/rpit/non-defining-use.stderr b/tests/ui/impl-trait/rpit/non-defining-use.stderr index 19987d47672b0..2aeed913869ae 100644 --- a/tests/ui/impl-trait/rpit/non-defining-use.stderr +++ b/tests/ui/impl-trait/rpit/non-defining-use.stderr @@ -14,18 +14,6 @@ LL | fn bar(val: T) -> impl Sized { LL | let _: u8 = bar(0u8); | ^^ -error: concrete type differs from previous defining opaque type use - --> $DIR/non-defining-use.rs:8:17 - | -LL | let _: u8 = bar(0u8); - | ^^^^^^^^ expected `T`, got `u8` - | -note: previous use here - --> $DIR/non-defining-use.rs:7:22 - | -LL | fn bar(val: T) -> impl Sized { - | ^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/transmute/in-defining-scope.stderr b/tests/ui/impl-trait/transmute/in-defining-scope.stderr index 7172bfdf0d7e2..06d835da56358 100644 --- a/tests/ui/impl-trait/transmute/in-defining-scope.stderr +++ b/tests/ui/impl-trait/transmute/in-defining-scope.stderr @@ -1,41 +1,25 @@ -error[E0391]: cycle detected when computing type of `foo::{opaque#0}` - --> $DIR/in-defining-scope.rs:6:13 - | -LL | fn foo() -> impl Sized { - | ^^^^^^^^^^ - | -note: ...which requires computing type of opaque `foo::{opaque#0}`... - --> $DIR/in-defining-scope.rs:6:13 - | -LL | fn foo() -> impl Sized { - | ^^^^^^^^^^ -note: ...which requires type-checking `foo`... +error[E0391]: cycle detected when type-checking `foo` --> $DIR/in-defining-scope.rs:6:1 | LL | fn foo() -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^ + | = note: ...which requires computing layout of `foo::{opaque#0}`... = note: ...which requires normalizing `foo::{opaque#0}`... - = note: ...which again requires computing type of `foo::{opaque#0}`, completing the cycle -note: cycle used when checking that `foo::{opaque#0}` is well-formed +note: ...which requires computing type of `foo::{opaque#0}`... --> $DIR/in-defining-scope.rs:6:13 | LL | fn foo() -> impl Sized { | ^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -warning: function cannot return without recursing - --> $DIR/in-defining-scope.rs:6:1 +note: ...which requires computing type of opaque `foo::{opaque#0}`... + --> $DIR/in-defining-scope.rs:6:13 | LL | fn foo() -> impl Sized { - | ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -... -LL | transmute::<_, u8>(foo()); - | ----- recursive call site - | - = help: a `loop` may express intention better if this is on purpose - = note: `#[warn(unconditional_recursion)]` on by default + | ^^^^^^^^^^ + = note: ...which again requires type-checking `foo`, completing the cycle + = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr index b70676ece0e2c..11b57ad98c458 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr @@ -1,24 +1,3 @@ -error: item does not constrain `A::{opaque#0}`, but has it in its signature - --> $DIR/two_tait_defining_each_other2.rs:11:4 - | -LL | fn muh(x: A) -> B { - | ^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/two_tait_defining_each_other2.rs:6:10 - | -LL | type A = impl Foo; - | ^^^^^^^^ - -error: unconstrained opaque type - --> $DIR/two_tait_defining_each_other2.rs:6:10 - | -LL | type A = impl Foo; - | ^^^^^^^^ - | - = note: `A` must be used in combination with a concrete type within the same module - error: opaque type's hidden type cannot be another opaque type from the same scope --> $DIR/two_tait_defining_each_other2.rs:14:5 | @@ -36,5 +15,5 @@ note: opaque type being used as hidden type LL | type A = impl Foo; | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index 1fb69db98c162..512fab8704259 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -342,25 +342,37 @@ LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | = note: `impl Trait` is only allowed in arguments and return types of functions and methods -error[E0283]: type annotations needed - --> $DIR/where-allowed.rs:46:57 +error[E0053]: method `in_trait_impl_return` has an incompatible type for trait + --> $DIR/where-allowed.rs:129:34 | -LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } - | ^^^^^^^^^^ cannot infer type +LL | type Out = impl Debug; + | ---------- the expected opaque type +... +LL | fn in_trait_impl_return() -> impl Debug { () } + | ^^^^^^^^^^ expected opaque type, found a different opaque type | - = note: cannot satisfy `_: Debug` +note: type in trait + --> $DIR/where-allowed.rs:119:34 + | +LL | fn in_trait_impl_return() -> Self::Out; + | ^^^^^^^^^ + = note: expected signature `fn() -> <() as DummyTrait>::Out` + found signature `fn() -> impl Debug` + = note: distinct uses of `impl Trait` result in different opaque types +help: change the output type to match the trait + | +LL | fn in_trait_impl_return() -> <() as DummyTrait>::Out { () } + | ~~~~~~~~~~~~~~~~~~~~~~~ -error[E0283]: type annotations needed - --> $DIR/where-allowed.rs:64:46 +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:246:36 | -LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type +LL | fn in_method_generic_param_default(_: T) {} + | ^^^^^^^^^^^^^^ | - = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: - - impl Fn for &F - where A: Tuple, F: Fn, F: ?Sized; - - impl Fn for Box - where Args: Tuple, F: Fn, A: Allocator, F: ?Sized; + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions --> $DIR/where-allowed.rs:239:7 @@ -370,7 +382,6 @@ LL | impl T {} | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #36887 - = note: `#[deny(invalid_type_param_default)]` on by default error[E0118]: no nominal type found for inherent implementation --> $DIR/where-allowed.rs:239:1 @@ -380,6 +391,26 @@ LL | impl T {} | = note: either implement a trait on it or create a newtype to wrap it instead +error[E0283]: type annotations needed + --> $DIR/where-allowed.rs:46:57 + | +LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } + | ^^^^^^^^^^ cannot infer type + | + = note: cannot satisfy `_: Debug` + +error[E0283]: type annotations needed + --> $DIR/where-allowed.rs:64:46 + | +LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + | + = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: + - impl Fn for &F + where A: Tuple, F: Fn, F: ?Sized; + - impl Fn for Box + where Args: Tuple, F: Fn, A: Allocator, F: ?Sized; + error[E0599]: no function or associated item named `into_vec` found for slice `[_]` in the current scope --> $DIR/where-allowed.rs:81:5 | @@ -390,36 +421,11 @@ help: there is an associated function `to_vec` with a similar name --> $SRC_DIR/alloc/src/slice.rs:LL:COL = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0053]: method `in_trait_impl_return` has an incompatible type for trait - --> $DIR/where-allowed.rs:129:34 - | -LL | type Out = impl Debug; - | ---------- the expected opaque type -... -LL | fn in_trait_impl_return() -> impl Debug { () } - | ^^^^^^^^^^ expected opaque type, found a different opaque type - | -note: type in trait - --> $DIR/where-allowed.rs:119:34 - | -LL | fn in_trait_impl_return() -> Self::Out; - | ^^^^^^^^^ - = note: expected signature `fn() -> <() as DummyTrait>::Out` - found signature `fn() -> impl Debug` - = note: distinct uses of `impl Trait` result in different opaque types -help: change the output type to match the trait - | -LL | fn in_trait_impl_return() -> <() as DummyTrait>::Out { () } - | ~~~~~~~~~~~~~~~~~~~~~~~ - -error: unconstrained opaque type - --> $DIR/where-allowed.rs:122:16 - | -LL | type Out = impl Debug; - | ^^^^^^^^^^ - | - = note: `Out` must be used in combination with a concrete type within the same impl +error: aborting due to 49 previous errors +Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666. +For more information about an error, try `rustc --explain E0053`. +Future incompatibility report: Future breakage diagnostic: error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions --> $DIR/where-allowed.rs:246:36 | @@ -428,12 +434,9 @@ LL | fn in_method_generic_param_default(_: T) {} | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default -error: aborting due to 50 previous errors - -Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666. -For more information about an error, try `rustc --explain E0053`. -Future incompatibility report: Future breakage diagnostic: +Future breakage diagnostic: error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions --> $DIR/where-allowed.rs:239:7 | @@ -444,14 +447,3 @@ LL | impl T {} = note: for more information, see issue #36887 = note: `#[deny(invalid_type_param_default)]` on by default -Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:246:36 - | -LL | fn in_method_generic_param_default(_: T) {} - | ^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36887 - = note: `#[deny(invalid_type_param_default)]` on by default - diff --git a/tests/ui/lint/dead-code/impl-trait.stderr b/tests/ui/lint/dead-code/impl-trait.stderr index 1c7d6d9459763..dab1a8dc948b3 100644 --- a/tests/ui/lint/dead-code/impl-trait.stderr +++ b/tests/ui/lint/dead-code/impl-trait.stderr @@ -1,8 +1,8 @@ -error: type alias `Unused` is never used - --> $DIR/impl-trait.rs:12:6 +error: trait `Trait` is never used + --> $DIR/impl-trait.rs:3:7 | -LL | type Unused = (); - | ^^^^^^ +LL | trait Trait { + | ^^^^^ | note: the lint level is defined here --> $DIR/impl-trait.rs:1:9 @@ -10,5 +10,17 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: aborting due to 1 previous error +error: type alias `Used` is never used + --> $DIR/impl-trait.rs:11:6 + | +LL | type Used = (); + | ^^^^ + +error: type alias `Unused` is never used + --> $DIR/impl-trait.rs:12:6 + | +LL | type Unused = (); + | ^^^^^^ + +error: aborting due to 3 previous errors diff --git a/tests/ui/pattern/usefulness/impl-trait.stderr b/tests/ui/pattern/usefulness/impl-trait.stderr index c079f5a259dde..93cf104729c31 100644 --- a/tests/ui/pattern/usefulness/impl-trait.stderr +++ b/tests/ui/pattern/usefulness/impl-trait.stderr @@ -11,6 +11,20 @@ note: the lint level is defined here LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ +error[E0004]: non-exhaustive patterns: type `impl Copy` is non-empty + --> $DIR/impl-trait.rs:23:11 + | +LL | match return_never_rpit(x) {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `impl Copy` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match return_never_rpit(x) { +LL + _ => todo!(), +LL + } + | + error: unreachable pattern --> $DIR/impl-trait.rs:31:13 | @@ -19,6 +33,20 @@ LL | _ => {} | = note: this pattern matches no values because `Void` is uninhabited +error[E0004]: non-exhaustive patterns: type `T` is non-empty + --> $DIR/impl-trait.rs:37:11 + | +LL | match return_never_tait(x) {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `T` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match return_never_tait(x) { +LL + _ => todo!(), +LL + } + | + error: unreachable pattern --> $DIR/impl-trait.rs:45:13 | @@ -107,34 +135,6 @@ LL | _ => {} | = note: this pattern matches no values because `SecretelyDoubleVoid` is uninhabited -error[E0004]: non-exhaustive patterns: type `impl Copy` is non-empty - --> $DIR/impl-trait.rs:23:11 - | -LL | match return_never_rpit(x) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: the matched value is of type `impl Copy` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match return_never_rpit(x) { -LL + _ => todo!(), -LL + } - | - -error[E0004]: non-exhaustive patterns: type `T` is non-empty - --> $DIR/impl-trait.rs:37:11 - | -LL | match return_never_tait(x) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: the matched value is of type `T` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match return_never_tait(x) { -LL + _ => todo!(), -LL + } - | - error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr index b59c6d1eed8da..207761e678bc2 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr @@ -27,34 +27,6 @@ error: `~const` can only be applied to `#[const_trait]` traits LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) | ^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:18:20 - | -LL | -> impl ~const PartialEq + ~const Destruct - | ^^^^^^^^^ - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:18:39 - | -LL | -> impl ~const PartialEq + ~const Destruct - | ^^^^^^^^ - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:18:20 - | -LL | -> impl ~const PartialEq + ~const Destruct - | ^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:18:39 - | -LL | -> impl ~const PartialEq + ~const Destruct - | ^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-impl-trait.rs:25:29 | @@ -68,62 +40,58 @@ LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:25:29 + --> $DIR/const-impl-trait.rs:29:29 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:25:48 + --> $DIR/const-impl-trait.rs:29:48 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:25:29 + --> $DIR/const-impl-trait.rs:29:29 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:25:48 + --> $DIR/const-impl-trait.rs:29:48 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:29:29 + --> $DIR/const-impl-trait.rs:18:20 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^^^^ +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:29:48 + --> $DIR/const-impl-trait.rs:18:39 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^^^ +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:29:29 + --> $DIR/const-impl-trait.rs:18:20 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^^^^ +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:29:48 + --> $DIR/const-impl-trait.rs:18:39 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^^^ +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -243,7 +211,7 @@ LL | const fn apit_assoc_bound(_: impl IntoIterator + ~const Des | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 33 previous errors +error: aborting due to 29 previous errors Some errors have detailed explanations: E0493, E0635. For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr index fb1e4cca3f40b..cc2308dae5532 100644 --- a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr +++ b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr @@ -1,3 +1,27 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/higher-ranked-regions-basic.rs:57:41 + | +LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'static>> {} + | ^^^^^^^^^^^^^^^^^^^^^^ argument `'static` is not a generic parameter + | +note: for this opaque type + --> $DIR/higher-ranked-regions-basic.rs:56:25 + | +LL | type Opq0<'a, 'b> = impl Sized; + | ^^^^^^^^^^ + +error: non-defining opaque type use in defining scope + --> $DIR/higher-ranked-regions-basic.rs:66:41 + | +LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'a>> {} + | ^^^^^^^^^^^^^^^^^ generic argument `'a` used twice + | +note: for this opaque type + --> $DIR/higher-ranked-regions-basic.rs:65:25 + | +LL | type Opq0<'a, 'b> = impl Sized; + | ^^^^^^^^^^ + error[E0792]: expected generic lifetime parameter, found `'a` --> $DIR/higher-ranked-regions-basic.rs:15:55 | @@ -46,18 +70,6 @@ LL | type Opq2 = impl for<'a> Trait<'a, Ty = Opq1<'a>>; LL | fn test() -> Opq2 {} | ^^ -error[E0792]: non-defining opaque type use in defining scope - --> $DIR/higher-ranked-regions-basic.rs:57:41 - | -LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'static>> {} - | ^^^^^^^^^^^^^^^^^^^^^^ argument `'static` is not a generic parameter - | -note: for this opaque type - --> $DIR/higher-ranked-regions-basic.rs:56:25 - | -LL | type Opq0<'a, 'b> = impl Sized; - | ^^^^^^^^^^ - error[E0792]: expected generic lifetime parameter, found `'a` --> $DIR/higher-ranked-regions-basic.rs:57:65 | @@ -66,18 +78,6 @@ LL | type Opq0<'a, 'b> = impl Sized; LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'static>> {} | ^^ -error: non-defining opaque type use in defining scope - --> $DIR/higher-ranked-regions-basic.rs:66:41 - | -LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'a>> {} - | ^^^^^^^^^^^^^^^^^ generic argument `'a` used twice - | -note: for this opaque type - --> $DIR/higher-ranked-regions-basic.rs:65:25 - | -LL | type Opq0<'a, 'b> = impl Sized; - | ^^^^^^^^^^ - error[E0792]: expected generic lifetime parameter, found `'a` --> $DIR/higher-ranked-regions-basic.rs:66:60 | diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index 61a2925f582b2..a7d636b63bd27 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -150,14 +150,6 @@ help: consider introducing a named lifetime parameter LL | fn g<'a>(mut x: impl Iterator) -> Option<&()> { x.next() } | ++++ ++ -error: lifetime may not live long enough - --> $DIR/impl-trait-missing-lifetime-gated.rs:19:67 - | -LL | async fn i(mut x: impl Iterator) -> Option<&()> { x.next() } - | ----------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static` - | | - | return type `impl Future>` contains a lifetime `'1` - error[E0658]: anonymous lifetimes in `impl Trait` are unstable --> $DIR/impl-trait-missing-lifetime-gated.rs:25:35 | @@ -184,14 +176,6 @@ help: consider introducing a named lifetime parameter LL | fn g<'a>(mut x: impl Iterator) -> Option<&'_ ()> { x.next() } | ++++ ~~ -error: lifetime may not live long enough - --> $DIR/impl-trait-missing-lifetime-gated.rs:38:73 - | -LL | async fn i(mut x: impl Iterator) -> Option<&'_ ()> { x.next() } - | ----------------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static` - | | - | return type `impl Future>` contains a lifetime `'1` - error[E0658]: anonymous lifetimes in `impl Trait` are unstable --> $DIR/impl-trait-missing-lifetime-gated.rs:46:18 | @@ -244,6 +228,22 @@ help: consider introducing a named lifetime parameter LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() } | ++++ +++ +error: lifetime may not live long enough + --> $DIR/impl-trait-missing-lifetime-gated.rs:19:67 + | +LL | async fn i(mut x: impl Iterator) -> Option<&()> { x.next() } + | ----------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static` + | | + | return type `impl Future>` contains a lifetime `'1` + +error: lifetime may not live long enough + --> $DIR/impl-trait-missing-lifetime-gated.rs:38:73 + | +LL | async fn i(mut x: impl Iterator) -> Option<&'_ ()> { x.next() } + | ----------------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static` + | | + | return type `impl Future>` contains a lifetime `'1` + error: aborting due to 16 previous errors Some errors have detailed explanations: E0106, E0658. diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime.stderr index 70998b67c04bf..650b322269fea 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime.stderr @@ -40,6 +40,12 @@ LL - async fn i(mut x: impl Iterator) -> Option<&'_ ()> { x.next( LL + async fn i(mut x: impl Iterator) -> Option<()> { x.next() } | +error: lifetime may not live long enough + --> $DIR/impl-trait-missing-lifetime.rs:9:63 + | +LL | fn g(mut x: impl Iterator) -> Option<&'_ ()> { x.next() } + | ----- has type `x` ^^^^^^^^ returning this value requires that `'1` must outlive `'static` + error: lifetime may not live long enough --> $DIR/impl-trait-missing-lifetime.rs:17:69 | @@ -48,12 +54,6 @@ LL | async fn i(mut x: impl Iterator) -> Option<&'_ ()> { x.next( | | | return type `impl Future>` contains a lifetime `'1` -error: lifetime may not live long enough - --> $DIR/impl-trait-missing-lifetime.rs:9:63 - | -LL | fn g(mut x: impl Iterator) -> Option<&'_ ()> { x.next() } - | ----- has type `x` ^^^^^^^^ returning this value requires that `'1` must outlive `'static` - error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr index 6bdc76aab4503..75c18f870b670 100644 --- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr +++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr @@ -1,22 +1,19 @@ -error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits - --> $DIR/auto-trait-leakage3.rs:13:17 +error[E0391]: cycle detected when type-checking `m::bar` + --> $DIR/auto-trait-leakage3.rs:13:9 | LL | is_send(foo()); - | ------- ^^^^^ - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^ | - = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule -note: opaque type is declared here + = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`... +note: ...which requires computing type of opaque `m::Foo::{opaque#0}`... --> $DIR/auto-trait-leakage3.rs:7:20 | LL | pub type Foo = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `is_send` - --> $DIR/auto-trait-leakage3.rs:17:19 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` + = note: ...which again requires type-checking `m::bar`, completing the cycle + = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index 407def09469f5..3b6999cabc416 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -1,43 +1,3 @@ -error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/const_generic_type.rs:8:10 - | -LL | async fn test() { - | ^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/const_generic_type.rs:5:12 - | -LL | type Bar = impl std::fmt::Display; - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/const_generic_type.rs:8:1 - | -LL | / async fn test() { -LL | | -LL | | -LL | | -LL | | #[cfg(infer)] -LL | | let x: u32 = N; -LL | | } - | |_^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/const_generic_type.rs:5:12 - | -LL | type Bar = impl std::fmt::Display; - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: unconstrained opaque type - --> $DIR/const_generic_type.rs:5:12 - | -LL | type Bar = impl std::fmt::Display; - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Bar` must be used in combination with a concrete type within the same module - error: `Bar` is forbidden as the type of a const generic parameter --> $DIR/const_generic_type.rs:8:24 | @@ -46,5 +6,5 @@ LL | async fn test() { | = note: the only supported types are integers, `bool` and `char` -error: aborting due to 4 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/constrain_inputs.stderr b/tests/ui/type-alias-impl-trait/constrain_inputs.stderr index 2468fb7480b07..58d7c4068a3be 100644 --- a/tests/ui/type-alias-impl-trait/constrain_inputs.stderr +++ b/tests/ui/type-alias-impl-trait/constrain_inputs.stderr @@ -7,19 +7,6 @@ LL | fn execute(ty: Ty<'_>) -> &str { todo!() } = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter -error: item does not constrain `lifetime_params::Ty::{opaque#0}`, but has it in its signature - --> $DIR/constrain_inputs.rs:6:8 - | -LL | fn execute(ty: Ty<'_>) -> &str { todo!() } - | ^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/constrain_inputs.rs:4:19 - | -LL | type Ty<'a> = impl Sized; - | ^^^^^^^^^^ - error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types --> $DIR/constrain_inputs.rs:10:35 | @@ -47,19 +34,6 @@ LL | fn execute(ty: Ty<'_>) -> &str { ty() } = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter -error: item does not constrain `lifetime_params_2::Ty::{opaque#0}`, but has it in its signature - --> $DIR/constrain_inputs.rs:19:8 - | -LL | fn execute(ty: Ty<'_>) -> &str { ty() } - | ^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/constrain_inputs.rs:17:19 - | -LL | type Ty<'a> = impl FnOnce() -> &'a str; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types --> $DIR/constrain_inputs.rs:29:37 | @@ -78,7 +52,7 @@ LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str; = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0581, E0582. For more information about an error, try `rustc --explain E0581`. diff --git a/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr b/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr index d60f1ffbccc2d..338dc230ac2ea 100644 --- a/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr +++ b/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr @@ -1,11 +1,3 @@ -error: unconstrained opaque type - --> $DIR/declared_but_not_defined_in_scope.rs:7:20 - | -LL | pub type Boo = impl ::std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Boo` must be used in combination with a concrete type within the same module - error[E0308]: mismatched types --> $DIR/declared_but_not_defined_in_scope.rs:11:5 | @@ -25,6 +17,6 @@ note: this item must have the opaque type in its signature in order to be able t LL | fn bomp() -> boo::Boo { | ^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr index 6f5be5467f704..3efce33a1487f 100644 --- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr @@ -10,17 +10,5 @@ note: previous use here LL | let y: Tait<'b> = 1i32; | ^^^^ -error: concrete type differs from previous defining opaque type use - --> $DIR/different_defining_uses_never_type-2.rs:8:31 - | -LL | let y: Tait<'b> = 1i32; - | ^^^^ expected `()`, got `i32` - | -note: previous use here - --> $DIR/different_defining_uses_never_type-2.rs:7:14 - | -LL | if { return } { - | ^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/failed-to-normalize-ice-99945.stderr b/tests/ui/type-alias-impl-trait/failed-to-normalize-ice-99945.stderr index 9a3f4ae4c1c31..466fd69a755cd 100644 --- a/tests/ui/type-alias-impl-trait/failed-to-normalize-ice-99945.stderr +++ b/tests/ui/type-alias-impl-trait/failed-to-normalize-ice-99945.stderr @@ -1,29 +1,3 @@ -error: item does not constrain `StateWidget::{opaque#0}`, but has it in its signature - --> $DIR/failed-to-normalize-ice-99945.rs:25:8 - | -LL | fn make_state(&self) -> Self::State {} - | ^^^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/failed-to-normalize-ice-99945.rs:20:24 - | -LL | type StateWidget<'a> = impl Widget<&'a ()>; - | ^^^^^^^^^^^^^^^^^^^ - -error: item does not constrain `StateWidget::{opaque#0}`, but has it in its signature - --> $DIR/failed-to-normalize-ice-99945.rs:29:4 - | -LL | fn new_stateful_widget Fn(&'a ()) -> StateWidget<'a>>(build: F) -> impl Widget<()> { - | ^^^^^^^^^^^^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/failed-to-normalize-ice-99945.rs:20:24 - | -LL | type StateWidget<'a> = impl Widget<&'a ()>; - | ^^^^^^^^^^^^^^^^^^^ - error[E0308]: mismatched types --> $DIR/failed-to-normalize-ice-99945.rs:36:29 | @@ -45,7 +19,7 @@ LL | type StateWidget<'a> = impl Widget<&'a ()>; LL | StatefulWidget(build) | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0308, E0792. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index 73570de53266f..9d7221680dc39 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -10,18 +10,6 @@ note: for this opaque type LL | type TwoTys = impl Debug; | ^^^^^^^^^^ -error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:23:5 - | -LL | t - | ^ - | -note: type used multiple times - --> $DIR/generic_duplicate_param_use.rs:15:13 - | -LL | type TwoTys = impl Debug; - | ^ ^ - error: non-defining opaque type use in defining scope --> $DIR/generic_duplicate_param_use.rs:27:36 | @@ -46,6 +34,18 @@ note: for this opaque type LL | type TwoConsts = impl Debug; | ^^^^^^^^^^ +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use.rs:23:5 + | +LL | t + | ^ + | +note: type used multiple times + --> $DIR/generic_duplicate_param_use.rs:15:13 + | +LL | type TwoTys = impl Debug; + | ^ ^ + error: non-defining opaque type use in defining scope --> $DIR/generic_duplicate_param_use.rs:29:5 | diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr index bd68b4e3ea469..af6978e32718e 100644 --- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr @@ -10,15 +10,6 @@ note: for this opaque type LL | type OneTy = impl Debug; | ^^^^^^^^^^ -error[E0792]: expected generic type parameter, found `u32` - --> $DIR/generic_nondefining_use.rs:17:5 - | -LL | type OneTy = impl Debug; - | - this generic parameter must be used with a generic type parameter -... -LL | 5u32 - | ^^^^ - error[E0792]: non-defining opaque type use in defining scope --> $DIR/generic_nondefining_use.rs:21:27 | @@ -43,6 +34,15 @@ note: for this opaque type LL | type OneConst = impl Debug; | ^^^^^^^^^^ +error[E0792]: expected generic type parameter, found `u32` + --> $DIR/generic_nondefining_use.rs:17:5 + | +LL | type OneTy = impl Debug; + | - this generic parameter must be used with a generic type parameter +... +LL | 5u32 + | ^^^^ + error[E0792]: expected generic lifetime parameter, found `'static` --> $DIR/generic_nondefining_use.rs:23:5 | diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr index be9b07823ae0a..88529b370f133 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -1,13 +1,8 @@ error[E0277]: the trait bound `T: Trait` is not satisfied - --> $DIR/generic_underconstrained.rs:9:51 + --> $DIR/generic_underconstrained.rs:9:31 | -LL | fn underconstrain(_: T) -> Underconstrained { - | ___________________________________________________^ -LL | | -LL | | -LL | | unimplemented!() -LL | | } - | |_^ the trait `Trait` is not implemented for `T` +LL | fn underconstrain(_: T) -> Underconstrained { + | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained.rs:6:26 @@ -20,10 +15,15 @@ LL | fn underconstrain(_: T) -> Underconstrained { | +++++++ error[E0277]: the trait bound `T: Trait` is not satisfied - --> $DIR/generic_underconstrained.rs:9:31 + --> $DIR/generic_underconstrained.rs:9:51 | -LL | fn underconstrain(_: T) -> Underconstrained { - | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` +LL | fn underconstrain(_: T) -> Underconstrained { + | ___________________________________________________^ +LL | | +LL | | +LL | | unimplemented!() +LL | | } + | |_^ the trait `Trait` is not implemented for `T` | note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained.rs:6:26 diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr index 15d96191ba9e2..b3b9cbca96854 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -1,13 +1,8 @@ error[E0277]: `U` doesn't implement `Debug` - --> $DIR/generic_underconstrained2.rs:8:53 + --> $DIR/generic_underconstrained2.rs:8:33 | -LL | fn underconstrained(_: U) -> Underconstrained { - | _____________________________________________________^ -LL | | -LL | | -LL | | 5u32 -LL | | } - | |_^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` +LL | fn underconstrained(_: U) -> Underconstrained { + | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` | note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained2.rs:5:26 @@ -20,15 +15,10 @@ LL | fn underconstrained(_: U) -> Underconstrained { | +++++++++++++++++ error[E0277]: `V` doesn't implement `Debug` - --> $DIR/generic_underconstrained2.rs:17:64 + --> $DIR/generic_underconstrained2.rs:17:43 | -LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { - | ________________________________________________________________^ -LL | | -LL | | -LL | | 5u32 -LL | | } - | |_^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` +LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { + | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | note: required by a bound on the type alias `Underconstrained2` --> $DIR/generic_underconstrained2.rs:14:27 @@ -41,10 +31,15 @@ LL | fn underconstrained2(_: U, _: V) -> Underconstrained | +++++++++++++++++ error[E0277]: `U` doesn't implement `Debug` - --> $DIR/generic_underconstrained2.rs:8:33 + --> $DIR/generic_underconstrained2.rs:8:53 | -LL | fn underconstrained(_: U) -> Underconstrained { - | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` +LL | fn underconstrained(_: U) -> Underconstrained { + | _____________________________________________________^ +LL | | +LL | | +LL | | 5u32 +LL | | } + | |_^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` | note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained2.rs:5:26 @@ -57,10 +52,15 @@ LL | fn underconstrained(_: U) -> Underconstrained { | +++++++++++++++++ error[E0277]: `V` doesn't implement `Debug` - --> $DIR/generic_underconstrained2.rs:17:43 + --> $DIR/generic_underconstrained2.rs:17:64 | -LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { - | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` +LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { + | ________________________________________________________________^ +LL | | +LL | | +LL | | 5u32 +LL | | } + | |_^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | note: required by a bound on the type alias `Underconstrained2` --> $DIR/generic_underconstrained2.rs:14:27 diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr index 20afd687d507f..d807b2722680f 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr @@ -1,43 +1,3 @@ -error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature - --> $DIR/hkl_forbidden4.rs:19:10 - | -LL | async fn call(_f: F) - | ^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/hkl_forbidden4.rs:10:23 - | -LL | type FutNothing<'a> = impl 'a + Future; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature - --> $DIR/hkl_forbidden4.rs:19:1 - | -LL | / async fn call(_f: F) -LL | | -LL | | where -LL | | for<'any> F: FnMut(&'any mut ()) -> FutNothing<'any>, -... | -LL | | -LL | | } - | |_^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/hkl_forbidden4.rs:10:23 - | -LL | type FutNothing<'a> = impl 'a + Future; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: unconstrained opaque type - --> $DIR/hkl_forbidden4.rs:10:23 - | -LL | type FutNothing<'a> = impl 'a + Future; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `FutNothing` must be used in combination with a concrete type within the same module - error[E0792]: expected generic lifetime parameter, found `'any` --> $DIR/hkl_forbidden4.rs:15:5 | @@ -47,18 +7,6 @@ LL | LL | call(operation).await | ^^^^^^^^^^^^^^^ -error: concrete type differs from previous defining opaque type use - --> $DIR/hkl_forbidden4.rs:13:1 - | -LL | async fn operation(_: &mut ()) -> () { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `FutNothing<'_>`, got `{async fn body of operation()}` - | -note: previous use here - --> $DIR/hkl_forbidden4.rs:15:5 - | -LL | call(operation).await - | ^^^^^^^^^^^^^^^ - error[E0792]: expected generic lifetime parameter, found `'any` --> $DIR/hkl_forbidden4.rs:23:1 | @@ -71,6 +19,18 @@ LL | | LL | | } | |_^ -error: aborting due to 6 previous errors +error: concrete type differs from previous defining opaque type use + --> $DIR/hkl_forbidden4.rs:13:1 + | +LL | async fn operation(_: &mut ()) -> () { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `FutNothing<'_>`, got `{async fn body of operation()}` + | +note: previous use here + --> $DIR/hkl_forbidden4.rs:15:5 + | +LL | call(operation).await + | ^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr index 22c776e171c2f..1c286e0638086 100644 --- a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr @@ -1,35 +1,9 @@ -error: item does not constrain `DummyT::{opaque#0}`, but has it in its signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:28:8 - | -LL | fn new() -> Self { - | ^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:20:18 - | -LL | type DummyT = impl F; - | ^^^^^^ - -error: item does not constrain `DummyT::{opaque#0}`, but has it in its signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:44:8 - | -LL | fn my_index(self) -> Self::O { - | ^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:20:18 - | -LL | type DummyT = impl F; - | ^^^^^^ - error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:41:6 | LL | impl>>, U> MyIndex> for Scope { | ^ unconstrained type parameter -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr index f2e5e95b96f04..4e36efa2449cf 100644 --- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr @@ -1,17 +1,3 @@ -error[E0310]: the parameter type `A` may not live long enough - --> $DIR/implied_lifetime_wf_check4_static.rs:4:22 - | -LL | pub type Ty = impl Sized + 'static; - | ^^^^^^^^^^^^^^^^^^^^ - | | - | the parameter type `A` must be valid for the static lifetime... - | ...so that the type `A` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound - | -LL | pub type Ty = impl Sized + 'static; - | +++++++++ - error[E0310]: the parameter type `A` may not live long enough --> $DIR/implied_lifetime_wf_check4_static.rs:17:5 | @@ -26,6 +12,6 @@ help: consider adding an explicit lifetime bound LL | fn test() | +++++++++ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.stderr b/tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.stderr index 1274a8b60dea0..7ce4517fb1e9a 100644 --- a/tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.stderr +++ b/tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.stderr @@ -9,14 +9,6 @@ LL | fn bar<'a: 'a>() LL | let _: Self::Assoc<'a> = x; | ^^^^^^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/in-assoc-ty-early-bound2.rs:9:22 - | -LL | type Assoc<'a> = impl Sized; - | ^^^^^^^^^^ - | - = note: `Assoc` must be used in combination with a concrete type within the same impl - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/type-alias-impl-trait/in-where-clause.stderr b/tests/ui/type-alias-impl-trait/in-where-clause.stderr index f1361b47c56e6..5ac09e20b02c2 100644 --- a/tests/ui/type-alias-impl-trait/in-where-clause.stderr +++ b/tests/ui/type-alias-impl-trait/in-where-clause.stderr @@ -1,14 +1,25 @@ -error[E0391]: cycle detected when computing type of `Bar::{opaque#0}` - --> $DIR/in-where-clause.rs:5:12 +error[E0283]: type annotations needed: cannot satisfy `Bar: Send` + --> $DIR/in-where-clause.rs:12:9 | -LL | type Bar = impl Sized; - | ^^^^^^^^^^ +LL | [0; 1 + 2] + | ^^^^^ | -note: ...which requires computing type of opaque `Bar::{opaque#0}`... + = note: cannot satisfy `Bar: Send` +note: required by a bound in `foo` + --> $DIR/in-where-clause.rs:10:10 + | +LL | fn foo() -> Bar + | --- required by a bound in this function +LL | where +LL | Bar: Send, + | ^^^^ required by this bound in `foo` + +error[E0391]: cycle detected when computing type of opaque `Bar::{opaque#0}` --> $DIR/in-where-clause.rs:5:12 | LL | type Bar = impl Sized; | ^^^^^^^^^^ + | note: ...which requires type-checking `foo`... --> $DIR/in-where-clause.rs:8:1 | @@ -17,30 +28,15 @@ LL | | where LL | | Bar: Send, | |______________^ = note: ...which requires revealing opaque types in `[Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }]`... - = note: ...which again requires computing type of `Bar::{opaque#0}`, completing the cycle -note: cycle used when checking that `Bar::{opaque#0}` is well-formed +note: ...which requires computing type of `Bar::{opaque#0}`... --> $DIR/in-where-clause.rs:5:12 | LL | type Bar = impl Sized; | ^^^^^^^^^^ + = note: ...which again requires computing type of opaque `Bar::{opaque#0}`, completing the cycle + = note: cycle used when evaluating trait selection obligation `Bar: core::marker::Send` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0283]: type annotations needed: cannot satisfy `Bar: Send` - --> $DIR/in-where-clause.rs:12:9 - | -LL | [0; 1 + 2] - | ^^^^^ - | - = note: cannot satisfy `Bar: Send` -note: required by a bound in `foo` - --> $DIR/in-where-clause.rs:10:10 - | -LL | fn foo() -> Bar - | --- required by a bound in this function -LL | where -LL | Bar: Send, - | ^^^^ required by this bound in `foo` - error: aborting due to 2 previous errors Some errors have detailed explanations: E0283, E0391. diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr index 8b809ba014d96..d21215e70903b 100644 --- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr +++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr @@ -1,22 +1,19 @@ -error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits - --> $DIR/inference-cycle.rs:13:17 +error[E0391]: cycle detected when type-checking `m::bar` + --> $DIR/inference-cycle.rs:13:9 | LL | is_send(foo()); - | ------- ^^^^^ - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^ | - = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule -note: opaque type is declared here + = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`... +note: ...which requires computing type of opaque `m::Foo::{opaque#0}`... --> $DIR/inference-cycle.rs:5:20 | LL | pub type Foo = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `is_send` - --> $DIR/inference-cycle.rs:21:19 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` + = note: ...which again requires type-checking `m::bar`, completing the cycle + = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/issue-109054.stderr b/tests/ui/type-alias-impl-trait/issue-109054.stderr index 2a4aa63bb8ca1..ede31e23f9730 100644 --- a/tests/ui/type-alias-impl-trait/issue-109054.stderr +++ b/tests/ui/type-alias-impl-trait/issue-109054.stderr @@ -1,16 +1,3 @@ -error: item does not constrain `ReturnType::{opaque#0}`, but has it in its signature - --> $DIR/issue-109054.rs:13:8 - | -LL | fn deref(&self) -> &Self::Target { - | ^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/issue-109054.rs:7:23 - | -LL | type ReturnType<'a> = impl std::future::Future + 'a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0792]: expected generic lifetime parameter, found `'_` --> $DIR/issue-109054.rs:19:9 | @@ -20,6 +7,6 @@ LL | type ReturnType<'a> = impl std::future::Future + 'a; LL | &inner | ^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr index 0f0b6a10aea7a..ac580866704d7 100644 --- a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr +++ b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr @@ -10,75 +10,33 @@ note: for this opaque type LL | type Bug = impl Fn(T) -> U + Copy; | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0391]: cycle detected when computing type of `Bug::{opaque#0}` - --> $DIR/issue-53092-2.rs:4:18 - | -LL | type Bug = impl Fn(T) -> U + Copy; - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires computing type of opaque `Bug::{opaque#0}`... - --> $DIR/issue-53092-2.rs:4:18 - | -LL | type Bug = impl Fn(T) -> U + Copy; - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires type-checking `CONST_BUG`... +error[E0391]: cycle detected when type-checking `CONST_BUG` --> $DIR/issue-53092-2.rs:6:1 | LL | const CONST_BUG: Bug = unsafe { std::mem::transmute(|_: u8| ()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | = note: ...which requires computing layout of `Bug`... = note: ...which requires normalizing `Bug`... - = note: ...which again requires computing type of `Bug::{opaque#0}`, completing the cycle -note: cycle used when checking that `Bug::{opaque#0}` is well-formed +note: ...which requires computing type of `Bug::{opaque#0}`... --> $DIR/issue-53092-2.rs:4:18 | LL | type Bug = impl Fn(T) -> U + Copy; | ^^^^^^^^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: item does not constrain `Bug::{opaque#0}`, but has it in its signature - --> $DIR/issue-53092-2.rs:6:7 - | -LL | const CONST_BUG: Bug = unsafe { std::mem::transmute(|_: u8| ()) }; - | ^^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature +note: ...which requires computing type of opaque `Bug::{opaque#0}`... --> $DIR/issue-53092-2.rs:4:18 | LL | type Bug = impl Fn(T) -> U + Copy; | ^^^^^^^^^^^^^^^^^^^^^^ - -error: item does not constrain `Bug::{opaque#0}`, but has it in its signature - --> $DIR/issue-53092-2.rs:6:61 + = note: ...which again requires type-checking `CONST_BUG`, completing the cycle +note: cycle used when checking that `CONST_BUG` is well-formed + --> $DIR/issue-53092-2.rs:6:1 | LL | const CONST_BUG: Bug = unsafe { std::mem::transmute(|_: u8| ()) }; - | ^^^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/issue-53092-2.rs:4:18 - | -LL | type Bug = impl Fn(T) -> U + Copy; - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `U: From` is not satisfied - --> $DIR/issue-53092-2.rs:12:5 - | -LL | |x| x.into() - | ^^^^^^^^^^^^ the trait `From` is not implemented for `U` - | -note: required by a bound in `make_bug` - --> $DIR/issue-53092-2.rs:11:19 - | -LL | fn make_bug>() -> Bug { - | ^^^^^^^ required by this bound in `make_bug` -help: consider restricting type parameter `U` - | -LL | type Bug> = impl Fn(T) -> U + Copy; - | +++++++++++++++++++++++ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0391, E0792. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0391, E0792. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr index 2b064dcfc31a5..ad4de003a0a01 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr @@ -1,16 +1,3 @@ -error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/issue-84660-unsoundness.rs:22:8 - | -LL | fn convert(_i: In) -> Self::Out { - | ^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/issue-84660-unsoundness.rs:12:12 - | -LL | type Bar = impl Foo; - | ^^^^^^^^ - error[E0119]: conflicting implementations of trait `Trait` --> $DIR/issue-84660-unsoundness.rs:29:1 | @@ -20,6 +7,6 @@ LL | impl Trait for Out { LL | impl Trait<(), In> for Out { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr index 5a728a00138c8..e33102f687c53 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr @@ -1,3 +1,12 @@ +error[E0119]: conflicting implementations of trait `Trait` + --> $DIR/issue-84660-unsoundness.rs:29:1 + | +LL | impl Trait for Out { + | ------------------------------------ first implementation here +... +LL | impl Trait<(), In> for Out { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + error[E0284]: type annotations needed: cannot satisfy `Bar == _` --> $DIR/issue-84660-unsoundness.rs:22:37 | @@ -9,15 +18,6 @@ LL | | unreachable!(); LL | | } | |_____^ cannot satisfy `Bar == _` -error[E0119]: conflicting implementations of trait `Trait` - --> $DIR/issue-84660-unsoundness.rs:29:1 - | -LL | impl Trait for Out { - | ------------------------------------ first implementation here -... -LL | impl Trait<(), In> for Out { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0119, E0284. diff --git a/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr b/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr index ca15b134a9947..e59ad6ad6c9f9 100644 --- a/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr +++ b/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr @@ -25,23 +25,7 @@ help: consider importing this struct LL + use std::thread::LocalKey; | -error: unconstrained opaque type - --> $DIR/nested-impl-trait-in-tait.rs:3:17 - | -LL | pub type Tait = impl Iterator; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Tait` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/nested-impl-trait-in-tait.rs:3:54 - | -LL | pub type Tait = impl Iterator; - | ^^^^^^^^^^^^^ - | - = note: `Tait` must be used in combination with a concrete type within the same module - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0261, E0412. For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/type-alias-impl-trait/nested-in-anon-const.stderr b/tests/ui/type-alias-impl-trait/nested-in-anon-const.stderr index d0fe920b35f4a..892e4cca49190 100644 --- a/tests/ui/type-alias-impl-trait/nested-in-anon-const.stderr +++ b/tests/ui/type-alias-impl-trait/nested-in-anon-const.stderr @@ -1,11 +1,3 @@ -error: unconstrained opaque type - --> $DIR/nested-in-anon-const.rs:13:33 - | -LL | type B = impl Sized; - | ^^^^^^^^^^ - | - = note: `B` must be used in combination with a concrete type within the same item - error[E0308]: mismatched types --> $DIR/nested-in-anon-const.rs:12:17 | @@ -15,6 +7,6 @@ LL | | LL | | }, | |_________________^ expected `usize`, found `()` -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/nested.stderr b/tests/ui/type-alias-impl-trait/nested.stderr index ca1cf6058ea95..cfcf3d2c07434 100644 --- a/tests/ui/type-alias-impl-trait/nested.stderr +++ b/tests/ui/type-alias-impl-trait/nested.stderr @@ -1,16 +1,3 @@ -error: item does not constrain `Foo::{opaque#0}`, but has it in its signature - --> $DIR/nested.rs:10:4 - | -LL | fn bar() -> Bar { - | ^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/nested.rs:3:12 - | -LL | type Foo = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ - error[E0277]: `Bar` doesn't implement `Debug` --> $DIR/nested.rs:16:22 | @@ -20,6 +7,6 @@ LL | println!("{:?}", bar()); = help: the trait `Debug` is not implemented for `Bar` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr index 889cff1ba09eb..e06d6b9dfa73c 100644 --- a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr +++ b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr @@ -1,16 +1,3 @@ -error: item does not constrain `Foo::{opaque#0}`, but has it in its signature - --> $DIR/nested_type_alias_impl_trait.rs:13:12 - | -LL | pub fn get_foot(_: Foo) -> Foot { - | ^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/nested_type_alias_impl_trait.rs:6:20 - | -LL | pub type Foo = impl Debug; - | ^^^^^^^^^^ - error: opaque type's hidden type cannot be another opaque type from the same scope --> $DIR/nested_type_alias_impl_trait.rs:15:9 | @@ -28,5 +15,5 @@ note: opaque type being used as hidden type LL | pub type Foo = impl Debug; | ^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr index a40dac06a01c3..ae6a664ebc46c 100644 --- a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr @@ -1,27 +1,3 @@ -error: concrete type differs from previous defining opaque type use - --> $DIR/normalize-hidden-types.rs:26:20 - | -LL | fn define() -> Opaque { - | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` - | -note: previous use here - --> $DIR/normalize-hidden-types.rs:27:9 - | -LL | dyn_hoops::<_>(0) - | ^^^^^^^^^^^^^^^^^ - -error: concrete type differs from previous defining opaque type use - --> $DIR/normalize-hidden-types.rs:34:22 - | -LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } - | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` - | -note: previous use here - --> $DIR/normalize-hidden-types.rs:34:31 - | -LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } - | ^^^^^^^^^^^^^^^^^ - error[E0308]: mismatched types --> $DIR/normalize-hidden-types.rs:43:25 | @@ -38,18 +14,6 @@ LL | let _: Opaque = dyn_hoops::(0); = help: consider constraining the associated type `::Gat<'_>` to `()` or calling a method that returns `::Gat<'_>` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html -error: concrete type differs from previous defining opaque type use - --> $DIR/normalize-hidden-types.rs:52:25 - | -LL | let _: Opaque = dyn_hoops::<_>(0); - | ^^^^^^^^^^^^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` - | -note: previous use here - --> $DIR/normalize-hidden-types.rs:53:9 - | -LL | None - | ^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr index 9829c58cf73b7..a7d0d971a57bf 100644 --- a/tests/ui/type-alias-impl-trait/reveal_local.stderr +++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr @@ -1,20 +1,18 @@ -error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits - --> $DIR/reveal_local.rs:12:15 +error[E0391]: cycle detected when type-checking `not_good` + --> $DIR/reveal_local.rs:12:5 | LL | is_send::(); - | ^^^ + | ^^^^^^^^^^^^^^^^ | - = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule -note: opaque type is declared here + = note: ...which requires evaluating trait selection obligation `Foo: core::marker::Send`... +note: ...which requires computing type of opaque `Foo::{opaque#0}`... --> $DIR/reveal_local.rs:5:12 | LL | type Foo = impl Debug; | ^^^^^^^^^^ -note: required by a bound in `is_send` - --> $DIR/reveal_local.rs:7:15 - | -LL | fn is_send() {} - | ^^^^ required by this bound in `is_send` + = note: ...which again requires type-checking `not_good`, completing the cycle + = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0283]: type annotations needed: cannot satisfy `Foo: Send` --> $DIR/reveal_local.rs:22:15 @@ -31,4 +29,5 @@ LL | fn is_send() {} error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0283, E0391. +For more information about an error, try `rustc --explain E0283`. diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error-4.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error-4.stderr index aedb78bf5e7a1..99646aa4d1b2c 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error-4.stderr +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error-4.stderr @@ -10,18 +10,6 @@ note: required by a bound on the type alias `Ty` LL | Ty: Id, | ^^^^^^^^^^^^^^ required by this bound -error[E0275]: overflow evaluating the requirement `Ty: Id` - --> $DIR/type-alias-impl-trait-with-cycle-error-4.rs:15:19 - | -LL | fn define() -> Ty {} - | ^^ - | -note: required by a bound on the type alias `Ty` - --> $DIR/type-alias-impl-trait-with-cycle-error-4.rs:13:9 - | -LL | Ty: Id, - | ^^^^^^^^^^^^^^ required by this bound - error[E0275]: overflow evaluating the requirement `Ty: Id` --> $DIR/type-alias-impl-trait-with-cycle-error-4.rs:15:16 | @@ -34,6 +22,6 @@ note: required by a bound on the type alias `Ty` LL | Ty: Id, | ^^^^^^^^^^^^^^ required by this bound -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type-alias-impl-trait/variance.stderr b/tests/ui/type-alias-impl-trait/variance.stderr index e5ced7a498171..78f32c772ef5c 100644 --- a/tests/ui/type-alias-impl-trait/variance.stderr +++ b/tests/ui/type-alias-impl-trait/variance.stderr @@ -22,214 +22,6 @@ note: lifetime declared here LL | type Captured<'a> = dyn for<'b> Iterator>; | ^^ -error: unconstrained opaque type - --> $DIR/variance.rs:8:29 - | -LL | type NotCapturedEarly<'a> = impl Sized; - | ^^^^^^^^^^ - | - = note: `NotCapturedEarly` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/variance.rs:11:26 - | -LL | type CapturedEarly<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `CapturedEarly` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/variance.rs:14:56 - | -LL | type NotCapturedLate<'a> = dyn for<'b> Iterator; - | ^^^^^^^^^^ - | - = note: `NotCapturedLate` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/variance.rs:18:49 - | -LL | type Captured<'a> = dyn for<'b> Iterator>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Captured` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/variance.rs:22:27 - | -LL | type Bar<'a, 'b: 'b, T> = impl Sized; - | ^^^^^^^^^^ - | - = note: `Bar` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/variance.rs:34:32 - | -LL | type ImplicitCapture<'a> = impl Sized; - | ^^^^^^^^^^ - | - = note: `ImplicitCapture` must be used in combination with a concrete type within the same impl - -error: unconstrained opaque type - --> $DIR/variance.rs:37:42 - | -LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `ExplicitCaptureFromHeader` must be used in combination with a concrete type within the same impl - -error: unconstrained opaque type - --> $DIR/variance.rs:40:39 - | -LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl - -error: unconstrained opaque type - --> $DIR/variance.rs:45:32 - | -LL | type ImplicitCapture<'a> = impl Sized; - | ^^^^^^^^^^ - | - = note: `ImplicitCapture` must be used in combination with a concrete type within the same impl - -error: unconstrained opaque type - --> $DIR/variance.rs:48:42 - | -LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `ExplicitCaptureFromHeader` must be used in combination with a concrete type within the same impl - -error: unconstrained opaque type - --> $DIR/variance.rs:51:39 - | -LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl - -error: [*, o] - --> $DIR/variance.rs:8:29 - | -LL | type NotCapturedEarly<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [*, o] - --> $DIR/variance.rs:11:26 - | -LL | type CapturedEarly<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, o, o] - --> $DIR/variance.rs:14:56 - | -LL | type NotCapturedLate<'a> = dyn for<'b> Iterator; - | ^^^^^^^^^^ - -error: [*, o, o] - --> $DIR/variance.rs:18:49 - | -LL | type Captured<'a> = dyn for<'b> Iterator>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o, o] - --> $DIR/variance.rs:22:27 - | -LL | type Bar<'a, 'b: 'b, T> = impl Sized; - | ^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:34:32 - | -LL | type ImplicitCapture<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:37:42 - | -LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:40:39 - | -LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:45:32 - | -LL | type ImplicitCapture<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:48:42 - | -LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:51:39 - | -LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, o] - --> $DIR/variance.rs:62:5 - | -LL | / impl Nesting< -LL | | 'a, -LL | | Output = impl Nesting< -LL | | 'a, -... | -LL | | >, -LL | | >; - | |_____^ - -error: [*, o] - --> $DIR/variance.rs:64:18 - | -LL | Output = impl Nesting< - | __________________^ -LL | | 'a, -LL | | Output = impl Nesting< -LL | | 'a, -... | -LL | | >, -LL | | >, - | |_________^ - -error: [*, o] - --> $DIR/variance.rs:66:22 - | -LL | Output = impl Nesting< - | ______________________^ -LL | | 'a, -LL | | Output = impl Nesting< -LL | | 'a, -LL | | Output = impl Nesting<'a> -LL | | > -LL | | >, - | |_____________^ - -error: [*, o] - --> $DIR/variance.rs:68:26 - | -LL | Output = impl Nesting< - | __________________________^ -LL | | 'a, -LL | | Output = impl Nesting<'a> -LL | | > - | |_________________^ - -error: [*, o] - --> $DIR/variance.rs:70:30 - | -LL | Output = impl Nesting<'a> - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 29 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0657`.