]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #99028 - tmiasko:inline, r=estebank
authorbors <bors@rust-lang.org>
Sat, 9 Jul 2022 04:34:51 +0000 (04:34 +0000)
committerbors <bors@rust-lang.org>
Sat, 9 Jul 2022 04:34:51 +0000 (04:34 +0000)
Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.

571 files changed:
Cargo.lock
compiler/rustc_ast/src/ast.rs
compiler/rustc_ast_lowering/src/asm.rs
compiler/rustc_ast_lowering/src/block.rs
compiler/rustc_ast_lowering/src/expr.rs
compiler/rustc_ast_lowering/src/item.rs
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_ast_lowering/src/path.rs
compiler/rustc_borrowck/src/borrowck_errors.rs
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
compiler/rustc_borrowck/src/lib.rs
compiler/rustc_borrowck/src/region_infer/mod.rs
compiler/rustc_borrowck/src/region_infer/opaque_types.rs
compiler/rustc_borrowck/src/universal_regions.rs
compiler/rustc_builtin_macros/src/deriving/clone.rs
compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs
compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs
compiler/rustc_builtin_macros/src/deriving/debug.rs
compiler/rustc_builtin_macros/src/deriving/decodable.rs
compiler/rustc_builtin_macros/src/deriving/default.rs
compiler/rustc_builtin_macros/src/deriving/encodable.rs
compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
compiler/rustc_builtin_macros/src/deriving/hash.rs
compiler/rustc_codegen_gcc/src/common.rs
compiler/rustc_codegen_gcc/src/context.rs
compiler/rustc_codegen_gcc/src/lib.rs
compiler/rustc_codegen_llvm/src/common.rs
compiler/rustc_codegen_llvm/src/context.rs
compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs
compiler/rustc_codegen_llvm/src/lib.rs
compiler/rustc_codegen_ssa/src/back/archive.rs
compiler/rustc_codegen_ssa/src/back/command.rs
compiler/rustc_codegen_ssa/src/back/link.rs
compiler/rustc_codegen_ssa/src/back/linker.rs
compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
compiler/rustc_codegen_ssa/src/mir/block.rs
compiler/rustc_codegen_ssa/src/traits/consts.rs
compiler/rustc_const_eval/src/errors.rs [new file with mode: 0644]
compiler/rustc_const_eval/src/interpret/validity.rs
compiler/rustc_const_eval/src/lib.rs
compiler/rustc_const_eval/src/transform/check_consts/check.rs
compiler/rustc_const_eval/src/transform/check_consts/ops.rs
compiler/rustc_data_structures/src/lib.rs
compiler/rustc_data_structures/src/sync.rs
compiler/rustc_error_messages/locales/en-US/builtin_macros.ftl
compiler/rustc_error_messages/locales/en-US/const_eval.ftl [new file with mode: 0644]
compiler/rustc_error_messages/src/lib.rs
compiler/rustc_errors/Cargo.toml
compiler/rustc_errors/src/diagnostic.rs
compiler/rustc_errors/src/emitter.rs
compiler/rustc_errors/src/json.rs
compiler/rustc_hir/Cargo.toml
compiler/rustc_hir/src/arena.rs
compiler/rustc_hir/src/hir.rs
compiler/rustc_hir/src/intravisit.rs
compiler/rustc_hir/src/lib.rs
compiler/rustc_incremental/src/assert_dep_graph.rs
compiler/rustc_infer/src/infer/free_regions.rs
compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
compiler/rustc_infer/src/infer/mod.rs
compiler/rustc_infer/src/infer/opaque_types.rs
compiler/rustc_infer/src/infer/resolve.rs
compiler/rustc_infer/src/infer/undo_log.rs
compiler/rustc_infer/src/traits/project.rs
compiler/rustc_interface/src/passes.rs
compiler/rustc_interface/src/queries.rs
compiler/rustc_interface/src/tests.rs
compiler/rustc_lint/src/late.rs
compiler/rustc_lint/src/lib.rs
compiler/rustc_macros/src/diagnostics/fluent.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_middle/src/dep_graph/dep_node.rs
compiler/rustc_middle/src/dep_graph/mod.rs
compiler/rustc_middle/src/hir/map/mod.rs
compiler/rustc_middle/src/hir/mod.rs
compiler/rustc_middle/src/hir/nested_filter.rs
compiler/rustc_middle/src/mir/interpret/allocation.rs
compiler/rustc_middle/src/mir/interpret/error.rs
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/query/mod.rs
compiler/rustc_middle/src/traits/mod.rs
compiler/rustc_middle/src/traits/select.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/mod.rs
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/util.rs
compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
compiler/rustc_mir_transform/src/const_prop.rs
compiler/rustc_mir_transform/src/coverage/mod.rs
compiler/rustc_mir_transform/src/inline.rs
compiler/rustc_mir_transform/src/lib.rs
compiler/rustc_parse/src/parser/item.rs
compiler/rustc_passes/src/check_attr.rs
compiler/rustc_passes/src/check_const.rs
compiler/rustc_passes/src/hir_id_validator.rs
compiler/rustc_passes/src/liveness.rs
compiler/rustc_passes/src/loops.rs
compiler/rustc_passes/src/naked_functions.rs
compiler/rustc_passes/src/stability.rs
compiler/rustc_query_impl/src/on_disk_cache.rs
compiler/rustc_query_impl/src/plumbing.rs
compiler/rustc_query_system/src/dep_graph/dep_node.rs
compiler/rustc_query_system/src/dep_graph/graph.rs
compiler/rustc_query_system/src/dep_graph/mod.rs
compiler/rustc_query_system/src/ich/hcx.rs
compiler/rustc_query_system/src/query/plumbing.rs
compiler/rustc_resolve/src/diagnostics.rs
compiler/rustc_session/src/config.rs
compiler/rustc_session/src/options.rs
compiler/rustc_session/src/session.rs
compiler/rustc_span/src/symbol.rs
compiler/rustc_symbol_mangling/src/legacy.rs
compiler/rustc_trait_selection/src/lib.rs
compiler/rustc_trait_selection/src/opaque_types.rs [deleted file]
compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_trait_selection/src/traits/structural_match.rs
compiler/rustc_trait_selection/src/traits/wf.rs
compiler/rustc_type_ir/src/lib.rs
compiler/rustc_typeck/src/check/callee.rs
compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs
compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_build.rs
compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_visualize.rs
compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs
compiler/rustc_typeck/src/check/method/confirm.rs
compiler/rustc_typeck/src/check/method/suggest.rs
compiler/rustc_typeck/src/check/upvar.rs
compiler/rustc_typeck/src/check/wfcheck.rs
compiler/rustc_typeck/src/collect.rs
compiler/rustc_typeck/src/hir_wf_check.rs
library/core/src/future/into_future.rs
library/core/src/future/mod.rs
library/std/src/os/windows/process.rs
library/std/src/process.rs
library/std/src/sys/windows/process.rs
src/bootstrap/builder.rs
src/bootstrap/compile.rs
src/bootstrap/config.rs
src/bootstrap/flags.rs
src/bootstrap/format.rs
src/bootstrap/lib.rs
src/bootstrap/sanity.rs
src/bootstrap/setup.rs
src/bootstrap/test.rs
src/bootstrap/tool.rs
src/bootstrap/toolstate.rs
src/bootstrap/util.rs
src/librustdoc/config.rs
src/librustdoc/core.rs
src/librustdoc/html/format.rs
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/print_item.rs
src/librustdoc/lib.rs
src/librustdoc/passes/check_code_block_syntax.rs
src/librustdoc/scrape_examples.rs
src/test/codegen/consts.rs
src/test/codegen/generator-debug-msvc.rs
src/test/codegen/generator-debug.rs
src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir
src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir
src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir
src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
src/test/mir-opt/inline/inline_generator.main.Inline.diff
src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir
src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.closure.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.generator.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.yield.txt
src/test/run-make/issue-88756-default-output/output-default.stdout
src/test/rustdoc-ui/diagnostic-width.rs [new file with mode: 0644]
src/test/rustdoc-ui/diagnostic-width.stderr [new file with mode: 0644]
src/test/ui/asm/aarch64/type-check-2-2.rs
src/test/ui/asm/aarch64/type-check-2-2.stderr
src/test/ui/asm/aarch64/type-check-2.stderr
src/test/ui/asm/x86_64/type-check-2.stderr
src/test/ui/asm/x86_64/type-check-5.rs
src/test/ui/asm/x86_64/type-check-5.stderr
src/test/ui/associated-item/associated-item-enum.stderr
src/test/ui/async-await/await-into-future.rs
src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
src/test/ui/async-await/issue-70935-complex-spans.normal.stderr
src/test/ui/async-await/issues/issue-62009-1.stderr
src/test/ui/async-await/no-non-guaranteed-initialization.rs
src/test/ui/async-await/no-non-guaranteed-initialization.stderr
src/test/ui/async-await/partial-initialization-across-await.rs
src/test/ui/async-await/partial-initialization-across-await.stderr
src/test/ui/async-await/pin-needed-to-poll.stderr
src/test/ui/block-result/issue-20862.stderr
src/test/ui/bogus-tag.stderr
src/test/ui/borrowck/assign_mutable_fields.stderr
src/test/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.stderr
src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr
src/test/ui/borrowck/borrow-raw-address-of-mutability.stderr
src/test/ui/borrowck/borrowck-and-init.rs
src/test/ui/borrowck/borrowck-and-init.stderr
src/test/ui/borrowck/borrowck-block-unint.rs
src/test/ui/borrowck/borrowck-block-unint.stderr
src/test/ui/borrowck/borrowck-break-uninit-2.rs
src/test/ui/borrowck/borrowck-break-uninit-2.stderr
src/test/ui/borrowck/borrowck-break-uninit.rs
src/test/ui/borrowck/borrowck-break-uninit.stderr
src/test/ui/borrowck/borrowck-field-sensitivity.rs
src/test/ui/borrowck/borrowck-field-sensitivity.stderr
src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.rs [new file with mode: 0644]
src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.stderr [new file with mode: 0644]
src/test/ui/borrowck/borrowck-if-no-else.rs
src/test/ui/borrowck/borrowck-if-no-else.stderr
src/test/ui/borrowck/borrowck-if-with-else.rs
src/test/ui/borrowck/borrowck-if-with-else.stderr
src/test/ui/borrowck/borrowck-in-static.stderr
src/test/ui/borrowck/borrowck-init-in-called-fn-expr.rs
src/test/ui/borrowck/borrowck-init-in-called-fn-expr.stderr
src/test/ui/borrowck/borrowck-init-in-fn-expr.rs
src/test/ui/borrowck/borrowck-init-in-fn-expr.stderr
src/test/ui/borrowck/borrowck-init-in-fru.rs
src/test/ui/borrowck/borrowck-init-in-fru.stderr
src/test/ui/borrowck/borrowck-init-op-equal.rs
src/test/ui/borrowck/borrowck-init-op-equal.stderr
src/test/ui/borrowck/borrowck-init-plus-equal.rs
src/test/ui/borrowck/borrowck-init-plus-equal.stderr
src/test/ui/borrowck/borrowck-move-by-capture.stderr
src/test/ui/borrowck/borrowck-or-init.rs
src/test/ui/borrowck/borrowck-or-init.stderr
src/test/ui/borrowck/borrowck-partial-reinit-4.rs
src/test/ui/borrowck/borrowck-partial-reinit-4.stderr
src/test/ui/borrowck/borrowck-return.rs
src/test/ui/borrowck/borrowck-return.stderr
src/test/ui/borrowck/borrowck-storage-dead.stderr
src/test/ui/borrowck/borrowck-uninit-after-item.rs
src/test/ui/borrowck/borrowck-uninit-after-item.stderr
src/test/ui/borrowck/borrowck-uninit-field-access.stderr
src/test/ui/borrowck/borrowck-uninit-in-assignop.rs
src/test/ui/borrowck/borrowck-uninit-in-assignop.stderr
src/test/ui/borrowck/borrowck-uninit-ref-chain.rs
src/test/ui/borrowck/borrowck-uninit-ref-chain.stderr
src/test/ui/borrowck/borrowck-uninit.rs
src/test/ui/borrowck/borrowck-uninit.stderr
src/test/ui/borrowck/borrowck-union-uninitialized.rs
src/test/ui/borrowck/borrowck-union-uninitialized.stderr
src/test/ui/borrowck/borrowck-use-in-index-lvalue.stderr
src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr
src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.stderr
src/test/ui/borrowck/borrowck-while-break.rs
src/test/ui/borrowck/borrowck-while-break.stderr
src/test/ui/borrowck/borrowck-while-cond.rs
src/test/ui/borrowck/borrowck-while-cond.stderr
src/test/ui/borrowck/borrowck-while.rs
src/test/ui/borrowck/borrowck-while.stderr
src/test/ui/borrowck/disallow-possibly-uninitialized.rs
src/test/ui/borrowck/disallow-possibly-uninitialized.stderr
src/test/ui/borrowck/issue-24267-flow-exit.rs
src/test/ui/borrowck/issue-24267-flow-exit.stderr
src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr
src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs
src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.stderr
src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs
src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.stderr
src/test/ui/borrowck/issue-62107-match-arm-scopes.rs
src/test/ui/borrowck/issue-62107-match-arm-scopes.stderr
src/test/ui/borrowck/issue-81899.stderr
src/test/ui/borrowck/issue-87456-point-to-closure.stderr
src/test/ui/borrowck/issue-88434-minimal-example.stderr
src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr
src/test/ui/borrowck/mutability-errors.stderr
src/test/ui/borrowck/reassignment_immutable_fields.stderr
src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr
src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr
src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr
src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.rs
src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr
src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr
src/test/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr
src/test/ui/closures/2229_closure_analysis/migrations/macro.stderr
src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr
src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr
src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr
src/test/ui/closures/closure-move-sync.stderr
src/test/ui/closures/closure-no-fn-1.stderr
src/test/ui/closures/closure-no-fn-2.stderr
src/test/ui/closures/closure-no-fn-3.stderr
src/test/ui/closures/closure-no-fn-4.stderr
src/test/ui/closures/closure-no-fn-5.stderr
src/test/ui/closures/closure-reform-bad.stderr
src/test/ui/closures/closure-wrong-kind.stderr
src/test/ui/closures/closure_cap_coerce_many_fail.stderr
src/test/ui/closures/print/closure-print-generic-1.stderr
src/test/ui/closures/print/closure-print-generic-2.stderr
src/test/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr
src/test/ui/closures/print/closure-print-generic-verbose-2.stderr
src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr
src/test/ui/confuse-field-and-method/issue-18343.stderr
src/test/ui/confuse-field-and-method/issue-2392.stderr
src/test/ui/confuse-field-and-method/issue-32128.stderr
src/test/ui/confuse-field-and-method/issue-33784.stderr
src/test/ui/confuse-field-and-method/private-field.stderr
src/test/ui/const-generics/const-generic-default-wont-borrowck.rs
src/test/ui/const-generics/const-generic-default-wont-borrowck.stderr
src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr
src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr
src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr
src/test/ui/const-generics/issue-70408.rs [new file with mode: 0644]
src/test/ui/const-generics/issue-80471.rs [new file with mode: 0644]
src/test/ui/const-generics/issue-80471.stderr [new file with mode: 0644]
src/test/ui/consts/const-needs_drop-monomorphic.stderr
src/test/ui/consts/issue-78655.rs
src/test/ui/consts/issue-78655.stderr
src/test/ui/copy-a-resource.stderr
src/test/ui/dep-graph/dep-graph-struct-signature.stderr
src/test/ui/dep-graph/dep-graph-type-alias.stderr
src/test/ui/derives/derive-assoc-type-not-impl.stderr
src/test/ui/derives/issue-91492.stderr
src/test/ui/derives/issue-91550.stderr
src/test/ui/deriving/deriving-all-codegen.rs
src/test/ui/deriving/deriving-all-codegen.stdout
src/test/ui/diagnostic-width/flag-human.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/flag-human.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/flag-json.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/flag-json.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/non-whitespace-trimming-2.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/non-whitespace-trimming-2.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/non-whitespace-trimming-unicode.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/non-whitespace-trimming.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/non-whitespace-trimming.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/tabs-trimming.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/tabs-trimming.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/whitespace-trimming-2.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/whitespace-trimming-2.stderr [new file with mode: 0644]
src/test/ui/diagnostic-width/whitespace-trimming.rs [new file with mode: 0644]
src/test/ui/diagnostic-width/whitespace-trimming.stderr [new file with mode: 0644]
src/test/ui/did_you_mean/issue-40006.stderr
src/test/ui/dont-suggest-private-trait-method.stderr
src/test/ui/drop/repeat-drop-2.rs
src/test/ui/drop/repeat-drop-2.stderr
src/test/ui/enum/suggest-default-attribute.rs
src/test/ui/enum/suggest-default-attribute.stderr
src/test/ui/error-codes/E0599.stderr
src/test/ui/fn/fn-closure-mutable-capture.rs
src/test/ui/fn/fn-closure-mutable-capture.stderr
src/test/ui/functions-closures/fn-help-with-err.stderr
src/test/ui/generator/drop-yield-twice.stderr
src/test/ui/generator/generator-yielding-or-returning-itself.stderr
src/test/ui/generator/issue-68112.stderr
src/test/ui/generator/not-send-sync.stderr
src/test/ui/generator/partial-drop.stderr
src/test/ui/generator/partial-initialization-across-yield.rs
src/test/ui/generator/partial-initialization-across-yield.stderr
src/test/ui/generator/print/generator-print-verbose-1.stderr
src/test/ui/generator/print/generator-print-verbose-2.stderr
src/test/ui/generator/static-not-unpin.stderr
src/test/ui/generator/type-mismatch-signature-deduction.stderr
src/test/ui/generic-associated-types/method-unsatified-assoc-type-predicate.stderr
src/test/ui/higher-rank-trait-bounds/issue-59311.stderr
src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr
src/test/ui/hrtb/issue-30786.stderr
src/test/ui/hrtb/issue-62203-hrtb-ice.stderr
src/test/ui/impl-trait/auto-trait-leak.rs
src/test/ui/impl-trait/auto-trait-leak.stderr
src/test/ui/impl-trait/auto-trait-leak2.stderr
src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr
src/test/ui/impl-trait/issues/issue-62742.stderr
src/test/ui/impl-trait/issues/issue-74282.stderr
src/test/ui/impl-trait/method-suggestion-no-duplication.stderr
src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
src/test/ui/impl-trait/nested-return-type2-tait.stderr
src/test/ui/impl-trait/nested-return-type2-tait2.stderr
src/test/ui/impl-trait/nested-return-type2-tait3.stderr
src/test/ui/impl-trait/nested-return-type2.stderr
src/test/ui/impl-trait/no-method-suggested-traits.stderr
src/test/ui/impl-trait/recursive-impl-trait-type-indirect.stderr
src/test/ui/impl-trait/static-return-lifetime-infered.stderr
src/test/ui/infinite/infinite-autoderef.stderr
src/test/ui/interior-mutability/interior-mutability.stderr
src/test/ui/intrinsics/const-eval-select-bad.stderr
src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr
src/test/ui/issues/issue-12127.stderr
src/test/ui/issues/issue-19692.stderr
src/test/ui/issues/issue-21600.stderr
src/test/ui/issues/issue-21974.stderr
src/test/ui/issues/issue-22933-2.stderr
src/test/ui/issues/issue-23173.stderr
src/test/ui/issues/issue-23217.stderr
src/test/ui/issues/issue-24036.stderr
src/test/ui/issues/issue-24424.stderr
src/test/ui/issues/issue-2823.stderr
src/test/ui/issues/issue-28971.stderr
src/test/ui/issues/issue-3044.stderr
src/test/ui/issues/issue-31173.stderr
src/test/ui/issues/issue-41880.stderr
src/test/ui/issues/issue-4335.stderr
src/test/ui/issues/issue-48838.stderr
src/test/ui/issues/issue-50600.stderr
src/test/ui/issues/issue-50688.stderr
src/test/ui/issues/issue-51154.stderr
src/test/ui/issues/issue-64430.stderr
src/test/ui/issues/issue-7950.stderr
src/test/ui/kindck/kindck-nonsendable-1.stderr
src/test/ui/lifetimes/issue-34979.stderr
src/test/ui/lifetimes/issue-79187-2.stderr
src/test/ui/lifetimes/issue-79187.stderr
src/test/ui/lint/trivial_casts.stderr
src/test/ui/loops/loop-proper-liveness.rs
src/test/ui/loops/loop-proper-liveness.stderr
src/test/ui/methods/method-call-err-msg.stderr
src/test/ui/methods/method-missing-call.stderr
src/test/ui/methods/method-not-found-generic-arg-elision.stderr
src/test/ui/mir/drop-elaboration-after-borrowck-error.rs
src/test/ui/mir/drop-elaboration-after-borrowck-error.stderr
src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
src/test/ui/mismatched_types/closure-mismatch.stderr
src/test/ui/mismatched_types/issue-36053-2.stderr
src/test/ui/moves/issue-72649-uninit-in-loop.rs
src/test/ui/moves/issue-72649-uninit-in-loop.stderr
src/test/ui/moves/move-into-dead-array-1.rs
src/test/ui/moves/move-into-dead-array-1.stderr
src/test/ui/moves/move-of-addr-of-mut.rs
src/test/ui/moves/move-of-addr-of-mut.stderr
src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr
src/test/ui/never_type/fallback-closure-wrap.fallback.stderr
src/test/ui/nll/closure-captures.stderr
src/test/ui/nll/closure-requirements/escape-argument-callee.stderr
src/test/ui/nll/closure-requirements/escape-argument.stderr
src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr
src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr
src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr
src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr
src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr
src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.rs
src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.stderr
src/test/ui/nll/issue-21232-partial-init-and-use.rs
src/test/ui/nll/issue-21232-partial-init-and-use.stderr
src/test/ui/nll/issue-52663-span-decl-captured-variable.stderr
src/test/ui/nll/issue-54556-stephaneyfx.stderr
src/test/ui/nll/match-cfg-fake-edges.rs
src/test/ui/nll/match-cfg-fake-edges.stderr
src/test/ui/nll/match-on-borrowed.stderr
src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr
src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr
src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr
src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr
src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr
src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr
src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr
src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr
src/test/ui/nll/user-annotations/adt-nullary-enums.stderr
src/test/ui/nll/user-annotations/adt-tuple-struct-calls.stderr
src/test/ui/nll/user-annotations/fns.stderr
src/test/ui/nll/user-annotations/method-call.stderr
src/test/ui/nll/user-annotations/method-ufcs-3.stderr
src/test/ui/no-send-res-ports.stderr
src/test/ui/noncopyable-class.stderr
src/test/ui/not-clone-closure.stderr
src/test/ui/parser/emoji-identifiers.stderr
src/test/ui/parser/expr-as-stmt.stderr
src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr
src/test/ui/pattern/non-structural-match-types.stderr
src/test/ui/polymorphization/const_parameters/closures.stderr
src/test/ui/polymorphization/generators.stderr
src/test/ui/polymorphization/lifetimes.stderr
src/test/ui/polymorphization/predicates.stderr
src/test/ui/polymorphization/type_parameters/closures.stderr
src/test/ui/polymorphization/unsized_cast.stderr
src/test/ui/recursion/issue-83150.stderr
src/test/ui/rfc-2497-if-let-chains/chains-without-let.rs
src/test/ui/rfc-2497-if-let-chains/chains-without-let.stderr
src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
src/test/ui/rust-2018/uniform-paths/issue-87932.stderr
src/test/ui/self/point-at-arbitrary-self-type-method.stderr
src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr
src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr
src/test/ui/span/issue-7575.stderr
src/test/ui/span/move-closure.stderr
src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr
src/test/ui/stability-attribute/missing-const-stability.stderr
src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
src/test/ui/suggestions/derive-trait-for-method-call.stderr
src/test/ui/suggestions/dont-suggest-ref/move-into-closure.stderr
src/test/ui/suggestions/dont-wrap-ambiguous-receivers.stderr
src/test/ui/suggestions/field-has-method.stderr
src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr
src/test/ui/suggestions/issue-84973-blacklist.stderr
src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
src/test/ui/suggestions/option-content-move2.stderr
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr
src/test/ui/suggestions/suggest-box.stderr
src/test/ui/suggestions/suggest-methods.stderr
src/test/ui/suggestions/suggest-variants.stderr
src/test/ui/suggestions/unnamable-types.stderr
src/test/ui/suggestions/use-placement-typeck.stderr
src/test/ui/terminal-width/flag-human.rs [deleted file]
src/test/ui/terminal-width/flag-human.stderr [deleted file]
src/test/ui/terminal-width/flag-json.rs [deleted file]
src/test/ui/terminal-width/flag-json.stderr [deleted file]
src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs [deleted file]
src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr [deleted file]
src/test/ui/terminal-width/non-whitespace-trimming-2.rs [deleted file]
src/test/ui/terminal-width/non-whitespace-trimming-2.stderr [deleted file]
src/test/ui/terminal-width/non-whitespace-trimming-unicode.rs [deleted file]
src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr [deleted file]
src/test/ui/terminal-width/non-whitespace-trimming.rs [deleted file]
src/test/ui/terminal-width/non-whitespace-trimming.stderr [deleted file]
src/test/ui/terminal-width/tabs-trimming.rs [deleted file]
src/test/ui/terminal-width/tabs-trimming.stderr [deleted file]
src/test/ui/terminal-width/whitespace-trimming-2.rs [deleted file]
src/test/ui/terminal-width/whitespace-trimming-2.stderr [deleted file]
src/test/ui/terminal-width/whitespace-trimming.rs [deleted file]
src/test/ui/terminal-width/whitespace-trimming.stderr [deleted file]
src/test/ui/trait-bounds/impl-derived-implicit-sized-bound-2.rs [new file with mode: 0644]
src/test/ui/trait-bounds/impl-derived-implicit-sized-bound-2.stderr [new file with mode: 0644]
src/test/ui/trait-bounds/impl-derived-implicit-sized-bound.rs [new file with mode: 0644]
src/test/ui/trait-bounds/impl-derived-implicit-sized-bound.stderr [new file with mode: 0644]
src/test/ui/traits/issue-3973.stderr
src/test/ui/traits/issue-85735.stderr
src/test/ui/traits/issue-91949-hangs-on-recursion.stderr
src/test/ui/traits/item-privacy.stderr
src/test/ui/traits/negative-impls/explicitly-unimplemented-error-message.stderr
src/test/ui/try-block/try-block-opt-init.rs
src/test/ui/try-block/try-block-opt-init.stderr
src/test/ui/tuple/wrong_argument_ice-4.stderr
src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs
src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
src/test/ui/type-alias-impl-trait/inference-cycle.rs
src/test/ui/type-alias-impl-trait/inference-cycle.stderr
src/test/ui/type-alias-impl-trait/issue-53092-2.stderr
src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr
src/test/ui/type-alias-impl-trait/issue-63279.stderr
src/test/ui/type-alias-impl-trait/issue-94429.stderr
src/test/ui/type-alias-impl-trait/issue-98604.rs [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-98604.stderr [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-98608.rs [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-98608.stderr [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/reveal_local.rs
src/test/ui/type-alias-impl-trait/reveal_local.stderr
src/test/ui/type/type-check/issue-40294.stderr
src/test/ui/typeck/issue-91334.stderr
src/test/ui/typeck/return_type_containing_closure.stderr
src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr
src/test/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr
src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr
src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr
src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr
src/test/ui/uninhabited/privately-uninhabited-mir-call.rs
src/test/ui/uninhabited/privately-uninhabited-mir-call.stderr
src/test/ui/union/union-derive-clone.mirunsafeck.stderr
src/test/ui/union/union-derive-clone.thirunsafeck.stderr
src/test/ui/unsized/box-instead-of-dyn-fn.stderr
src/test/ui/unsized/issue-91801.stderr
src/tools/clippy/clippy_lints/src/misc.rs
src/tools/clippy/tests/ui/crashes/ice-6251.stderr
src/tools/clippy/tests/ui/used_underscore_binding.rs
src/tools/clippy/tests/ui/used_underscore_binding.stderr
src/tools/miri
src/tools/rustc-workspace-hack/Cargo.toml

index 75b9c0fce2295e8e7d85eb356643cfaecd86f7ec..35fefd2fb247e1f0df4b61677eab5e78cc61e380 100644 (file)
@@ -3480,6 +3480,7 @@ dependencies = [
  "proc-macro2",
  "quote",
  "rand_core 0.5.1",
+ "regex",
  "serde",
  "serde_json",
  "smallvec",
@@ -3813,6 +3814,7 @@ dependencies = [
  "atty",
  "rustc_data_structures",
  "rustc_error_messages",
+ "rustc_hir",
  "rustc_lint_defs",
  "rustc_macros",
  "rustc_serialize",
@@ -3869,6 +3871,7 @@ name = "rustc_hir"
 version = "0.0.0"
 dependencies = [
  "odht",
+ "rustc_arena",
  "rustc_ast",
  "rustc_data_structures",
  "rustc_error_messages",
index 2820d5e6e0c0523171d4882ced275d561b82d599..f705d004422277325ab4c9d1739c93fabd4e4dcc 100644 (file)
@@ -2036,6 +2036,14 @@ pub fn is_implicit_self(&self) -> bool {
     pub fn is_unit(&self) -> bool {
         matches!(self, TyKind::Tup(tys) if tys.is_empty())
     }
+
+    pub fn is_simple_path(&self) -> Option<Symbol> {
+        if let TyKind::Path(None, Path { segments, .. }) = &self && segments.len() == 1 {
+            Some(segments[0].ident.name)
+        } else {
+            None
+        }
+    }
 }
 
 /// Syntax used to declare a trait object.
index aab9b90e4b7e567bc85abd466139c39a055fbd98..0e395d703358610447ae658266608d0f063e1273 100644 (file)
@@ -24,10 +24,16 @@ pub(crate) fn lower_inline_asm(
     ) -> &'hir hir::InlineAsm<'hir> {
         // Rustdoc needs to support asm! from foreign architectures: don't try
         // lowering the register constraints in this case.
-        let asm_arch = if self.sess.opts.actually_rustdoc { None } else { self.sess.asm_arch };
-        if asm_arch.is_none() && !self.sess.opts.actually_rustdoc {
-            struct_span_err!(self.sess, sp, E0472, "inline assembly is unsupported on this target")
-                .emit();
+        let asm_arch =
+            if self.tcx.sess.opts.actually_rustdoc { None } else { self.tcx.sess.asm_arch };
+        if asm_arch.is_none() && !self.tcx.sess.opts.actually_rustdoc {
+            struct_span_err!(
+                self.tcx.sess,
+                sp,
+                E0472,
+                "inline assembly is unsupported on this target"
+            )
+            .emit();
         }
         if let Some(asm_arch) = asm_arch {
             // Inline assembly is currently only stable for these architectures.
@@ -40,9 +46,9 @@ pub(crate) fn lower_inline_asm(
                     | asm::InlineAsmArch::RiscV32
                     | asm::InlineAsmArch::RiscV64
             );
-            if !is_stable && !self.sess.features_untracked().asm_experimental_arch {
+            if !is_stable && !self.tcx.features().asm_experimental_arch {
                 feature_err(
-                    &self.sess.parse_sess,
+                    &self.tcx.sess.parse_sess,
                     sym::asm_experimental_arch,
                     sp,
                     "inline assembly is not stable yet on this architecture",
@@ -52,17 +58,16 @@ pub(crate) fn lower_inline_asm(
         }
         if asm.options.contains(InlineAsmOptions::ATT_SYNTAX)
             && !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
-            && !self.sess.opts.actually_rustdoc
+            && !self.tcx.sess.opts.actually_rustdoc
         {
-            self.sess
+            self.tcx
+                .sess
                 .struct_span_err(sp, "the `att_syntax` option is only supported on x86")
                 .emit();
         }
-        if asm.options.contains(InlineAsmOptions::MAY_UNWIND)
-            && !self.sess.features_untracked().asm_unwind
-        {
+        if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
             feature_err(
-                &self.sess.parse_sess,
+                &self.tcx.sess.parse_sess,
                 sym::asm_unwind,
                 sp,
                 "the `may_unwind` option is unstable",
@@ -73,12 +78,12 @@ pub(crate) fn lower_inline_asm(
         let mut clobber_abis = FxHashMap::default();
         if let Some(asm_arch) = asm_arch {
             for (abi_name, abi_span) in &asm.clobber_abis {
-                match asm::InlineAsmClobberAbi::parse(asm_arch, &self.sess.target, *abi_name) {
+                match asm::InlineAsmClobberAbi::parse(asm_arch, &self.tcx.sess.target, *abi_name) {
                     Ok(abi) => {
                         // If the abi was already in the list, emit an error
                         match clobber_abis.get(&abi) {
                             Some((prev_name, prev_sp)) => {
-                                let mut err = self.sess.struct_span_err(
+                                let mut err = self.tcx.sess.struct_span_err(
                                     *abi_span,
                                     &format!("`{}` ABI specified multiple times", prev_name),
                                 );
@@ -86,7 +91,7 @@ pub(crate) fn lower_inline_asm(
 
                                 // Multiple different abi names may actually be the same ABI
                                 // If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
-                                let source_map = self.sess.source_map();
+                                let source_map = self.tcx.sess.source_map();
                                 if source_map.span_to_snippet(*prev_sp)
                                     != source_map.span_to_snippet(*abi_span)
                                 {
@@ -101,7 +106,8 @@ pub(crate) fn lower_inline_asm(
                         }
                     }
                     Err(&[]) => {
-                        self.sess
+                        self.tcx
+                            .sess
                             .struct_span_err(
                                 *abi_span,
                                 "`clobber_abi` is not supported on this target",
@@ -109,8 +115,10 @@ pub(crate) fn lower_inline_asm(
                             .emit();
                     }
                     Err(supported_abis) => {
-                        let mut err =
-                            self.sess.struct_span_err(*abi_span, "invalid ABI for `clobber_abi`");
+                        let mut err = self
+                            .tcx
+                            .sess
+                            .struct_span_err(*abi_span, "invalid ABI for `clobber_abi`");
                         let mut abis = format!("`{}`", supported_abis[0]);
                         for m in &supported_abis[1..] {
                             let _ = write!(abis, ", `{}`", m);
@@ -128,7 +136,7 @@ pub(crate) fn lower_inline_asm(
         // Lower operands to HIR. We use dummy register classes if an error
         // occurs during lowering because we still need to be able to produce a
         // valid HIR.
-        let sess = self.sess;
+        let sess = self.tcx.sess;
         let mut operands: Vec<_> = asm
             .operands
             .iter()
@@ -184,9 +192,9 @@ pub(crate) fn lower_inline_asm(
                         }
                     }
                     InlineAsmOperand::Const { ref anon_const } => {
-                        if !self.sess.features_untracked().asm_const {
+                        if !self.tcx.features().asm_const {
                             feature_err(
-                                &self.sess.parse_sess,
+                                &sess.parse_sess,
                                 sym::asm_const,
                                 *op_sp,
                                 "const operands for inline assembly are unstable",
@@ -198,9 +206,9 @@ pub(crate) fn lower_inline_asm(
                         }
                     }
                     InlineAsmOperand::Sym { ref sym } => {
-                        if !self.sess.features_untracked().asm_sym {
+                        if !self.tcx.features().asm_sym {
                             feature_err(
-                                &self.sess.parse_sess,
+                                &sess.parse_sess,
                                 sym::asm_sym,
                                 *op_sp,
                                 "sym operands for inline assembly are unstable",
index 3a7e0a70585f125e53d264d2e16e8e3e70043141..9444fffc331c79adbbc8863ca5d8d834c30cdafe 100644 (file)
@@ -159,9 +159,9 @@ fn lower_let_else(
             span,
             kind: hir::ExprKind::If(let_expr, then_expr, Some(else_expr)),
         });
-        if !self.sess.features_untracked().let_else {
+        if !self.tcx.features().let_else {
             feature_err(
-                &self.sess.parse_sess,
+                &self.tcx.sess.parse_sess,
                 sym::let_else,
                 local.span,
                 "`let...else` statements are unstable",
index 3babe73030a45efac44d1eab8f4c50e9e4fb7385..9e02e7ed3b9cf0048e66d07435aa03b0c747e437 100644 (file)
@@ -46,7 +46,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
                             let hir_id = self.lower_node_id(e.id);
                             return hir::Expr { hir_id, kind, span: self.lower_span(e.span) };
                         } else {
-                            self.sess
+                            self.tcx.sess
                                 .struct_span_err(
                                     e.span,
                                     "#[rustc_box] requires precisely one argument \
@@ -207,8 +207,8 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
                     self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), lims)
                 }
                 ExprKind::Underscore => {
-                    self.sess
-                        .struct_span_err(
+                    self.tcx
+                        .sess.struct_span_err(
                             e.span,
                             "in expressions, `_` can only be used on the left-hand side of an assignment",
                         )
@@ -245,7 +245,8 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
                     let rest = match &se.rest {
                         StructRest::Base(e) => Some(self.lower_expr(e)),
                         StructRest::Rest(sp) => {
-                            self.sess
+                            self.tcx
+                                .sess
                                 .struct_span_err(*sp, "base expression required after `..`")
                                 .span_label(*sp, "add a base expression here")
                                 .emit();
@@ -474,7 +475,7 @@ fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind<'hir> {
             } else {
                 let try_span = this.mark_span_with_reason(
                     DesugaringKind::TryBlock,
-                    this.sess.source_map().end_point(body.span),
+                    this.tcx.sess.source_map().end_point(body.span),
                     this.allow_try_trait.clone(),
                 );
 
@@ -653,7 +654,7 @@ fn lower_expr_await(&mut self, dot_await_span: Span, expr: &Expr) -> hir::ExprKi
             Some(hir::GeneratorKind::Async(_)) => {}
             Some(hir::GeneratorKind::Gen) | None => {
                 let mut err = struct_span_err!(
-                    self.sess,
+                    self.tcx.sess,
                     dot_await_span,
                     E0728,
                     "`await` is only allowed inside `async` functions and blocks"
@@ -878,7 +879,7 @@ fn generator_movability_for_fn(
             Some(hir::GeneratorKind::Gen) => {
                 if decl.inputs.len() > 1 {
                     struct_span_err!(
-                        self.sess,
+                        self.tcx.sess,
                         fn_decl_span,
                         E0628,
                         "too many parameters for a generator (expected 0 or 1 parameters)"
@@ -892,8 +893,13 @@ fn generator_movability_for_fn(
             }
             None => {
                 if movability == Movability::Static {
-                    struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static")
-                        .emit();
+                    struct_span_err!(
+                        self.tcx.sess,
+                        fn_decl_span,
+                        E0697,
+                        "closures cannot be static"
+                    )
+                    .emit();
                 }
                 None
             }
@@ -916,7 +922,7 @@ fn lower_expr_async_closure(
             // FIXME(cramertj): allow `async` non-`move` closures with arguments.
             if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
                 struct_span_err!(
-                    this.sess,
+                    this.tcx.sess,
                     fn_decl_span,
                     E0708,
                     "`async` non-`move` closures with parameters are not currently supported",
@@ -1163,7 +1169,8 @@ fn destructure_assign_mut(
                 );
                 let fields_omitted = match &se.rest {
                     StructRest::Base(e) => {
-                        self.sess
+                        self.tcx
+                            .sess
                             .struct_span_err(
                                 e.span,
                                 "functional record updates are not allowed in destructuring \
@@ -1371,7 +1378,7 @@ fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::Expr
             Some(hir::GeneratorKind::Gen) => {}
             Some(hir::GeneratorKind::Async(_)) => {
                 struct_span_err!(
-                    self.sess,
+                    self.tcx.sess,
                     span,
                     E0727,
                     "`async` generators are not yet supported"
@@ -1516,7 +1523,7 @@ fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind<'hir>
             span,
             self.allow_try_trait.clone(),
         );
-        let try_span = self.sess.source_map().end_point(span);
+        let try_span = self.tcx.sess.source_map().end_point(span);
         let try_span = self.mark_span_with_reason(
             DesugaringKind::QuestionMark,
             try_span,
index 112197c6e399313cbb09db14f2708416ce2298db..7da49143b461e2a785038bf64cab2ff490581b83 100644 (file)
@@ -1,7 +1,6 @@
 use super::ResolverAstLoweringExt;
 use super::{AstOwner, ImplTraitContext, ImplTraitPosition};
-use super::{LoweringContext, ParamMode};
-use crate::{Arena, FnDeclKind};
+use super::{FnDeclKind, LoweringContext, ParamMode};
 
 use rustc_ast::ptr::P;
 use rustc_ast::visit::AssocCtxt;
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, Res};
 use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
-use rustc_hir::definitions::Definitions;
 use rustc_hir::PredicateOrigin;
 use rustc_index::vec::{Idx, IndexVec};
-use rustc_middle::ty::{ResolverAstLowering, ResolverOutputs};
-use rustc_session::cstore::CrateStoreDyn;
-use rustc_session::Session;
+use rustc_middle::ty::{DefIdTree, ResolverAstLowering, TyCtxt};
 use rustc_span::source_map::DesugaringKind;
 use rustc_span::symbol::{kw, sym, Ident};
 use rustc_span::Span;
 use std::iter;
 
 pub(super) struct ItemLowerer<'a, 'hir> {
-    pub(super) sess: &'a Session,
-    pub(super) definitions: &'a mut Definitions,
-    pub(super) cstore: &'a CrateStoreDyn,
-    pub(super) resolutions: &'a ResolverOutputs,
+    pub(super) tcx: TyCtxt<'hir>,
     pub(super) resolver: &'a mut ResolverAstLowering,
-    pub(super) arena: &'hir Arena<'hir>,
     pub(super) ast_index: &'a IndexVec<LocalDefId, AstOwner<'a>>,
     pub(super) owners: &'a mut IndexVec<LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>>,
 }
@@ -65,12 +57,9 @@ fn with_lctx(
     ) {
         let mut lctx = LoweringContext {
             // Pseudo-globals.
-            sess: &self.sess,
-            definitions: self.definitions,
-            cstore: self.cstore,
-            resolutions: self.resolutions,
+            tcx: self.tcx,
             resolver: self.resolver,
-            arena: self.arena,
+            arena: self.tcx.hir_arena,
 
             // HirId handling.
             bodies: Vec::new(),
@@ -144,12 +133,7 @@ fn lower_item(&mut self, item: &Item) {
     fn lower_assoc_item(&mut self, item: &AssocItem, ctxt: AssocCtxt) {
         let def_id = self.resolver.node_id_to_def_id[&item.id];
 
-        let parent_id = {
-            let parent = self.definitions.def_key(def_id).parent;
-            let local_def_index = parent.unwrap();
-            LocalDefId { local_def_index }
-        };
-
+        let parent_id = self.tcx.local_parent(def_id);
         let parent_hir = self.lower_node(parent_id).unwrap();
         self.with_lctx(item.id, |lctx| {
             // Evaluate with the lifetimes in `params` in-scope.
@@ -1278,7 +1262,7 @@ pub(super) fn lower_extern(&mut self, ext: Extern) -> abi::Abi {
     }
 
     fn error_on_invalid_abi(&self, abi: StrLit) {
-        struct_span_err!(self.sess, abi.span, E0703, "invalid ABI: found `{}`", abi.symbol)
+        struct_span_err!(self.tcx.sess, abi.span, E0703, "invalid ABI: found `{}`", abi.symbol)
             .span_label(abi.span, "invalid ABI")
             .help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
             .emit();
index e8b92eaad5c8dbfba258398f6f3fbcab75453d0f..2dcbd0782ef72d9adcf6121e76f76916d138aae0 100644 (file)
 use rustc_data_structures::sorted_map::SortedMap;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_data_structures::sync::Lrc;
-use rustc_errors::{struct_span_err, Applicability};
+use rustc_errors::{struct_span_err, Applicability, Handler};
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
 use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
-use rustc_hir::definitions::{DefPathData, Definitions};
+use rustc_hir::definitions::DefPathData;
 use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
 use rustc_index::vec::{Idx, IndexVec};
-use rustc_middle::ty::{ResolverAstLowering, ResolverOutputs};
-use rustc_query_system::ich::StableHashingContext;
-use rustc_session::cstore::CrateStoreDyn;
+use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
 use rustc_session::parse::feature_err;
-use rustc_session::Session;
 use rustc_span::hygiene::MacroKind;
 use rustc_span::source_map::DesugaringKind;
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -83,19 +80,12 @@ macro_rules! arena_vec {
 mod pat;
 mod path;
 
-rustc_hir::arena_types!(rustc_arena::declare_arena);
-
-struct LoweringContext<'a, 'hir: 'a> {
-    /// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
-    sess: &'a Session,
-
-    definitions: &'a mut Definitions,
-    cstore: &'a CrateStoreDyn,
-    resolutions: &'a ResolverOutputs,
+struct LoweringContext<'a, 'hir> {
+    tcx: TyCtxt<'hir>,
     resolver: &'a mut ResolverAstLowering,
 
     /// Used to allocate HIR nodes.
-    arena: &'hir Arena<'hir>,
+    arena: &'hir hir::Arena<'hir>,
 
     /// Bodies inside the owner being lowered.
     bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
@@ -391,61 +381,58 @@ fn visit_foreign_item(&mut self, item: &'a ast::ForeignItem) {
 /// Compute the hash for the HIR of the full crate.
 /// This hash will then be part of the crate_hash which is stored in the metadata.
 fn compute_hir_hash(
-    sess: &Session,
-    definitions: &Definitions,
-    cstore: &CrateStoreDyn,
-    resolver: &ResolverOutputs,
+    tcx: TyCtxt<'_>,
     owners: &IndexVec<LocalDefId, hir::MaybeOwner<&hir::OwnerInfo<'_>>>,
 ) -> Fingerprint {
     let mut hir_body_nodes: Vec<_> = owners
         .iter_enumerated()
         .filter_map(|(def_id, info)| {
             let info = info.as_owner()?;
-            let def_path_hash = definitions.def_path_hash(def_id);
+            let def_path_hash = tcx.hir().def_path_hash(def_id);
             Some((def_path_hash, info))
         })
         .collect();
     hir_body_nodes.sort_unstable_by_key(|bn| bn.0);
 
-    let mut stable_hasher = StableHasher::new();
-    let mut hcx = StableHashingContext::new(sess, definitions, cstore, &resolver.source_span);
-    hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher);
-    stable_hasher.finish()
+    tcx.with_stable_hashing_context(|mut hcx| {
+        let mut stable_hasher = StableHasher::new();
+        hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher);
+        stable_hasher.finish()
+    })
 }
 
-pub fn lower_crate<'hir>(
-    sess: &Session,
-    krate: &Crate,
-    definitions: &mut Definitions,
-    cstore: &CrateStoreDyn,
-    resolutions: &ResolverOutputs,
-    mut resolver: ResolverAstLowering,
-    arena: &'hir Arena<'hir>,
-) -> &'hir hir::Crate<'hir> {
-    let _prof_timer = sess.prof.verbose_generic_activity("hir_lowering");
+pub fn lower_to_hir<'hir>(tcx: TyCtxt<'hir>, (): ()) -> hir::Crate<'hir> {
+    let sess = tcx.sess;
+    let krate = tcx.untracked_crate.steal();
+    let mut resolver = tcx.resolver_for_lowering(()).steal();
 
-    let ast_index = index_crate(&resolver.node_id_to_def_id, krate);
-
-    let mut owners =
-        IndexVec::from_fn_n(|_| hir::MaybeOwner::Phantom, definitions.def_index_count());
+    let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
+    let mut owners = IndexVec::from_fn_n(
+        |_| hir::MaybeOwner::Phantom,
+        tcx.definitions_untracked().def_index_count(),
+    );
 
     for def_id in ast_index.indices() {
         item::ItemLowerer {
-            sess,
-            definitions,
-            cstore,
-            resolutions,
+            tcx,
             resolver: &mut resolver,
-            arena,
             ast_index: &ast_index,
             owners: &mut owners,
         }
         .lower_node(def_id);
     }
 
-    let hir_hash = compute_hir_hash(sess, definitions, cstore, resolutions, &owners);
-    let krate = hir::Crate { owners, hir_hash };
-    arena.alloc(krate)
+    // Drop AST to free memory
+    std::mem::drop(ast_index);
+    sess.time("drop_ast", || std::mem::drop(krate));
+
+    // Discard hygiene data, which isn't required after lowering to HIR.
+    if !sess.opts.debugging_opts.keep_hygiene_data {
+        rustc_span::hygiene::clear_syntax_context_map();
+    }
+
+    let hir_hash = compute_hir_hash(tcx, &owners);
+    hir::Crate { owners, hir_hash }
 }
 
 #[derive(Copy, Clone, PartialEq, Debug)]
@@ -464,38 +451,25 @@ enum ParenthesizedGenericArgs {
 }
 
 impl<'a, 'hir> LoweringContext<'a, 'hir> {
-    fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
-        StableHashingContext::new(
-            self.sess,
-            self.definitions,
-            self.cstore,
-            &self.resolutions.source_span,
-        )
-    }
-
     fn create_def(
         &mut self,
         parent: LocalDefId,
         node_id: ast::NodeId,
         data: DefPathData,
     ) -> LocalDefId {
+        debug_assert_ne!(node_id, ast::DUMMY_NODE_ID);
         assert!(
             self.opt_local_def_id(node_id).is_none(),
             "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
             node_id,
             data,
-            self.definitions.def_key(self.local_def_id(node_id)),
+            self.tcx.hir().def_key(self.local_def_id(node_id)),
         );
 
-        let def_id = self.definitions.create_def(parent, data);
+        let def_id = self.tcx.create_def(parent, data);
 
-        // Some things for which we allocate `LocalDefId`s don't correspond to
-        // anything in the AST, so they don't have a `NodeId`. For these cases
-        // we don't need a mapping from `NodeId` to `LocalDefId`.
-        if node_id != ast::DUMMY_NODE_ID {
-            debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
-            self.resolver.node_id_to_def_id.insert(node_id, def_id);
-        }
+        debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
+        self.resolver.node_id_to_def_id.insert(node_id, def_id);
 
         def_id
     }
@@ -515,6 +489,11 @@ fn local_def_id(&self, node: NodeId) -> LocalDefId {
         self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
     }
 
+    /// Freshen the `LoweringContext` and ready it to lower a nested item.
+    /// The lowered item is registered into `self.children`.
+    ///
+    /// This function sets up `HirId` lowering infrastructure,
+    /// and stashes the shared mutable state to avoid pollution by the closure.
     #[instrument(level = "debug", skip(self, f))]
     fn with_hir_id_owner(
         &mut self,
@@ -533,8 +512,10 @@ fn with_hir_id_owner(
             std::mem::replace(&mut self.item_local_id_counter, hir::ItemLocalId::new(1));
         let current_impl_trait_defs = std::mem::take(&mut self.impl_trait_defs);
         let current_impl_trait_bounds = std::mem::take(&mut self.impl_trait_bounds);
-        // Do not reset `next_node_id` and `node_id_to_def_id` as we want to refer to the
-        // subdefinitions' nodes.
+
+        // Do not reset `next_node_id` and `node_id_to_def_id`:
+        // we want `f` to be able to refer to the `LocalDefId`s that the caller created.
+        // and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
 
         // Always allocate the first `HirId` for the owner itself.
         let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::new(0));
@@ -578,7 +559,8 @@ fn make_owner_info(&mut self, node: hir::OwnerNode<'hir>) -> &'hir hir::OwnerInf
         bodies.sort_by_key(|(k, _)| *k);
         let bodies = SortedMap::from_presorted_elements(bodies);
         let (hash_including_bodies, hash_without_bodies) = self.hash_owner(node, &bodies);
-        let (nodes, parenting) = index::index_hir(self.sess, self.definitions, node, &bodies);
+        let (nodes, parenting) =
+            index::index_hir(self.tcx.sess, &*self.tcx.definitions_untracked(), node, &bodies);
         let nodes = hir::OwnerNodes {
             hash_including_bodies,
             hash_without_bodies,
@@ -587,10 +569,11 @@ fn make_owner_info(&mut self, node: hir::OwnerNode<'hir>) -> &'hir hir::OwnerInf
             local_id_to_def_id,
         };
         let attrs = {
-            let mut hcx = self.create_stable_hashing_context();
-            let mut stable_hasher = StableHasher::new();
-            attrs.hash_stable(&mut hcx, &mut stable_hasher);
-            let hash = stable_hasher.finish();
+            let hash = self.tcx.with_stable_hashing_context(|mut hcx| {
+                let mut stable_hasher = StableHasher::new();
+                attrs.hash_stable(&mut hcx, &mut stable_hasher);
+                stable_hasher.finish()
+            });
             hir::AttributeMap { map: attrs, hash }
         };
 
@@ -604,18 +587,19 @@ fn hash_owner(
         node: hir::OwnerNode<'hir>,
         bodies: &SortedMap<hir::ItemLocalId, &'hir hir::Body<'hir>>,
     ) -> (Fingerprint, Fingerprint) {
-        let mut hcx = self.create_stable_hashing_context();
-        let mut stable_hasher = StableHasher::new();
-        hcx.with_hir_bodies(true, node.def_id(), bodies, |hcx| {
-            node.hash_stable(hcx, &mut stable_hasher)
-        });
-        let hash_including_bodies = stable_hasher.finish();
-        let mut stable_hasher = StableHasher::new();
-        hcx.with_hir_bodies(false, node.def_id(), bodies, |hcx| {
-            node.hash_stable(hcx, &mut stable_hasher)
-        });
-        let hash_without_bodies = stable_hasher.finish();
-        (hash_including_bodies, hash_without_bodies)
+        self.tcx.with_stable_hashing_context(|mut hcx| {
+            let mut stable_hasher = StableHasher::new();
+            hcx.with_hir_bodies(true, node.def_id(), bodies, |hcx| {
+                node.hash_stable(hcx, &mut stable_hasher)
+            });
+            let hash_including_bodies = stable_hasher.finish();
+            let mut stable_hasher = StableHasher::new();
+            hcx.with_hir_bodies(false, node.def_id(), bodies, |hcx| {
+                node.hash_stable(hcx, &mut stable_hasher)
+            });
+            let hash_without_bodies = stable_hasher.finish();
+            (hash_including_bodies, hash_without_bodies)
+        })
     }
 
     /// This method allocates a new `HirId` for the given `NodeId` and stores it in
@@ -656,9 +640,13 @@ fn lower_node_id(&mut self, ast_node_id: NodeId) -> hir::HirId {
         }
     }
 
+    /// Generate a new `HirId` without a backing `NodeId`.
     fn next_id(&mut self) -> hir::HirId {
-        let node_id = self.next_node_id();
-        self.lower_node_id(node_id)
+        let owner = self.current_hir_id_owner;
+        let local_id = self.item_local_id_counter;
+        assert_ne!(local_id, hir::ItemLocalId::new(0));
+        self.item_local_id_counter.increment_by(1);
+        hir::HirId { owner, local_id }
     }
 
     #[instrument(level = "trace", skip(self))]
@@ -691,8 +679,8 @@ fn expect_full_res_from_use(&mut self, id: NodeId) -> impl Iterator<Item = Res<N
         self.resolver.get_import_res(id).present_items()
     }
 
-    fn diagnostic(&self) -> &rustc_errors::Handler {
-        self.sess.diagnostic()
+    fn diagnostic(&self) -> &Handler {
+        self.tcx.sess.diagnostic()
     }
 
     /// Reuses the span but adds information like the kind of the desugaring and features that are
@@ -703,18 +691,15 @@ fn mark_span_with_reason(
         span: Span,
         allow_internal_unstable: Option<Lrc<[Symbol]>>,
     ) -> Span {
-        span.mark_with_reason(
-            allow_internal_unstable,
-            reason,
-            self.sess.edition(),
-            self.create_stable_hashing_context(),
-        )
+        self.tcx.with_stable_hashing_context(|hcx| {
+            span.mark_with_reason(allow_internal_unstable, reason, self.tcx.sess.edition(), hcx)
+        })
     }
 
     /// Intercept all spans entering HIR.
     /// Mark a span as relative to the current owning item.
     fn lower_span(&self, span: Span) -> Span {
-        if self.sess.opts.debugging_opts.incremental_relative_spans {
+        if self.tcx.sess.opts.debugging_opts.incremental_relative_spans {
             span.with_parent(Some(self.current_hir_id_owner))
         } else {
             // Do not make spans relative when not using incremental compilation.
@@ -1061,7 +1046,7 @@ fn lower_assoc_ty_constraint(
     }
 
     fn emit_bad_parenthesized_trait_in_assoc_ty(&self, data: &ParenthesizedArgs) {
-        let mut err = self.sess.struct_span_err(
+        let mut err = self.tcx.sess.struct_span_err(
             data.span,
             "parenthesized generic arguments cannot be used in associated type constraints",
         );
@@ -1106,7 +1091,7 @@ fn lower_generic_arg(
             ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(&lt)),
             ast::GenericArg::Type(ty) => {
                 match ty.kind {
-                    TyKind::Infer if self.sess.features_untracked().generic_arg_infer => {
+                    TyKind::Infer if self.tcx.features().generic_arg_infer => {
                         return GenericArg::Infer(hir::InferArg {
                             hir_id: self.lower_node_id(ty.id),
                             span: self.lower_span(ty.span),
@@ -1203,7 +1188,7 @@ fn lower_ty_direct(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir>
                     } else {
                         self.next_node_id()
                     };
-                    let span = self.sess.source_map().next_point(t.span.shrink_to_lo());
+                    let span = self.tcx.sess.source_map().next_point(t.span.shrink_to_lo());
                     Lifetime { ident: Ident::new(kw::UnderscoreLifetime, span), id }
                 });
                 let lifetime = self.lower_lifetime(&region);
@@ -1307,7 +1292,7 @@ fn lower_ty_direct(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir>
                     }
                     ImplTraitContext::Disallowed(position) => {
                         let mut err = struct_span_err!(
-                            self.sess,
+                            self.tcx.sess,
                             t.span,
                             E0562,
                             "`impl Trait` only allowed in function and inherent method return types, not in {}",
@@ -1320,7 +1305,7 @@ fn lower_ty_direct(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir>
             }
             TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
             TyKind::CVarArgs => {
-                self.sess.delay_span_bug(
+                self.tcx.sess.delay_span_bug(
                     t.span,
                     "`TyKind::CVarArgs` should have been handled elsewhere",
                 );
@@ -1925,7 +1910,7 @@ fn lower_generic_param(&mut self, param: &GenericParam) -> hir::GenericParam<'hi
             hir_id,
             name,
             span: self.lower_span(param.span()),
-            pure_wrt_drop: self.sess.contains_name(&param.attrs, sym::may_dangle),
+            pure_wrt_drop: self.tcx.sess.contains_name(&param.attrs, sym::may_dangle),
             kind,
             colon_span: param.colon_span.map(|s| self.lower_span(s)),
         }
@@ -2067,11 +2052,11 @@ fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
     fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen {
         match c.value.kind {
             ExprKind::Underscore => {
-                if self.sess.features_untracked().generic_arg_infer {
+                if self.tcx.features().generic_arg_infer {
                     hir::ArrayLen::Infer(self.lower_node_id(c.id), c.value.span)
                 } else {
                     feature_err(
-                        &self.sess.parse_sess,
+                        &self.tcx.sess.parse_sess,
                         sym::generic_arg_infer,
                         c.value.span,
                         "using `_` for array lengths is unstable",
index 52ba5daf01410046555852aa3eb8ce2f5327c1d7..393be3b454c3787c7630750abb2c1d79369dc1f4 100644 (file)
@@ -133,7 +133,7 @@ pub(crate) fn lower_qpath(
 
         // We should've returned in the for loop above.
 
-        self.sess.diagnostic().span_bug(
+        self.diagnostic().span_bug(
             p.span,
             &format!(
                 "lower_qpath: no final extension segment in {}..{}",
@@ -193,7 +193,7 @@ pub(crate) fn lower_path_segment(
                 GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
                     ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
                     ParenthesizedGenericArgs::Err => {
-                        let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
+                        let mut err = struct_span_err!(self.tcx.sess, data.span, E0214, "{}", msg);
                         err.span_label(data.span, "only `Fn` traits may use parentheses");
                         // Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
                         if !data.inputs.is_empty() {
index a5d9a2bc597fa8f2ef817fa9f26cad9a0b1ff4a6..08ea00d71ef9d246620a96d91f16b1afde05dc0c 100644 (file)
@@ -33,22 +33,6 @@ pub(crate) fn cannot_use_when_mutably_borrowed(
         err
     }
 
-    pub(crate) fn cannot_act_on_uninitialized_variable(
-        &self,
-        span: Span,
-        verb: &str,
-        desc: &str,
-    ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
-        struct_span_err!(
-            self,
-            span,
-            E0381,
-            "{} of possibly-uninitialized variable: `{}`",
-            verb,
-            desc,
-        )
-    }
-
     pub(crate) fn cannot_mutably_borrow_multiply(
         &self,
         new_loan_span: Span,
@@ -175,8 +159,7 @@ pub(crate) fn cannot_reborrow_already_uniquely_borrowed(
             self,
             new_loan_span,
             E0501,
-            "cannot borrow {}{} as {} because previous closure \
-             requires unique access",
+            "cannot borrow {}{} as {} because previous closure requires unique access",
             desc_new,
             opt_via,
             kind_new,
@@ -453,9 +436,8 @@ pub(crate) fn cannot_capture_in_long_lived_closure(
             self,
             closure_span,
             E0373,
-            "{} may outlive the current function, \
-             but it borrows {}, \
-             which is owned by the current function",
+            "{} may outlive the current function, but it borrows {}, which is owned by the current \
+             function",
             closure_kind,
             borrowed_path,
         );
@@ -479,7 +461,7 @@ pub(crate) fn temporary_value_borrowed_for_too_long(
     }
 
     #[rustc_lint_diagnostics]
-    fn struct_span_err_with_code<S: Into<MultiSpan>>(
+    pub(crate) fn struct_span_err_with_code<S: Into<MultiSpan>>(
         &self,
         sp: S,
         msg: impl Into<DiagnosticMessage>,
index d2a54a646ec6d538b3ac91f1ca3cae5469acc0de..b9cfc3732dc7cf13cd77a9e2195d4c4899859b62 100644 (file)
@@ -2,9 +2,12 @@
 use rustc_const_eval::util::CallKind;
 use rustc_data_structures::captures::Captures;
 use rustc_data_structures::fx::FxHashSet;
-use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
+use rustc_errors::{
+    struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan,
+};
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
+use rustc_hir::intravisit::{walk_expr, Visitor};
 use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
 use rustc_infer::infer::TyCtxtInferExt;
 use rustc_infer::traits::ObligationCause;
@@ -18,6 +21,7 @@
     self, subst::Subst, suggest_constraining_type_params, EarlyBinder, PredicateKind, Ty,
 };
 use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
+use rustc_span::hygiene::DesugaringKind;
 use rustc_span::symbol::sym;
 use rustc_span::{BytePos, Span};
 use rustc_trait_selection::infer::InferCtxtExt;
@@ -94,32 +98,20 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
                 return;
             }
 
-            let item_msg =
-                match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
-                    Some(name) => format!("`{}`", name),
-                    None => "value".to_owned(),
-                };
-            let mut err = self.cannot_act_on_uninitialized_variable(
+            let err = self.report_use_of_uninitialized(
+                mpi,
+                used_place,
+                moved_place,
+                desired_action,
                 span,
-                desired_action.as_noun(),
-                &self
-                    .describe_place_with_options(moved_place, IncludingDowncast(true))
-                    .unwrap_or_else(|| "_".to_owned()),
+                use_spans,
             );
-            err.span_label(span, format!("use of possibly-uninitialized {}", item_msg));
-
-            use_spans.var_span_label_path_only(
-                &mut err,
-                format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
-            );
-
             self.buffer_error(err);
         } else {
             if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) {
                 if self.prefixes(*reported_place, PrefixSet::All).any(|p| p == used_place) {
                     debug!(
-                        "report_use_of_moved_or_uninitialized place: error suppressed \
-                         mois={:?}",
+                        "report_use_of_moved_or_uninitialized place: error suppressed mois={:?}",
                         move_out_indices
                     );
                     return;
@@ -326,6 +318,130 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
         }
     }
 
+    fn report_use_of_uninitialized(
+        &self,
+        mpi: MovePathIndex,
+        used_place: PlaceRef<'tcx>,
+        moved_place: PlaceRef<'tcx>,
+        desired_action: InitializationRequiringAction,
+        span: Span,
+        use_spans: UseSpans<'tcx>,
+    ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
+        // We need all statements in the body where the binding was assigned to to later find all
+        // the branching code paths where the binding *wasn't* assigned to.
+        let inits = &self.move_data.init_path_map[mpi];
+        let move_path = &self.move_data.move_paths[mpi];
+        let decl_span = self.body.local_decls[move_path.place.local].source_info.span;
+        let mut spans = vec![];
+        for init_idx in inits {
+            let init = &self.move_data.inits[*init_idx];
+            let span = init.span(&self.body);
+            if !span.is_dummy() {
+                spans.push(span);
+            }
+        }
+
+        let (name, desc) =
+            match self.describe_place_with_options(moved_place, IncludingDowncast(true)) {
+                Some(name) => (format!("`{name}`"), format!("`{name}` ")),
+                None => ("the variable".to_string(), String::new()),
+            };
+        let path = match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
+            Some(name) => format!("`{name}`"),
+            None => "value".to_string(),
+        };
+
+        // We use the statements were the binding was initialized, and inspect the HIR to look
+        // for the branching codepaths that aren't covered, to point at them.
+        let hir_id = self.mir_hir_id();
+        let map = self.infcx.tcx.hir();
+        let body_id = map.body_owned_by(hir_id);
+        let body = map.body(body_id);
+
+        let mut visitor = ConditionVisitor { spans: &spans, name: &name, errors: vec![] };
+        visitor.visit_body(&body);
+
+        let isnt_initialized = if let InitializationRequiringAction::PartialAssignment
+        | InitializationRequiringAction::Assignment = desired_action
+        {
+            // The same error is emitted for bindings that are *sometimes* initialized and the ones
+            // that are *partially* initialized by assigning to a field of an uninitialized
+            // binding. We differentiate between them for more accurate wording here.
+            "isn't fully initialized"
+        } else if spans
+            .iter()
+            .filter(|i| {
+                // We filter these to avoid misleading wording in cases like the following,
+                // where `x` has an `init`, but it is in the same place we're looking at:
+                // ```
+                // let x;
+                // x += 1;
+                // ```
+                !i.contains(span)
+                    // We filter these to avoid incorrect main message on `match-cfg-fake-edges.rs`
+                        && !visitor
+                            .errors
+                            .iter()
+                            .map(|(sp, _)| *sp)
+                            .any(|sp| span < sp && !sp.contains(span))
+            })
+            .count()
+            == 0
+        {
+            "isn't initialized"
+        } else {
+            "is possibly-uninitialized"
+        };
+
+        let used = desired_action.as_general_verb_in_past_tense();
+        let mut err =
+            struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
+        use_spans.var_span_label_path_only(
+            &mut err,
+            format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
+        );
+
+        if let InitializationRequiringAction::PartialAssignment
+        | InitializationRequiringAction::Assignment = desired_action
+        {
+            err.help(
+                "partial initialization isn't supported, fully initialize the binding with a \
+                 default value and mutate it, or use `std::mem::MaybeUninit`",
+            );
+        }
+        err.span_label(span, format!("{path} {used} here but it {isnt_initialized}"));
+
+        let mut shown = false;
+        for (sp, label) in visitor.errors {
+            if sp < span && !sp.overlaps(span) {
+                // When we have a case like `match-cfg-fake-edges.rs`, we don't want to mention
+                // match arms coming after the primary span because they aren't relevant:
+                // ```
+                // let x;
+                // match y {
+                //     _ if { x = 2; true } => {}
+                //     _ if {
+                //         x; //~ ERROR
+                //         false
+                //     } => {}
+                //     _ => {} // We don't want to point to this.
+                // };
+                // ```
+                err.span_label(sp, &label);
+                shown = true;
+            }
+        }
+        if !shown {
+            for sp in &spans {
+                if *sp < span && !sp.overlaps(span) {
+                    err.span_label(*sp, "binding initialized here in some conditions");
+                }
+            }
+        }
+        err.span_label(decl_span, "binding declared here but left uninitialized");
+        err
+    }
+
     fn suggest_borrow_fn_like(
         &self,
         err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
@@ -2448,3 +2564,142 @@ pub(crate) fn emit(&self, cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diagnos
         }
     }
 }
+
+/// Detect whether one of the provided spans is a statement nested within the top-most visited expr
+struct ReferencedStatementsVisitor<'a>(&'a [Span], bool);
+
+impl<'a, 'v> Visitor<'v> for ReferencedStatementsVisitor<'a> {
+    fn visit_stmt(&mut self, s: &'v hir::Stmt<'v>) {
+        match s.kind {
+            hir::StmtKind::Semi(expr) if self.0.contains(&expr.span) => {
+                self.1 = true;
+            }
+            _ => {}
+        }
+    }
+}
+
+/// Given a set of spans representing statements initializing the relevant binding, visit all the
+/// function expressions looking for branching code paths that *do not* initialize the binding.
+struct ConditionVisitor<'b> {
+    spans: &'b [Span],
+    name: &'b str,
+    errors: Vec<(Span, String)>,
+}
+
+impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
+    fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
+        match ex.kind {
+            hir::ExprKind::If(cond, body, None) => {
+                // `if` expressions with no `else` that initialize the binding might be missing an
+                // `else` arm.
+                let mut v = ReferencedStatementsVisitor(self.spans, false);
+                v.visit_expr(body);
+                if v.1 {
+                    self.errors.push((
+                        cond.span,
+                        format!(
+                            "if this `if` condition is `false`, {} is not initialized",
+                            self.name,
+                        ),
+                    ));
+                    self.errors.push((
+                        ex.span.shrink_to_hi(),
+                        format!("an `else` arm might be missing here, initializing {}", self.name),
+                    ));
+                }
+            }
+            hir::ExprKind::If(cond, body, Some(other)) => {
+                // `if` expressions where the binding is only initialized in one of the two arms
+                // might be missing a binding initialization.
+                let mut a = ReferencedStatementsVisitor(self.spans, false);
+                a.visit_expr(body);
+                let mut b = ReferencedStatementsVisitor(self.spans, false);
+                b.visit_expr(other);
+                match (a.1, b.1) {
+                    (true, true) | (false, false) => {}
+                    (true, false) => {
+                        if other.span.is_desugaring(DesugaringKind::WhileLoop) {
+                            self.errors.push((
+                                cond.span,
+                                format!(
+                                    "if this condition isn't met and the `while` loop runs 0 \
+                                     times, {} is not initialized",
+                                    self.name
+                                ),
+                            ));
+                        } else {
+                            self.errors.push((
+                                body.span.shrink_to_hi().until(other.span),
+                                format!(
+                                    "if the `if` condition is `false` and this `else` arm is \
+                                     executed, {} is not initialized",
+                                    self.name
+                                ),
+                            ));
+                        }
+                    }
+                    (false, true) => {
+                        self.errors.push((
+                            cond.span,
+                            format!(
+                                "if this condition is `true`, {} is not initialized",
+                                self.name
+                            ),
+                        ));
+                    }
+                }
+            }
+            hir::ExprKind::Match(e, arms, loop_desugar) => {
+                // If the binding is initialized in one of the match arms, then the other match
+                // arms might be missing an initialization.
+                let results: Vec<bool> = arms
+                    .iter()
+                    .map(|arm| {
+                        let mut v = ReferencedStatementsVisitor(self.spans, false);
+                        v.visit_arm(arm);
+                        v.1
+                    })
+                    .collect();
+                if results.iter().any(|x| *x) && !results.iter().all(|x| *x) {
+                    for (arm, seen) in arms.iter().zip(results) {
+                        if !seen {
+                            if loop_desugar == hir::MatchSource::ForLoopDesugar {
+                                self.errors.push((
+                                    e.span,
+                                    format!(
+                                        "if the `for` loop runs 0 times, {} is not initialized ",
+                                        self.name
+                                    ),
+                                ));
+                            } else if let Some(guard) = &arm.guard {
+                                self.errors.push((
+                                    arm.pat.span.to(guard.body().span),
+                                    format!(
+                                        "if this pattern and condition are matched, {} is not \
+                                         initialized",
+                                        self.name
+                                    ),
+                                ));
+                            } else {
+                                self.errors.push((
+                                    arm.pat.span,
+                                    format!(
+                                        "if this pattern is matched, {} is not initialized",
+                                        self.name
+                                    ),
+                                ));
+                            }
+                        }
+                    }
+                }
+            }
+            // FIXME: should we also account for binops, particularly `&&` and `||`? `try` should
+            // also be accounted for. For now it is fine, as if we don't find *any* relevant
+            // branching code paths, we point at the places where the binding *is* initialized for
+            // *some* context.
+            _ => {}
+        }
+        walk_expr(self, ex);
+    }
+}
index 3c5dd32d2816ecea37208d1bbac1aa0c80d13531..8134e1226628fa2aef91e132497f0b4599ce6d98 100644 (file)
@@ -861,7 +861,7 @@ fn expected_fn_found_fn_mut_call(&self, err: &mut Diagnostic, sp: Span, act: &st
             let arg_pos = args
                 .iter()
                 .enumerate()
-                .filter(|(_, arg)| arg.span == self.body.span)
+                .filter(|(_, arg)| arg.hir_id == closure_id)
                 .map(|(pos, _)| pos)
                 .next();
             let def_id = hir.local_def_id(item_id);
@@ -903,9 +903,7 @@ fn expected_fn_found_fn_mut_call(&self, err: &mut Diagnostic, sp: Span, act: &st
                 if let Some(span) = arg {
                     err.span_label(span, "change this to accept `FnMut` instead of `Fn`");
                     err.span_label(func.span, "expects `Fn` instead of `FnMut`");
-                    if self.infcx.tcx.sess.source_map().is_multiline(self.body.span) {
-                        err.span_label(self.body.span, "in this closure");
-                    }
+                    err.span_label(self.body.span, "in this closure");
                     look_at_return = false;
                 }
             }
index 338df3c70e340551a1fbb6e1c8109f6fb4dabfec..2ed35062da129f4eaba6510c34cee7d3457bf003 100644 (file)
@@ -907,6 +907,16 @@ fn as_verb_in_past_tense(self) -> &'static str {
             InitializationRequiringAction::PartialAssignment => "partially assigned",
         }
     }
+
+    fn as_general_verb_in_past_tense(self) -> &'static str {
+        match self {
+            InitializationRequiringAction::Borrow
+            | InitializationRequiringAction::MatchOn
+            | InitializationRequiringAction::Use => "used",
+            InitializationRequiringAction::Assignment => "assigned",
+            InitializationRequiringAction::PartialAssignment => "partially assigned",
+        }
+    }
 }
 
 impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
index d0e0203bf8c44d0e918f941839f878272baedabc..ea3602e8a056a52010bf6b269e8c47539a3aa5c6 100644 (file)
@@ -495,8 +495,7 @@ fn init_free_and_bound_regions(&mut self) {
                     }
                 }
 
-                NllRegionVariableOrigin::RootEmptyRegion
-                | NllRegionVariableOrigin::Existential { .. } => {
+                NllRegionVariableOrigin::Existential { .. } => {
                     // For existential, regions, nothing to do.
                 }
             }
@@ -1410,8 +1409,7 @@ fn check_universal_regions(
                     self.check_bound_universal_region(fr, placeholder, errors_buffer);
                 }
 
-                NllRegionVariableOrigin::RootEmptyRegion
-                | NllRegionVariableOrigin::Existential { .. } => {
+                NllRegionVariableOrigin::Existential { .. } => {
                     // nothing to check here
                 }
             }
@@ -1513,8 +1511,7 @@ fn check_polonius_subset_errors(
                     self.check_bound_universal_region(fr, placeholder, errors_buffer);
                 }
 
-                NllRegionVariableOrigin::RootEmptyRegion
-                | NllRegionVariableOrigin::Existential { .. } => {
+                NllRegionVariableOrigin::Existential { .. } => {
                     // nothing to check here
                 }
             }
@@ -1788,9 +1785,9 @@ pub(crate) fn cannot_name_placeholder(&self, r1: RegionVid, r2: RegionVid) -> bo
                 universe1.cannot_name(placeholder.universe)
             }
 
-            NllRegionVariableOrigin::RootEmptyRegion
-            | NllRegionVariableOrigin::FreeRegion
-            | NllRegionVariableOrigin::Existential { .. } => false,
+            NllRegionVariableOrigin::FreeRegion | NllRegionVariableOrigin::Existential { .. } => {
+                false
+            }
         }
     }
 
@@ -2152,8 +2149,7 @@ pub(crate) fn best_blame_constraint(
         let blame_source = match from_region_origin {
             NllRegionVariableOrigin::FreeRegion
             | NllRegionVariableOrigin::Existential { from_forall: false } => true,
-            NllRegionVariableOrigin::RootEmptyRegion
-            | NllRegionVariableOrigin::Placeholder(_)
+            NllRegionVariableOrigin::Placeholder(_)
             | NllRegionVariableOrigin::Existential { from_forall: true } => false,
         };
 
index d129e8454265bdab3e19adafe2f7d4299295acac..7c1fa28b8dfcc9c9e731e34b2beda85bcc2897bd 100644 (file)
@@ -1,11 +1,20 @@
+use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::vec_map::VecMap;
 use rustc_hir::def_id::DefId;
 use rustc_hir::OpaqueTyOrigin;
+use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
 use rustc_infer::infer::InferCtxt;
+use rustc_infer::infer::TyCtxtInferExt as _;
+use rustc_infer::traits::{Obligation, ObligationCause, TraitEngine};
+use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable};
+use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts};
+use rustc_middle::ty::visit::TypeVisitable;
 use rustc_middle::ty::{
-    self, OpaqueHiddenType, OpaqueTypeKey, TyCtxt, TypeFoldable, TypeVisitable,
+    self, OpaqueHiddenType, OpaqueTypeKey, ToPredicate, Ty, TyCtxt, TypeFoldable,
 };
-use rustc_trait_selection::opaque_types::InferCtxtExt;
+use rustc_span::Span;
+use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
+use rustc_trait_selection::traits::TraitEngineExt as _;
 
 use super::RegionInferenceContext;
 
@@ -173,3 +182,474 @@ pub(crate) fn name_regions<T>(&self, tcx: TyCtxt<'tcx>, ty: T) -> T
         })
     }
 }
+
+pub trait InferCtxtExt<'tcx> {
+    fn infer_opaque_definition_from_instantiation(
+        &self,
+        opaque_type_key: OpaqueTypeKey<'tcx>,
+        instantiated_ty: OpaqueHiddenType<'tcx>,
+        origin: OpaqueTyOrigin,
+    ) -> Ty<'tcx>;
+}
+
+impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
+    /// Given the fully resolved, instantiated type for an opaque
+    /// type, i.e., the value of an inference variable like C1 or C2
+    /// (*), computes the "definition type" for an opaque type
+    /// definition -- that is, the inferred value of `Foo1<'x>` or
+    /// `Foo2<'x>` that we would conceptually use in its definition:
+    /// ```ignore (illustrative)
+    /// type Foo1<'x> = impl Bar<'x> = AAA;  // <-- this type AAA
+    /// type Foo2<'x> = impl Bar<'x> = BBB;  // <-- or this type BBB
+    /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
+    /// ```
+    /// Note that these values are defined in terms of a distinct set of
+    /// generic parameters (`'x` instead of `'a`) from C1 or C2. The main
+    /// purpose of this function is to do that translation.
+    ///
+    /// (*) C1 and C2 were introduced in the comments on
+    /// `register_member_constraints`. Read that comment for more context.
+    ///
+    /// # Parameters
+    ///
+    /// - `def_id`, the `impl Trait` type
+    /// - `substs`, the substs  used to instantiate this opaque type
+    /// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
+    ///   `opaque_defn.concrete_ty`
+    #[instrument(level = "debug", skip(self))]
+    fn infer_opaque_definition_from_instantiation(
+        &self,
+        opaque_type_key: OpaqueTypeKey<'tcx>,
+        instantiated_ty: OpaqueHiddenType<'tcx>,
+        origin: OpaqueTyOrigin,
+    ) -> Ty<'tcx> {
+        if self.is_tainted_by_errors() {
+            return self.tcx.ty_error();
+        }
+
+        let OpaqueTypeKey { def_id, substs } = opaque_type_key;
+
+        // Use substs to build up a reverse map from regions to their
+        // identity mappings. This is necessary because of `impl
+        // Trait` lifetimes are computed by replacing existing
+        // lifetimes with 'static and remapping only those used in the
+        // `impl Trait` return type, resulting in the parameters
+        // shifting.
+        let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
+        debug!(?id_substs);
+        let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> =
+            substs.iter().enumerate().map(|(index, subst)| (subst, id_substs[index])).collect();
+        debug!("map = {:#?}", map);
+
+        // Convert the type from the function into a type valid outside
+        // the function, by replacing invalid regions with 'static,
+        // after producing an error for each of them.
+        let definition_ty = instantiated_ty.ty.fold_with(&mut ReverseMapper::new(
+            self.tcx,
+            def_id,
+            map,
+            instantiated_ty.ty,
+            instantiated_ty.span,
+        ));
+        debug!(?definition_ty);
+
+        if !check_opaque_type_parameter_valid(
+            self.tcx,
+            opaque_type_key,
+            origin,
+            instantiated_ty.span,
+        ) {
+            return self.tcx.ty_error();
+        }
+
+        // Only check this for TAIT. RPIT already supports `src/test/ui/impl-trait/nested-return-type2.rs`
+        // on stable and we'd break that.
+        if let OpaqueTyOrigin::TyAlias = origin {
+            // This logic duplicates most of `check_opaque_meets_bounds`.
+            // FIXME(oli-obk): Also do region checks here and then consider removing `check_opaque_meets_bounds` entirely.
+            let param_env = self.tcx.param_env(def_id);
+            let body_id = self.tcx.local_def_id_to_hir_id(def_id.as_local().unwrap());
+            self.tcx.infer_ctxt().enter(move |infcx| {
+                // Require the hidden type to be well-formed with only the generics of the opaque type.
+                // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
+                // hidden type is well formed even without those bounds.
+                let predicate =
+                    ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()))
+                        .to_predicate(infcx.tcx);
+                let mut fulfillment_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
+
+                // Require that the hidden type actually fulfills all the bounds of the opaque type, even without
+                // the bounds that the function supplies.
+                match infcx.register_hidden_type(
+                    OpaqueTypeKey { def_id, substs: id_substs },
+                    ObligationCause::misc(instantiated_ty.span, body_id),
+                    param_env,
+                    definition_ty,
+                    origin,
+                ) {
+                    Ok(infer_ok) => {
+                        for obligation in infer_ok.obligations {
+                            fulfillment_cx.register_predicate_obligation(&infcx, obligation);
+                        }
+                    }
+                    Err(err) => {
+                        infcx
+                            .report_mismatched_types(
+                                &ObligationCause::misc(instantiated_ty.span, body_id),
+                                self.tcx.mk_opaque(def_id, id_substs),
+                                definition_ty,
+                                err,
+                            )
+                            .emit();
+                    }
+                }
+
+                fulfillment_cx.register_predicate_obligation(
+                    &infcx,
+                    Obligation::misc(instantiated_ty.span, body_id, param_env, predicate),
+                );
+
+                // Check that all obligations are satisfied by the implementation's
+                // version.
+                let errors = fulfillment_cx.select_all_or_error(&infcx);
+
+                let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
+
+                if errors.is_empty() {
+                    definition_ty
+                } else {
+                    infcx.report_fulfillment_errors(&errors, None, false);
+                    self.tcx.ty_error()
+                }
+            })
+        } else {
+            definition_ty
+        }
+    }
+}
+
+fn check_opaque_type_parameter_valid(
+    tcx: TyCtxt<'_>,
+    opaque_type_key: OpaqueTypeKey<'_>,
+    origin: OpaqueTyOrigin,
+    span: Span,
+) -> bool {
+    match origin {
+        // No need to check return position impl trait (RPIT)
+        // because for type and const parameters they are correct
+        // by construction: we convert
+        //
+        // fn foo<P0..Pn>() -> impl Trait
+        //
+        // into
+        //
+        // type Foo<P0...Pn>
+        // fn foo<P0..Pn>() -> Foo<P0...Pn>.
+        //
+        // For lifetime parameters we convert
+        //
+        // fn foo<'l0..'ln>() -> impl Trait<'l0..'lm>
+        //
+        // into
+        //
+        // type foo::<'p0..'pn>::Foo<'q0..'qm>
+        // fn foo<l0..'ln>() -> foo::<'static..'static>::Foo<'l0..'lm>.
+        //
+        // which would error here on all of the `'static` args.
+        OpaqueTyOrigin::FnReturn(..) | OpaqueTyOrigin::AsyncFn(..) => return true,
+        // Check these
+        OpaqueTyOrigin::TyAlias => {}
+    }
+    let opaque_generics = tcx.generics_of(opaque_type_key.def_id);
+    let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default();
+    for (i, arg) in opaque_type_key.substs.iter().enumerate() {
+        let arg_is_param = match arg.unpack() {
+            GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
+            GenericArgKind::Lifetime(lt) if lt.is_static() => {
+                tcx.sess
+                    .struct_span_err(span, "non-defining opaque type use in defining scope")
+                    .span_label(
+                        tcx.def_span(opaque_generics.param_at(i, tcx).def_id),
+                        "cannot use static lifetime; use a bound lifetime \
+                                    instead or remove the lifetime parameter from the \
+                                    opaque type",
+                    )
+                    .emit();
+                return false;
+            }
+            GenericArgKind::Lifetime(lt) => {
+                matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
+            }
+            GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
+        };
+
+        if arg_is_param {
+            seen_params.entry(arg).or_default().push(i);
+        } else {
+            // Prevent `fn foo() -> Foo<u32>` from being defining.
+            let opaque_param = opaque_generics.param_at(i, tcx);
+            tcx.sess
+                .struct_span_err(span, "non-defining opaque type use in defining scope")
+                .span_note(
+                    tcx.def_span(opaque_param.def_id),
+                    &format!(
+                        "used non-generic {} `{}` for generic parameter",
+                        opaque_param.kind.descr(),
+                        arg,
+                    ),
+                )
+                .emit();
+            return false;
+        }
+    }
+
+    for (_, indices) in seen_params {
+        if indices.len() > 1 {
+            let descr = opaque_generics.param_at(indices[0], tcx).kind.descr();
+            let spans: Vec<_> = indices
+                .into_iter()
+                .map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id))
+                .collect();
+            tcx.sess
+                .struct_span_err(span, "non-defining opaque type use in defining scope")
+                .span_note(spans, &format!("{} used multiple times", descr))
+                .emit();
+            return false;
+        }
+    }
+    true
+}
+
+struct ReverseMapper<'tcx> {
+    tcx: TyCtxt<'tcx>,
+
+    opaque_type_def_id: DefId,
+    map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
+    map_missing_regions_to_empty: bool,
+
+    /// initially `Some`, set to `None` once error has been reported
+    hidden_ty: Option<Ty<'tcx>>,
+
+    /// Span of function being checked.
+    span: Span,
+}
+
+impl<'tcx> ReverseMapper<'tcx> {
+    fn new(
+        tcx: TyCtxt<'tcx>,
+        opaque_type_def_id: DefId,
+        map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
+        hidden_ty: Ty<'tcx>,
+        span: Span,
+    ) -> Self {
+        Self {
+            tcx,
+            opaque_type_def_id,
+            map,
+            map_missing_regions_to_empty: false,
+            hidden_ty: Some(hidden_ty),
+            span,
+        }
+    }
+
+    fn fold_kind_mapping_missing_regions_to_empty(
+        &mut self,
+        kind: GenericArg<'tcx>,
+    ) -> GenericArg<'tcx> {
+        assert!(!self.map_missing_regions_to_empty);
+        self.map_missing_regions_to_empty = true;
+        let kind = kind.fold_with(self);
+        self.map_missing_regions_to_empty = false;
+        kind
+    }
+
+    fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
+        assert!(!self.map_missing_regions_to_empty);
+        kind.fold_with(self)
+    }
+}
+
+impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
+    fn tcx(&self) -> TyCtxt<'tcx> {
+        self.tcx
+    }
+
+    #[instrument(skip(self), level = "debug")]
+    fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
+        match *r {
+            // Ignore bound regions and `'static` regions that appear in the
+            // type, we only need to remap regions that reference lifetimes
+            // from the function declaration.
+            // This would ignore `'r` in a type like `for<'r> fn(&'r u32)`.
+            ty::ReLateBound(..) | ty::ReStatic => return r,
+
+            // If regions have been erased (by writeback), don't try to unerase
+            // them.
+            ty::ReErased => return r,
+
+            // The regions that we expect from borrow checking.
+            ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReEmpty(ty::UniverseIndex::ROOT) => {}
+
+            ty::ReEmpty(_) | ty::RePlaceholder(_) | ty::ReVar(_) => {
+                // All of the regions in the type should either have been
+                // erased by writeback, or mapped back to named regions by
+                // borrow checking.
+                bug!("unexpected region kind in opaque type: {:?}", r);
+            }
+        }
+
+        let generics = self.tcx().generics_of(self.opaque_type_def_id);
+        match self.map.get(&r.into()).map(|k| k.unpack()) {
+            Some(GenericArgKind::Lifetime(r1)) => r1,
+            Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
+            None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
+            None if generics.parent.is_some() => {
+                if let Some(hidden_ty) = self.hidden_ty.take() {
+                    unexpected_hidden_region_diagnostic(
+                        self.tcx,
+                        self.tcx.def_span(self.opaque_type_def_id),
+                        hidden_ty,
+                        r,
+                    )
+                    .emit();
+                }
+                self.tcx.lifetimes.re_root_empty
+            }
+            None => {
+                self.tcx
+                    .sess
+                    .struct_span_err(self.span, "non-defining opaque type use in defining scope")
+                    .span_label(
+                        self.span,
+                        format!(
+                            "lifetime `{}` is part of concrete type but not used in \
+                                 parameter list of the `impl Trait` type alias",
+                            r
+                        ),
+                    )
+                    .emit();
+
+                self.tcx().lifetimes.re_static
+            }
+        }
+    }
+
+    fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
+        match *ty.kind() {
+            ty::Closure(def_id, substs) => {
+                // I am a horrible monster and I pray for death. When
+                // we encounter a closure here, it is always a closure
+                // from within the function that we are currently
+                // type-checking -- one that is now being encapsulated
+                // in an opaque type. Ideally, we would
+                // go through the types/lifetimes that it references
+                // and treat them just like we would any other type,
+                // which means we would error out if we find any
+                // reference to a type/region that is not in the
+                // "reverse map".
+                //
+                // **However,** in the case of closures, there is a
+                // somewhat subtle (read: hacky) consideration. The
+                // problem is that our closure types currently include
+                // all the lifetime parameters declared on the
+                // enclosing function, even if they are unused by the
+                // closure itself. We can't readily filter them out,
+                // so here we replace those values with `'empty`. This
+                // can't really make a difference to the rest of the
+                // compiler; those regions are ignored for the
+                // outlives relation, and hence don't affect trait
+                // selection or auto traits, and they are erased
+                // during codegen.
+
+                let generics = self.tcx.generics_of(def_id);
+                let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
+                    if index < generics.parent_count {
+                        // Accommodate missing regions in the parent kinds...
+                        self.fold_kind_mapping_missing_regions_to_empty(kind)
+                    } else {
+                        // ...but not elsewhere.
+                        self.fold_kind_normally(kind)
+                    }
+                }));
+
+                self.tcx.mk_closure(def_id, substs)
+            }
+
+            ty::Generator(def_id, substs, movability) => {
+                let generics = self.tcx.generics_of(def_id);
+                let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
+                    if index < generics.parent_count {
+                        // Accommodate missing regions in the parent kinds...
+                        self.fold_kind_mapping_missing_regions_to_empty(kind)
+                    } else {
+                        // ...but not elsewhere.
+                        self.fold_kind_normally(kind)
+                    }
+                }));
+
+                self.tcx.mk_generator(def_id, substs, movability)
+            }
+
+            ty::Param(param) => {
+                // Look it up in the substitution list.
+                match self.map.get(&ty.into()).map(|k| k.unpack()) {
+                    // Found it in the substitution list; replace with the parameter from the
+                    // opaque type.
+                    Some(GenericArgKind::Type(t1)) => t1,
+                    Some(u) => panic!("type mapped to unexpected kind: {:?}", u),
+                    None => {
+                        debug!(?param, ?self.map);
+                        self.tcx
+                            .sess
+                            .struct_span_err(
+                                self.span,
+                                &format!(
+                                    "type parameter `{}` is part of concrete type but not \
+                                          used in parameter list for the `impl Trait` type alias",
+                                    ty
+                                ),
+                            )
+                            .emit();
+
+                        self.tcx().ty_error()
+                    }
+                }
+            }
+
+            _ => ty.super_fold_with(self),
+        }
+    }
+
+    fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
+        trace!("checking const {:?}", ct);
+        // Find a const parameter
+        match ct.kind() {
+            ty::ConstKind::Param(..) => {
+                // Look it up in the substitution list.
+                match self.map.get(&ct.into()).map(|k| k.unpack()) {
+                    // Found it in the substitution list, replace with the parameter from the
+                    // opaque type.
+                    Some(GenericArgKind::Const(c1)) => c1,
+                    Some(u) => panic!("const mapped to unexpected kind: {:?}", u),
+                    None => {
+                        self.tcx
+                            .sess
+                            .struct_span_err(
+                                self.span,
+                                &format!(
+                                    "const parameter `{}` is part of concrete type but not \
+                                          used in parameter list for the `impl Trait` type alias",
+                                    ct
+                                ),
+                            )
+                            .emit();
+
+                        self.tcx().const_error(ct.ty())
+                    }
+                }
+            }
+
+            _ => ct,
+        }
+    }
+}
index 89d84fcf09cfe66c7250f6435ce486ec2e54b557..2a7713bc4df3b6d1e8be939ef07799a5c412f820 100644 (file)
@@ -503,7 +503,7 @@ fn build(self) -> UniversalRegions<'tcx> {
 
         let root_empty = self
             .infcx
-            .next_nll_region_var(NllRegionVariableOrigin::RootEmptyRegion)
+            .next_nll_region_var(NllRegionVariableOrigin::Existential { from_forall: true })
             .to_region_vid();
 
         UniversalRegions {
index 1c507678489fec998af4969df78e2e464acb2a9e..0a55d4e0ce0a638287fea46d604df06727104de5 100644 (file)
@@ -2,8 +2,8 @@
 use crate::deriving::generic::*;
 use crate::deriving::path_std;
 
-use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, Generics, ItemKind, MetaItem, VariantData};
+use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData};
+use rustc_data_structures::fx::FxHashSet;
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_span::symbol::{kw, sym, Ident};
 use rustc_span::Span;
@@ -98,22 +98,31 @@ fn cs_clone_simple(
     trait_span: Span,
     substr: &Substructure<'_>,
     is_union: bool,
-) -> P<Expr> {
+) -> BlockOrExpr {
     let mut stmts = Vec::new();
+    let mut seen_type_names = FxHashSet::default();
     let mut process_variant = |variant: &VariantData| {
         for field in variant.fields() {
-            // let _: AssertParamIsClone<FieldTy>;
-            super::assert_ty_bounds(
-                cx,
-                &mut stmts,
-                field.ty.clone(),
-                field.span,
-                &[sym::clone, sym::AssertParamIsClone],
-            );
+            // This basic redundancy checking only prevents duplication of
+            // assertions like `AssertParamIsClone<Foo>` where the type is a
+            // simple name. That's enough to get a lot of cases, though.
+            if let Some(name) = field.ty.kind.is_simple_path() && !seen_type_names.insert(name) {
+                // Already produced an assertion for this type.
+            } else {
+                // let _: AssertParamIsClone<FieldTy>;
+                super::assert_ty_bounds(
+                    cx,
+                    &mut stmts,
+                    field.ty.clone(),
+                    field.span,
+                    &[sym::clone, sym::AssertParamIsClone],
+                );
+            }
         }
     };
 
     if is_union {
+        // Just a single assertion for unions, that the union impls `Copy`.
         // let _: AssertParamIsCopy<Self>;
         let self_ty = cx.ty_path(cx.path_ident(trait_span, Ident::with_dummy_span(kw::SelfUpper)));
         super::assert_ty_bounds(
@@ -139,8 +148,7 @@ fn cs_clone_simple(
             ),
         }
     }
-    stmts.push(cx.stmt_expr(cx.expr_deref(trait_span, cx.expr_self(trait_span))));
-    cx.expr_block(cx.block(trait_span, stmts))
+    BlockOrExpr::new_mixed(stmts, cx.expr_deref(trait_span, cx.expr_self(trait_span)))
 }
 
 fn cs_clone(
@@ -148,7 +156,7 @@ fn cs_clone(
     cx: &mut ExtCtxt<'_>,
     trait_span: Span,
     substr: &Substructure<'_>,
-) -> P<Expr> {
+) -> BlockOrExpr {
     let ctor_path;
     let all_fields;
     let fn_path = cx.std_path(&[sym::clone, sym::Clone, sym::clone]);
@@ -177,7 +185,7 @@ fn cs_clone(
         }
     }
 
-    match *vdata {
+    let expr = match *vdata {
         VariantData::Struct(..) => {
             let fields = all_fields
                 .iter()
@@ -201,5 +209,6 @@ fn cs_clone(
             cx.expr_call(trait_span, path, subcalls)
         }
         VariantData::Unit(..) => cx.expr_path(ctor_path),
-    }
+    };
+    BlockOrExpr::new_expr(expr)
 }
index cb2ad283a1971208cc165a1dd77971f4d5e8e962..c1a2ebcc14601e5d384de4a2ad54be2395f3c590 100644 (file)
@@ -2,8 +2,8 @@
 use crate::deriving::generic::*;
 use crate::deriving::path_std;
 
-use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, MetaItem};
+use rustc_data_structures::fx::FxHashSet;
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_span::symbol::{sym, Ident};
 use rustc_span::Span;
@@ -52,18 +52,26 @@ fn cs_total_eq_assert(
     cx: &mut ExtCtxt<'_>,
     trait_span: Span,
     substr: &Substructure<'_>,
-) -> P<Expr> {
+) -> BlockOrExpr {
     let mut stmts = Vec::new();
+    let mut seen_type_names = FxHashSet::default();
     let mut process_variant = |variant: &ast::VariantData| {
         for field in variant.fields() {
-            // let _: AssertParamIsEq<FieldTy>;
-            super::assert_ty_bounds(
-                cx,
-                &mut stmts,
-                field.ty.clone(),
-                field.span,
-                &[sym::cmp, sym::AssertParamIsEq],
-            );
+            // This basic redundancy checking only prevents duplication of
+            // assertions like `AssertParamIsEq<Foo>` where the type is a
+            // simple name. That's enough to get a lot of cases, though.
+            if let Some(name) = field.ty.kind.is_simple_path() && !seen_type_names.insert(name) {
+                // Already produced an assertion for this type.
+            } else {
+                // let _: AssertParamIsEq<FieldTy>;
+                super::assert_ty_bounds(
+                    cx,
+                    &mut stmts,
+                    field.ty.clone(),
+                    field.span,
+                    &[sym::cmp, sym::AssertParamIsEq],
+                );
+            }
         }
     };
 
@@ -78,5 +86,5 @@ fn cs_total_eq_assert(
         }
         _ => cx.span_bug(trait_span, "unexpected substructure in `derive(Eq)`"),
     }
-    cx.expr_block(cx.block(trait_span, stmts))
+    BlockOrExpr::new_stmts(stmts)
 }
index c7850cd4b4cf6f4226153a8cfbe7edef31ddbf0f..bec59aac5eee1d13ba4f90eb3eea69423795bf5a 100644 (file)
@@ -3,7 +3,7 @@
 use crate::deriving::path_std;
 
 use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, MetaItem};
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_span::symbol::{sym, Ident};
 use rustc_span::Span;
@@ -51,7 +51,7 @@ pub fn ordering_collapsed(
     cx.expr_call_global(span, fn_cmp_path, vec![lft, rgt])
 }
 
-pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
     let test_id = Ident::new(sym::cmp, span);
     let equals_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
 
@@ -70,7 +70,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
     // cmp => cmp
     // }
     //
-    cs_fold(
+    let expr = cs_fold(
         // foldr nests the if-elses correctly, leaving the first field
         // as the outermost one, and the last as the innermost.
         false,
@@ -79,15 +79,12 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
             //     ::std::cmp::Ordering::Equal => old,
             //     cmp => cmp
             // }
-
             let new = {
                 let [other_f] = other_fs else {
                     cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`");
                 };
-
                 let args =
                     vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())];
-
                 cx.expr_call_global(span, cmp_path.clone(), args)
             };
 
@@ -96,7 +93,21 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
 
             cx.expr_match(span, new, vec![eq_arm, neq_arm])
         },
-        cx.expr_path(equals_path.clone()),
+        |cx, args| match args {
+            Some((span, self_f, other_fs)) => {
+                let new = {
+                    let [other_f] = other_fs else {
+                            cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`");
+                        };
+                    let args =
+                        vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())];
+                    cx.expr_call_global(span, cmp_path.clone(), args)
+                };
+
+                new
+            }
+            None => cx.expr_path(equals_path.clone()),
+        },
         Box::new(|cx, span, tag_tuple| {
             if tag_tuple.len() != 2 {
                 cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`")
@@ -107,5 +118,6 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
         cx,
         span,
         substr,
-    )
+    );
+    BlockOrExpr::new_expr(expr)
 }
index ca5ca29eb826a6f02c3244049a79d734c28b0ccb..b44c290d12f567990efef4176040cfa6e5e858d0 100644 (file)
@@ -15,8 +15,6 @@ pub fn expand_deriving_partial_eq(
     item: &Annotatable,
     push: &mut dyn FnMut(Annotatable),
 ) {
-    // structures are equal if all fields are equal, and non equal, if
-    // any fields are not equal or if the enum variants are different
     fn cs_op(
         cx: &mut ExtCtxt<'_>,
         span: Span,
@@ -24,7 +22,7 @@ fn cs_op(
         op: BinOpKind,
         combiner: BinOpKind,
         base: bool,
-    ) -> P<Expr> {
+    ) -> BlockOrExpr {
         let op = |cx: &mut ExtCtxt<'_>, span: Span, self_f: P<Expr>, other_fs: &[P<Expr>]| {
             let [other_f] = other_fs else {
                 cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`");
@@ -33,7 +31,7 @@ fn cs_op(
             cx.expr_binary(span, op, self_f, other_f.clone())
         };
 
-        cs_fold1(
+        let expr = cs_fold(
             true, // use foldl
             |cx, span, subexpr, self_f, other_fs| {
                 let eq = op(cx, span, self_f, other_fs);
@@ -52,13 +50,14 @@ fn cs_op(
             cx,
             span,
             substr,
-        )
+        );
+        BlockOrExpr::new_expr(expr)
     }
 
-    fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+    fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
         cs_op(cx, span, substr, BinOpKind::Eq, BinOpKind::And, true)
     }
-    fn cs_ne(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+    fn cs_ne(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
         cs_op(cx, span, substr, BinOpKind::Ne, BinOpKind::Or, false)
     }
 
index 07db82fee935bb9d48537bf4529162567ac5b07f..5769f08f494824d7e8d8fa9be4361793a5c9ee82 100644 (file)
@@ -48,11 +48,10 @@ pub fn expand_deriving_partial_ord(
     trait_def.expand(cx, mitem, item, push)
 }
 
-pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
     let test_id = Ident::new(sym::cmp, span);
     let ordering = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
     let ordering_expr = cx.expr_path(ordering.clone());
-    let equals_expr = cx.expr_some(span, ordering_expr);
 
     let partial_cmp_path = cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]);
 
@@ -69,7 +68,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
     // cmp => cmp
     // }
     //
-    cs_fold(
+    let expr = cs_fold(
         // foldr nests the if-elses correctly, leaving the first field
         // as the outermost one, and the last as the innermost.
         false,
@@ -95,7 +94,21 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
 
             cx.expr_match(span, new, vec![eq_arm, neq_arm])
         },
-        equals_expr,
+        |cx: &mut ExtCtxt<'_>, args: Option<(Span, P<Expr>, &[P<Expr>])>| match args {
+            Some((span, self_f, other_fs)) => {
+                let new = {
+                    let [other_f] = other_fs else {
+                            cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`");
+                        };
+                    let args =
+                        vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())];
+                    cx.expr_call_global(span, partial_cmp_path.clone(), args)
+                };
+
+                new
+            }
+            None => cx.expr_some(span, ordering_expr.clone()),
+        },
         Box::new(|cx, span, tag_tuple| {
             if tag_tuple.len() != 2 {
                 cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
@@ -110,5 +123,6 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
         cx,
         span,
         substr,
-    )
+    );
+    BlockOrExpr::new_expr(expr)
 }
index 1411c60c0bfd5e22a13c1bbb7874ce27c49e34bd..e04898287608b756523f714298de5b43b525d0cd 100644 (file)
@@ -2,8 +2,7 @@
 use crate::deriving::generic::*;
 use crate::deriving::path_std;
 
-use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, MetaItem};
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_span::symbol::{sym, Ident, Symbol};
 use rustc_span::Span;
@@ -42,7 +41,7 @@ pub fn expand_deriving_debug(
     trait_def.expand(cx, mitem, item, push)
 }
 
-fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
     let (ident, vdata, fields) = match substr.fields {
         Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
         EnumMatching(_, _, v, fields) => (v.ident, &v.data, fields),
@@ -74,7 +73,8 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
     if fields.is_empty() {
         // Special case for no fields.
         let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
-        cx.expr_call_global(span, fn_path_write_str, vec![fmt, name])
+        let expr = cx.expr_call_global(span, fn_path_write_str, vec![fmt, name]);
+        BlockOrExpr::new_expr(expr)
     } else if fields.len() <= CUTOFF {
         // Few enough fields that we can use a specific-length method.
         let debug = if is_struct {
@@ -100,7 +100,8 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
             let field = cx.expr_addr_of(field.span, field);
             args.push(field);
         }
-        cx.expr_call_global(span, fn_path_debug, args)
+        let expr = cx.expr_call_global(span, fn_path_debug, args);
+        BlockOrExpr::new_expr(expr)
     } else {
         // Enough fields that we must use the any-length method.
         let mut name_exprs = Vec::with_capacity(fields.len());
@@ -176,8 +177,6 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
             stmts.push(names_let.unwrap());
         }
         stmts.push(values_let);
-        stmts.push(cx.stmt_expr(expr));
-
-        cx.expr_block(cx.block(span, stmts))
+        BlockOrExpr::new_mixed(stmts, expr)
     }
 }
index 16154fb4d031b160bc1d6bcd75f9a45cbcd7b7a0..b9f2a75082224a5647b856ca092cc165ea205c30 100644 (file)
@@ -62,7 +62,7 @@ fn decodable_substructure(
     trait_span: Span,
     substr: &Substructure<'_>,
     krate: Symbol,
-) -> P<Expr> {
+) -> BlockOrExpr {
     let decoder = substr.nonself_args[0].clone();
     let recurse = vec![
         Ident::new(krate, trait_span),
@@ -74,7 +74,7 @@ fn decodable_substructure(
     let blkarg = Ident::new(sym::_d, trait_span);
     let blkdecoder = cx.expr_ident(trait_span, blkarg);
 
-    match *substr.fields {
+    let expr = match *substr.fields {
         StaticStruct(_, ref summary) => {
             let nfields = match *summary {
                 Unnamed(ref fields, _) => fields.len(),
@@ -173,7 +173,8 @@ fn decodable_substructure(
             )
         }
         _ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
-    }
+    };
+    BlockOrExpr::new_expr(expr)
 }
 
 /// Creates a decoder for a single enum variant/struct:
index d41b25343b08e702c081d01c2a77bdf23b3deafc..90d5cdbc0a0783ac494e2b7941859875f1734f5b 100644 (file)
@@ -1,11 +1,10 @@
 use crate::deriving::generic::ty::*;
 use crate::deriving::generic::*;
 
-use rustc_ast::ptr::P;
+use rustc_ast as ast;
 use rustc_ast::walk_list;
 use rustc_ast::EnumDef;
 use rustc_ast::VariantData;
-use rustc_ast::{Expr, MetaItem};
 use rustc_errors::Applicability;
 use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
 use rustc_span::symbol::Ident;
@@ -16,7 +15,7 @@
 pub fn expand_deriving_default(
     cx: &mut ExtCtxt<'_>,
     span: Span,
-    mitem: &MetaItem,
+    mitem: &ast::MetaItem,
     item: &Annotatable,
     push: &mut dyn FnMut(Annotatable),
 ) {
@@ -59,12 +58,12 @@ fn default_struct_substructure(
     trait_span: Span,
     substr: &Substructure<'_>,
     summary: &StaticFields,
-) -> P<Expr> {
+) -> BlockOrExpr {
     // Note that `kw::Default` is "default" and `sym::Default` is "Default"!
     let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]);
     let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
 
-    match summary {
+    let expr = match summary {
         Unnamed(ref fields, is_tuple) => {
             if !is_tuple {
                 cx.expr_ident(trait_span, substr.type_ident)
@@ -80,31 +79,27 @@ fn default_struct_substructure(
                 .collect();
             cx.expr_struct_ident(trait_span, substr.type_ident, default_fields)
         }
-    }
+    };
+    BlockOrExpr::new_expr(expr)
 }
 
 fn default_enum_substructure(
     cx: &mut ExtCtxt<'_>,
     trait_span: Span,
     enum_def: &EnumDef,
-) -> P<Expr> {
-    let Ok(default_variant) = extract_default_variant(cx, enum_def, trait_span) else {
-        return DummyResult::raw_expr(trait_span, true);
+) -> BlockOrExpr {
+    let expr = if let Ok(default_variant) = extract_default_variant(cx, enum_def, trait_span)
+        && let Ok(_) = validate_default_attribute(cx, default_variant)
+    {
+        // We now know there is exactly one unit variant with exactly one `#[default]` attribute.
+        cx.expr_path(cx.path(
+            default_variant.span,
+            vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident],
+        ))
+    } else {
+        DummyResult::raw_expr(trait_span, true)
     };
-
-    // At this point, we know that there is exactly one variant with a `#[default]` attribute. The
-    // attribute hasn't yet been validated.
-
-    if let Err(()) = validate_default_attribute(cx, default_variant) {
-        return DummyResult::raw_expr(trait_span, true);
-    }
-
-    // We now know there is exactly one unit variant with exactly one `#[default]` attribute.
-
-    cx.expr_path(cx.path(
-        default_variant.span,
-        vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident],
-    ))
+    BlockOrExpr::new_expr(expr)
 }
 
 fn extract_default_variant<'a>(
index 7dc0584618d664401ca9f9271ebe54efff41a50d..0dfce114bfc5399af72a809b64cc3d80721cc0e3 100644 (file)
@@ -89,8 +89,7 @@
 use crate::deriving::generic::*;
 use crate::deriving::pathvec_std;
 
-use rustc_ast::ptr::P;
-use rustc_ast::{Expr, ExprKind, MetaItem, Mutability};
+use rustc_ast::{ExprKind, MetaItem, Mutability};
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_span::symbol::{sym, Ident, Symbol};
 use rustc_span::Span;
@@ -147,7 +146,7 @@ fn encodable_substructure(
     trait_span: Span,
     substr: &Substructure<'_>,
     krate: Symbol,
-) -> P<Expr> {
+) -> BlockOrExpr {
     let encoder = substr.nonself_args[0].clone();
     // throw an underscore in front to suppress unused variable warnings
     let blkarg = Ident::new(sym::_e, trait_span);
@@ -208,7 +207,7 @@ fn encodable_substructure(
             let fn_emit_struct_path =
                 cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_struct]);
 
-            cx.expr_call_global(
+            let expr = cx.expr_call_global(
                 trait_span,
                 fn_emit_struct_path,
                 vec![
@@ -217,7 +216,8 @@ fn encodable_substructure(
                     cx.expr_usize(trait_span, fields.len()),
                     blk,
                 ],
-            )
+            );
+            BlockOrExpr::new_expr(expr)
         }
 
         EnumMatching(idx, _, variant, ref fields) => {
@@ -279,12 +279,12 @@ fn encodable_substructure(
             let blk = cx.lambda1(trait_span, call, blkarg);
             let fn_emit_enum_path: Vec<_> =
                 cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum]);
-            let ret = cx.expr_call_global(
+            let expr = cx.expr_call_global(
                 trait_span,
                 fn_emit_enum_path,
                 vec![encoder, cx.expr_str(trait_span, substr.type_ident.name), blk],
             );
-            cx.expr_block(cx.block(trait_span, vec![me, cx.stmt_expr(ret)]))
+            BlockOrExpr::new_mixed(vec![me], expr)
         }
 
         _ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"),
index 2a9e37081e09e48990e55186c87af928a0de17e1..e618255b0c6fd4b0866d4b58a67bb14f1334f4d3 100644 (file)
@@ -296,7 +296,7 @@ pub enum SubstructureFields<'a> {
 /// Combine the values of all the fields together. The last argument is
 /// all the fields of all the structures.
 pub type CombineSubstructureFunc<'a> =
-    Box<dyn FnMut(&mut ExtCtxt<'_>, Span, &Substructure<'_>) -> P<Expr> + 'a>;
+    Box<dyn FnMut(&mut ExtCtxt<'_>, Span, &Substructure<'_>) -> BlockOrExpr + 'a>;
 
 /// Deal with non-matching enum variants. The slice is the identifiers holding
 /// the variant index value for each of the `Self` arguments.
@@ -314,6 +314,48 @@ struct TypeParameter {
     ty: P<ast::Ty>,
 }
 
+// The code snippets built up for derived code are sometimes used as blocks
+// (e.g. in a function body) and sometimes used as expressions (e.g. in a match
+// arm). This structure avoids committing to either form until necessary,
+// avoiding the insertion of any unnecessary blocks.
+//
+// The statements come before the expression.
+pub struct BlockOrExpr(Vec<ast::Stmt>, Option<P<Expr>>);
+
+impl BlockOrExpr {
+    pub fn new_stmts(stmts: Vec<ast::Stmt>) -> BlockOrExpr {
+        BlockOrExpr(stmts, None)
+    }
+
+    pub fn new_expr(expr: P<Expr>) -> BlockOrExpr {
+        BlockOrExpr(vec![], Some(expr))
+    }
+
+    pub fn new_mixed(stmts: Vec<ast::Stmt>, expr: P<Expr>) -> BlockOrExpr {
+        BlockOrExpr(stmts, Some(expr))
+    }
+
+    // Converts it into a block.
+    fn into_block(mut self, cx: &ExtCtxt<'_>, span: Span) -> P<ast::Block> {
+        if let Some(expr) = self.1 {
+            self.0.push(cx.stmt_expr(expr));
+        }
+        cx.block(span, self.0)
+    }
+
+    // Converts it into an expression.
+    fn into_expr(self, cx: &ExtCtxt<'_>, span: Span) -> P<Expr> {
+        if self.0.is_empty() {
+            match self.1 {
+                None => cx.expr_block(cx.block(span, vec![])),
+                Some(expr) => expr,
+            }
+        } else {
+            cx.expr_block(self.into_block(cx, span))
+        }
+    }
+}
+
 /// This method helps to extract all the type parameters referenced from a
 /// type. For a type parameter `<T>`, it looks for either a `TyPath` that
 /// is not global and starts with `T`, or a `TyQPath`.
@@ -827,7 +869,7 @@ fn call_substructure_method(
         type_ident: Ident,
         nonself_args: &[P<Expr>],
         fields: &SubstructureFields<'_>,
-    ) -> P<Expr> {
+    ) -> BlockOrExpr {
         let span = trait_.span;
         let substructure = Substructure { type_ident, nonself_args, fields };
         let mut f = self.combine_substructure.borrow_mut();
@@ -902,7 +944,7 @@ fn create_method(
         generics: &Generics,
         explicit_self: Option<ast::ExplicitSelf>,
         arg_types: Vec<(Ident, P<ast::Ty>)>,
-        body: P<Expr>,
+        body: BlockOrExpr,
     ) -> P<ast::AssocItem> {
         let span = trait_.span;
         // Create the generics that aren't for `Self`.
@@ -921,7 +963,7 @@ fn create_method(
 
         let method_ident = Ident::new(self.name, span);
         let fn_decl = cx.fn_decl(args, ast::FnRetTy::Ty(ret_type));
-        let body_block = cx.block_expr(body);
+        let body_block = body.into_block(cx, span);
 
         let trait_lo_sp = span.shrink_to_lo();
 
@@ -986,7 +1028,7 @@ fn expand_struct_method_body<'b>(
         nonself_args: &[P<Expr>],
         use_temporaries: bool,
         is_packed: bool,
-    ) -> P<Expr> {
+    ) -> BlockOrExpr {
         let mut raw_fields = Vec::new(); // Vec<[fields of self], [fields of next Self arg], [etc]>
         let span = trait_.span;
         let mut patterns = Vec::new();
@@ -1047,16 +1089,14 @@ fn expand_struct_method_body<'b>(
         );
 
         if !is_packed {
-            body.span = span;
             body
         } else {
             // Do the let-destructuring.
             let mut stmts: Vec<_> = iter::zip(self_args, patterns)
                 .map(|(arg_expr, pat)| cx.stmt_let_pat(span, pat, arg_expr.clone()))
                 .collect();
-            stmts.push(cx.stmt_expr(body));
-
-            cx.expr_block(cx.block(span, stmts))
+            stmts.extend(std::mem::take(&mut body.0));
+            BlockOrExpr(stmts, body.1)
         }
     }
 
@@ -1067,7 +1107,7 @@ fn expand_static_struct_method_body(
         struct_def: &VariantData,
         type_ident: Ident,
         nonself_args: &[P<Expr>],
-    ) -> P<Expr> {
+    ) -> BlockOrExpr {
         let summary = trait_.summarise_struct(cx, struct_def);
 
         self.call_substructure_method(
@@ -1130,7 +1170,7 @@ fn expand_enum_method_body<'b>(
         type_ident: Ident,
         mut self_args: Vec<P<Expr>>,
         nonself_args: &[P<Expr>],
-    ) -> P<Expr> {
+    ) -> BlockOrExpr {
         let span = trait_.span;
         let variants = &enum_def.variants;
 
@@ -1199,7 +1239,11 @@ fn expand_enum_method_body<'b>(
                 }
 
                 // Here is the pat = `(&VariantK, &VariantK, ...)`
-                let single_pat = cx.pat_tuple(span, subpats);
+                let single_pat = if subpats.len() == 1 {
+                    subpats.pop().unwrap()
+                } else {
+                    cx.pat_tuple(span, subpats)
+                };
 
                 // For the BodyK, we need to delegate to our caller,
                 // passing it an EnumMatching to indicate which case
@@ -1253,13 +1297,9 @@ fn expand_enum_method_body<'b>(
                 // Self arg, assuming all are instances of VariantK.
                 // Build up code associated with such a case.
                 let substructure = EnumMatching(index, variants.len(), variant, field_tuples);
-                let arm_expr = self.call_substructure_method(
-                    cx,
-                    trait_,
-                    type_ident,
-                    nonself_args,
-                    &substructure,
-                );
+                let arm_expr = self
+                    .call_substructure_method(cx, trait_, type_ident, nonself_args, &substructure)
+                    .into_expr(cx, span);
 
                 cx.arm(span, single_pat, arm_expr)
             })
@@ -1271,13 +1311,16 @@ fn expand_enum_method_body<'b>(
                 // The index and actual variant aren't meaningful in this case,
                 // so just use whatever
                 let substructure = EnumMatching(0, variants.len(), v, Vec::new());
-                Some(self.call_substructure_method(
-                    cx,
-                    trait_,
-                    type_ident,
-                    nonself_args,
-                    &substructure,
-                ))
+                Some(
+                    self.call_substructure_method(
+                        cx,
+                        trait_,
+                        type_ident,
+                        nonself_args,
+                        &substructure,
+                    )
+                    .into_expr(cx, span),
+                )
             }
             _ if variants.len() > 1 && self_args.len() > 1 => {
                 // Since we know that all the arguments will match if we reach
@@ -1341,13 +1384,15 @@ fn expand_enum_method_body<'b>(
                 }
             }
 
-            let arm_expr = self.call_substructure_method(
-                cx,
-                trait_,
-                type_ident,
-                nonself_args,
-                &catch_all_substructure,
-            );
+            let arm_expr = self
+                .call_substructure_method(
+                    cx,
+                    trait_,
+                    type_ident,
+                    nonself_args,
+                    &catch_all_substructure,
+                )
+                .into_expr(cx, span);
 
             // Final wrinkle: the self_args are expressions that deref
             // down to desired places, but we cannot actually deref
@@ -1371,8 +1416,7 @@ fn expand_enum_method_body<'b>(
             //  }
             let all_match = cx.expr_match(span, match_arg, match_arms);
             let arm_expr = cx.expr_if(span, discriminant_test, all_match, Some(arm_expr));
-            index_let_stmts.push(cx.stmt_expr(arm_expr));
-            cx.expr_block(cx.block(span, index_let_stmts))
+            BlockOrExpr(index_let_stmts, Some(arm_expr))
         } else if variants.is_empty() {
             // As an additional wrinkle, For a zero-variant enum A,
             // currently the compiler
@@ -1423,7 +1467,7 @@ fn expand_enum_method_body<'b>(
             // derive Debug on such a type could here generate code
             // that needs the feature gate enabled.)
 
-            deriving::call_unreachable(cx, span)
+            BlockOrExpr(vec![], Some(deriving::call_unreachable(cx, span)))
         } else {
             // Final wrinkle: the self_args are expressions that deref
             // down to desired places, but we cannot actually deref
@@ -1431,8 +1475,12 @@ fn expand_enum_method_body<'b>(
             // expression; here add a layer of borrowing, turning
             // `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
             self_args.map_in_place(|self_arg| cx.expr_addr_of(span, self_arg));
-            let match_arg = cx.expr(span, ast::ExprKind::Tup(self_args));
-            cx.expr_match(span, match_arg, match_arms)
+            let match_arg = if self_args.len() == 1 {
+                self_args.pop().unwrap()
+            } else {
+                cx.expr(span, ast::ExprKind::Tup(self_args))
+            };
+            BlockOrExpr(vec![], Some(cx.expr_match(span, match_arg, match_arms)))
         }
     }
 
@@ -1443,7 +1491,7 @@ fn expand_static_enum_method_body(
         enum_def: &EnumDef,
         type_ident: Ident,
         nonself_args: &[P<Expr>],
-    ) -> P<Expr> {
+    ) -> BlockOrExpr {
         let summary = enum_def
             .variants
             .iter()
@@ -1606,71 +1654,6 @@ fn create_enum_variant_pattern(
     }
 }
 
-// helpful premade recipes
-
-fn cs_fold_fields<'a, F>(
-    use_foldl: bool,
-    mut f: F,
-    base: P<Expr>,
-    cx: &mut ExtCtxt<'_>,
-    all_fields: &[FieldInfo<'a>],
-) -> P<Expr>
-where
-    F: FnMut(&mut ExtCtxt<'_>, Span, P<Expr>, P<Expr>, &[P<Expr>]) -> P<Expr>,
-{
-    if use_foldl {
-        all_fields
-            .iter()
-            .fold(base, |old, field| f(cx, field.span, old, field.self_.clone(), &field.other))
-    } else {
-        all_fields
-            .iter()
-            .rev()
-            .fold(base, |old, field| f(cx, field.span, old, field.self_.clone(), &field.other))
-    }
-}
-
-fn cs_fold_enumnonmatch(
-    mut enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
-    cx: &mut ExtCtxt<'_>,
-    trait_span: Span,
-    substructure: &Substructure<'_>,
-) -> P<Expr> {
-    match *substructure.fields {
-        EnumNonMatchingCollapsed(tuple) => enum_nonmatch_f(cx, trait_span, tuple),
-        _ => cx.span_bug(trait_span, "cs_fold_enumnonmatch expected an EnumNonMatchingCollapsed"),
-    }
-}
-
-fn cs_fold_static(cx: &mut ExtCtxt<'_>, trait_span: Span) -> P<Expr> {
-    cx.span_bug(trait_span, "static function in `derive`")
-}
-
-/// Fold the fields. `use_foldl` controls whether this is done
-/// left-to-right (`true`) or right-to-left (`false`).
-pub fn cs_fold<F>(
-    use_foldl: bool,
-    f: F,
-    base: P<Expr>,
-    enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
-    cx: &mut ExtCtxt<'_>,
-    trait_span: Span,
-    substructure: &Substructure<'_>,
-) -> P<Expr>
-where
-    F: FnMut(&mut ExtCtxt<'_>, Span, P<Expr>, P<Expr>, &[P<Expr>]) -> P<Expr>,
-{
-    match *substructure.fields {
-        EnumMatching(.., ref all_fields) | Struct(_, ref all_fields) => {
-            cs_fold_fields(use_foldl, f, base, cx, all_fields)
-        }
-        EnumNonMatchingCollapsed(..) => {
-            cs_fold_enumnonmatch(enum_nonmatch_f, cx, trait_span, substructure)
-        }
-        StaticEnum(..) | StaticStruct(..) => cs_fold_static(cx, trait_span),
-    }
-}
-
 /// Function to fold over fields, with three cases, to generate more efficient and concise code.
 /// When the `substructure` has grouped fields, there are two cases:
 /// Zero fields: call the base case function with `None` (like the usual base case of `cs_fold`).
@@ -1679,11 +1662,11 @@ pub fn cs_fold<F>(
 /// fields.
 /// When the `substructure` is an `EnumNonMatchingCollapsed`, the result of `enum_nonmatch_f`
 /// is returned. Statics may not be folded over.
-pub fn cs_fold1<F, B>(
+pub fn cs_fold<F, B>(
     use_foldl: bool,
-    f: F,
+    mut f: F,
     mut b: B,
-    enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
+    mut enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
     cx: &mut ExtCtxt<'_>,
     trait_span: Span,
     substructure: &Substructure<'_>,
@@ -1708,12 +1691,18 @@ pub fn cs_fold1<F, B>(
                 (true, _) => (b(cx, None), &all_fields[..]),
             };
 
-            cs_fold_fields(use_foldl, f, base, cx, rest)
-        }
-        EnumNonMatchingCollapsed(..) => {
-            cs_fold_enumnonmatch(enum_nonmatch_f, cx, trait_span, substructure)
+            if use_foldl {
+                rest.iter().fold(base, |old, field| {
+                    f(cx, field.span, old, field.self_.clone(), &field.other)
+                })
+            } else {
+                rest.iter().rev().fold(base, |old, field| {
+                    f(cx, field.span, old, field.self_.clone(), &field.other)
+                })
+            }
         }
-        StaticEnum(..) | StaticStruct(..) => cs_fold_static(cx, trait_span),
+        EnumNonMatchingCollapsed(tuple) => enum_nonmatch_f(cx, trait_span, tuple),
+        StaticEnum(..) | StaticStruct(..) => cx.span_bug(trait_span, "static function in `derive`"),
     }
 }
 
index 9790449c4b331735a902344bbcb5443ef18e3690..c3f7d09886b3a23681dc8e6f5e2f7bee1a5370d9 100644 (file)
@@ -2,8 +2,7 @@
 use crate::deriving::generic::*;
 use crate::deriving::{self, path_std, pathvec_std};
 
-use rustc_ast::ptr::P;
-use rustc_ast::{Expr, MetaItem, Mutability};
+use rustc_ast::{MetaItem, Mutability};
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_span::symbol::sym;
 use rustc_span::Span;
@@ -45,7 +44,11 @@ pub fn expand_deriving_hash(
     hash_trait_def.expand(cx, mitem, item, push);
 }
 
-fn hash_substructure(cx: &mut ExtCtxt<'_>, trait_span: Span, substr: &Substructure<'_>) -> P<Expr> {
+fn hash_substructure(
+    cx: &mut ExtCtxt<'_>,
+    trait_span: Span,
+    substr: &Substructure<'_>,
+) -> BlockOrExpr {
     let [state_expr] = substr.nonself_args else {
         cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`");
     };
@@ -81,6 +84,5 @@ fn hash_substructure(cx: &mut ExtCtxt<'_>, trait_span: Span, substr: &Substructu
     stmts.extend(
         fields.iter().map(|FieldInfo { ref self_, span, .. }| call_hash(*span, self_.clone())),
     );
-
-    cx.expr_block(cx.block(trait_span, stmts))
+    BlockOrExpr::new_stmts(stmts)
 }
index ce341406eaf4561a2d6aefa29283e8ecb28837dc..d156f87443497b5d7a909f01991298e4a4b05f8b 100644 (file)
@@ -12,7 +12,6 @@
 use rustc_middle::ty::ScalarInt;
 use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
 use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
-use rustc_span::Symbol;
 use rustc_target::abi::{self, HasDataLayout, Pointer, Size};
 
 use crate::consts::const_alloc_to_gcc;
@@ -125,12 +124,15 @@ fn const_real(&self, typ: Type<'gcc>, val: f64) -> RValue<'gcc> {
         self.context.new_rvalue_from_double(typ, val)
     }
 
-    fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) {
-        let s_str = s.as_str();
-        let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
-            self.global_string(s_str)
-        });
-        let len = s_str.len();
+    fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
+        let str_global = *self
+            .const_str_cache
+            .borrow_mut()
+            .raw_entry_mut()
+            .from_key(s)
+            .or_insert_with(|| (s.to_owned(), self.global_string(s)))
+            .1;
+        let len = s.len();
         let cs = self.const_ptrcast(str_global.get_address(None),
             self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
         );
index 44f36cfa4cad4388e11f8ec333deea71c4291f19..478f6d893dd0f347210b4297139f2087f99cdabf 100644 (file)
@@ -13,7 +13,7 @@
 use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
 use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, TyAndLayout, LayoutOfHelpers};
 use rustc_session::Session;
-use rustc_span::{Span, Symbol};
+use rustc_span::Span;
 use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
 use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
 
@@ -101,7 +101,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
     pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>,
 
     /// Cache of constant strings,
-    pub const_str_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
+    pub const_str_cache: RefCell<FxHashMap<String, LValue<'gcc>>>,
 
     /// Cache of globals.
     pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>,
index 5bfdeb8b93a484fc4077f1efad4372155e5c6137..399830de84cb951b68f9f85ce8204e84d2063c02 100644 (file)
@@ -6,7 +6,14 @@
  * TODO(antoyo): remove the patches.
  */
 
-#![feature(rustc_private, decl_macro, associated_type_bounds, never_type, trusted_len)]
+#![feature(
+    rustc_private,
+    decl_macro,
+    associated_type_bounds,
+    never_type,
+    trusted_len,
+    hash_raw_entry
+)]
 #![allow(broken_intra_doc_links)]
 #![recursion_limit="256"]
 #![warn(rust_2018_idioms)]
index d37aadeb523a1ad48c2a8b9b9e0830a939ffcfb9..fc20dee4c74d4c76f6740979ad1abb700a7dcf4e 100644 (file)
@@ -14,7 +14,6 @@
 use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
 use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
 use rustc_middle::ty::ScalarInt;
-use rustc_span::symbol::Symbol;
 use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer, Size};
 
 use libc::{c_char, c_uint};
@@ -180,22 +179,27 @@ fn const_real(&self, t: &'ll Type, val: f64) -> &'ll Value {
         unsafe { llvm::LLVMConstReal(t, val) }
     }
 
-    fn const_str(&self, s: Symbol) -> (&'ll Value, &'ll Value) {
-        let s_str = s.as_str();
-        let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
-            let sc = self.const_bytes(s_str.as_bytes());
-            let sym = self.generate_local_symbol_name("str");
-            let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
-                bug!("symbol `{}` is already defined", sym);
-            });
-            unsafe {
-                llvm::LLVMSetInitializer(g, sc);
-                llvm::LLVMSetGlobalConstant(g, True);
-                llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage);
-            }
-            g
-        });
-        let len = s_str.len();
+    fn const_str(&self, s: &str) -> (&'ll Value, &'ll Value) {
+        let str_global = *self
+            .const_str_cache
+            .borrow_mut()
+            .raw_entry_mut()
+            .from_key(s)
+            .or_insert_with(|| {
+                let sc = self.const_bytes(s.as_bytes());
+                let sym = self.generate_local_symbol_name("str");
+                let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
+                    bug!("symbol `{}` is already defined", sym);
+                });
+                unsafe {
+                    llvm::LLVMSetInitializer(g, sc);
+                    llvm::LLVMSetGlobalConstant(g, True);
+                    llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage);
+                }
+                (s.to_owned(), g)
+            })
+            .1;
+        let len = s.len();
         let cs = consts::ptrcast(
             str_global,
             self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)),
index c007728095f79852708a56c28313c3c8cbcbcd96..55e4a4a7255b585aa181091573de1de4e287fc95 100644 (file)
@@ -26,7 +26,6 @@
 use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
 use rustc_session::Session;
 use rustc_span::source_map::Span;
-use rustc_span::symbol::Symbol;
 use rustc_target::abi::{
     call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
 };
@@ -56,7 +55,7 @@ pub struct CodegenCx<'ll, 'tcx> {
     pub vtables:
         RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
     /// Cache of constant strings,
-    pub const_str_cache: RefCell<FxHashMap<Symbol, &'ll Value>>,
+    pub const_str_cache: RefCell<FxHashMap<String, &'ll Value>>,
 
     /// Reverse-direction for const ptrs cast from globals.
     ///
index 87fbb737ea8a933f8f88179850f903c6feeb63b9..8fc8118849baef066ba68165e7ddb6dd92229822 100644 (file)
@@ -93,8 +93,9 @@ pub fn for_vtable_ty(
     /// Right now this takes the form of a hex-encoded opaque hash value.
     pub fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String {
         let mut hasher = StableHasher::new();
-        let mut hcx = tcx.create_stable_hashing_context();
-        hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher));
+        tcx.with_stable_hashing_context(|mut hcx| {
+            hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher))
+        });
         hasher.finish::<Fingerprint>().to_hex()
     }
 
index 6713a75673550839bbc043d203149b9d97345975..a7dd8e16d28eb7195ecccdfda308a4f708388d2a 100644 (file)
@@ -5,6 +5,7 @@
 //! This API is completely unstable and subject to change.
 
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
+#![feature(hash_raw_entry)]
 #![feature(let_chains)]
 #![feature(let_else)]
 #![feature(extern_types)]
index 553486ae8ec65e4d970cb16a2ce8d31b56acaf1d..1cb8d3423812937658391356d9b8ec3a9c2ef9e1 100644 (file)
@@ -1,13 +1,12 @@
 use rustc_data_structures::temp_dir::MaybeTempDir;
 use rustc_session::cstore::DllImport;
 use rustc_session::Session;
-use rustc_span::symbol::Symbol;
 
 use std::io;
 use std::path::{Path, PathBuf};
 
 pub(super) fn find_library(
-    name: Symbol,
+    name: &str,
     verbatim: bool,
     search_paths: &[PathBuf],
     sess: &Session,
index 6c29692bd3bfe471b6ffa6455d2223fe4452528c..9b0ba34135c11efd00a6e2ffd128e074c1e0ef5b 100644 (file)
@@ -7,7 +7,6 @@
 use std::mem;
 use std::process::{self, Output};
 
-use rustc_span::symbol::Symbol;
 use rustc_target::spec::LldFlavor;
 
 #[derive(Clone)]
@@ -47,11 +46,6 @@ pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
         self
     }
 
-    pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
-        self.arg(arg.as_str());
-        self
-    }
-
     pub fn args<I>(&mut self, args: I) -> &mut Command
     where
         I: IntoIterator<Item: AsRef<OsStr>>,
index 960e98243ac727b8c8d8904d4271812fb9f8fe0b..1628d580b88d33c79c836325a4bb68065334f06f 100644 (file)
@@ -358,7 +358,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
         }
         if let Some(name) = lib.name {
             let location =
-                find_library(name, lib.verbatim.unwrap_or(false), &lib_search_paths, sess);
+                find_library(name.as_str(), lib.verbatim.unwrap_or(false), &lib_search_paths, sess);
             ab.add_archive(&location, |_| false).unwrap_or_else(|e| {
                 sess.fatal(&format!(
                     "failed to add native library {}: {}",
@@ -1122,7 +1122,7 @@ fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf {
         let path = find_sanitizer_runtime(&sess, &filename);
         let rpath = path.to_str().expect("non-utf8 component in path");
         linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
-        linker.link_dylib(Symbol::intern(&filename), false, true);
+        linker.link_dylib(&filename, false, true);
     } else {
         let filename = format!("librustc{}_rt.{}.a", channel, name);
         let path = find_sanitizer_runtime(&sess, &filename).join(&filename);
@@ -2204,6 +2204,7 @@ fn add_local_native_libraries(
         let Some(name) = lib.name else {
             continue;
         };
+        let name = name.as_str();
 
         // Skip if this library is the same as the last.
         last = if (lib.name, lib.kind, lib.verbatim) == last {
@@ -2367,6 +2368,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
                         let Some(name) = lib.name else {
                             continue;
                         };
+                        let name = name.as_str();
                         if !relevant_lib(sess, lib) {
                             continue;
                         }
@@ -2524,7 +2526,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
         }
         let filestem = cratepath.file_stem().unwrap().to_str().unwrap();
         cmd.link_rust_dylib(
-            Symbol::intern(&unlib(&sess.target, filestem)),
+            &unlib(&sess.target, filestem),
             parent.unwrap_or_else(|| Path::new("")),
         );
     }
@@ -2556,6 +2558,7 @@ fn add_upstream_native_libraries(
             let Some(name) = lib.name else {
                 continue;
             };
+            let name = name.as_str();
             if !relevant_lib(sess, &lib) {
                 continue;
             }
index b5b63942e2c6ecac60ff6e0d7b4e91ba965ccb2d..955ee245b28aebe4091d8c433f43c4e9d813946d 100644 (file)
@@ -16,7 +16,6 @@
 use rustc_middle::ty::TyCtxt;
 use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
 use rustc_session::Session;
-use rustc_span::symbol::Symbol;
 use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
 
 use cc::windows_registry;
@@ -163,13 +162,13 @@ pub fn get_linker<'a>(
 pub trait Linker {
     fn cmd(&mut self) -> &mut Command;
     fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path);
-    fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool);
-    fn link_rust_dylib(&mut self, lib: Symbol, path: &Path);
-    fn link_framework(&mut self, framework: Symbol, as_needed: bool);
-    fn link_staticlib(&mut self, lib: Symbol, verbatim: bool);
+    fn link_dylib(&mut self, lib: &str, verbatim: bool, as_needed: bool);
+    fn link_rust_dylib(&mut self, lib: &str, path: &Path);
+    fn link_framework(&mut self, framework: &str, as_needed: bool);
+    fn link_staticlib(&mut self, lib: &str, verbatim: bool);
     fn link_rlib(&mut self, lib: &Path);
     fn link_whole_rlib(&mut self, lib: &Path);
-    fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, search_path: &[PathBuf]);
+    fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]);
     fn include_path(&mut self, path: &Path);
     fn framework_path(&mut self, path: &Path);
     fn output_filename(&mut self, path: &Path);
@@ -423,8 +422,8 @@ fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path)
         }
     }
 
-    fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool) {
-        if self.sess.target.os == "illumos" && lib.as_str() == "c" {
+    fn link_dylib(&mut self, lib: &str, verbatim: bool, as_needed: bool) {
+        if self.sess.target.os == "illumos" && lib == "c" {
             // libc will be added via late_link_args on illumos so that it will
             // appear last in the library search order.
             // FIXME: This should be replaced by a more complete and generic
@@ -454,7 +453,7 @@ fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool) {
             }
         }
     }
-    fn link_staticlib(&mut self, lib: Symbol, verbatim: bool) {
+    fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
         self.hint_static();
         self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib));
     }
@@ -484,20 +483,20 @@ fn no_relro(&mut self) {
         self.linker_arg("-znorelro");
     }
 
-    fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
+    fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
         self.hint_dynamic();
         self.cmd.arg(format!("-l{}", lib));
     }
 
-    fn link_framework(&mut self, framework: Symbol, as_needed: bool) {
+    fn link_framework(&mut self, framework: &str, as_needed: bool) {
         self.hint_dynamic();
         if !as_needed {
             // FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
             // flag but we have no way to detect that here.
-            // self.cmd.arg("-needed_framework").sym_arg(framework);
+            // self.cmd.arg("-needed_framework").arg(framework);
             self.sess.warn("`as-needed` modifier not implemented yet for ld64");
         }
-        self.cmd.arg("-framework").sym_arg(framework);
+        self.cmd.arg("-framework").arg(framework);
     }
 
     // Here we explicitly ask that the entire archive is included into the
@@ -506,7 +505,7 @@ fn link_framework(&mut self, framework: Symbol, as_needed: bool) {
     // don't otherwise explicitly reference them. This can occur for
     // libraries which are just providing bindings, libraries with generic
     // functions, etc.
-    fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, search_path: &[PathBuf]) {
+    fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]) {
         self.hint_static();
         let target = &self.sess.target;
         if !target.is_like_osx {
@@ -836,11 +835,11 @@ fn no_gc_sections(&mut self) {
         self.cmd.arg("/OPT:NOREF,NOICF");
     }
 
-    fn link_dylib(&mut self, lib: Symbol, verbatim: bool, _as_needed: bool) {
+    fn link_dylib(&mut self, lib: &str, verbatim: bool, _as_needed: bool) {
         self.cmd.arg(format!("{}{}", lib, if verbatim { "" } else { ".lib" }));
     }
 
-    fn link_rust_dylib(&mut self, lib: Symbol, path: &Path) {
+    fn link_rust_dylib(&mut self, lib: &str, path: &Path) {
         // When producing a dll, the MSVC linker may not actually emit a
         // `foo.lib` file if the dll doesn't actually export any symbols, so we
         // check to see if the file is there and just omit linking to it if it's
@@ -851,7 +850,7 @@ fn link_rust_dylib(&mut self, lib: Symbol, path: &Path) {
         }
     }
 
-    fn link_staticlib(&mut self, lib: Symbol, verbatim: bool) {
+    fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
         self.cmd.arg(format!("{}{}", lib, if verbatim { "" } else { ".lib" }));
     }
 
@@ -890,11 +889,11 @@ fn output_filename(&mut self, path: &Path) {
     fn framework_path(&mut self, _path: &Path) {
         bug!("frameworks are not supported on windows")
     }
-    fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+    fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
         bug!("frameworks are not supported on windows")
     }
 
-    fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
+    fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, _search_path: &[PathBuf]) {
         self.cmd.arg(format!("/WHOLEARCHIVE:{}{}", lib, if verbatim { "" } else { ".lib" }));
     }
     fn link_whole_rlib(&mut self, path: &Path) {
@@ -1047,8 +1046,8 @@ fn include_path(&mut self, path: &Path) {
         self.cmd.arg("-L").arg(path);
     }
 
-    fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
-        self.cmd.arg("-l").sym_arg(lib);
+    fn link_staticlib(&mut self, lib: &str, _verbatim: bool) {
+        self.cmd.arg("-l").arg(lib);
     }
 
     fn output_filename(&mut self, path: &Path) {
@@ -1059,12 +1058,12 @@ fn add_object(&mut self, path: &Path) {
         self.cmd.arg(path);
     }
 
-    fn link_dylib(&mut self, lib: Symbol, verbatim: bool, _as_needed: bool) {
+    fn link_dylib(&mut self, lib: &str, verbatim: bool, _as_needed: bool) {
         // Emscripten always links statically
         self.link_staticlib(lib, verbatim);
     }
 
-    fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
+    fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, _search_path: &[PathBuf]) {
         // not supported?
         self.link_staticlib(lib, verbatim);
     }
@@ -1074,7 +1073,7 @@ fn link_whole_rlib(&mut self, lib: &Path) {
         self.link_rlib(lib);
     }
 
-    fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
+    fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
         self.link_dylib(lib, false, true);
     }
 
@@ -1098,7 +1097,7 @@ fn framework_path(&mut self, _path: &Path) {
         bug!("frameworks are not supported on Emscripten")
     }
 
-    fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+    fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
         bug!("frameworks are not supported on Emscripten")
     }
 
@@ -1237,12 +1236,12 @@ fn set_output_kind(&mut self, output_kind: LinkOutputKind, _out_filename: &Path)
         }
     }
 
-    fn link_dylib(&mut self, lib: Symbol, _verbatim: bool, _as_needed: bool) {
-        self.cmd.arg("-l").sym_arg(lib);
+    fn link_dylib(&mut self, lib: &str, _verbatim: bool, _as_needed: bool) {
+        self.cmd.arg("-l").arg(lib);
     }
 
-    fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
-        self.cmd.arg("-l").sym_arg(lib);
+    fn link_staticlib(&mut self, lib: &str, _verbatim: bool) {
+        self.cmd.arg("-l").arg(lib);
     }
 
     fn link_rlib(&mut self, lib: &Path) {
@@ -1271,16 +1270,16 @@ fn partial_relro(&mut self) {}
 
     fn no_relro(&mut self) {}
 
-    fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
-        self.cmd.arg("-l").sym_arg(lib);
+    fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
+        self.cmd.arg("-l").arg(lib);
     }
 
-    fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+    fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
         panic!("frameworks not supported")
     }
 
-    fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
-        self.cmd.arg("-l").sym_arg(lib);
+    fn link_whole_staticlib(&mut self, lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
+        self.cmd.arg("-l").arg(lib);
     }
 
     fn link_whole_rlib(&mut self, lib: &Path) {
@@ -1360,10 +1359,10 @@ pub struct L4Bender<'a> {
 }
 
 impl<'a> Linker for L4Bender<'a> {
-    fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
+    fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) {
         bug!("dylibs are not supported on L4Re");
     }
-    fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
+    fn link_staticlib(&mut self, lib: &str, _verbatim: bool) {
         self.hint_static();
         self.cmd.arg(format!("-PC{}", lib));
     }
@@ -1404,15 +1403,15 @@ fn cmd(&mut self) -> &mut Command {
 
     fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
 
-    fn link_rust_dylib(&mut self, _: Symbol, _: &Path) {
+    fn link_rust_dylib(&mut self, _: &str, _: &Path) {
         panic!("Rust dylibs not supported");
     }
 
-    fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+    fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
         bug!("frameworks not supported on L4Re");
     }
 
-    fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
+    fn link_whole_staticlib(&mut self, lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
         self.hint_static();
         self.cmd.arg("--whole-archive").arg(format!("-l{}", lib));
         self.cmd.arg("--no-whole-archive");
@@ -1617,19 +1616,19 @@ fn output_filename(&mut self, path: &Path) {
         self.cmd.arg("-o").arg(path);
     }
 
-    fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
+    fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) {
         panic!("external dylibs not supported")
     }
 
-    fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) {
+    fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) {
         panic!("external dylibs not supported")
     }
 
-    fn link_staticlib(&mut self, _lib: Symbol, _verbatim: bool) {
+    fn link_staticlib(&mut self, _lib: &str, _verbatim: bool) {
         panic!("staticlibs not supported")
     }
 
-    fn link_whole_staticlib(&mut self, _lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
+    fn link_whole_staticlib(&mut self, _lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
         panic!("staticlibs not supported")
     }
 
@@ -1637,7 +1636,7 @@ fn framework_path(&mut self, _path: &Path) {
         panic!("frameworks not supported")
     }
 
-    fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+    fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
         panic!("frameworks not supported")
     }
 
@@ -1717,19 +1716,19 @@ fn output_filename(&mut self, path: &Path) {
         self.cmd.arg("-o").arg(path);
     }
 
-    fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
+    fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) {
         panic!("external dylibs not supported")
     }
 
-    fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) {
+    fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) {
         panic!("external dylibs not supported")
     }
 
-    fn link_staticlib(&mut self, _lib: Symbol, _verbatim: bool) {
+    fn link_staticlib(&mut self, _lib: &str, _verbatim: bool) {
         panic!("staticlibs not supported")
     }
 
-    fn link_whole_staticlib(&mut self, _lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
+    fn link_whole_staticlib(&mut self, _lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
         panic!("staticlibs not supported")
     }
 
@@ -1737,7 +1736,7 @@ fn framework_path(&mut self, _path: &Path) {
         panic!("frameworks not supported")
     }
 
-    fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+    fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
         panic!("frameworks not supported")
     }
 
index 8755d91818d229ecf5117b054f8c3c43fb598206..8cd5a0fc24759efd8178d138f8a30449539bac29 100644 (file)
@@ -701,16 +701,20 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
                 // If we cannot evaluate the constant to a known type, we fall back
                 // to emitting a stable hash value of the constant. This isn't very pretty
                 // but we get a deterministic, virtually unique value for the constant.
-                let hcx = &mut tcx.create_stable_hashing_context();
-                let mut hasher = StableHasher::new();
-                let ct = ct.eval(tcx, ty::ParamEnv::reveal_all());
-                hcx.while_hashing_spans(false, |hcx| ct.to_valtree().hash_stable(hcx, &mut hasher));
+                //
                 // Let's only emit 64 bits of the hash value. That should be plenty for
                 // avoiding collisions and will make the emitted type names shorter.
-                // Note: Don't use `StableHashResult` impl of `u64` here directly, since that
-                // would lead to endianness problems.
-                let hash: u128 = hasher.finish();
-                let hash_short = (hash.to_le() as u64).to_le();
+                let hash_short = tcx.with_stable_hashing_context(|mut hcx| {
+                    let mut hasher = StableHasher::new();
+                    let ct = ct.eval(tcx, ty::ParamEnv::reveal_all());
+                    hcx.while_hashing_spans(false, |hcx| {
+                        ct.to_valtree().hash_stable(hcx, &mut hasher)
+                    });
+                    // Note: Don't use `StableHashResult` impl of `u64` here directly, since that
+                    // would lead to endianness problems.
+                    let hash: u128 = hasher.finish();
+                    (hash.to_le() as u64).to_le()
+                });
 
                 if cpp_like_debuginfo(tcx) {
                     write!(output, "CONST${:x}", hash_short)
index f296a04dea16f143eee0cd82c2eb12eab7121239..b8e3cb32ef633baeb184b0d0350c6a82af136997 100644 (file)
@@ -489,8 +489,7 @@ fn codegen_assert_terminator(
                 (LangItem::PanicBoundsCheck, vec![index, len, location])
             }
             _ => {
-                let msg_str = Symbol::intern(msg.description());
-                let msg = bx.const_str(msg_str);
+                let msg = bx.const_str(msg.description());
                 // It's `pub fn panic(expr: &str)`, with the wide reference being passed
                 // as two arguments, and `#[track_caller]` adds an implicit third argument.
                 (LangItem::Panic, vec![msg.0, msg.1, location])
@@ -571,7 +570,7 @@ enum AssertIntrinsic {
                         }
                     })
                 });
-                let msg = bx.const_str(Symbol::intern(&msg_str));
+                let msg = bx.const_str(&msg_str);
                 let location = self.get_caller_location(bx, source_info).immediate();
 
                 // Obtain the panic entry point.
index c3519a24d5325069d537f585b088617dd55b1a21..fdc7a30e841ed1b7e4d64ff077a3fd6e1b26baf4 100644 (file)
@@ -2,7 +2,6 @@
 use crate::mir::place::PlaceRef;
 use rustc_middle::mir::interpret::{ConstAllocation, Scalar};
 use rustc_middle::ty::layout::TyAndLayout;
-use rustc_span::Symbol;
 use rustc_target::abi::{self, Size};
 
 pub trait ConstMethods<'tcx>: BackendTypes {
@@ -21,7 +20,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
     fn const_u8(&self, i: u8) -> Self::Value;
     fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
 
-    fn const_str(&self, s: Symbol) -> (Self::Value, Self::Value);
+    fn const_str(&self, s: &str) -> (Self::Value, Self::Value);
     fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
 
     fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
new file mode 100644 (file)
index 0000000..a463fe7
--- /dev/null
@@ -0,0 +1,89 @@
+use rustc_hir::ConstContext;
+use rustc_macros::SessionDiagnostic;
+use rustc_span::Span;
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::unstable_in_stable)]
+pub(crate) struct UnstableInStable {
+    pub gate: String,
+    #[primary_span]
+    pub span: Span,
+    #[suggestion(
+        const_eval::unstable_sugg,
+        code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n",
+        applicability = "has-placeholders"
+    )]
+    #[suggestion(
+        const_eval::bypass_sugg,
+        code = "#[rustc_allow_const_fn_unstable({gate})]\n",
+        applicability = "has-placeholders"
+    )]
+    pub attr_span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::thread_local_access, code = "E0625")]
+pub(crate) struct NonConstOpErr {
+    #[primary_span]
+    pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::static_access, code = "E0013")]
+#[help]
+pub(crate) struct StaticAccessErr {
+    #[primary_span]
+    pub span: Span,
+    pub kind: ConstContext,
+    #[note(const_eval::teach_note)]
+    #[help(const_eval::teach_help)]
+    pub teach: Option<()>,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::raw_ptr_to_int)]
+#[note]
+#[note(const_eval::note2)]
+pub(crate) struct RawPtrToIntErr {
+    #[primary_span]
+    pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::raw_ptr_comparison)]
+#[note]
+pub(crate) struct RawPtrComparisonErr {
+    #[primary_span]
+    pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::panic_non_str)]
+pub(crate) struct PanicNonStrErr {
+    #[primary_span]
+    pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::mut_deref, code = "E0658")]
+pub(crate) struct MutDerefErr {
+    #[primary_span]
+    pub span: Span,
+    pub kind: ConstContext,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::transient_mut_borrow, code = "E0658")]
+pub(crate) struct TransientMutBorrowErr {
+    #[primary_span]
+    pub span: Span,
+    pub kind: ConstContext,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::transient_mut_borrow_raw, code = "E0658")]
+pub(crate) struct TransientMutBorrowErrRaw {
+    #[primary_span]
+    pub span: Span,
+    pub kind: ConstContext,
+}
index 0bf78446e37fa0ff27573433cc9bac121a27337b..08102585a7b743342e526dbecd5ec94145105e7b 100644 (file)
@@ -427,7 +427,7 @@ fn check_safe_pointer(
             err_ub!(DanglingIntPointer(0, _)) =>
                 { "a null {kind}" },
             err_ub!(DanglingIntPointer(i, _)) =>
-                { "a dangling {kind} (address 0x{i:x} is unallocated)" },
+                { "a dangling {kind} (address {i:#x} is unallocated)" },
             err_ub!(PointerOutOfBounds { .. }) =>
                 { "a dangling {kind} (going beyond the bounds of its allocation)" },
             // This cannot happen during const-eval (because interning already detects
@@ -941,7 +941,7 @@ fn visit_aggregate(
                                 // element that byte belongs to so we can
                                 // provide an index.
                                 let i = usize::try_from(
-                                    access.uninit_offset.bytes() / layout.size.bytes(),
+                                    access.uninit.start.bytes() / layout.size.bytes(),
                                 )
                                 .unwrap();
                                 self.path.push(PathElem::ArrayElem(i));
index 2d42ae236ad9d99344b5f4a55ff7c0c85699f992..d65d4f7eb720ec4e3cc1981d133759739c792453 100644 (file)
@@ -31,6 +31,7 @@
 extern crate rustc_middle;
 
 pub mod const_eval;
+mod errors;
 pub mod interpret;
 pub mod transform;
 pub mod util;
index f87de4f6a08a4e58200a1f05a75ea8aec9705f99..3dcd96df33cf50dc92b0ed114597effc2a8d626a 100644 (file)
@@ -1,6 +1,6 @@
 //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
 
-use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed};
+use rustc_errors::{Diagnostic, ErrorGuaranteed};
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
 use rustc_index::bit_set::BitSet;
@@ -24,6 +24,7 @@
 use super::resolver::FlowSensitiveAnalysis;
 use super::{ConstCx, Qualif};
 use crate::const_eval::is_unstable_const_fn;
+use crate::errors::UnstableInStable;
 
 type QualifResults<'mir, 'tcx, Q> =
     rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
@@ -1026,23 +1027,5 @@ fn is_int_bool_or_char(ty: Ty<'_>) -> bool {
 fn emit_unstable_in_stable_error(ccx: &ConstCx<'_, '_>, span: Span, gate: Symbol) {
     let attr_span = ccx.tcx.def_span(ccx.def_id()).shrink_to_lo();
 
-    ccx.tcx
-        .sess
-        .struct_span_err(
-            span,
-            &format!("const-stable function cannot use `#[feature({})]`", gate.as_str()),
-        )
-        .span_suggestion(
-            attr_span,
-            "if it is not part of the public API, make this function unstably const",
-            concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n'),
-            Applicability::HasPlaceholders,
-        )
-        .span_suggestion(
-            attr_span,
-            "otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks",
-            format!("#[rustc_allow_const_fn_unstable({})]\n", gate),
-            Applicability::MaybeIncorrect,
-        )
-        .emit();
+    ccx.tcx.sess.emit_err(UnstableInStable { gate: gate.to_string(), span, attr_span });
 }
index 9574661282ba1b2bb5a9f57dd4ff351ab416559a..17376e59e09cc3715d3ab9670530391b6fc83012 100644 (file)
@@ -1,7 +1,9 @@
 //! Concrete error types for all operations which may be invalid in a certain const context.
 
 use hir::def_id::LocalDefId;
-use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
+use rustc_errors::{
+    error_code, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
+};
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
 use rustc_infer::infer::TyCtxtInferExt;
 use rustc_trait_selection::traits::SelectionContext;
 
 use super::ConstCx;
+use crate::errors::{
+    MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrComparisonErr, RawPtrToIntErr,
+    StaticAccessErr, TransientMutBorrowErr, TransientMutBorrowErrRaw,
+};
 use crate::util::{call_kind, CallDesugaringKind, CallKind};
 
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -590,17 +596,17 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        let raw = match self.0 {
-            hir::BorrowKind::Raw => "raw ",
-            hir::BorrowKind::Ref => "",
-        };
-
-        feature_err(
-            &ccx.tcx.sess.parse_sess,
-            sym::const_mut_refs,
-            span,
-            &format!("{}mutable references are not allowed in {}s", raw, ccx.const_kind()),
-        )
+        let kind = ccx.const_kind();
+        match self.0 {
+            hir::BorrowKind::Raw => ccx
+                .tcx
+                .sess
+                .create_feature_err(TransientMutBorrowErrRaw { span, kind }, sym::const_mut_refs),
+            hir::BorrowKind::Ref => ccx
+                .tcx
+                .sess
+                .create_feature_err(TransientMutBorrowErr { span, kind }, sym::const_mut_refs),
+        }
     }
 }
 
@@ -621,12 +627,9 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        feature_err(
-            &ccx.tcx.sess.parse_sess,
-            sym::const_mut_refs,
-            span,
-            &format!("mutation through a reference is not allowed in {}s", ccx.const_kind()),
-        )
+        ccx.tcx
+            .sess
+            .create_feature_err(MutDerefErr { span, kind: ccx.const_kind() }, sym::const_mut_refs)
     }
 }
 
@@ -639,10 +642,7 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        ccx.tcx.sess.struct_span_err(
-            span,
-            "argument to `panic!()` in a const context must have type `&str`",
-        )
+        ccx.tcx.sess.create_err(PanicNonStrErr { span })
     }
 }
 
@@ -657,15 +657,7 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        let mut err = ccx
-            .tcx
-            .sess
-            .struct_span_err(span, "pointers cannot be reliably compared during const eval");
-        err.note(
-            "see issue #53020 <https://github.com/rust-lang/rust/issues/53020> \
-            for more information",
-        );
-        err
+        ccx.tcx.sess.create_err(RawPtrComparisonErr { span })
     }
 }
 
@@ -701,15 +693,7 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        let mut err = ccx
-            .tcx
-            .sess
-            .struct_span_err(span, "pointers cannot be cast to integers during const eval");
-        err.note("at compile-time, pointers do not have an integer value");
-        err.note(
-            "avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior",
-        );
-        err
+        ccx.tcx.sess.create_err(RawPtrToIntErr { span })
     }
 }
 
@@ -730,24 +714,11 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        let mut err = struct_span_err!(
-            ccx.tcx.sess,
+        ccx.tcx.sess.create_err(StaticAccessErr {
             span,
-            E0013,
-            "{}s cannot refer to statics",
-            ccx.const_kind()
-        );
-        err.help(
-            "consider extracting the value of the `static` to a `const`, and referring to that",
-        );
-        if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
-            err.note(
-                "`static` and `const` variables can refer to other `const` variables. \
-                    A `const` variable, however, cannot refer to a `static` variable.",
-            );
-            err.help("To fix this, the value can be extracted to a `const` and then used.");
-        }
-        err
+            kind: ccx.const_kind(),
+            teach: ccx.tcx.sess.teach(&error_code!(E0013)).then_some(()),
+        })
     }
 }
 
@@ -760,13 +731,7 @@ fn build_error(
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        struct_span_err!(
-            ccx.tcx.sess,
-            span,
-            E0625,
-            "thread-local statics cannot be \
-            accessed at compile-time"
-        )
+        ccx.tcx.sess.create_err(NonConstOpErr { span })
     }
 }
 
index 390a44d3f337dee7549d6162f7e1d38b0339455a..0a2d2b40709041873c0739f6a51bafe03bba9254 100644 (file)
@@ -10,6 +10,7 @@
 #![feature(array_windows)]
 #![feature(associated_type_bounds)]
 #![feature(auto_traits)]
+#![feature(cell_leak)]
 #![feature(control_flow_enum)]
 #![feature(extend_one)]
 #![feature(let_else)]
index 4437c0b1b6964b38c2cd885ac31d428dad9bf486..cf0940df9e487c66a18b2a3c1b5ee31502824e02 100644 (file)
@@ -539,6 +539,33 @@ pub fn borrow(&self) -> ReadGuard<'_, T> {
     pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
         self.write()
     }
+
+    #[cfg(not(parallel_compiler))]
+    #[inline(always)]
+    pub fn clone_guard<'a>(rg: &ReadGuard<'a, T>) -> ReadGuard<'a, T> {
+        ReadGuard::clone(rg)
+    }
+
+    #[cfg(parallel_compiler)]
+    #[inline(always)]
+    pub fn clone_guard<'a>(rg: &ReadGuard<'a, T>) -> ReadGuard<'a, T> {
+        ReadGuard::rwlock(&rg).read()
+    }
+
+    #[cfg(not(parallel_compiler))]
+    #[inline(always)]
+    pub fn leak(&self) -> &T {
+        ReadGuard::leak(self.read())
+    }
+
+    #[cfg(parallel_compiler)]
+    #[inline(always)]
+    pub fn leak(&self) -> &T {
+        let guard = self.read();
+        let ret = unsafe { &*(&*guard as *const T) };
+        std::mem::forget(guard);
+        ret
+    }
 }
 
 // FIXME: Probably a bad idea
index 4a42d52f71004c851b27f04b98b0dc5ce83db328..1d3e33c81851f5cb84b1132f51fdda2a535f81ad 100644 (file)
@@ -1,5 +1,5 @@
-builtin_macros-requires-cfg-pattern =
+builtin-macros-requires-cfg-pattern =
     macro requires a cfg-pattern as an argument
     .label = cfg-pattern required
 
-builtin_macros-expected-one-cfg-pattern = expected 1 cfg-pattern
+builtin-macros-expected-one-cfg-pattern = expected 1 cfg-pattern
diff --git a/compiler/rustc_error_messages/locales/en-US/const_eval.ftl b/compiler/rustc_error_messages/locales/en-US/const_eval.ftl
new file mode 100644 (file)
index 0000000..3f2ff86
--- /dev/null
@@ -0,0 +1,31 @@
+const-eval-unstable-in-stable =
+    const-stable function cannot use `#[feature({$gate})]`
+    .unstable-sugg = if it is not part of the public API, make this function unstably const
+    .bypass-sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
+
+const-eval-thread-local-access =
+    thread-local statics cannot be accessed at compile-time
+
+const-eval-static-access =
+    {$kind}s cannot refer to statics
+    .help = consider extracting the value of the `static` to a `const`, and referring to that
+    .teach-note = `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+    .teach-help = To fix this, the value can be extracted to a `const` and then used.
+
+const-eval-raw-ptr-to-int =
+    pointers cannot be cast to integers during const eval
+    .note = at compile-time, pointers do not have an integer value
+    .note2 = avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
+
+const-eval-raw-ptr-comparison =
+    pointers cannot be reliably compared during const eval
+    .note = see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
+
+const-eval-panic-non-str = argument to `panic!()` in a const context must have type `&str`
+
+const-eval-mut-deref =
+    mutation through a reference is not allowed in {$kind}s
+
+const-eval-transient-mut-borrow = mutable references are not allowed in {$kind}s
+
+const-eval-transient-mut-borrow-raw = raw mutable references are not allowed in {$kind}s
index 563d0534d8f388c460daccf53783a9a631d4ad5c..5a482bc5b2c392e311d0a22e093fedb216cf33e3 100644 (file)
@@ -37,6 +37,7 @@
     parser => "../locales/en-US/parser.ftl",
     privacy => "../locales/en-US/privacy.ftl",
     typeck => "../locales/en-US/typeck.ftl",
+    const_eval => "../locales/en-US/const_eval.ftl",
 }
 
 pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES};
index 89557626057133ccbd2d623bcf7e46105d21521e..7d7e92c522922fbf99ba2ac57eb238023a85c715 100644 (file)
@@ -13,6 +13,7 @@ rustc_serialize = { path = "../rustc_serialize" }
 rustc_span = { path = "../rustc_span" }
 rustc_macros = { path = "../rustc_macros" }
 rustc_data_structures = { path = "../rustc_data_structures" }
+rustc_hir = { path = "../rustc_hir" }
 rustc_lint_defs = { path = "../rustc_lint_defs" }
 unicode-width = "0.1.4"
 atty = "0.2"
index 0d1d017d87458655a8af1a162a4e991271ef2151..9429ad1a897453ec2dd7d63abf8eebf3f5f45ab7 100644 (file)
@@ -5,6 +5,7 @@
 };
 use rustc_data_structures::stable_map::FxHashMap;
 use rustc_error_messages::FluentValue;
+use rustc_hir as hir;
 use rustc_lint_defs::{Applicability, LintExpectationId};
 use rustc_span::edition::LATEST_STABLE_EDITION;
 use rustc_span::symbol::{Ident, Symbol};
@@ -160,6 +161,16 @@ fn into(self) -> FluentValue<'source> {
     }
 }
 
+impl IntoDiagnosticArg for hir::ConstContext {
+    fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
+        DiagnosticArgValue::Str(Cow::Borrowed(match self {
+            hir::ConstContext::ConstFn => "constant function",
+            hir::ConstContext::Static(_) => "static",
+            hir::ConstContext::Const => "constant",
+        }))
+    }
+}
+
 /// Trait implemented by error types. This should not be implemented manually. Instead, use
 /// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic].
 #[rustc_diagnostic_item = "AddSubdiagnostic"]
index 6d74e9a9f2b9e5dd20ab8c134b8d21d05934142e..85ea8eb3937822708c0c8206286a3ca4eb0ac18d 100644 (file)
@@ -63,7 +63,7 @@ pub fn new_emitter(
         bundle: Option<Lrc<FluentBundle>>,
         fallback_bundle: LazyFallbackBundle,
         teach: bool,
-        terminal_width: Option<usize>,
+        diagnostic_width: Option<usize>,
         macro_backtrace: bool,
     ) -> EmitterWriter {
         let (short, color_config) = self.unzip();
@@ -76,7 +76,7 @@ pub fn new_emitter(
             short,
             teach,
             color,
-            terminal_width,
+            diagnostic_width,
             macro_backtrace,
         )
     }
@@ -710,7 +710,7 @@ pub struct EmitterWriter {
     short_message: bool,
     teach: bool,
     ui_testing: bool,
-    terminal_width: Option<usize>,
+    diagnostic_width: Option<usize>,
 
     macro_backtrace: bool,
 }
@@ -730,7 +730,7 @@ pub fn stderr(
         fallback_bundle: LazyFallbackBundle,
         short_message: bool,
         teach: bool,
-        terminal_width: Option<usize>,
+        diagnostic_width: Option<usize>,
         macro_backtrace: bool,
     ) -> EmitterWriter {
         let dst = Destination::from_stderr(color_config);
@@ -742,7 +742,7 @@ pub fn stderr(
             short_message,
             teach,
             ui_testing: false,
-            terminal_width,
+            diagnostic_width,
             macro_backtrace,
         }
     }
@@ -755,7 +755,7 @@ pub fn new(
         short_message: bool,
         teach: bool,
         colored: bool,
-        terminal_width: Option<usize>,
+        diagnostic_width: Option<usize>,
         macro_backtrace: bool,
     ) -> EmitterWriter {
         EmitterWriter {
@@ -766,7 +766,7 @@ pub fn new(
             short_message,
             teach,
             ui_testing: false,
-            terminal_width,
+            diagnostic_width,
             macro_backtrace,
         }
     }
@@ -1615,7 +1615,7 @@ fn emit_message_default(
                     width_offset + annotated_file.multiline_depth + 1
                 };
 
-                let column_width = if let Some(width) = self.terminal_width {
+                let column_width = if let Some(width) = self.diagnostic_width {
                     width.saturating_sub(code_offset)
                 } else if self.ui_testing {
                     DEFAULT_COLUMN_WIDTH
index d4d1491c16945f40d2b1225bac3be0a39a3bc190..b8cd334b4c6c6af6844526f60dc7316ff5a0ab7d 100644 (file)
@@ -42,7 +42,7 @@ pub struct JsonEmitter {
     pretty: bool,
     ui_testing: bool,
     json_rendered: HumanReadableErrorType,
-    terminal_width: Option<usize>,
+    diagnostic_width: Option<usize>,
     macro_backtrace: bool,
 }
 
@@ -54,7 +54,7 @@ pub fn stderr(
         fallback_bundle: LazyFallbackBundle,
         pretty: bool,
         json_rendered: HumanReadableErrorType,
-        terminal_width: Option<usize>,
+        diagnostic_width: Option<usize>,
         macro_backtrace: bool,
     ) -> JsonEmitter {
         JsonEmitter {
@@ -66,7 +66,7 @@ pub fn stderr(
             pretty,
             ui_testing: false,
             json_rendered,
-            terminal_width,
+            diagnostic_width,
             macro_backtrace,
         }
     }
@@ -76,7 +76,7 @@ pub fn basic(
         json_rendered: HumanReadableErrorType,
         fluent_bundle: Option<Lrc<FluentBundle>>,
         fallback_bundle: LazyFallbackBundle,
-        terminal_width: Option<usize>,
+        diagnostic_width: Option<usize>,
         macro_backtrace: bool,
     ) -> JsonEmitter {
         let file_path_mapping = FilePathMapping::empty();
@@ -87,7 +87,7 @@ pub fn basic(
             fallback_bundle,
             pretty,
             json_rendered,
-            terminal_width,
+            diagnostic_width,
             macro_backtrace,
         )
     }
@@ -100,7 +100,7 @@ pub fn new(
         fallback_bundle: LazyFallbackBundle,
         pretty: bool,
         json_rendered: HumanReadableErrorType,
-        terminal_width: Option<usize>,
+        diagnostic_width: Option<usize>,
         macro_backtrace: bool,
     ) -> JsonEmitter {
         JsonEmitter {
@@ -112,7 +112,7 @@ pub fn new(
             pretty,
             ui_testing: false,
             json_rendered,
-            terminal_width,
+            diagnostic_width,
             macro_backtrace,
         }
     }
@@ -345,7 +345,7 @@ fn flush(&mut self) -> io::Result<()> {
                 je.fluent_bundle.clone(),
                 je.fallback_bundle.clone(),
                 false,
-                je.terminal_width,
+                je.diagnostic_width,
                 je.macro_backtrace,
             )
             .ui_testing(je.ui_testing)
index 064ed0cde9675dd1ddfe45eb589dab62eb6b86de..69ad623b7ea864b3eda089500698fa72cd122236 100644 (file)
@@ -7,6 +7,7 @@ edition = "2021"
 doctest = false
 
 [dependencies]
+rustc_arena = { path = "../rustc_arena" }
 rustc_target = { path = "../rustc_target" }
 rustc_macros = { path = "../rustc_macros" }
 rustc_data_structures = { path = "../rustc_data_structures" }
index 5d1314ebb488d08bd39fc386d1d3d50921f06393..a6d10f3adae9f510510e7c69f041f8b756ca242b 100644 (file)
@@ -9,7 +9,7 @@ macro_rules! arena_types {
             // HIR types
             [] hir_krate: rustc_hir::Crate<'tcx>,
             [] arm: rustc_hir::Arm<'tcx>,
-            [] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, Span),
+            [] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, rustc_span::Span),
             [] asm_template: rustc_ast::InlineAsmTemplatePiece,
             [] attribute: rustc_ast::Attribute,
             [] block: rustc_hir::Block<'tcx>,
index a2ef158ce8d324cd1338fc704764954d4a617440..acd77f5d2ee9136b835cb3b9bc3758b7607020ef 100644 (file)
@@ -1595,6 +1595,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
+// NOTE: `IntoDiagnosticArg` impl for `ConstContext` lives in `rustc_errors`
+// due to a cyclical dependency between hir that crate.
+
 /// A literal.
 pub type Lit = Spanned<LitKind>;
 
index 384a0f9c22532082abd6ce7131432b61d3434eb0..531d9f14040217c86c2580c1fe08ae187a561665 100644 (file)
@@ -19,7 +19,7 @@
 //!    - Example: Examine each expression to look for its type and do some check or other.
 //!    - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
 //!      `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use
-//!      `tcx.hir().deep_visit_all_item_likes(&mut visitor)`. Within your
+//!      `tcx.hir().visit_all_item_likes_in_crate(&mut visitor)`. Within your
 //!      `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke
 //!      `intravisit::walk_expr()` to keep walking the subparts).
 //!    - Pro: Visitor methods for any kind of HIR node, not just item-like things.
@@ -190,7 +190,7 @@ impl NestedFilter<'_> for None {
 /// (this is why the module is called `intravisit`, to distinguish it
 /// from the AST's `visit` module, which acts differently). If you
 /// simply want to visit all items in the crate in some order, you
-/// should call `Crate::visit_all_items`. Otherwise, see the comment
+/// should call `tcx.hir().visit_all_item_likes_in_crate`. Otherwise, see the comment
 /// on `visit_nested_item` for details on how to visit nested items.
 ///
 /// If you want to ensure that your code handles every variant
index 9f32a7da159a2e8feefb33c83cb8965d1327729f..0f9e6fa7b98951648a32d3b3c52515bad42e9218 100644 (file)
@@ -18,6 +18,8 @@
 #[macro_use]
 extern crate rustc_data_structures;
 
+extern crate self as rustc_hir;
+
 mod arena;
 pub mod def;
 pub mod def_path_hash_map;
@@ -41,3 +43,5 @@
 pub use lang_items::{LangItem, LanguageItems};
 pub use stable_hash_impls::HashStableContext;
 pub use target::{MethodKind, Target};
+
+arena_types!(rustc_arena::declare_arena);
index a89b9eafaa62d6e24825306622e6aeff2ed9c939..93528b4514b56ed250f5af5cbab4353a7dbda7a9 100644 (file)
@@ -75,7 +75,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
             let mut visitor =
                 IfThisChanged { tcx, if_this_changed: vec![], then_this_would_need: vec![] };
             visitor.process_attrs(hir::CRATE_HIR_ID);
-            tcx.hir().deep_visit_all_item_likes(&mut visitor);
+            tcx.hir().visit_all_item_likes_in_crate(&mut visitor);
             (visitor.if_this_changed, visitor.then_this_would_need)
         };
 
index fad949a3bc6a15a55fa2aeb34284e1b6a96ba9ee..d566634a49203b9272a9ed4802f51f3d2fd70d04 100644 (file)
@@ -4,7 +4,7 @@
 //! and use that to decide when one free region outlives another, and so forth.
 
 use rustc_data_structures::transitive_relation::TransitiveRelation;
-use rustc_middle::ty::{self, Lift, Region, TyCtxt};
+use rustc_middle::ty::{Lift, Region, TyCtxt};
 
 /// Combines a `FreeRegionMap` and a `TyCtxt`.
 ///
@@ -49,7 +49,7 @@ pub fn is_empty(&self) -> bool {
     // (with the exception that `'static: 'x` is not notable)
     pub fn relate_regions(&mut self, sub: Region<'tcx>, sup: Region<'tcx>) {
         debug!("relate_regions(sub={:?}, sup={:?})", sub, sup);
-        if self.is_free_or_static(sub) && self.is_free(sup) {
+        if sub.is_free_or_static() && sup.is_free() {
             self.relation.add(sub, sup)
         }
     }
@@ -68,7 +68,7 @@ pub fn sub_free_regions(
         r_a: Region<'tcx>,
         r_b: Region<'tcx>,
     ) -> bool {
-        assert!(self.is_free_or_static(r_a) && self.is_free_or_static(r_b));
+        assert!(r_a.is_free_or_static() && r_b.is_free_or_static());
         let re_static = tcx.lifetimes.re_static;
         if self.check_relation(re_static, r_b) {
             // `'a <= 'static` is always true, and not stored in the
@@ -85,20 +85,6 @@ fn check_relation(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> bool {
         r_a == r_b || self.relation.contains(r_a, r_b)
     }
 
-    /// True for free regions other than `'static`.
-    pub fn is_free(&self, r: Region<'_>) -> bool {
-        matches!(*r, ty::ReEarlyBound(_) | ty::ReFree(_))
-    }
-
-    /// True if `r` is a free region or static of the sort that this
-    /// free region map can be used with.
-    pub fn is_free_or_static(&self, r: Region<'_>) -> bool {
-        match *r {
-            ty::ReStatic => true,
-            _ => self.is_free(r),
-        }
-    }
-
     /// Computes the least-upper-bound of two free regions. In some
     /// cases, this is more conservative than necessary, in order to
     /// avoid making arbitrary choices. See
@@ -110,8 +96,8 @@ pub fn lub_free_regions(
         r_b: Region<'tcx>,
     ) -> Region<'tcx> {
         debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
-        assert!(self.is_free(r_a));
-        assert!(self.is_free(r_b));
+        assert!(r_a.is_free());
+        assert!(r_b.is_free());
         let result = if r_a == r_b {
             r_a
         } else {
index 87fa22b3835ef1c2a1fbcff2d40c58d19cbb7241..3783cfb4cc5c85c85aaf53e674bdfb7916a95ba8 100644 (file)
@@ -47,7 +47,6 @@ pub(crate) fn resolve<'tcx>(
 #[derive(Clone)]
 pub struct LexicalRegionResolutions<'tcx> {
     pub(crate) values: IndexVec<RegionVid, VarValue<'tcx>>,
-    pub(crate) error_region: ty::Region<'tcx>,
 }
 
 #[derive(Copy, Clone, Debug)]
@@ -140,7 +139,6 @@ fn num_vars(&self) -> usize {
     /// empty region. The `expansion` phase will grow this larger.
     fn construct_var_data(&self, tcx: TyCtxt<'tcx>) -> LexicalRegionResolutions<'tcx> {
         LexicalRegionResolutions {
-            error_region: tcx.lifetimes.re_static,
             values: IndexVec::from_fn_n(
                 |vid| {
                     let vid_universe = self.var_infos[vid].universe;
@@ -310,7 +308,7 @@ fn sub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> bool {
 
         // Check for the case where we know that `'b: 'static` -- in that case,
         // `a <= b` for all `a`.
-        let b_free_or_static = self.region_rels.free_regions.is_free_or_static(b);
+        let b_free_or_static = b.is_free_or_static();
         if b_free_or_static && sub_free_regions(tcx.lifetimes.re_static, b) {
             return true;
         }
@@ -320,7 +318,7 @@ fn sub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> bool {
         // `lub` relationship defined below, since sometimes the "lub"
         // is actually the `postdom_upper_bound` (see
         // `TransitiveRelation` for more details).
-        let a_free_or_static = self.region_rels.free_regions.is_free_or_static(a);
+        let a_free_or_static = a.is_free_or_static();
         if a_free_or_static && b_free_or_static {
             return sub_free_regions(a, b);
         }
@@ -864,10 +862,7 @@ fn normalize<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
     where
         T: TypeFoldable<'tcx>,
     {
-        tcx.fold_regions(value, |r, _db| match *r {
-            ty::ReVar(rid) => self.resolve_var(rid),
-            _ => r,
-        })
+        tcx.fold_regions(value, |r, _db| self.resolve_region(tcx, r))
     }
 
     fn value(&self, rid: RegionVid) -> &VarValue<'tcx> {
@@ -878,12 +873,19 @@ fn value_mut(&mut self, rid: RegionVid) -> &mut VarValue<'tcx> {
         &mut self.values[rid]
     }
 
-    pub fn resolve_var(&self, rid: RegionVid) -> ty::Region<'tcx> {
-        let result = match self.values[rid] {
-            VarValue::Value(r) => r,
-            VarValue::ErrorValue => self.error_region,
+    pub(crate) fn resolve_region(
+        &self,
+        tcx: TyCtxt<'tcx>,
+        r: ty::Region<'tcx>,
+    ) -> ty::Region<'tcx> {
+        let result = match *r {
+            ty::ReVar(rid) => match self.values[rid] {
+                VarValue::Value(r) => r,
+                VarValue::ErrorValue => tcx.lifetimes.re_static,
+            },
+            _ => r,
         };
-        debug!("resolve_var({:?}) = {:?}", rid, result);
+        debug!("resolve_region({:?}) = {:?}", r, result);
         result
     }
 }
index 991fd23ab4344660949b4e0ce80673f672cc5aaa..28f037cc61a76136e2c67d06b52ee6ee76c7c618 100644 (file)
@@ -466,9 +466,6 @@ pub enum NllRegionVariableOrigin {
     /// from a `for<'a> T` binder). Meant to represent "any region".
     Placeholder(ty::PlaceholderRegion),
 
-    /// The variable we create to represent `'empty(U0)`.
-    RootEmptyRegion,
-
     Existential {
         /// If this is true, then this variable was created to represent a lifetime
         /// bound in a `for` binder. For example, it might have been created to
@@ -891,6 +888,10 @@ pub fn region_constraints_added_in_snapshot(
             .region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
     }
 
+    pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'a, 'tcx>) -> bool {
+        self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
+    }
+
     pub fn add_given(&self, sub: ty::Region<'tcx>, sup: ty::RegionVid) {
         self.inner.borrow_mut().unwrap_region_constraints().add_given(sub, sup);
     }
@@ -1250,7 +1251,6 @@ pub fn skip_region_resolution(&self) {
         };
 
         let lexical_region_resolutions = LexicalRegionResolutions {
-            error_region: self.tcx.lifetimes.re_static,
             values: rustc_index::vec::IndexVec::from_elem_n(
                 crate::infer::lexical_region_resolve::VarValue::Value(self.tcx.lifetimes.re_erased),
                 var_infos.len(),
index 26d689f29eeaf690c4dfc47186e712b33f421811..f11701bba6f43d61bec267fa252f0ff9b24698c5 100644 (file)
@@ -95,7 +95,7 @@ pub fn handle_opaque_type(
         }
         let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
         let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
-            ty::Opaque(def_id, substs) => {
+            ty::Opaque(def_id, substs) if def_id.is_local() => {
                 let origin = if self.defining_use_anchor.is_some() {
                     // Check that this is `impl Trait` type is
                     // declared by `parent_def_id` -- i.e., one whose
index a61456874292075af538eaac5597f9f97b117659..3d99f0958f7f9a7220a0c8d946272b7520564ae5 100644 (file)
@@ -206,13 +206,13 @@ fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
 
     fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> {
         match *r {
-            ty::ReVar(rid) => Ok(self
+            ty::ReVar(_) => Ok(self
                 .infcx
                 .lexical_region_resolutions
                 .borrow()
                 .as_ref()
                 .expect("region resolution not performed")
-                .resolve_var(rid)),
+                .resolve_region(self.infcx.tcx, r)),
             _ => Ok(r),
         }
     }
index 1b696f21cbcf479364509311159e6912478123d5..74a26ebc39f817c0673c1e86e9595312c4d9d8b1 100644 (file)
@@ -185,6 +185,10 @@ pub(crate) fn region_constraints_in_snapshot(
         })
     }
 
+    pub(crate) fn opaque_types_in_snapshot(&self, s: &Snapshot<'tcx>) -> bool {
+        self.logs[s.undo_len..].iter().any(|log| matches!(log, UndoLog::OpaqueTypes(..)))
+    }
+
     pub(crate) fn region_constraints(
         &self,
     ) -> impl Iterator<Item = &'_ region_constraints::UndoLog<'tcx>> + Clone {
index 932e597509f9990631cb4d05b8b5d73a87282c0e..5d22f9f972e10626b34adecb59283ba04905db0e 100644 (file)
@@ -203,7 +203,7 @@ pub fn complete(&mut self, key: ProjectionCacheKey<'tcx>, result: EvaluationResu
             Some(&ProjectionCacheEntry::NormalizedTy { ref ty, complete: _ }) => {
                 info!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty);
                 let mut ty = ty.clone();
-                if result == EvaluationResult::EvaluatedToOk {
+                if result.must_apply_considering_regions() {
                     ty.obligations = vec![];
                 }
                 map.insert(key, ProjectionCacheEntry::NormalizedTy { ty, complete: Some(result) });
index 5b263aded9cdfe11b6e9b2c34a0a5c517d59efa8..b7d1d6edfaa7b5dcf8be794b9ba7ed44ddfd54e4 100644 (file)
@@ -14,7 +14,6 @@
 use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
 use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
 use rustc_hir::definitions::Definitions;
-use rustc_hir::Crate;
 use rustc_lint::{EarlyCheckNode, LintStore};
 use rustc_metadata::creader::CStore;
 use rustc_metadata::{encode_metadata, EncodedMetadata};
@@ -482,37 +481,6 @@ pub fn configure_and_expand(
     Ok(krate)
 }
 
-fn lower_to_hir<'tcx>(
-    sess: &Session,
-    definitions: &mut Definitions,
-    cstore: &CrateStoreDyn,
-    resolutions: &ty::ResolverOutputs,
-    resolver: ty::ResolverAstLowering,
-    krate: Rc<ast::Crate>,
-    arena: &'tcx rustc_ast_lowering::Arena<'tcx>,
-) -> &'tcx Crate<'tcx> {
-    // Lower AST to HIR.
-    let hir_crate = rustc_ast_lowering::lower_crate(
-        sess,
-        &krate,
-        definitions,
-        cstore,
-        resolutions,
-        resolver,
-        arena,
-    );
-
-    // Drop AST to free memory
-    sess.time("drop_ast", || std::mem::drop(krate));
-
-    // Discard hygiene data, which isn't required after lowering to HIR.
-    if !sess.opts.debugging_opts.keep_hygiene_data {
-        rustc_span::hygiene::clear_syntax_context_map();
-    }
-
-    hir_crate
-}
-
 // Returns all the paths that correspond to generated files.
 fn generated_output_paths(
     sess: &Session,
@@ -777,6 +745,7 @@ pub fn prepare_outputs(
 pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
     let providers = &mut Providers::default();
     providers.analysis = analysis;
+    providers.hir_crate = rustc_ast_lowering::lower_to_hir;
     proc_macro_decls::provide(providers);
     rustc_const_eval::provide(providers);
     rustc_middle::hir::provide(providers);
@@ -823,7 +792,7 @@ pub fn enter<F, R>(&mut self, f: F) -> R
 pub fn create_global_ctxt<'tcx>(
     compiler: &'tcx Compiler,
     lint_store: Lrc<LintStore>,
-    krate: Rc<ast::Crate>,
+    krate: Lrc<ast::Crate>,
     dep_graph: DepGraph,
     resolver: Rc<RefCell<BoxedResolver>>,
     outputs: OutputFilenames,
@@ -831,29 +800,17 @@ pub fn create_global_ctxt<'tcx>(
     queries: &'tcx OnceCell<TcxQueries<'tcx>>,
     global_ctxt: &'tcx OnceCell<GlobalCtxt<'tcx>>,
     arena: &'tcx WorkerLocal<Arena<'tcx>>,
-    hir_arena: &'tcx WorkerLocal<rustc_ast_lowering::Arena<'tcx>>,
+    hir_arena: &'tcx WorkerLocal<rustc_hir::Arena<'tcx>>,
 ) -> QueryContext<'tcx> {
     // We're constructing the HIR here; we don't care what we will
     // read, since we haven't even constructed the *input* to
     // incr. comp. yet.
     dep_graph.assert_ignored();
 
-    let (mut definitions, cstore, resolver_outputs, resolver_for_lowering) =
+    let (definitions, cstore, resolver_outputs, resolver_for_lowering) =
         BoxedResolver::to_resolver_outputs(resolver);
 
     let sess = &compiler.session();
-
-    // Lower AST to HIR.
-    let krate = lower_to_hir(
-        sess,
-        &mut definitions,
-        &*cstore,
-        &resolver_outputs,
-        resolver_for_lowering,
-        krate,
-        hir_arena,
-    );
-
     let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess);
 
     let codegen_backend = compiler.codegen_backend();
@@ -877,9 +834,11 @@ pub fn create_global_ctxt<'tcx>(
                 sess,
                 lint_store,
                 arena,
+                hir_arena,
                 definitions,
                 cstore,
                 resolver_outputs,
+                resolver_for_lowering,
                 krate,
                 dep_graph,
                 queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
index 136f0443fa0a36e4285366095e2c788af36a800d..8ffb1ad05399427d5f866b813d741965db17bacc 100644 (file)
@@ -72,13 +72,13 @@ pub struct Queries<'tcx> {
     queries: OnceCell<TcxQueries<'tcx>>,
 
     arena: WorkerLocal<Arena<'tcx>>,
-    hir_arena: WorkerLocal<rustc_ast_lowering::Arena<'tcx>>,
+    hir_arena: WorkerLocal<rustc_hir::Arena<'tcx>>,
 
     dep_graph_future: Query<Option<DepGraphFuture>>,
     parse: Query<ast::Crate>,
     crate_name: Query<String>,
     register_plugins: Query<(ast::Crate, Lrc<LintStore>)>,
-    expansion: Query<(Rc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>,
+    expansion: Query<(Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>,
     dep_graph: Query<DepGraph>,
     prepare_outputs: Query<OutputFilenames>,
     global_ctxt: Query<QueryContext<'tcx>>,
@@ -92,7 +92,7 @@ pub fn new(compiler: &'tcx Compiler) -> Queries<'tcx> {
             gcx: OnceCell::new(),
             queries: OnceCell::new(),
             arena: WorkerLocal::new(|_| Arena::default()),
-            hir_arena: WorkerLocal::new(|_| rustc_ast_lowering::Arena::default()),
+            hir_arena: WorkerLocal::new(|_| rustc_hir::Arena::default()),
             dep_graph_future: Default::default(),
             parse: Default::default(),
             crate_name: Default::default(),
@@ -164,7 +164,7 @@ pub fn crate_name(&self) -> Result<&Query<String>> {
 
     pub fn expansion(
         &self,
-    ) -> Result<&Query<(Rc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>> {
+    ) -> Result<&Query<(Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>> {
         tracing::trace!("expansion");
         self.expansion.compute(|| {
             let crate_name = self.crate_name()?.peek().clone();
@@ -180,7 +180,7 @@ pub fn expansion(
             let krate = resolver.access(|resolver| {
                 passes::configure_and_expand(sess, &lint_store, krate, &crate_name, resolver)
             })?;
-            Ok((Rc::new(krate), Rc::new(RefCell::new(resolver)), lint_store))
+            Ok((Lrc::new(krate), Rc::new(RefCell::new(resolver)), lint_store))
         })
     }
 
index 30a29ed6ed38f8640bfe80adf2872f9b89c2801f..1bb79a0264dd1c146f2fd77b125771513b08ebe2 100644 (file)
@@ -649,6 +649,7 @@ macro_rules! untracked {
     untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
     untracked!(dont_buffer_diagnostics, true);
     untracked!(dump_dep_graph, true);
+    untracked!(dump_drop_tracking_cfg, Some("cfg.dot".to_string()));
     untracked!(dump_mir, Some(String::from("abc")));
     untracked!(dump_mir_dataflow, true);
     untracked!(dump_mir_dir, String::from("abc"));
@@ -689,7 +690,6 @@ macro_rules! untracked {
     untracked!(span_debug, true);
     untracked!(span_free_formats, true);
     untracked!(temps_dir, Some(String::from("abc")));
-    untracked!(terminal_width, Some(80));
     untracked!(threads, 99);
     untracked!(time, true);
     untracked!(time_llvm_passes, true);
index c1d8d76c975d887d8b8f0709db0e9ba1d80d219b..27f67207209dd81cc275b3f1cb9a7e0bac5c5860 100644 (file)
@@ -34,7 +34,7 @@
 
 /// Extract the `LintStore` from the query context.
 /// This function exists because we've erased `LintStore` as `dyn Any` in the context.
-pub(crate) fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore {
+pub fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore {
     let store: &dyn Any = &*tcx.lint_store;
     store.downcast_ref().unwrap()
 }
index c1255ae5056ac54932d395b4f099ab9222b8e941..aaee0caa070e72d83816116aa6aa590282617f4c 100644 (file)
@@ -99,7 +99,7 @@
 pub use context::{CheckLintNameResult, FindLintError, LintStore};
 pub use context::{EarlyContext, LateContext, LintContext};
 pub use early::{check_ast_node, EarlyCheckNode};
-pub use late::check_crate;
+pub use late::{check_crate, unerased_lint_store};
 pub use passes::{EarlyLintPass, LateLintPass};
 pub use rustc_session::lint::Level::{self, *};
 pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
index 2317186e65502d522809b84fd629b6db50610a3f..2758fcd1310fecff31a716a09c096b5ce3319f6b 100644 (file)
@@ -189,9 +189,13 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
             if let Entry::Message(Message { id: Identifier { name }, attributes, .. }) = entry {
                 let _ = previous_defns.entry(name.to_string()).or_insert(ident_span);
 
-                // `typeck-foo-bar` => `foo_bar`
+                // `typeck-foo-bar` => `foo_bar` (in `typeck.ftl`)
+                // `const-eval-baz` => `baz` (in `const_eval.ftl`)
                 let snake_name = Ident::new(
-                    &name.replace(&format!("{}-", res.ident), "").replace("-", "_"),
+                    // FIXME: should probably trim prefix, not replace all occurrences
+                    &name
+                        .replace(&format!("{}-", res.ident).replace("_", "-"), "")
+                        .replace("-", "_"),
                     span,
                 );
                 constants.extend(quote! {
index bb4b502bded459fc90c7212d0b5bbfcd9a58ed90..caf5965c3a4927114d73f13735f68df6459f3ce6 100644 (file)
@@ -419,11 +419,11 @@ fn encode_info_for_items(&mut self) {
             return;
         }
 
-        self.tcx.hir().deep_visit_all_item_likes(self);
+        self.tcx.hir().visit_all_item_likes_in_crate(self);
     }
 
     fn encode_def_path_table(&mut self) {
-        let table = self.tcx.definitions_untracked().def_path_table();
+        let table = self.tcx.def_path_table();
         if self.is_proc_macro {
             for def_index in std::iter::once(CRATE_DEF_INDEX)
                 .chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index))
@@ -443,9 +443,7 @@ fn encode_def_path_table(&mut self) {
     }
 
     fn encode_def_path_hash_map(&mut self) -> LazyValue<DefPathHashMapRef<'static>> {
-        self.lazy(DefPathHashMapRef::BorrowedFromTcx(
-            self.tcx.definitions_untracked().def_path_hash_to_def_index_map(),
-        ))
+        self.lazy(DefPathHashMapRef::BorrowedFromTcx(self.tcx.def_path_hash_to_def_index_map()))
     }
 
     fn encode_source_map(&mut self) -> LazyArray<rustc_span::SourceFile> {
@@ -614,7 +612,8 @@ fn encode_crate_root(&mut self) -> LazyValue<CrateRoot> {
         let interpret_alloc_index_bytes = self.position() - i;
 
         // Encode the proc macro data. This affects 'tables',
-        // so we need to do this before we encode the tables
+        // so we need to do this before we encode the tables.
+        // This overwrites def_keys, so it must happen after encode_def_path_table.
         i = self.position();
         let proc_macro_data = self.encode_proc_macros();
         let proc_macro_data_bytes = self.position() - i;
@@ -992,8 +991,7 @@ fn encode_def_ids(&mut self) {
             return;
         }
         let tcx = self.tcx;
-        let hir = tcx.hir();
-        for local_id in hir.iter_local_def_id() {
+        for local_id in tcx.iter_local_def_id() {
             let def_id = local_id.to_def_id();
             let def_kind = tcx.opt_def_kind(local_id);
             let Some(def_kind) = def_kind else { continue };
@@ -1854,12 +1852,13 @@ fn encode_incoherent_impls(&mut self) -> LazyArray<IncoherentImpls> {
         debug!("EncodeContext::encode_traits_and_impls()");
         empty_proc_macro!(self);
         let tcx = self.tcx;
-        let mut ctx = tcx.create_stable_hashing_context();
         let mut all_impls: Vec<_> = tcx.crate_inherent_impls(()).incoherent_impls.iter().collect();
-        all_impls.sort_by_cached_key(|&(&simp, _)| {
-            let mut hasher = StableHasher::new();
-            simp.hash_stable(&mut ctx, &mut hasher);
-            hasher.finish::<Fingerprint>();
+        tcx.with_stable_hashing_context(|mut ctx| {
+            all_impls.sort_by_cached_key(|&(&simp, _)| {
+                let mut hasher = StableHasher::new();
+                simp.hash_stable(&mut ctx, &mut hasher);
+                hasher.finish::<Fingerprint>()
+            })
         });
         let all_impls: Vec<_> = all_impls
             .into_iter()
index 555baae35f506a647d601db0b3d457c3cf056d47..2d095438fc4e9fcd5bf0c24500a4420eb7395599 100644 (file)
@@ -183,6 +183,9 @@ pub mod label_strs {
     // We use this for most things when incr. comp. is turned off.
     [] Null,
 
+    // We use this to create a forever-red node.
+    [] Red,
+
     [anon] TraitSelect,
 
     // WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
index e335cb395f84f3b9d4305975cd7835e37928d621..c8b3b52b0fb2bd7d6467f626f173dc494d76fbb7 100644 (file)
@@ -23,6 +23,7 @@
 
 impl rustc_query_system::dep_graph::DepKind for DepKind {
     const NULL: Self = DepKind::Null;
+    const RED: Self = DepKind::Red;
 
     fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         write!(f, "{:?}(", node.kind)?;
@@ -71,8 +72,8 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
     type DepKind = DepKind;
 
     #[inline]
-    fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
-        TyCtxt::create_stable_hashing_context(*self)
+    fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R {
+        TyCtxt::with_stable_hashing_context(*self, f)
     }
 
     #[inline]
index cda0a60fa4e1c0c5ea82f22ceabe3b12a7882465..3e99ba5742a4bd0e5b63a9b30370a1506b811707 100644 (file)
@@ -218,13 +218,6 @@ pub fn local_def_id_to_hir_id(self, def_id: LocalDefId) -> HirId {
         self.tcx.local_def_id_to_hir_id(def_id)
     }
 
-    pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'hir {
-        // Create a dependency to the crate to be sure we re-execute this when the amount of
-        // definitions change.
-        self.tcx.ensure().hir_crate(());
-        self.tcx.definitions_untracked().iter_local_def_id()
-    }
-
     /// Do not call this function directly. The query should be called.
     pub(super) fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
         let hir_id = self.local_def_id_to_hir_id(local_def_id);
@@ -568,7 +561,7 @@ pub fn get_module(self, module: LocalDefId) -> (&'hir Mod<'hir>, Span, HirId) {
         }
     }
 
-    /// Walks the contents of a crate. See also `Crate::visit_all_items`.
+    /// Walks the contents of the local crate. See also `visit_all_item_likes_in_crate`.
     pub fn walk_toplevel_module(self, visitor: &mut impl Visitor<'hir>) {
         let (top_mod, span, hir_id) = self.get_module(CRATE_DEF_ID);
         visitor.visit_mod(top_mod, span, hir_id);
@@ -588,53 +581,61 @@ pub fn walk_attributes(self, visitor: &mut impl Visitor<'hir>) {
         }
     }
 
-    /// Visits all items in the crate in some deterministic (but
-    /// unspecified) order. If you need to process every item,
-    /// and care about nesting -- usually because your algorithm
-    /// follows lexical scoping rules -- then this method is the best choice.
-    /// If you don't care about nesting, you should use the `tcx.hir_crate_items()` query
-    /// or `items()` instead.
+    /// Visits all item-likes in the crate in some deterministic (but unspecified) order. If you
+    /// need to process every item-like, and don't care about visiting nested items in a particular
+    /// order then this method is the best choice.  If you do care about this nesting, you should
+    /// use the `tcx.hir().walk_toplevel_module`.
+    ///
+    /// Note that this function will access HIR for all the item-likes in the crate.  If you only
+    /// need to access some of them, it is usually better to manually loop on the iterators
+    /// provided by `tcx.hir_crate_items(())`.
     ///
     /// Please see the notes in `intravisit.rs` for more information.
-    pub fn deep_visit_all_item_likes<V>(self, visitor: &mut V)
+    pub fn visit_all_item_likes_in_crate<V>(self, visitor: &mut V)
     where
         V: Visitor<'hir>,
     {
-        let krate = self.krate();
-        for owner in krate.owners.iter().filter_map(|i| i.as_owner()) {
-            match owner.node() {
-                OwnerNode::Item(item) => visitor.visit_item(item),
-                OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
-                OwnerNode::ImplItem(item) => visitor.visit_impl_item(item),
-                OwnerNode::TraitItem(item) => visitor.visit_trait_item(item),
-                OwnerNode::Crate(_) => {}
-            }
+        let krate = self.tcx.hir_crate_items(());
+
+        for id in krate.items() {
+            visitor.visit_item(self.item(id));
+        }
+
+        for id in krate.trait_items() {
+            visitor.visit_trait_item(self.trait_item(id));
+        }
+
+        for id in krate.impl_items() {
+            visitor.visit_impl_item(self.impl_item(id));
+        }
+
+        for id in krate.foreign_items() {
+            visitor.visit_foreign_item(self.foreign_item(id));
         }
     }
 
-    /// If you don't care about nesting, you should use the
-    /// `tcx.hir_module_items()` query or `module_items()` instead.
-    /// Please see notes in `deep_visit_all_item_likes`.
-    pub fn deep_visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
+    /// This method is the equivalent of `visit_all_item_likes_in_crate` but restricted to
+    /// item-likes in a single module.
+    pub fn visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
     where
         V: Visitor<'hir>,
     {
         let module = self.tcx.hir_module_items(module);
 
-        for id in module.items.iter() {
-            visitor.visit_item(self.item(*id));
+        for id in module.items() {
+            visitor.visit_item(self.item(id));
         }
 
-        for id in module.trait_items.iter() {
-            visitor.visit_trait_item(self.trait_item(*id));
+        for id in module.trait_items() {
+            visitor.visit_trait_item(self.trait_item(id));
         }
 
-        for id in module.impl_items.iter() {
-            visitor.visit_impl_item(self.impl_item(*id));
+        for id in module.impl_items() {
+            visitor.visit_impl_item(self.impl_item(id));
         }
 
-        for id in module.foreign_items.iter() {
-            visitor.visit_foreign_item(self.foreign_item(*id));
+        for id in module.foreign_items() {
+            visitor.visit_foreign_item(self.foreign_item(id));
         }
     }
 
@@ -1020,6 +1021,7 @@ fn named_span(item_span: Span, ident: Ident, generics: Option<&Generics<'_>>) ->
                 _ => named_span(item.span, item.ident, None),
             },
             Node::Ctor(_) => return self.opt_span(self.get_parent_node(hir_id)),
+            Node::Expr(Expr { kind: ExprKind::Closure { fn_decl_span, .. }, .. }) => *fn_decl_span,
             _ => self.span_with_body(hir_id),
         };
         Some(span)
@@ -1142,34 +1144,35 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
 
     source_file_names.sort_unstable();
 
-    let mut hcx = tcx.create_stable_hashing_context();
-    let mut stable_hasher = StableHasher::new();
-    hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher);
-    upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
-    source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
-    if tcx.sess.opts.debugging_opts.incremental_relative_spans {
-        let definitions = &tcx.definitions_untracked();
-        let mut owner_spans: Vec<_> = krate
-            .owners
-            .iter_enumerated()
-            .filter_map(|(def_id, info)| {
-                let _ = info.as_owner()?;
-                let def_path_hash = definitions.def_path_hash(def_id);
-                let span = resolutions.source_span[def_id];
-                debug_assert_eq!(span.parent(), None);
-                Some((def_path_hash, span))
-            })
-            .collect();
-        owner_spans.sort_unstable_by_key(|bn| bn.0);
-        owner_spans.hash_stable(&mut hcx, &mut stable_hasher);
-    }
-    tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher);
-    tcx.sess.local_stable_crate_id().hash_stable(&mut hcx, &mut stable_hasher);
-    // Hash visibility information since it does not appear in HIR.
-    resolutions.visibilities.hash_stable(&mut hcx, &mut stable_hasher);
-    resolutions.has_pub_restricted.hash_stable(&mut hcx, &mut stable_hasher);
+    let crate_hash: Fingerprint = tcx.with_stable_hashing_context(|mut hcx| {
+        let mut stable_hasher = StableHasher::new();
+        hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher);
+        upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
+        source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
+        if tcx.sess.opts.debugging_opts.incremental_relative_spans {
+            let definitions = tcx.definitions_untracked();
+            let mut owner_spans: Vec<_> = krate
+                .owners
+                .iter_enumerated()
+                .filter_map(|(def_id, info)| {
+                    let _ = info.as_owner()?;
+                    let def_path_hash = definitions.def_path_hash(def_id);
+                    let span = resolutions.source_span[def_id];
+                    debug_assert_eq!(span.parent(), None);
+                    Some((def_path_hash, span))
+                })
+                .collect();
+            owner_spans.sort_unstable_by_key(|bn| bn.0);
+            owner_spans.hash_stable(&mut hcx, &mut stable_hasher);
+        }
+        tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher);
+        tcx.sess.local_stable_crate_id().hash_stable(&mut hcx, &mut stable_hasher);
+        // Hash visibility information since it does not appear in HIR.
+        resolutions.visibilities.hash_stable(&mut hcx, &mut stable_hasher);
+        resolutions.has_pub_restricted.hash_stable(&mut hcx, &mut stable_hasher);
+        stable_hasher.finish()
+    });
 
-    let crate_hash: Fingerprint = stable_hasher.finish();
     Svh::new(crate_hash.to_smaller_hash())
 }
 
index 12209d6725c902f30e3e47accce21ee55b029efe..070a063c881e6128813cf69fa40b89bb0230a3fb 100644 (file)
@@ -111,7 +111,6 @@ pub fn provide(providers: &mut Providers) {
         let hir = tcx.hir();
         hir.get_module_parent_node(hir.local_def_id_to_hir_id(id))
     };
-    providers.hir_crate = |tcx, ()| tcx.untracked_crate;
     providers.hir_crate_items = map::hir_crate_items;
     providers.crate_hash = map::crate_hash;
     providers.hir_module_items = map::hir_module_items;
index d56e87bbb47453c77c30831ec126d2a6ddf251cb..6896837aa910966677d84e094b80954da807ee87 100644 (file)
@@ -8,7 +8,7 @@
 /// constant arguments of types, e.g. in `let _: [(); /* HERE */];`.
 ///
 /// **This is the most common choice.** A very common pattern is
-/// to use `deep_visit_all_item_likes()` as an outer loop,
+/// to use `visit_all_item_likes_in_crate()` as an outer loop,
 /// and to have the visitor that visits the contents of each item
 /// using this setting.
 pub struct OnlyBodies(());
index 1bbd71c3f1f517d45d1d1e7fbd1c762701c3cf47..ae333846f067c73fce5f891d9831ed27fc5c28a8 100644 (file)
@@ -179,6 +179,11 @@ pub fn alloc_range(start: Size, size: Size) -> AllocRange {
 }
 
 impl AllocRange {
+    #[inline]
+    pub fn from(r: Range<Size>) -> Self {
+        alloc_range(r.start, r.end - r.start) // `Size` subtraction (overflow-checked)
+    }
+
     #[inline(always)]
     pub fn end(self) -> Size {
         self.start + self.size // This does overflow checking.
@@ -1095,9 +1100,9 @@ impl InitMask {
     /// Returns `Ok(())` if it's initialized. Otherwise returns a range of byte
     /// indexes for the first contiguous span of the uninitialized access.
     #[inline]
-    pub fn is_range_initialized(&self, start: Size, end: Size) -> Result<(), Range<Size>> {
+    pub fn is_range_initialized(&self, start: Size, end: Size) -> Result<(), AllocRange> {
         if end > self.len {
-            return Err(self.len..end);
+            return Err(AllocRange::from(self.len..end));
         }
 
         let uninit_start = self.find_bit(start, end, false);
@@ -1105,7 +1110,7 @@ pub fn is_range_initialized(&self, start: Size, end: Size) -> Result<(), Range<S
         match uninit_start {
             Some(uninit_start) => {
                 let uninit_end = self.find_bit(uninit_start, end, true).unwrap_or(end);
-                Err(uninit_start..uninit_end)
+                Err(AllocRange::from(uninit_start..uninit_end))
             }
             None => Ok(()),
         }
@@ -1176,19 +1181,17 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
     ///
     /// Returns `Ok(())` if it's initialized. Otherwise returns the range of byte
     /// indexes of the first contiguous uninitialized access.
-    fn is_init(&self, range: AllocRange) -> Result<(), Range<Size>> {
+    fn is_init(&self, range: AllocRange) -> Result<(), AllocRange> {
         self.init_mask.is_range_initialized(range.start, range.end()) // `Size` addition
     }
 
     /// Checks that a range of bytes is initialized. If not, returns the `InvalidUninitBytes`
     /// error which will report the first range of bytes which is uninitialized.
     fn check_init(&self, range: AllocRange) -> AllocResult {
-        self.is_init(range).map_err(|idx_range| {
+        self.is_init(range).map_err(|uninit_range| {
             AllocError::InvalidUninitBytes(Some(UninitBytesAccess {
-                access_offset: range.start,
-                access_size: range.size,
-                uninit_offset: idx_range.start,
-                uninit_size: idx_range.end - idx_range.start, // `Size` subtraction
+                access: range,
+                uninit: uninit_range,
             }))
         })
     }
index 2a1fd6f736e915604dc2b6efd7be1e902c9a42e5..795f23edb318641df48bdf93fcaafa027b27676e 100644 (file)
@@ -1,4 +1,4 @@
-use super::{AllocId, ConstAlloc, Pointer, Scalar};
+use super::{AllocId, AllocRange, ConstAlloc, Pointer, Scalar};
 
 use crate::mir::interpret::ConstValue;
 use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty, ValTree};
@@ -162,9 +162,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             AlreadyReported(ErrorGuaranteed { .. }) => {
                 write!(f, "encountered constants with type errors, stopping evaluation")
             }
-            Layout(ref err) => write!(f, "{}", err),
-            FnAbiAdjustForForeignAbi(ref err) => write!(f, "{}", err),
-            SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{}`", ty),
+            Layout(ref err) => write!(f, "{err}"),
+            FnAbiAdjustForForeignAbi(ref err) => write!(f, "{err}"),
+            SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{ty}`"),
         }
     }
 }
@@ -205,14 +205,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 /// Details of an access to uninitialized bytes where it is not allowed.
 #[derive(Debug)]
 pub struct UninitBytesAccess {
-    /// Location of the original memory access.
-    pub access_offset: Size,
-    /// Size of the original memory access.
-    pub access_size: Size,
-    /// Location of the first uninitialized byte that was accessed.
-    pub uninit_offset: Size,
-    /// Number of consecutive uninitialized bytes that were accessed.
-    pub uninit_size: Size,
+    /// Range of the original memory access.
+    pub access: AllocRange,
+    /// Range of the uninit memory that was encountered. (Might not be maximal.)
+    pub uninit: AllocRange,
 }
 
 /// Information about a size mismatch.
@@ -308,30 +304,28 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         use UndefinedBehaviorInfo::*;
         match self {
-            Ub(msg) => write!(f, "{}", msg),
+            Ub(msg) => write!(f, "{msg}"),
             Unreachable => write!(f, "entering unreachable code"),
             BoundsCheckFailed { ref len, ref index } => {
-                write!(f, "indexing out of bounds: the len is {} but the index is {}", len, index)
+                write!(f, "indexing out of bounds: the len is {len} but the index is {index}")
             }
             DivisionByZero => write!(f, "dividing by zero"),
             RemainderByZero => write!(f, "calculating the remainder with a divisor of zero"),
             DivisionOverflow => write!(f, "overflow in signed division (dividing MIN by -1)"),
             RemainderOverflow => write!(f, "overflow in signed remainder (dividing MIN by -1)"),
             PointerArithOverflow => write!(f, "overflowing in-bounds pointer arithmetic"),
-            InvalidMeta(msg) => write!(f, "invalid metadata in wide pointer: {}", msg),
+            InvalidMeta(msg) => write!(f, "invalid metadata in wide pointer: {msg}"),
             InvalidVtableDropFn(sig) => write!(
                 f,
-                "invalid drop function signature: got {}, expected exactly one argument which must be a pointer type",
-                sig
+                "invalid drop function signature: got {sig}, expected exactly one argument which must be a pointer type",
             ),
             InvalidVtableSize => {
                 write!(f, "invalid vtable: size is bigger than largest supported object")
             }
-            InvalidVtableAlignment(msg) => write!(f, "invalid vtable: alignment {}", msg),
+            InvalidVtableAlignment(msg) => write!(f, "invalid vtable: alignment {msg}"),
             UnterminatedCString(p) => write!(
                 f,
-                "reading a null-terminated string starting at {:?} with no null found before end of allocation",
-                p,
+                "reading a null-terminated string starting at {p:?} with no null found before end of allocation",
             ),
             PointerUseAfterFree(a) => {
                 write!(f, "pointer to {a:?} was dereferenced after this allocation got freed")
@@ -359,41 +353,36 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             }
             AlignmentCheckFailed { required, has } => write!(
                 f,
-                "accessing memory with alignment {}, but alignment {} is required",
-                has.bytes(),
-                required.bytes()
+                "accessing memory with alignment {has}, but alignment {required} is required",
+                has = has.bytes(),
+                required = required.bytes()
             ),
             WriteToReadOnly(a) => write!(f, "writing to {a:?} which is read-only"),
             DerefFunctionPointer(a) => write!(f, "accessing {a:?} which contains a function"),
             ValidationFailure { path: None, msg } => {
-                write!(f, "constructing invalid value: {}", msg)
+                write!(f, "constructing invalid value: {msg}")
             }
             ValidationFailure { path: Some(path), msg } => {
-                write!(f, "constructing invalid value at {}: {}", path, msg)
+                write!(f, "constructing invalid value at {path}: {msg}")
             }
             InvalidBool(b) => {
-                write!(f, "interpreting an invalid 8-bit value as a bool: 0x{:02x}", b)
+                write!(f, "interpreting an invalid 8-bit value as a bool: 0x{b:02x}")
             }
             InvalidChar(c) => {
-                write!(f, "interpreting an invalid 32-bit value as a char: 0x{:08x}", c)
+                write!(f, "interpreting an invalid 32-bit value as a char: 0x{c:08x}")
             }
-            InvalidTag(val) => write!(f, "enum value has invalid tag: {:x}", val),
+            InvalidTag(val) => write!(f, "enum value has invalid tag: {val:x}"),
             InvalidFunctionPointer(p) => {
-                write!(f, "using {:?} as function pointer but it does not point to a function", p)
+                write!(f, "using {p:?} as function pointer but it does not point to a function")
             }
-            InvalidStr(err) => write!(f, "this string is not valid UTF-8: {}", err),
-            InvalidUninitBytes(Some((alloc, access))) => write!(
+            InvalidStr(err) => write!(f, "this string is not valid UTF-8: {err}"),
+            InvalidUninitBytes(Some((alloc, info))) => write!(
                 f,
-                "reading {} byte{} of memory starting at {:?}, \
-                 but {} byte{} {} uninitialized starting at {:?}, \
+                "reading memory at {alloc:?}{access:?}, \
+                 but memory is uninitialized at {uninit:?}, \
                  and this operation requires initialized memory",
-                access.access_size.bytes(),
-                pluralize!(access.access_size.bytes()),
-                Pointer::new(*alloc, access.access_offset),
-                access.uninit_size.bytes(),
-                pluralize!(access.uninit_size.bytes()),
-                pluralize!("is", access.uninit_size.bytes()),
-                Pointer::new(*alloc, access.uninit_offset),
+                access = info.access,
+                uninit = info.uninit,
             ),
             InvalidUninitBytes(None) => write!(
                 f,
@@ -402,8 +391,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             DeadLocal => write!(f, "accessing a dead local variable"),
             ScalarSizeMismatch(self::ScalarSizeMismatch { target_size, data_size }) => write!(
                 f,
-                "scalar size mismatch: expected {} bytes but got {} bytes instead",
-                target_size, data_size
+                "scalar size mismatch: expected {target_size} bytes but got {data_size} bytes instead",
             ),
             UninhabitedEnumVariantWritten => {
                 write!(f, "writing discriminant of an uninhabited enum")
@@ -437,13 +425,13 @@ impl fmt::Display for UnsupportedOpInfo {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         use UnsupportedOpInfo::*;
         match self {
-            Unsupported(ref msg) => write!(f, "{}", msg),
+            Unsupported(ref msg) => write!(f, "{msg}"),
             ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes"),
             PartialPointerOverwrite(ptr) => {
-                write!(f, "unable to overwrite parts of a pointer in memory at {:?}", ptr)
+                write!(f, "unable to overwrite parts of a pointer in memory at {ptr:?}")
             }
-            ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
-            ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did),
+            ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({did:?})"),
+            ReadExternStatic(did) => write!(f, "cannot read from extern static ({did:?})"),
         }
     }
 }
@@ -526,11 +514,11 @@ impl fmt::Display for InterpError<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         use InterpError::*;
         match *self {
-            Unsupported(ref msg) => write!(f, "{}", msg),
-            InvalidProgram(ref msg) => write!(f, "{}", msg),
-            UndefinedBehavior(ref msg) => write!(f, "{}", msg),
-            ResourceExhaustion(ref msg) => write!(f, "{}", msg),
-            MachineStop(ref msg) => write!(f, "{}", msg),
+            Unsupported(ref msg) => write!(f, "{msg}"),
+            InvalidProgram(ref msg) => write!(f, "{msg}"),
+            UndefinedBehavior(ref msg) => write!(f, "{msg}"),
+            ResourceExhaustion(ref msg) => write!(f, "{msg}"),
+            MachineStop(ref msg) => write!(f, "{msg}"),
         }
     }
 }
index 93686128101982c040652482e721cc3e1ddf7067..f136b8e236824ca3a50de017b20381082824bd88 100644 (file)
@@ -1048,6 +1048,8 @@ pub fn start_location(self) -> Location {
 ///////////////////////////////////////////////////////////////////////////
 // BasicBlockData
 
+/// Data for a basic block, including a list of its statements.
+///
 /// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
 #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
 pub struct BasicBlockData<'tcx> {
@@ -1079,7 +1081,7 @@ pub fn new(terminator: Option<Terminator<'tcx>>) -> BasicBlockData<'tcx> {
     /// Accessor for terminator.
     ///
     /// Terminator may not be None after construction of the basic block is complete. This accessor
-    /// provides a convenience way to reach the terminator.
+    /// provides a convenient way to reach the terminator.
     #[inline]
     pub fn terminator(&self) -> &Terminator<'tcx> {
         self.terminator.as_ref().expect("invalid terminator state")
@@ -1286,6 +1288,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///////////////////////////////////////////////////////////////////////////
 // Statements
 
+/// A statement in a basic block, including information about its source code.
 #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
 pub struct Statement<'tcx> {
     pub source_info: SourceInfo,
index 57c4f3f3ba3922fe7abcfcfe253f3a44b6ccbb48..cbc45526e89fbc2d8b2f6229e1ffabb9954973e6 100644 (file)
         desc { "get the resolver outputs" }
     }
 
+    query resolver_for_lowering(_: ()) -> &'tcx Steal<ty::ResolverAstLowering> {
+        eval_always
+        no_hash
+        desc { "get the resolver for lowering" }
+    }
+
     /// Return the span for a definition.
     /// Contrary to `def_span` below, this query returns the full absolute span of the definition.
     /// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
@@ -40,7 +46,8 @@
     /// This is because the `hir_crate` query gives you access to all other items.
     /// To avoid this fate, do not call `tcx.hir().krate()`; instead,
     /// prefer wrappers like `tcx.visit_all_items_in_krate()`.
-    query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
+    query hir_crate(key: ()) -> Crate<'tcx> {
+        storage(ArenaCacheSelector<'tcx>)
         eval_always
         desc { "get the crate HIR" }
     }
index eee44df8645efedadbc4ae6d1f5555324351d367..fe7f72024d358476b49b46c7184e0f7270ad1793 100644 (file)
@@ -546,9 +546,17 @@ pub enum SelectionError<'tcx> {
     ErrorReporting,
     /// Multiple applicable `impl`s where found. The `DefId`s correspond to
     /// all the `impl`s' Items.
-    Ambiguous(Vec<DefId>),
+    Ambiguous(Vec<AmbiguousSelection>),
 }
 
+#[derive(Copy, Clone, Debug)]
+pub enum AmbiguousSelection {
+    Impl(DefId),
+    ParamEnv(Span),
+}
+
+TrivialTypeTraversalAndLiftImpls! { AmbiguousSelection, }
+
 /// When performing resolution, it is typically the case that there
 /// can be one of three outcomes:
 ///
index 34703b6282042d1a96754e9ba1307bc29d9de09c..0ca5a532b754269c9faf40ff63eb1c63db326841 100644 (file)
@@ -176,6 +176,10 @@ pub enum EvaluationResult {
     EvaluatedToOk,
     /// Evaluation successful, but there were unevaluated region obligations.
     EvaluatedToOkModuloRegions,
+    /// Evaluation successful, but need to rerun because opaque types got
+    /// hidden types assigned without it being known whether the opaque types
+    /// are within their defining scope
+    EvaluatedToOkModuloOpaqueTypes,
     /// Evaluation is known to be ambiguous -- it *might* hold for some
     /// assignment of inference variables, but it might not.
     ///
@@ -252,9 +256,11 @@ pub fn must_apply_modulo_regions(self) -> bool {
 
     pub fn may_apply(self) -> bool {
         match self {
-            EvaluatedToOk | EvaluatedToOkModuloRegions | EvaluatedToAmbig | EvaluatedToUnknown => {
-                true
-            }
+            EvaluatedToOkModuloOpaqueTypes
+            | EvaluatedToOk
+            | EvaluatedToOkModuloRegions
+            | EvaluatedToAmbig
+            | EvaluatedToUnknown => true,
 
             EvaluatedToErr | EvaluatedToRecur => false,
         }
@@ -264,7 +270,11 @@ pub fn is_stack_dependent(self) -> bool {
         match self {
             EvaluatedToUnknown | EvaluatedToRecur => true,
 
-            EvaluatedToOk | EvaluatedToOkModuloRegions | EvaluatedToAmbig | EvaluatedToErr => false,
+            EvaluatedToOkModuloOpaqueTypes
+            | EvaluatedToOk
+            | EvaluatedToOkModuloRegions
+            | EvaluatedToAmbig
+            | EvaluatedToErr => false,
         }
     }
 }
index af071b4e939034a05121b3e165d282ac5f0e7813..a594dab2e20a30c00244f871c15504a6762a0a8d 100644 (file)
 use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_data_structures::steal::Steal;
-use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
+use rustc_data_structures::sync::{self, Lock, Lrc, ReadGuard, RwLock, WorkerLocal};
 use rustc_data_structures::vec_map::VecMap;
 use rustc_errors::{DecorateLint, ErrorGuaranteed, LintDiagnosticBuilder, MultiSpan};
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, Res};
 use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
+use rustc_hir::definitions::Definitions;
 use rustc_hir::intravisit::Visitor;
 use rustc_hir::lang_items::LangItem;
 use rustc_hir::{
@@ -1045,6 +1046,7 @@ fn deref(&self) -> &Self::Target {
 
 pub struct GlobalCtxt<'tcx> {
     pub arena: &'tcx WorkerLocal<Arena<'tcx>>,
+    pub hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
 
     interners: CtxtInterners<'tcx>,
 
@@ -1069,13 +1071,15 @@ pub struct GlobalCtxt<'tcx> {
     /// Common consts, pre-interned for your convenience.
     pub consts: CommonConsts<'tcx>,
 
-    definitions: rustc_hir::definitions::Definitions,
+    definitions: RwLock<Definitions>,
     cstore: Box<CrateStoreDyn>,
 
     /// Output of the resolver.
     pub(crate) untracked_resolutions: ty::ResolverOutputs,
-
-    pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>,
+    untracked_resolver_for_lowering: Steal<ty::ResolverAstLowering>,
+    /// The entire crate as AST. This field serves as the input for the hir_crate query,
+    /// which lowers it from AST to HIR. It must not be read or used by anything else.
+    pub untracked_crate: Steal<Lrc<ast::Crate>>,
 
     /// This provides access to the incremental compilation on-disk cache for query results.
     /// Do not access this directly. It is only meant to be used by
@@ -1233,10 +1237,12 @@ pub fn create_global_ctxt(
         s: &'tcx Session,
         lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
         arena: &'tcx WorkerLocal<Arena<'tcx>>,
-        definitions: rustc_hir::definitions::Definitions,
+        hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
+        definitions: Definitions,
         cstore: Box<CrateStoreDyn>,
         untracked_resolutions: ty::ResolverOutputs,
-        krate: &'tcx hir::Crate<'tcx>,
+        untracked_resolver_for_lowering: ty::ResolverAstLowering,
+        krate: Lrc<ast::Crate>,
         dep_graph: DepGraph,
         on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
         queries: &'tcx dyn query::QueryEngine<'tcx>,
@@ -1263,16 +1269,18 @@ pub fn create_global_ctxt(
             sess: s,
             lint_store,
             arena,
+            hir_arena,
             interners,
             dep_graph,
-            definitions,
+            definitions: RwLock::new(definitions),
             cstore,
-            untracked_resolutions,
             prof: s.prof.clone(),
             types: common_types,
             lifetimes: common_lifetimes,
             consts: common_consts,
-            untracked_crate: krate,
+            untracked_resolutions,
+            untracked_resolver_for_lowering: Steal::new(untracked_resolver_for_lowering),
+            untracked_crate: Steal::new(krate),
             on_disk_cache,
             queries,
             query_caches: query::QueryCaches::default(),
@@ -1368,7 +1376,7 @@ pub fn features(self) -> &'tcx rustc_feature::Features {
     pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
         // Accessing the DefKey is ok, since it is part of DefPathHash.
         if let Some(id) = id.as_local() {
-            self.definitions.def_key(id)
+            self.definitions_untracked().def_key(id)
         } else {
             self.cstore.def_key(id)
         }
@@ -1382,7 +1390,7 @@ pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
     pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath {
         // Accessing the DefPath is ok, since it is part of DefPathHash.
         if let Some(id) = id.as_local() {
-            self.definitions.def_path(id)
+            self.definitions_untracked().def_path(id)
         } else {
             self.cstore.def_path(id)
         }
@@ -1392,7 +1400,7 @@ pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath {
     pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash {
         // Accessing the DefPathHash is ok, it is incr. comp. stable.
         if let Some(def_id) = def_id.as_local() {
-            self.definitions.def_path_hash(def_id)
+            self.definitions_untracked().def_path_hash(def_id)
         } else {
             self.cstore.def_path_hash(def_id)
         }
@@ -1429,7 +1437,7 @@ pub fn def_path_hash_to_def_id(self, hash: DefPathHash, err: &mut dyn FnMut() ->
         // If this is a DefPathHash from the local crate, we can look up the
         // DefId in the tcx's `Definitions`.
         if stable_crate_id == self.sess.local_stable_crate_id() {
-            self.definitions.local_def_path_hash_to_def_id(hash, err).to_def_id()
+            self.definitions.read().local_def_path_hash_to_def_id(hash, err).to_def_id()
         } else {
             // If this is a DefPathHash from an upstream crate, let the CrateStore map
             // it to a DefId.
@@ -1460,6 +1468,64 @@ pub fn def_path_debug_str(self, def_id: DefId) -> String {
         )
     }
 
+    /// Create a new definition within the incr. comp. engine.
+    pub fn create_def(self, parent: LocalDefId, data: hir::definitions::DefPathData) -> LocalDefId {
+        // This function modifies `self.definitions` using a side-effect.
+        // We need to ensure that these side effects are re-run by the incr. comp. engine.
+        // Depending on the forever-red node will tell the graph that the calling query
+        // needs to be re-evaluated.
+        use rustc_query_system::dep_graph::DepNodeIndex;
+        self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE);
+
+        // The following call has the side effect of modifying the tables inside `definitions`.
+        // These very tables are relied on by the incr. comp. engine to decode DepNodes and to
+        // decode the on-disk cache.
+        //
+        // Any LocalDefId which is used within queries, either as key or result, either:
+        // - has been created before the construction of the TyCtxt;
+        // - has been created by this call to `create_def`.
+        // As a consequence, this LocalDefId is always re-created before it is needed by the incr.
+        // comp. engine itself.
+        //
+        // This call also writes to the value of `source_span` and `expn_that_defined` queries.
+        // This is fine because:
+        // - those queries are `eval_always` so we won't miss their result changing;
+        // - this write will have happened before these queries are called.
+        self.definitions.write().create_def(parent, data)
+    }
+
+    pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx {
+        // Create a dependency to the crate to be sure we re-execute this when the amount of
+        // definitions change.
+        self.ensure().hir_crate(());
+        // Leak a read lock once we start iterating on definitions, to prevent adding new onces
+        // while iterating.  If some query needs to add definitions, it should be `ensure`d above.
+        let definitions = self.definitions.leak();
+        definitions.iter_local_def_id()
+    }
+
+    pub fn def_path_table(self) -> &'tcx rustc_hir::definitions::DefPathTable {
+        // Create a dependency to the crate to be sure we reexcute this when the amount of
+        // definitions change.
+        self.ensure().hir_crate(());
+        // Leak a read lock once we start iterating on definitions, to prevent adding new onces
+        // while iterating.  If some query needs to add definitions, it should be `ensure`d above.
+        let definitions = self.definitions.leak();
+        definitions.def_path_table()
+    }
+
+    pub fn def_path_hash_to_def_index_map(
+        self,
+    ) -> &'tcx rustc_hir::def_path_hash_map::DefPathHashMap {
+        // Create a dependency to the crate to be sure we reexcute this when the amount of
+        // definitions change.
+        self.ensure().hir_crate(());
+        // Leak a read lock once we start iterating on definitions, to prevent adding new onces
+        // while iterating.  If some query needs to add definitions, it should be `ensure`d above.
+        let definitions = self.definitions.leak();
+        definitions.def_path_hash_to_def_index_map()
+    }
+
     /// Note that this is *untracked* and should only be used within the query
     /// system if the result is otherwise tracked through queries
     pub fn cstore_untracked(self) -> &'tcx CrateStoreDyn {
@@ -1468,8 +1534,9 @@ pub fn cstore_untracked(self) -> &'tcx CrateStoreDyn {
 
     /// Note that this is *untracked* and should only be used within the query
     /// system if the result is otherwise tracked through queries
-    pub fn definitions_untracked(self) -> &'tcx hir::definitions::Definitions {
-        &self.definitions
+    #[inline]
+    pub fn definitions_untracked(self) -> ReadGuard<'tcx, Definitions> {
+        self.definitions.read()
     }
 
     /// Note that this is *untracked* and should only be used within the query
@@ -1480,23 +1547,18 @@ pub fn source_span_untracked(self, def_id: LocalDefId) -> Span {
     }
 
     #[inline(always)]
-    pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> {
-        StableHashingContext::new(
-            self.sess,
-            &self.definitions,
-            &*self.cstore,
-            &self.untracked_resolutions.source_span,
-        )
-    }
-
-    #[inline(always)]
-    pub fn create_no_span_stable_hashing_context(self) -> StableHashingContext<'tcx> {
-        StableHashingContext::ignore_spans(
+    pub fn with_stable_hashing_context<R>(
+        self,
+        f: impl FnOnce(StableHashingContext<'_>) -> R,
+    ) -> R {
+        let definitions = self.definitions_untracked();
+        let hcx = StableHashingContext::new(
             self.sess,
-            &self.definitions,
+            &*definitions,
             &*self.cstore,
             &self.untracked_resolutions.source_span,
-        )
+        );
+        f(hcx)
     }
 
     pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult {
@@ -2304,7 +2366,7 @@ pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> {
         self.interners.intern_ty(
             st,
             self.sess,
-            &self.definitions,
+            &self.definitions.read(),
             &*self.cstore,
             // This is only used to create a stable hashing context.
             &self.untracked_resolutions.source_span,
@@ -2922,6 +2984,7 @@ fn ptr_eq<T, U>(t: *const T, u: *const U) -> bool {
 
 pub fn provide(providers: &mut ty::query::Providers) {
     providers.resolutions = |tcx, ()| &tcx.untracked_resolutions;
+    providers.resolver_for_lowering = |tcx, ()| &tcx.untracked_resolver_for_lowering;
     providers.module_reexports =
         |tcx, id| tcx.resolutions(()).reexport_map.get(&id).map(|v| &v[..]);
     providers.crate_name = |tcx, id| {
index 3a795af2121d0e409640353eb36da77e0b4f89de..f15108fb7501af64effab6e23c0485587b6bcdfe 100644 (file)
@@ -1089,6 +1089,7 @@ pub fn is_empty(&self) -> bool {
 #[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable, Lift)]
 #[derive(TypeFoldable, TypeVisitable)]
 pub struct OpaqueTypeKey<'tcx> {
+    // FIXME(oli-obk): make this a LocalDefId
     pub def_id: DefId,
     pub substs: SubstsRef<'tcx>,
 }
index 8369c7e0898ead62ff3f5b4fb38c9902c13ed972..4b51daadabf341dcb7d1d6e5e34df301c9e318e5 100644 (file)
@@ -1571,6 +1571,19 @@ pub fn free_region_binding_scope(self, tcx: TyCtxt<'_>) -> DefId {
             _ => bug!("free_region_binding_scope invoked on inappropriate region: {:?}", self),
         }
     }
+
+    /// True for free regions other than `'static`.
+    pub fn is_free(self) -> bool {
+        matches!(*self, ty::ReEarlyBound(_) | ty::ReFree(_))
+    }
+
+    /// True if `self` is a free region or static.
+    pub fn is_free_or_static(self) -> bool {
+        match *self {
+            ty::ReStatic => true,
+            _ => self.is_free(),
+        }
+    }
 }
 
 /// Type utilities
index 4637b30c7178d4a96cbaa5a3a1fcf3ef97bd9546..52da6c3a8c03b12f07e11a21e5f5165ebd517bce 100644 (file)
@@ -142,16 +142,16 @@ impl<'tcx> TyCtxt<'tcx> {
     /// Creates a hash of the type `Ty` which will be the same no matter what crate
     /// context it's calculated within. This is used by the `type_id` intrinsic.
     pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64 {
-        let mut hasher = StableHasher::new();
-        let mut hcx = self.create_stable_hashing_context();
-
         // We want the type_id be independent of the types free regions, so we
         // erase them. The erase_regions() call will also anonymize bound
         // regions, which is desirable too.
         let ty = self.erase_regions(ty);
 
-        hcx.while_hashing_spans(false, |hcx| ty.hash_stable(hcx, &mut hasher));
-        hasher.finish()
+        self.with_stable_hashing_context(|mut hcx| {
+            let mut hasher = StableHasher::new();
+            hcx.while_hashing_spans(false, |hcx| ty.hash_stable(hcx, &mut hasher));
+            hasher.finish()
+        })
     }
 
     pub fn res_generics_def_id(self, res: Res) -> Option<DefId> {
index eae9313b77138258934a48f6e94152e387168c52..f6b5af90a85c8e6e97300a7b5d35633397711b75 100644 (file)
@@ -153,7 +153,7 @@ fn statement_effect(
         _: &mir::Statement<'tcx>,
         loc: Location,
     ) {
-        // If we move from a place then only stops needing storage *after*
+        // If we move from a place then it only stops needing storage *after*
         // that statement.
         self.check_for_move(trans, loc);
     }
index 01eda979f9ec95446c8e1c05e80ad34d541ae20a..185f6c523d37ab7cfccfa8a5a3ab832ec0332d3d 100644 (file)
@@ -59,11 +59,8 @@ impl rustc_middle::mir::interpret::MachineStopType for Zst {}
 pub struct ConstProp;
 
 impl<'tcx> MirPass<'tcx> for ConstProp {
-    fn is_enabled(&self, _sess: &rustc_session::Session) -> bool {
-        // FIXME(#70073): Unlike the other passes in "optimizations", this one emits errors, so it
-        // runs even when MIR optimizations are disabled. We should separate the lint out from the
-        // transform and move the lint as early in the pipeline as possible.
-        true
+    fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
+        sess.mir_opt_level() >= 1
     }
 
     #[instrument(skip(self, tcx), level = "debug")]
@@ -794,12 +791,6 @@ fn replace_with_const(
 
     /// Returns `true` if and only if this `op` should be const-propagated into.
     fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
-        let mir_opt_level = self.tcx.sess.mir_opt_level();
-
-        if mir_opt_level == 0 {
-            return false;
-        }
-
         if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - OpTy: {:?}", op)) {
             return false;
         }
index 782b620e28fe048c775c3cd82581414d59285424..88ad5b7ef148227bf151995bc6faf5c5f1a6e644 100644 (file)
@@ -15,7 +15,6 @@
 use crate::MirPass;
 
 use rustc_data_structures::graph::WithNumNodes;
-use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_data_structures::sync::Lrc;
 use rustc_index::vec::IndexVec;
 use rustc_middle::hir;
@@ -576,12 +575,6 @@ fn get_body_span<'tcx>(
 
 fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, hir_body: &'tcx rustc_hir::Body<'tcx>) -> u64 {
     // FIXME(cjgillot) Stop hashing HIR manually here.
-    let mut hcx = tcx.create_no_span_stable_hashing_context();
-    let mut stable_hasher = StableHasher::new();
     let owner = hir_body.id().hir_id.owner;
-    let bodies = &tcx.hir_owner_nodes(owner).unwrap().bodies;
-    hcx.with_hir_bodies(false, owner, bodies, |hcx| {
-        hir_body.value.hash_stable(hcx, &mut stable_hasher)
-    });
-    stable_hasher.finish()
+    tcx.hir_owner_nodes(owner).unwrap().hash_including_bodies.to_smaller_hash()
 }
index 12f5764152e56e4025c46cbb7262b36ddb8f6da9..8f049a182eeaf593ec4af7a09343f3d0ec2cfec9 100644 (file)
@@ -588,7 +588,7 @@ fn dest_needs_borrow(place: Place<'_>) -> bool {
                 );
                 expn_data.def_site = callee_body.span;
                 let expn_data =
-                    LocalExpnId::fresh(expn_data, self.tcx.create_stable_hashing_context());
+                    self.tcx.with_stable_hashing_context(|hcx| LocalExpnId::fresh(expn_data, hcx));
                 let mut integrator = Integrator {
                     args: &args,
                     new_locals: Local::new(caller_body.local_decls.len())..,
index 9776cd0ab8bc9898f4be29ccdb26fc8d3e8a58b4..0887775aae5ede857061e273182d92cfa010fad8 100644 (file)
@@ -173,7 +173,7 @@ fn visit_variant_data(
             intravisit::walk_struct_def(self, v)
         }
     }
-    tcx.hir().deep_visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set });
+    tcx.hir().visit_all_item_likes_in_crate(&mut GatherCtors { tcx, set: &mut set });
 
     set
 }
index bf685aa8cadc34005755d89ccade55924b2b79f6..87bc0d9762ea57b6561a167a3a944294118c365f 100644 (file)
@@ -271,8 +271,7 @@ fn parse_item_kind(
             // MACRO_RULES ITEM
             self.parse_item_macro_rules(vis, has_bang)?
         } else if self.isnt_macro_invocation()
-            && (self.token.is_ident_named(Symbol::intern("import"))
-                || self.token.is_ident_named(Symbol::intern("using")))
+            && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using))
         {
             return self.recover_import_as_use();
         } else if self.isnt_macro_invocation() && vis.kind.is_pub() {
index 8c123c052e5ac4aa941a7d79adfc6ed87218d53a..d0723c68a77e8158269a0f0831359d9d7fea4804 100644 (file)
@@ -2428,7 +2428,7 @@ fn check_non_exported_macro_for_invalid_attrs(tcx: TyCtxt<'_>, item: &Item<'_>)
 
 fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
     let check_attr_visitor = &mut CheckAttrVisitor { tcx };
-    tcx.hir().deep_visit_item_likes_in_module(module_def_id, check_attr_visitor);
+    tcx.hir().visit_item_likes_in_module(module_def_id, check_attr_visitor);
     if module_def_id.is_top_level_module() {
         check_attr_visitor.check_attributes(CRATE_HIR_ID, DUMMY_SP, Target::Mod, None);
         check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
index 996ca66de0e45a6a3935992c4c16268521d686bb..31c159c1f75621d3ab9bc8d2fad4f7f0f0a92bc3 100644 (file)
@@ -56,7 +56,7 @@ fn required_feature_gates(self) -> Option<&'static [Symbol]> {
 
 fn check_mod_const_bodies(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
     let mut vis = CheckConstVisitor::new(tcx);
-    tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut vis);
+    tcx.hir().visit_item_likes_in_module(module_def_id, &mut vis);
 }
 
 pub(crate) fn provide(providers: &mut Providers) {
index 550c062f4de0a8da721f69b64e569de727bb4695..9deb0042ff3608c52053238212985fdda7d048dc 100644 (file)
@@ -28,7 +28,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
                 errors: &errors,
             };
 
-            tcx.hir().deep_visit_item_likes_in_module(module_id, &mut v);
+            tcx.hir().visit_item_likes_in_module(module_id, &mut v);
         });
 
         let errors = errors.into_inner();
index 80a263f4cb2dd09486d28737cb8294d5493cc8e5..0070c0699a4aa765365107733a509b17f1e8638e 100644 (file)
@@ -140,7 +140,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
 }
 
 fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
-    tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
+    tcx.hir().visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
 }
 
 pub fn provide(providers: &mut Providers) {
index 9cfef26fd0310669ef7f2fc48a022df14f566e3e..68b2a052391fa60e8cb0be0dfdaeb1bf04f186ed 100644 (file)
@@ -31,7 +31,7 @@ struct CheckLoopVisitor<'a, 'hir> {
 }
 
 fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
-    tcx.hir().deep_visit_item_likes_in_module(
+    tcx.hir().visit_item_likes_in_module(
         module_def_id,
         &mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal },
     );
index 40844b84af0799f6696561dd9304f8a675945a23..20765abf392803f414e18093e03edfec990b1790 100644 (file)
@@ -14,7 +14,7 @@
 use rustc_target::spec::abi::Abi;
 
 fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
-    tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
+    tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
 }
 
 pub(crate) fn provide(providers: &mut Providers) {
index 9eaefc8b8aa8fa9eeb90024ba54cc3622868f200..12050dceb60a60a84e8f950ed878a87422caba58 100644 (file)
@@ -660,7 +660,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
 /// Cross-references the feature names of unstable APIs with enabled
 /// features and possibly prints errors.
 fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
-    tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
+    tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
 }
 
 pub(crate) fn provide(providers: &mut Providers) {
@@ -890,7 +890,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
         let mut missing = MissingStabilityAnnotations { tcx, access_levels };
         missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID));
         tcx.hir().walk_toplevel_module(&mut missing);
-        tcx.hir().deep_visit_all_item_likes(&mut missing);
+        tcx.hir().visit_all_item_likes_in_crate(&mut missing);
     }
 
     let declared_lang_features = &tcx.features().declared_lang_features;
index b01c512a3b439d2fd75ff923079b7f09ba4e54f7..4c25075327f0149af69fab7e6183b0ceae85a552 100644 (file)
@@ -653,12 +653,11 @@ fn decode(decoder: &mut CacheDecoder<'a, 'tcx>) -> Self {
             #[cfg(debug_assertions)]
             {
                 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
-                let mut hcx = decoder.tcx.create_stable_hashing_context();
-                let mut hasher = StableHasher::new();
-                hcx.while_hashing_spans(true, |hcx| {
-                    expn_id.expn_data().hash_stable(hcx, &mut hasher)
+                let local_hash: u64 = decoder.tcx.with_stable_hashing_context(|mut hcx| {
+                    let mut hasher = StableHasher::new();
+                    expn_id.expn_data().hash_stable(&mut hcx, &mut hasher);
+                    hasher.finish()
                 });
-                let local_hash: u64 = hasher.finish();
                 debug_assert_eq!(hash.local_hash(), local_hash);
             }
 
index 3ed6632ba66adfe189b09b3fd16216b974159e63..333dc5aa668b02639020b5694bdd56476cfc6118 100644 (file)
@@ -291,11 +291,12 @@ pub fn $name<$tcx>(tcx: QueryCtxt<$tcx>, key: query_keys::$name<$tcx>) -> QueryS
                         .and_then(|def_id| tcx.opt_def_kind(def_id))
                 };
                 let hash = || {
-                    let mut hcx = tcx.create_stable_hashing_context();
-                    let mut hasher = StableHasher::new();
-                    std::mem::discriminant(&kind).hash_stable(&mut hcx, &mut hasher);
-                    key.hash_stable(&mut hcx, &mut hasher);
-                    hasher.finish::<u64>()
+                    tcx.with_stable_hashing_context(|mut hcx|{
+                        let mut hasher = StableHasher::new();
+                        std::mem::discriminant(&kind).hash_stable(&mut hcx, &mut hasher);
+                        key.hash_stable(&mut hcx, &mut hasher);
+                        hasher.finish::<u64>()
+                    })
                 };
 
                 QueryStackFrame::new(name, description, span, def_kind, hash)
@@ -376,6 +377,17 @@ pub fn Null() -> DepKindStruct {
                 }
             }
 
+            // We use this for the forever-red node.
+            pub fn Red() -> DepKindStruct {
+                DepKindStruct {
+                    is_anon: false,
+                    is_eval_always: false,
+                    fingerprint_style: FingerprintStyle::Unit,
+                    force_from_dep_node: Some(|_, dep_node| bug!("force_from_dep_node: encountered {:?}", dep_node)),
+                    try_load_from_on_disk_cache: None,
+                }
+            }
+
             pub fn TraitSelect() -> DepKindStruct {
                 DepKindStruct {
                     is_anon: true,
index bb2179a24953bfbcbd0d72c20c5ec137f8558ae3..c6210095b60fc0153ce9c79a8eb5b9c48b81cdfd 100644 (file)
@@ -131,12 +131,11 @@ impl<Ctxt: DepContext, T> DepNodeParams<Ctxt> for T
 
     #[inline(always)]
     default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint {
-        let mut hcx = tcx.create_stable_hashing_context();
-        let mut hasher = StableHasher::new();
-
-        self.hash_stable(&mut hcx, &mut hasher);
-
-        hasher.finish()
+        tcx.with_stable_hashing_context(|mut hcx| {
+            let mut hasher = StableHasher::new();
+            self.hash_stable(&mut hcx, &mut hasher);
+            hasher.finish()
+        })
     }
 
     #[inline(always)]
index 5d9a4d8ce4e9f3047badb19b4a556e7f8f4ac73a..e7026096e7b503fc7e6c17865daa1ebb1bca0bcb 100644 (file)
@@ -43,6 +43,7 @@ pub struct DepNodeIndex { .. }
 impl DepNodeIndex {
     pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
     pub const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0);
+    pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
 }
 
 impl std::convert::From<DepNodeIndex> for QueryInvocationId {
@@ -125,6 +126,8 @@ pub fn new(
             record_stats,
         );
 
+        let colors = DepNodeColorMap::new(prev_graph_node_count);
+
         // Instantiate a dependy-less node only once for anonymous queries.
         let _green_node_index = current.intern_new_node(
             profiler,
@@ -132,7 +135,19 @@ pub fn new(
             smallvec![],
             Fingerprint::ZERO,
         );
-        debug_assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE);
+        assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE);
+
+        // Instantiate a dependy-less red node only once for anonymous queries.
+        let (_red_node_index, _prev_and_index) = current.intern_node(
+            profiler,
+            &prev_graph,
+            DepNode { kind: DepKind::RED, hash: Fingerprint::ZERO.into() },
+            smallvec![],
+            None,
+            false,
+        );
+        assert_eq!(_red_node_index, DepNodeIndex::FOREVER_RED_NODE);
+        assert!(matches!(_prev_and_index, None | Some((_, DepNodeColor::Red))));
 
         DepGraph {
             data: Some(Lrc::new(DepGraphData {
@@ -141,7 +156,7 @@ pub fn new(
                 current,
                 processed_side_effects: Default::default(),
                 previous: prev_graph,
-                colors: DepNodeColorMap::new(prev_graph_node_count),
+                colors,
                 debug_loaded_from_disk: Default::default(),
             })),
             virtual_dep_node_index: Lrc::new(AtomicU32::new(0)),
@@ -329,10 +344,8 @@ fn with_task_impl<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
 
         let dcx = cx.dep_context();
         let hashing_timer = dcx.profiler().incr_result_hashing();
-        let current_fingerprint = hash_result.map(|f| {
-            let mut hcx = dcx.create_stable_hashing_context();
-            f(&mut hcx, &result)
-        });
+        let current_fingerprint =
+            hash_result.map(|f| dcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, &result)));
 
         let print_status = cfg!(debug_assertions) && dcx.sess().opts.debugging_opts.dep_tasks;
 
@@ -972,6 +985,7 @@ fn new(
         let nanos = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64;
         let mut stable_hasher = StableHasher::new();
         nanos.hash(&mut stable_hasher);
+        let anon_id_seed = stable_hasher.finish();
 
         #[cfg(debug_assertions)]
         let forbidden_edge = match env::var("RUST_FORBID_DEP_GRAPH_EDGE") {
@@ -1007,7 +1021,7 @@ fn new(
                 )
             }),
             prev_index_to_index: Lock::new(IndexVec::from_elem_n(None, prev_graph_node_count)),
-            anon_id_seed: stable_hasher.finish(),
+            anon_id_seed,
             #[cfg(debug_assertions)]
             forbidden_edge,
             total_read_count: AtomicU64::new(0),
index 5907ae309ca377abb9c5e81966f8999fa6e18a94..342d95ca490ea276a5ecd2dfb3b2bc6aa3b44f1f 100644 (file)
@@ -23,7 +23,7 @@ pub trait DepContext: Copy {
     type DepKind: self::DepKind;
 
     /// Create a hashing context for hashing new results.
-    fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
+    fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
 
     /// Access the DepGraph.
     fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
@@ -85,8 +85,12 @@ pub fn reconstructible(self) -> bool {
 
 /// Describe the different families of dependency nodes.
 pub trait DepKind: Copy + fmt::Debug + Eq + Hash + Send + Encodable<FileEncoder> + 'static {
+    /// DepKind to use when incr. comp. is turned off.
     const NULL: Self;
 
+    /// DepKind to use to create the initial forever-red node.
+    const RED: Self;
+
     /// Implementation of `std::fmt::Debug` for `DepNode`.
     fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
 
index 62a1f776fb352c63e5875a1dc2ba354ca762d97a..843f6f9d703674e3eabe10e8f7c695675f99161d 100644 (file)
@@ -1,4 +1,5 @@
 use crate::ich;
+
 use rustc_ast as ast;
 use rustc_data_structures::sorted_map::SortedMap;
 use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
@@ -118,13 +119,13 @@ pub fn with_hir_bodies(
         &mut self,
         hash_bodies: bool,
         owner: LocalDefId,
-        bodies: &'a SortedMap<hir::ItemLocalId, &'a hir::Body<'a>>,
-        f: impl FnOnce(&mut Self),
+        bodies: &SortedMap<hir::ItemLocalId, &hir::Body<'_>>,
+        f: impl FnOnce(&mut StableHashingContext<'_>),
     ) {
-        let prev = self.body_resolver;
-        self.body_resolver = BodyResolver::Traverse { hash_bodies, owner, bodies };
-        f(self);
-        self.body_resolver = prev;
+        f(&mut StableHashingContext {
+            body_resolver: BodyResolver::Traverse { hash_bodies, owner, bodies },
+            ..self.clone()
+        });
     }
 
     #[inline]
index 3e4c7ad9f8f41a2b66a75bc924f6d9702fc9091e..bbcd00be943a274bd180e869852f7605ec137be4 100644 (file)
@@ -542,8 +542,7 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
 
     debug!("BEGIN verify_ich({:?})", dep_node);
     let new_hash = query.hash_result.map_or(Fingerprint::ZERO, |f| {
-        let mut hcx = tcx.create_stable_hashing_context();
-        f(&mut hcx, result)
+        tcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, result))
     });
     let old_hash = tcx.dep_graph().prev_fingerprint_of(dep_node);
     debug!("END verify_ich({:?})", dep_node);
index 0f58206eee9f37de748666b6c62e5d41f65142f6..ec9ae63ca366abac87c4bb6eaff3c180bb2b5b81 100644 (file)
@@ -1499,10 +1499,16 @@ pub(crate) fn unresolved_macro_suggestions(
             && let ModuleKind::Def(DefKind::Enum, def_id, _) = parent_scope.module.kind
             && let Some(span) = self.opt_span(def_id)
         {
-            err.span_help(
-                self.session.source_map().guess_head_span(span),
-                "consider adding `#[derive(Default)]` to this enum",
-            );
+            let source_map = self.session.source_map();
+            let head_span = source_map.guess_head_span(span);
+            if let Ok(head) = source_map.span_to_snippet(head_span) {
+                err.span_suggestion(head_span, "consider adding a derive", format!("#[derive(Default)]\n{head}"), Applicability::MaybeIncorrect);
+            } else {
+                err.span_help(
+                    head_span,
+                    "consider adding `#[derive(Default)]` to this enum",
+                );
+            }
         }
         for ns in [Namespace::MacroNS, Namespace::TypeNS, Namespace::ValueNS] {
             if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
index e7717f1367cb053d4619a7a27f4e9189d2ce3354..b7da0f229420bdf16101473e3bd679089792dcaa 100644 (file)
@@ -726,6 +726,7 @@ fn default() -> Options {
             prints: Vec::new(),
             cg: Default::default(),
             error_format: ErrorOutputType::default(),
+            diagnostic_width: None,
             externs: Externs(BTreeMap::new()),
             crate_name: None,
             libs: Vec::new(),
@@ -1427,6 +1428,12 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
                                  never  = never colorize output",
             "auto|always|never",
         ),
+        opt::opt_s(
+            "",
+            "diagnostic-width",
+            "Inform rustc of the width of the output so that diagnostics can be truncated to fit",
+            "WIDTH",
+        ),
         opt::multi_s(
             "",
             "remap-path-prefix",
@@ -2202,6 +2209,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
     let error_format = parse_error_format(matches, color, json_rendered);
 
+    let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
+        early_error(error_format, "`--diagnostic-width` must be an positive integer");
+    });
+
     let unparsed_crate_types = matches.opt_strs("crate-type");
     let crate_types = parse_crate_types_from_list(unparsed_crate_types)
         .unwrap_or_else(|e| early_error(error_format, &e));
@@ -2474,6 +2485,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         prints,
         cg,
         error_format,
+        diagnostic_width,
         externs,
         unstable_features: UnstableFeatures::from_environment(crate_name.as_deref()),
         crate_name,
index be70ea5d5e48059b9c92548af34b446fef2ebf61..b617eb02eb6e3697cb057739e0bede19ab7d532a 100644 (file)
@@ -170,6 +170,7 @@ pub struct Options {
 
         test: bool [TRACKED],
         error_format: ErrorOutputType [UNTRACKED],
+        diagnostic_width: Option<usize> [UNTRACKED],
 
         /// If `Some`, enable incremental compilation, using the given
         /// directory to store intermediate results.
@@ -1245,6 +1246,8 @@ pub(crate) fn parse_branch_protection(
     dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
         "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
         (default: no)"),
+    dump_drop_tracking_cfg: Option<String> = (None, parse_opt_string, [UNTRACKED],
+        "dump drop-tracking control-flow graph as a `.dot` file (default: no)"),
     dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
         "dump MIR state to file.
         `val` is used to select which passes and functions to dump. For example:
@@ -1388,6 +1391,8 @@ pub(crate) fn parse_branch_protection(
         "panic strategy for out-of-memory handling"),
     osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
         "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
+    diagnostic_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
+        "set the current output width for diagnostic truncation"),
     panic_abort_tests: bool = (false, parse_bool, [TRACKED],
         "support compiling tests with panic=abort (default: no)"),
     panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
@@ -1514,8 +1519,6 @@ pub(crate) fn parse_branch_protection(
         "show extended diagnostic help (default: no)"),
     temps_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
         "the directory the intermediate files are written to"),
-    terminal_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
-        "set the current terminal width"),
     // Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved
     // alongside query results and changes to translation options can affect diagnostics - so
     // translation options should be tracked.
index 2a5ddd4e9e42016f606aec114d49d4c27776d240..1eee0c3163d400d8fe8cc26ee04e2fa4419084f3 100644 (file)
@@ -2,7 +2,7 @@
 use crate::code_stats::CodeStats;
 pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
 use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
-use crate::parse::ParseSess;
+use crate::parse::{add_feature_diagnostics, ParseSess};
 use crate::search_paths::{PathKind, SearchPath};
 use crate::{filesearch, lint};
 
@@ -458,6 +458,15 @@ pub fn create_err<'a>(
     ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
         self.parse_sess.create_err(err)
     }
+    pub fn create_feature_err<'a>(
+        &'a self,
+        err: impl SessionDiagnostic<'a>,
+        feature: Symbol,
+    ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
+        let mut err = self.parse_sess.create_err(err);
+        add_feature_diagnostics(&mut err, &self.parse_sess, feature);
+        err
+    }
     pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
         self.parse_sess.emit_err(err)
     }
@@ -1162,7 +1171,7 @@ fn default_emitter(
                         fallback_bundle,
                         short,
                         sopts.debugging_opts.teach,
-                        sopts.debugging_opts.terminal_width,
+                        sopts.diagnostic_width,
                         macro_backtrace,
                     ),
                     Some(dst) => EmitterWriter::new(
@@ -1173,7 +1182,7 @@ fn default_emitter(
                         short,
                         false, // no teach messages when writing to a buffer
                         false, // no colors when writing to a buffer
-                        None,  // no terminal width
+                        None,  // no diagnostic width
                         macro_backtrace,
                     ),
                 };
@@ -1188,7 +1197,7 @@ fn default_emitter(
                 fallback_bundle,
                 pretty,
                 json_rendered,
-                sopts.debugging_opts.terminal_width,
+                sopts.diagnostic_width,
                 macro_backtrace,
             )
             .ui_testing(sopts.debugging_opts.ui_testing),
@@ -1202,7 +1211,7 @@ fn default_emitter(
                 fallback_bundle,
                 pretty,
                 json_rendered,
-                sopts.debugging_opts.terminal_width,
+                sopts.diagnostic_width,
                 macro_backtrace,
             )
             .ui_testing(sopts.debugging_opts.ui_testing),
index 65a2a18e02f8f5ea3b826f59324abd6d9977ef19..9b6967621f1dc3b812fce01dfff3babd3a4fbe36 100644 (file)
         impl_lint_pass,
         impl_macros,
         impl_trait_in_bindings,
+        import,
         import_shadowing,
         imported_main,
         in_band_lifetimes,
         use_nested_groups,
         used,
         used_with_arg,
+        using,
         usize,
         v1,
         va_arg,
index 470438471cb96cdc80eb26b597d5968a7fd8c4bf..e3045c9321d1c74474ec44616c63408beb2d113c 100644 (file)
@@ -96,47 +96,48 @@ fn get_symbol_hash<'tcx>(
     let substs = instance.substs;
     debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
 
-    let mut hasher = StableHasher::new();
-    let mut hcx = tcx.create_stable_hashing_context();
-
-    record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
-        // the main symbol name is not necessarily unique; hash in the
-        // compiler's internal def-path, guaranteeing each symbol has a
-        // truly unique path
-        tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
-
-        // Include the main item-type. Note that, in this case, the
-        // assertions about `needs_subst` may not hold, but this item-type
-        // ought to be the same for every reference anyway.
-        assert!(!item_type.has_erasable_regions());
-        hcx.while_hashing_spans(false, |hcx| {
-            item_type.hash_stable(hcx, &mut hasher);
-
-            // If this is a function, we hash the signature as well.
-            // This is not *strictly* needed, but it may help in some
-            // situations, see the `run-make/a-b-a-linker-guard` test.
-            if let ty::FnDef(..) = item_type.kind() {
-                item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher);
-            }
+    tcx.with_stable_hashing_context(|mut hcx| {
+        let mut hasher = StableHasher::new();
+
+        record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
+            // the main symbol name is not necessarily unique; hash in the
+            // compiler's internal def-path, guaranteeing each symbol has a
+            // truly unique path
+            tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
+
+            // Include the main item-type. Note that, in this case, the
+            // assertions about `needs_subst` may not hold, but this item-type
+            // ought to be the same for every reference anyway.
+            assert!(!item_type.has_erasable_regions());
+            hcx.while_hashing_spans(false, |hcx| {
+                item_type.hash_stable(hcx, &mut hasher);
+
+                // If this is a function, we hash the signature as well.
+                // This is not *strictly* needed, but it may help in some
+                // situations, see the `run-make/a-b-a-linker-guard` test.
+                if let ty::FnDef(..) = item_type.kind() {
+                    item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher);
+                }
 
-            // also include any type parameters (for generic items)
-            substs.hash_stable(hcx, &mut hasher);
+                // also include any type parameters (for generic items)
+                substs.hash_stable(hcx, &mut hasher);
 
-            if let Some(instantiating_crate) = instantiating_crate {
-                tcx.def_path_hash(instantiating_crate.as_def_id())
-                    .stable_crate_id()
-                    .hash_stable(hcx, &mut hasher);
-            }
+                if let Some(instantiating_crate) = instantiating_crate {
+                    tcx.def_path_hash(instantiating_crate.as_def_id())
+                        .stable_crate_id()
+                        .hash_stable(hcx, &mut hasher);
+                }
 
-            // We want to avoid accidental collision between different types of instances.
-            // Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
-            // instances without this.
-            discriminant(&instance.def).hash_stable(hcx, &mut hasher);
+                // We want to avoid accidental collision between different types of instances.
+                // Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
+                // instances without this.
+                discriminant(&instance.def).hash_stable(hcx, &mut hasher);
+            });
         });
-    });
 
-    // 64 bits should be enough to avoid collisions.
-    hasher.finish::<u64>()
+        // 64 bits should be enough to avoid collisions.
+        hasher.finish::<u64>()
+    })
 }
 
 // Follow C++ namespace-mangling style, see
index 44ff3fd73061e87e8be7db9311b93e4e7ed7221e..282ee632ce5817dcf32fd54458f6663f7bf2264b 100644 (file)
@@ -37,5 +37,4 @@
 
 pub mod autoderef;
 pub mod infer;
-pub mod opaque_types;
 pub mod traits;
diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs
deleted file mode 100644 (file)
index d290f7b..0000000
+++ /dev/null
@@ -1,545 +0,0 @@
-use crate::traits;
-use crate::traits::error_reporting::InferCtxtExt as _;
-use crate::traits::TraitEngineExt as _;
-use rustc_data_structures::fx::FxHashMap;
-use rustc_hir::def_id::DefId;
-use rustc_hir::OpaqueTyOrigin;
-use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
-use rustc_infer::infer::{InferCtxt, TyCtxtInferExt as _};
-use rustc_infer::traits::{Obligation, ObligationCause, TraitEngine};
-use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
-use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts};
-use rustc_middle::ty::visit::TypeVisitable;
-use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, ToPredicate, Ty, TyCtxt};
-use rustc_span::Span;
-
-pub trait InferCtxtExt<'tcx> {
-    fn infer_opaque_definition_from_instantiation(
-        &self,
-        opaque_type_key: OpaqueTypeKey<'tcx>,
-        instantiated_ty: OpaqueHiddenType<'tcx>,
-        origin: OpaqueTyOrigin,
-    ) -> Ty<'tcx>;
-}
-
-impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
-    /// Given the fully resolved, instantiated type for an opaque
-    /// type, i.e., the value of an inference variable like C1 or C2
-    /// (*), computes the "definition type" for an opaque type
-    /// definition -- that is, the inferred value of `Foo1<'x>` or
-    /// `Foo2<'x>` that we would conceptually use in its definition:
-    /// ```ignore (illustrative)
-    /// type Foo1<'x> = impl Bar<'x> = AAA;  // <-- this type AAA
-    /// type Foo2<'x> = impl Bar<'x> = BBB;  // <-- or this type BBB
-    /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
-    /// ```
-    /// Note that these values are defined in terms of a distinct set of
-    /// generic parameters (`'x` instead of `'a`) from C1 or C2. The main
-    /// purpose of this function is to do that translation.
-    ///
-    /// (*) C1 and C2 were introduced in the comments on
-    /// `register_member_constraints`. Read that comment for more context.
-    ///
-    /// # Parameters
-    ///
-    /// - `def_id`, the `impl Trait` type
-    /// - `substs`, the substs  used to instantiate this opaque type
-    /// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
-    ///   `opaque_defn.concrete_ty`
-    #[instrument(level = "debug", skip(self))]
-    fn infer_opaque_definition_from_instantiation(
-        &self,
-        opaque_type_key: OpaqueTypeKey<'tcx>,
-        instantiated_ty: OpaqueHiddenType<'tcx>,
-        origin: OpaqueTyOrigin,
-    ) -> Ty<'tcx> {
-        if self.is_tainted_by_errors() {
-            return self.tcx.ty_error();
-        }
-
-        let OpaqueTypeKey { def_id, substs } = opaque_type_key;
-
-        // Use substs to build up a reverse map from regions to their
-        // identity mappings. This is necessary because of `impl
-        // Trait` lifetimes are computed by replacing existing
-        // lifetimes with 'static and remapping only those used in the
-        // `impl Trait` return type, resulting in the parameters
-        // shifting.
-        let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
-        debug!(?id_substs);
-        let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> =
-            substs.iter().enumerate().map(|(index, subst)| (subst, id_substs[index])).collect();
-        debug!("map = {:#?}", map);
-
-        // Convert the type from the function into a type valid outside
-        // the function, by replacing invalid regions with 'static,
-        // after producing an error for each of them.
-        let definition_ty = instantiated_ty.ty.fold_with(&mut ReverseMapper::new(
-            self.tcx,
-            def_id,
-            map,
-            instantiated_ty.ty,
-            instantiated_ty.span,
-        ));
-        debug!(?definition_ty);
-
-        if !check_opaque_type_parameter_valid(
-            self.tcx,
-            opaque_type_key,
-            origin,
-            instantiated_ty.span,
-        ) {
-            return self.tcx.ty_error();
-        }
-
-        // Only check this for TAIT. RPIT already supports `src/test/ui/impl-trait/nested-return-type2.rs`
-        // on stable and we'd break that.
-        if let OpaqueTyOrigin::TyAlias = origin {
-            // This logic duplicates most of `check_opaque_meets_bounds`.
-            // FIXME(oli-obk): Also do region checks here and then consider removing `check_opaque_meets_bounds` entirely.
-            let param_env = self.tcx.param_env(def_id);
-            let body_id = self.tcx.local_def_id_to_hir_id(def_id.as_local().unwrap());
-            self.tcx.infer_ctxt().enter(move |infcx| {
-                // Require the hidden type to be well-formed with only the generics of the opaque type.
-                // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
-                // hidden type is well formed even without those bounds.
-                let predicate =
-                    ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()))
-                        .to_predicate(infcx.tcx);
-                let mut fulfillment_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
-
-                // Require that the hidden type actually fulfills all the bounds of the opaque type, even without
-                // the bounds that the function supplies.
-                match infcx.register_hidden_type(
-                    OpaqueTypeKey { def_id, substs: id_substs },
-                    ObligationCause::misc(instantiated_ty.span, body_id),
-                    param_env,
-                    definition_ty,
-                    origin,
-                ) {
-                    Ok(infer_ok) => {
-                        for obligation in infer_ok.obligations {
-                            fulfillment_cx.register_predicate_obligation(&infcx, obligation);
-                        }
-                    }
-                    Err(err) => {
-                        infcx
-                            .report_mismatched_types(
-                                &ObligationCause::misc(instantiated_ty.span, body_id),
-                                self.tcx.mk_opaque(def_id, id_substs),
-                                definition_ty,
-                                err,
-                            )
-                            .emit();
-                    }
-                }
-
-                fulfillment_cx.register_predicate_obligation(
-                    &infcx,
-                    Obligation::misc(instantiated_ty.span, body_id, param_env, predicate),
-                );
-
-                // Check that all obligations are satisfied by the implementation's
-                // version.
-                let errors = fulfillment_cx.select_all_or_error(&infcx);
-
-                let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
-
-                if errors.is_empty() {
-                    definition_ty
-                } else {
-                    infcx.report_fulfillment_errors(&errors, None, false);
-                    self.tcx.ty_error()
-                }
-            })
-        } else {
-            definition_ty
-        }
-    }
-}
-
-fn check_opaque_type_parameter_valid(
-    tcx: TyCtxt<'_>,
-    opaque_type_key: OpaqueTypeKey<'_>,
-    origin: OpaqueTyOrigin,
-    span: Span,
-) -> bool {
-    match origin {
-        // No need to check return position impl trait (RPIT)
-        // because for type and const parameters they are correct
-        // by construction: we convert
-        //
-        // fn foo<P0..Pn>() -> impl Trait
-        //
-        // into
-        //
-        // type Foo<P0...Pn>
-        // fn foo<P0..Pn>() -> Foo<P0...Pn>.
-        //
-        // For lifetime parameters we convert
-        //
-        // fn foo<'l0..'ln>() -> impl Trait<'l0..'lm>
-        //
-        // into
-        //
-        // type foo::<'p0..'pn>::Foo<'q0..'qm>
-        // fn foo<l0..'ln>() -> foo::<'static..'static>::Foo<'l0..'lm>.
-        //
-        // which would error here on all of the `'static` args.
-        OpaqueTyOrigin::FnReturn(..) | OpaqueTyOrigin::AsyncFn(..) => return true,
-        // Check these
-        OpaqueTyOrigin::TyAlias => {}
-    }
-    let opaque_generics = tcx.generics_of(opaque_type_key.def_id);
-    let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default();
-    for (i, arg) in opaque_type_key.substs.iter().enumerate() {
-        let arg_is_param = match arg.unpack() {
-            GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
-            GenericArgKind::Lifetime(lt) if lt.is_static() => {
-                tcx.sess
-                    .struct_span_err(span, "non-defining opaque type use in defining scope")
-                    .span_label(
-                        tcx.def_span(opaque_generics.param_at(i, tcx).def_id),
-                        "cannot use static lifetime; use a bound lifetime \
-                                    instead or remove the lifetime parameter from the \
-                                    opaque type",
-                    )
-                    .emit();
-                return false;
-            }
-            GenericArgKind::Lifetime(lt) => {
-                matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
-            }
-            GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
-        };
-
-        if arg_is_param {
-            seen_params.entry(arg).or_default().push(i);
-        } else {
-            // Prevent `fn foo() -> Foo<u32>` from being defining.
-            let opaque_param = opaque_generics.param_at(i, tcx);
-            tcx.sess
-                .struct_span_err(span, "non-defining opaque type use in defining scope")
-                .span_note(
-                    tcx.def_span(opaque_param.def_id),
-                    &format!(
-                        "used non-generic {} `{}` for generic parameter",
-                        opaque_param.kind.descr(),
-                        arg,
-                    ),
-                )
-                .emit();
-            return false;
-        }
-    }
-
-    for (_, indices) in seen_params {
-        if indices.len() > 1 {
-            let descr = opaque_generics.param_at(indices[0], tcx).kind.descr();
-            let spans: Vec<_> = indices
-                .into_iter()
-                .map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id))
-                .collect();
-            tcx.sess
-                .struct_span_err(span, "non-defining opaque type use in defining scope")
-                .span_note(spans, &format!("{} used multiple times", descr))
-                .emit();
-            return false;
-        }
-    }
-    true
-}
-
-struct ReverseMapper<'tcx> {
-    tcx: TyCtxt<'tcx>,
-
-    opaque_type_def_id: DefId,
-    map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
-    map_missing_regions_to_empty: bool,
-
-    /// initially `Some`, set to `None` once error has been reported
-    hidden_ty: Option<Ty<'tcx>>,
-
-    /// Span of function being checked.
-    span: Span,
-}
-
-impl<'tcx> ReverseMapper<'tcx> {
-    fn new(
-        tcx: TyCtxt<'tcx>,
-        opaque_type_def_id: DefId,
-        map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
-        hidden_ty: Ty<'tcx>,
-        span: Span,
-    ) -> Self {
-        Self {
-            tcx,
-            opaque_type_def_id,
-            map,
-            map_missing_regions_to_empty: false,
-            hidden_ty: Some(hidden_ty),
-            span,
-        }
-    }
-
-    fn fold_kind_mapping_missing_regions_to_empty(
-        &mut self,
-        kind: GenericArg<'tcx>,
-    ) -> GenericArg<'tcx> {
-        assert!(!self.map_missing_regions_to_empty);
-        self.map_missing_regions_to_empty = true;
-        let kind = kind.fold_with(self);
-        self.map_missing_regions_to_empty = false;
-        kind
-    }
-
-    fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
-        assert!(!self.map_missing_regions_to_empty);
-        kind.fold_with(self)
-    }
-}
-
-impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
-    fn tcx(&self) -> TyCtxt<'tcx> {
-        self.tcx
-    }
-
-    #[instrument(skip(self), level = "debug")]
-    fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
-        match *r {
-            // Ignore bound regions and `'static` regions that appear in the
-            // type, we only need to remap regions that reference lifetimes
-            // from the function declaration.
-            // This would ignore `'r` in a type like `for<'r> fn(&'r u32)`.
-            ty::ReLateBound(..) | ty::ReStatic => return r,
-
-            // If regions have been erased (by writeback), don't try to unerase
-            // them.
-            ty::ReErased => return r,
-
-            // The regions that we expect from borrow checking.
-            ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReEmpty(ty::UniverseIndex::ROOT) => {}
-
-            ty::ReEmpty(_) | ty::RePlaceholder(_) | ty::ReVar(_) => {
-                // All of the regions in the type should either have been
-                // erased by writeback, or mapped back to named regions by
-                // borrow checking.
-                bug!("unexpected region kind in opaque type: {:?}", r);
-            }
-        }
-
-        let generics = self.tcx().generics_of(self.opaque_type_def_id);
-        match self.map.get(&r.into()).map(|k| k.unpack()) {
-            Some(GenericArgKind::Lifetime(r1)) => r1,
-            Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
-            None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
-            None if generics.parent.is_some() => {
-                if let Some(hidden_ty) = self.hidden_ty.take() {
-                    unexpected_hidden_region_diagnostic(
-                        self.tcx,
-                        self.tcx.def_span(self.opaque_type_def_id),
-                        hidden_ty,
-                        r,
-                    )
-                    .emit();
-                }
-                self.tcx.lifetimes.re_root_empty
-            }
-            None => {
-                self.tcx
-                    .sess
-                    .struct_span_err(self.span, "non-defining opaque type use in defining scope")
-                    .span_label(
-                        self.span,
-                        format!(
-                            "lifetime `{}` is part of concrete type but not used in \
-                                 parameter list of the `impl Trait` type alias",
-                            r
-                        ),
-                    )
-                    .emit();
-
-                self.tcx().lifetimes.re_static
-            }
-        }
-    }
-
-    fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
-        match *ty.kind() {
-            ty::Closure(def_id, substs) => {
-                // I am a horrible monster and I pray for death. When
-                // we encounter a closure here, it is always a closure
-                // from within the function that we are currently
-                // type-checking -- one that is now being encapsulated
-                // in an opaque type. Ideally, we would
-                // go through the types/lifetimes that it references
-                // and treat them just like we would any other type,
-                // which means we would error out if we find any
-                // reference to a type/region that is not in the
-                // "reverse map".
-                //
-                // **However,** in the case of closures, there is a
-                // somewhat subtle (read: hacky) consideration. The
-                // problem is that our closure types currently include
-                // all the lifetime parameters declared on the
-                // enclosing function, even if they are unused by the
-                // closure itself. We can't readily filter them out,
-                // so here we replace those values with `'empty`. This
-                // can't really make a difference to the rest of the
-                // compiler; those regions are ignored for the
-                // outlives relation, and hence don't affect trait
-                // selection or auto traits, and they are erased
-                // during codegen.
-
-                let generics = self.tcx.generics_of(def_id);
-                let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
-                    if index < generics.parent_count {
-                        // Accommodate missing regions in the parent kinds...
-                        self.fold_kind_mapping_missing_regions_to_empty(kind)
-                    } else {
-                        // ...but not elsewhere.
-                        self.fold_kind_normally(kind)
-                    }
-                }));
-
-                self.tcx.mk_closure(def_id, substs)
-            }
-
-            ty::Generator(def_id, substs, movability) => {
-                let generics = self.tcx.generics_of(def_id);
-                let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
-                    if index < generics.parent_count {
-                        // Accommodate missing regions in the parent kinds...
-                        self.fold_kind_mapping_missing_regions_to_empty(kind)
-                    } else {
-                        // ...but not elsewhere.
-                        self.fold_kind_normally(kind)
-                    }
-                }));
-
-                self.tcx.mk_generator(def_id, substs, movability)
-            }
-
-            ty::Param(param) => {
-                // Look it up in the substitution list.
-                match self.map.get(&ty.into()).map(|k| k.unpack()) {
-                    // Found it in the substitution list; replace with the parameter from the
-                    // opaque type.
-                    Some(GenericArgKind::Type(t1)) => t1,
-                    Some(u) => panic!("type mapped to unexpected kind: {:?}", u),
-                    None => {
-                        debug!(?param, ?self.map);
-                        self.tcx
-                            .sess
-                            .struct_span_err(
-                                self.span,
-                                &format!(
-                                    "type parameter `{}` is part of concrete type but not \
-                                          used in parameter list for the `impl Trait` type alias",
-                                    ty
-                                ),
-                            )
-                            .emit();
-
-                        self.tcx().ty_error()
-                    }
-                }
-            }
-
-            _ => ty.super_fold_with(self),
-        }
-    }
-
-    fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
-        trace!("checking const {:?}", ct);
-        // Find a const parameter
-        match ct.kind() {
-            ty::ConstKind::Param(..) => {
-                // Look it up in the substitution list.
-                match self.map.get(&ct.into()).map(|k| k.unpack()) {
-                    // Found it in the substitution list, replace with the parameter from the
-                    // opaque type.
-                    Some(GenericArgKind::Const(c1)) => c1,
-                    Some(u) => panic!("const mapped to unexpected kind: {:?}", u),
-                    None => {
-                        self.tcx
-                            .sess
-                            .struct_span_err(
-                                self.span,
-                                &format!(
-                                    "const parameter `{}` is part of concrete type but not \
-                                          used in parameter list for the `impl Trait` type alias",
-                                    ct
-                                ),
-                            )
-                            .emit();
-
-                        self.tcx().const_error(ct.ty())
-                    }
-                }
-            }
-
-            _ => ct,
-        }
-    }
-}
-
-/// Given a set of predicates that apply to an object type, returns
-/// the region bounds that the (erased) `Self` type must
-/// outlive. Precisely *because* the `Self` type is erased, the
-/// parameter `erased_self_ty` must be supplied to indicate what type
-/// has been used to represent `Self` in the predicates
-/// themselves. This should really be a unique type; `FreshTy(0)` is a
-/// popular choice.
-///
-/// N.B., in some cases, particularly around higher-ranked bounds,
-/// this function returns a kind of conservative approximation.
-/// That is, all regions returned by this function are definitely
-/// required, but there may be other region bounds that are not
-/// returned, as well as requirements like `for<'a> T: 'a`.
-///
-/// Requires that trait definitions have been processed so that we can
-/// elaborate predicates and walk supertraits.
-#[instrument(skip(tcx, predicates), level = "debug")]
-pub(crate) fn required_region_bounds<'tcx>(
-    tcx: TyCtxt<'tcx>,
-    erased_self_ty: Ty<'tcx>,
-    predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
-) -> Vec<ty::Region<'tcx>> {
-    assert!(!erased_self_ty.has_escaping_bound_vars());
-
-    traits::elaborate_predicates(tcx, predicates)
-        .filter_map(|obligation| {
-            debug!(?obligation);
-            match obligation.predicate.kind().skip_binder() {
-                ty::PredicateKind::Projection(..)
-                | ty::PredicateKind::Trait(..)
-                | ty::PredicateKind::Subtype(..)
-                | ty::PredicateKind::Coerce(..)
-                | ty::PredicateKind::WellFormed(..)
-                | ty::PredicateKind::ObjectSafe(..)
-                | ty::PredicateKind::ClosureKind(..)
-                | ty::PredicateKind::RegionOutlives(..)
-                | ty::PredicateKind::ConstEvaluatable(..)
-                | ty::PredicateKind::ConstEquate(..)
-                | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
-                ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
-                    // Search for a bound of the form `erased_self_ty
-                    // : 'a`, but be wary of something like `for<'a>
-                    // erased_self_ty : 'a` (we interpret a
-                    // higher-ranked bound like that as 'static,
-                    // though at present the code in `fulfill.rs`
-                    // considers such bounds to be unsatisfiable, so
-                    // it's kind of a moot point since you could never
-                    // construct such an object, but this seems
-                    // correct even if that code changes).
-                    if t == &erased_self_ty && !r.has_escaping_bound_vars() {
-                        Some(*r)
-                    } else {
-                        None
-                    }
-                }
-            }
-        })
-        .collect()
-}
index 8efefd476abc9b661a622533514e5f18b4663309..aa1c91362891ba5fb7dc7c41864c9c9c1a38b126 100644 (file)
@@ -23,7 +23,7 @@
 use rustc_hir::Item;
 use rustc_hir::Node;
 use rustc_infer::infer::error_reporting::same_type_modulo_infer;
-use rustc_infer::traits::TraitEngine;
+use rustc_infer::traits::{AmbiguousSelection, TraitEngine};
 use rustc_middle::thir::abstract_const::NotConstEvaluatable;
 use rustc_middle::traits::select::OverflowError;
 use rustc_middle::ty::error::ExpectedFound;
@@ -1404,7 +1404,7 @@ fn suggest_unsized_bound_if_applicable(
     fn annotate_source_of_ambiguity(
         &self,
         err: &mut Diagnostic,
-        impls: &[DefId],
+        impls: &[AmbiguousSelection],
         predicate: ty::Predicate<'tcx>,
     );
 
@@ -2020,6 +2020,14 @@ fn maybe_report_ambiguity(
                 );
                 match selcx.select_from_obligation(&obligation) {
                     Err(SelectionError::Ambiguous(impls)) if impls.len() > 1 => {
+                        if self.is_tainted_by_errors() && subst.is_none() {
+                            // If `subst.is_none()`, then this is probably two param-env
+                            // candidates or impl candidates that are equal modulo lifetimes.
+                            // Therefore, if we've already emitted an error, just skip this
+                            // one, since it's not particularly actionable.
+                            err.cancel();
+                            return;
+                        }
                         self.annotate_source_of_ambiguity(&mut err, &impls, predicate);
                     }
                     _ => {
@@ -2170,24 +2178,35 @@ fn maybe_report_ambiguity(
     fn annotate_source_of_ambiguity(
         &self,
         err: &mut Diagnostic,
-        impls: &[DefId],
+        impls: &[AmbiguousSelection],
         predicate: ty::Predicate<'tcx>,
     ) {
         let mut spans = vec![];
         let mut crates = vec![];
         let mut post = vec![];
-        for def_id in impls {
-            match self.tcx.span_of_impl(*def_id) {
-                Ok(span) => spans.push(span),
-                Err(name) => {
-                    crates.push(name);
-                    if let Some(header) = to_pretty_impl_header(self.tcx, *def_id) {
-                        post.push(header);
+        let mut or_where_clause = false;
+        for ambig in impls {
+            match ambig {
+                AmbiguousSelection::Impl(def_id) => match self.tcx.span_of_impl(*def_id) {
+                    Ok(span) => spans.push(span),
+                    Err(name) => {
+                        crates.push(name);
+                        if let Some(header) = to_pretty_impl_header(self.tcx, *def_id) {
+                            post.push(header);
+                        }
                     }
+                },
+                AmbiguousSelection::ParamEnv(span) => {
+                    or_where_clause = true;
+                    spans.push(*span);
                 }
             }
         }
-        let msg = format!("multiple `impl`s satisfying `{}` found", predicate);
+        let msg = format!(
+            "multiple `impl`s{} satisfying `{}` found",
+            if or_where_clause { " or `where` clauses" } else { "" },
+            predicate
+        );
         let mut crate_names: Vec<_> = crates.iter().map(|n| format!("`{}`", n)).collect();
         crate_names.sort();
         crate_names.dedup();
index 31d54b5b403937fe5e129f3da8474ec045491333..33585de600130c02cf6b100ff90f5124f5b2edeb 100644 (file)
@@ -777,6 +777,7 @@ fn suggest_fn_call(
             Ok(
                 EvaluationResult::EvaluatedToOk
                 | EvaluationResult::EvaluatedToOkModuloRegions
+                | EvaluationResult::EvaluatedToOkModuloOpaqueTypes
                 | EvaluationResult::EvaluatedToAmbig,
             ) => {}
             _ => return false,
index 0f7af41cfe3ff5b0b320e2f7861afdee1dcf6b6e..21e14eae0ee27bf22de576d1c236d38cd2ec9ee2 100644 (file)
@@ -6,9 +6,11 @@
 //!
 //! [rustc dev guide]:https://rustc-dev-guide.rust-lang.org/traits/resolution.html#candidate-assembly
 use hir::LangItem;
+use rustc_data_structures::fx::FxHashMap;
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
-use rustc_infer::traits::TraitEngine;
+use rustc_infer::traits::util::elaborate_predicates_with_span;
+use rustc_infer::traits::{AmbiguousSelection, TraitEngine};
 use rustc_infer::traits::{Obligation, SelectionError, TraitObligation};
 use rustc_lint_defs::builtin::DEREF_INTO_DYN_SUPERTRAIT;
 use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -199,11 +201,48 @@ fn candidate_from_obligation_no_cache<'o>(
                     // and report ambiguity.
                     if i > 1 {
                         debug!("multiple matches, ambig");
+
+                        // Collect a list of (probable) spans that point to a param-env candidate
+                        let tcx = self.infcx.tcx;
+                        let owner = stack.obligation.cause.body_id.owner.to_def_id();
+                        let predicates = tcx.predicates_of(owner).instantiate_identity(tcx);
+                        let param_env_spans: FxHashMap<_, _> = elaborate_predicates_with_span(
+                            tcx,
+                            std::iter::zip(predicates.predicates, predicates.spans),
+                        )
+                        .filter_map(|obligation| {
+                            let kind = obligation.predicate.kind();
+                            if let ty::PredicateKind::Trait(trait_pred) = kind.skip_binder() {
+                                if trait_pred.trait_ref
+                                    == ty::TraitRef::identity(tcx, trait_pred.def_id())
+                                        .skip_binder()
+                                {
+                                    // HACK: Remap the `Self: Trait` predicate that every trait has to a more useful span
+                                    Some((
+                                        kind.rebind(trait_pred),
+                                        tcx.def_span(trait_pred.def_id()),
+                                    ))
+                                } else {
+                                    Some((kind.rebind(trait_pred), obligation.cause.span))
+                                }
+                            } else {
+                                None
+                            }
+                        })
+                        .collect();
+
                         return Err(Ambiguous(
                             candidates
                                 .into_iter()
                                 .filter_map(|c| match c.candidate {
-                                    SelectionCandidate::ImplCandidate(def_id) => Some(def_id),
+                                    SelectionCandidate::ImplCandidate(def_id) => {
+                                        Some(AmbiguousSelection::Impl(def_id))
+                                    }
+                                    SelectionCandidate::ParamCandidate(predicate) => {
+                                        Some(AmbiguousSelection::ParamEnv(
+                                            *param_env_spans.get(&predicate)?,
+                                        ))
+                                    }
                                     _ => None,
                                 })
                                 .collect(),
index 596ee43562234421e37fe7153cdbe3d1bc22fa61..b205ca8fa11694855cb6c53557383a369c538c07 100644 (file)
@@ -394,6 +394,10 @@ fn evaluation_probe(
                 Err(_) => return Ok(EvaluatedToErr),
             }
 
+            if self.infcx.opaque_types_added_in_snapshot(snapshot) {
+                return Ok(result.max(EvaluatedToOkModuloOpaqueTypes));
+            }
+
             match self.infcx.region_constraints_added_in_snapshot(snapshot) {
                 None => Ok(result),
                 Some(_) => Ok(result.max(EvaluatedToOkModuloRegions)),
index f3ae34ce30a4883fb9c300bd03907f1d74246e0c..94ca138b9d20d64df7af6439cc20081fcdd91d21 100644 (file)
@@ -58,10 +58,7 @@ pub fn search_for_structural_match_violation<'tcx>(
     tcx: TyCtxt<'tcx>,
     ty: Ty<'tcx>,
 ) -> Option<NonStructuralMatchTy<'tcx>> {
-    // FIXME: we should instead pass in an `infcx` from the outside.
-    tcx.infer_ctxt().enter(|infcx| {
-        ty.visit_with(&mut Search { infcx, span, seen: FxHashSet::default() }).break_value()
-    })
+    ty.visit_with(&mut Search { tcx, span, seen: FxHashSet::default() }).break_value()
 }
 
 /// This method returns true if and only if `adt_ty` itself has been marked as
@@ -114,27 +111,23 @@ fn type_marked_structural<'tcx>(
 /// This implements the traversal over the structure of a given type to try to
 /// find instances of ADTs (specifically structs or enums) that do not implement
 /// the structural-match traits (`StructuralPartialEq` and `StructuralEq`).
-struct Search<'a, 'tcx> {
+struct Search<'tcx> {
     span: Span,
 
-    infcx: InferCtxt<'a, 'tcx>,
+    tcx: TyCtxt<'tcx>,
 
     /// Tracks ADTs previously encountered during search, so that
     /// we will not recur on them again.
     seen: FxHashSet<hir::def_id::DefId>,
 }
 
-impl<'a, 'tcx> Search<'a, 'tcx> {
-    fn tcx(&self) -> TyCtxt<'tcx> {
-        self.infcx.tcx
-    }
-
+impl<'tcx> Search<'tcx> {
     fn type_marked_structural(&self, adt_ty: Ty<'tcx>) -> bool {
-        adt_ty.is_structural_eq_shallow(self.tcx())
+        adt_ty.is_structural_eq_shallow(self.tcx)
     }
 }
 
-impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
+impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
     type BreakTy = NonStructuralMatchTy<'tcx>;
 
     fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
@@ -193,7 +186,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 return ControlFlow::CONTINUE;
             }
             ty::Array(_, n)
-                if { n.try_eval_usize(self.tcx(), ty::ParamEnv::reveal_all()) == Some(0) } =>
+                if { n.try_eval_usize(self.tcx, ty::ParamEnv::reveal_all()) == Some(0) } =>
             {
                 // rust-lang/rust#62336: ignore type of contents
                 // for empty array.
@@ -214,7 +207,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 bug!("unexpected type during structural-match checking: {:?}", ty);
             }
             ty::Error(_) => {
-                self.tcx().sess.delay_span_bug(self.span, "ty::Error in structural-match check");
+                self.tcx.sess.delay_span_bug(self.span, "ty::Error in structural-match check");
                 // We still want to check other types after encountering an error,
                 // as this may still emit relevant errors.
                 return ControlFlow::CONTINUE;
@@ -244,9 +237,9 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
 
         // even though we skip super_visit_with, we must recur on
         // fields of ADT.
-        let tcx = self.tcx();
+        let tcx = self.tcx;
         adt_def.all_fields().map(|field| field.ty(tcx, substs)).try_for_each(|field_ty| {
-            let ty = self.tcx().normalize_erasing_regions(ty::ParamEnv::empty(), field_ty);
+            let ty = self.tcx.normalize_erasing_regions(ty::ParamEnv::empty(), field_ty);
             debug!("structural-match ADT: field_ty={:?}, ty={:?}", field_ty, ty);
             ty.visit_with(self)
         })
index d43b3c9091fc6a9d6659bbb1cc19f2f134921fb4..7b5e1498f2695e0ae617d614eb849637f5ce7dd3 100644 (file)
@@ -1,5 +1,4 @@
 use crate::infer::InferCtxt;
-use crate::opaque_types::required_region_bounds;
 use crate::traits;
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
@@ -271,7 +270,7 @@ fn cause(&self, code: traits::ObligationCauseCode<'tcx>) -> traits::ObligationCa
     }
 
     fn normalize(mut self) -> Vec<traits::PredicateObligation<'tcx>> {
-        let cause = self.cause(traits::MiscObligation);
+        let cause = self.cause(traits::WellFormed(None));
         let infcx = &mut self.infcx;
         let param_env = self.param_env;
         let mut obligations = Vec::with_capacity(self.out.len());
@@ -385,7 +384,7 @@ fn compute_projection(&mut self, data: ty::ProjectionTy<'tcx>) {
         self.out.extend(obligations);
 
         let tcx = self.tcx();
-        let cause = self.cause(traits::MiscObligation);
+        let cause = self.cause(traits::WellFormed(None));
         let param_env = self.param_env;
         let depth = self.recursion_depth;
 
@@ -445,7 +444,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) {
                             let predicate =
                                 ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
                                     .to_predicate(self.tcx());
-                            let cause = self.cause(traits::MiscObligation);
+                            let cause = self.cause(traits::WellFormed(None));
                             self.out.push(traits::Obligation::with_depth(
                                 cause,
                                 self.recursion_depth,
@@ -457,7 +456,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) {
                             let resolved = self.infcx.shallow_resolve(infer);
                             // the `InferConst` changed, meaning that we made progress.
                             if resolved != infer {
-                                let cause = self.cause(traits::MiscObligation);
+                                let cause = self.cause(traits::WellFormed(None));
 
                                 let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
                                     kind: ty::ConstKind::Infer(resolved),
@@ -648,7 +647,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) {
                     let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
 
                     if !defer_to_coercion {
-                        let cause = self.cause(traits::MiscObligation);
+                        let cause = self.cause(traits::WellFormed(None));
                         let component_traits = data.auto_traits().chain(data.principal_def_id());
                         let tcx = self.tcx();
                         self.out.extend(component_traits.map(|did| {
@@ -679,7 +678,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) {
                     let ty = self.infcx.shallow_resolve(ty);
                     if let ty::Infer(ty::TyVar(_)) = ty.kind() {
                         // Not yet resolved, but we've made progress.
-                        let cause = self.cause(traits::MiscObligation);
+                        let cause = self.cause(traits::WellFormed(None));
                         self.out.push(traits::Obligation::with_depth(
                             cause,
                             self.recursion_depth,
@@ -810,3 +809,63 @@ pub fn object_region_bounds<'tcx>(
 
     required_region_bounds(tcx, open_ty, predicates)
 }
+
+/// Given a set of predicates that apply to an object type, returns
+/// the region bounds that the (erased) `Self` type must
+/// outlive. Precisely *because* the `Self` type is erased, the
+/// parameter `erased_self_ty` must be supplied to indicate what type
+/// has been used to represent `Self` in the predicates
+/// themselves. This should really be a unique type; `FreshTy(0)` is a
+/// popular choice.
+///
+/// N.B., in some cases, particularly around higher-ranked bounds,
+/// this function returns a kind of conservative approximation.
+/// That is, all regions returned by this function are definitely
+/// required, but there may be other region bounds that are not
+/// returned, as well as requirements like `for<'a> T: 'a`.
+///
+/// Requires that trait definitions have been processed so that we can
+/// elaborate predicates and walk supertraits.
+#[instrument(skip(tcx, predicates), level = "debug")]
+pub(crate) fn required_region_bounds<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    erased_self_ty: Ty<'tcx>,
+    predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
+) -> Vec<ty::Region<'tcx>> {
+    assert!(!erased_self_ty.has_escaping_bound_vars());
+
+    traits::elaborate_predicates(tcx, predicates)
+        .filter_map(|obligation| {
+            debug!(?obligation);
+            match obligation.predicate.kind().skip_binder() {
+                ty::PredicateKind::Projection(..)
+                | ty::PredicateKind::Trait(..)
+                | ty::PredicateKind::Subtype(..)
+                | ty::PredicateKind::Coerce(..)
+                | ty::PredicateKind::WellFormed(..)
+                | ty::PredicateKind::ObjectSafe(..)
+                | ty::PredicateKind::ClosureKind(..)
+                | ty::PredicateKind::RegionOutlives(..)
+                | ty::PredicateKind::ConstEvaluatable(..)
+                | ty::PredicateKind::ConstEquate(..)
+                | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
+                ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
+                    // Search for a bound of the form `erased_self_ty
+                    // : 'a`, but be wary of something like `for<'a>
+                    // erased_self_ty : 'a` (we interpret a
+                    // higher-ranked bound like that as 'static,
+                    // though at present the code in `fulfill.rs`
+                    // considers such bounds to be unsatisfiable, so
+                    // it's kind of a moot point since you could never
+                    // construct such an object, but this seems
+                    // correct even if that code changes).
+                    if t == &erased_self_ty && !r.has_escaping_bound_vars() {
+                        Some(*r)
+                    } else {
+                        None
+                    }
+                }
+            }
+        })
+        .collect()
+}
index 6744536338cbbc6bde9895194bc0b46e24eb8f92..fd6376ef6ee9dc04abfffdd00747a85c799d0670 100644 (file)
@@ -204,14 +204,6 @@ pub struct TypeFlags: u32 {
                                           | TypeFlags::HAS_CT_INFER.bits
                                           | TypeFlags::HAS_TY_PLACEHOLDER.bits
                                           | TypeFlags::HAS_CT_PLACEHOLDER.bits
-                                          // The `evaluate_obligation` query does not return further
-                                          // obligations. If it evaluates an obligation with an opaque
-                                          // type, that opaque type may get compared to another type,
-                                          // constraining it. We would lose this information.
-                                          // FIXME: differentiate between crate-local opaque types
-                                          // and opaque types from other crates, as only opaque types
-                                          // from the local crate can possibly be a local name
-                                          | TypeFlags::HAS_TY_OPAQUE.bits
                                           // We consider 'freshened' types and constants
                                           // to depend on a particular fn.
                                           // The freshening process throws away information,
index 2c8be88ef6c929343d01c5ba374539dda7efa269..3af73abe5ceda24feac79b29448290cd5b6f57f6 100644 (file)
@@ -117,7 +117,7 @@ pub fn check_call(
         };
 
         // we must check that return type of called functions is WF:
-        self.register_wf_obligation(output.into(), call_expr.span, traits::MiscObligation);
+        self.register_wf_obligation(output.into(), call_expr.span, traits::WellFormed(None));
 
         output
     }
index f3341e72e7362d9741914116ae34485223f806a4..cf7de1dc016c802496dea65ecbfa3988180edd1f 100644 (file)
@@ -496,7 +496,7 @@ pub fn register_bound(
 
     pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
         let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
-        self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
+        self.register_wf_obligation(t.into(), ast_t.span, traits::WellFormed(None));
         t
     }
 
@@ -526,7 +526,7 @@ pub fn to_const(&self, ast_c: &hir::AnonConst) -> ty::Const<'tcx> {
         self.register_wf_obligation(
             c.into(),
             self.tcx.hir().span(ast_c.hir_id),
-            ObligationCauseCode::MiscObligation,
+            ObligationCauseCode::WellFormed(None),
         );
         c
     }
@@ -544,7 +544,7 @@ pub fn const_arg_to_const(
         self.register_wf_obligation(
             c.into(),
             self.tcx.hir().span(ast_c.hir_id),
-            ObligationCauseCode::MiscObligation,
+            ObligationCauseCode::WellFormed(None),
         );
         c
     }
@@ -607,7 +607,7 @@ pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr<'_>) {
         for arg in substs.iter().filter(|arg| {
             matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
         }) {
-            self.register_wf_obligation(arg, expr.span, traits::MiscObligation);
+            self.register_wf_obligation(arg, expr.span, traits::WellFormed(None));
         }
     }
 
index c2b4c478ba387456995ae14a866f75d7a1769845..887c791af76c2c08dc51722ba05e20006db6d7f8 100644 (file)
@@ -109,7 +109,7 @@ pub struct TrackedValueIndex {
 }
 
 /// Identifies a value whose drop state we need to track.
-#[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)]
+#[derive(PartialEq, Eq, Hash, Clone, Copy)]
 enum TrackedValue {
     /// Represents a named variable, such as a let binding, parameter, or upvar.
     ///
@@ -121,6 +121,21 @@ enum TrackedValue {
     Temporary(HirId),
 }
 
+impl Debug for TrackedValue {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        ty::tls::with_opt(|opt_tcx| {
+            if let Some(tcx) = opt_tcx {
+                write!(f, "{}", tcx.hir().node_to_string(self.hir_id()))
+            } else {
+                match self {
+                    Self::Variable(hir_id) => write!(f, "Variable({:?})", hir_id),
+                    Self::Temporary(hir_id) => write!(f, "Temporary({:?})", hir_id),
+                }
+            }
+        })
+    }
+}
+
 impl TrackedValue {
     fn hir_id(&self) -> HirId {
         match self {
@@ -148,7 +163,7 @@ enum TrackedValueConversionError {
     /// Place projects are not currently supported.
     ///
     /// The reasoning around these is kind of subtle, so we choose to be more
-    /// conservative around these for now. There is not reason in theory we
+    /// conservative around these for now. There is no reason in theory we
     /// cannot support these, we just have not implemented it yet.
     PlaceProjectionsNotSupported,
 }
index 365ff429243f1ed1b0b8b2a68e7d56b3e4a86622..111d534abf83bc9e1fee448df8c10bdbb4862dd0 100644 (file)
@@ -33,6 +33,9 @@ pub(super) fn build_control_flow_graph<'tcx>(
     intravisit::walk_body(&mut drop_range_visitor, body);
 
     drop_range_visitor.drop_ranges.process_deferred_edges();
+    if let Some(filename) = &tcx.sess.opts.debugging_opts.dump_drop_tracking_cfg {
+        super::cfg_visualize::write_graph_to_file(&drop_range_visitor.drop_ranges, filename, tcx);
+    }
 
     (drop_range_visitor.drop_ranges, drop_range_visitor.places.borrowed_temporaries)
 }
@@ -126,13 +129,14 @@ fn record_drop(&mut self, value: TrackedValue) {
     /// ExprUseVisitor's consume callback doesn't go deep enough for our purposes in all
     /// expressions. This method consumes a little deeper into the expression when needed.
     fn consume_expr(&mut self, expr: &hir::Expr<'_>) {
-        debug!("consuming expr {:?}, count={:?}", expr.hir_id, self.expr_index);
+        debug!("consuming expr {:?}, count={:?}", expr.kind, self.expr_index);
         let places = self
             .places
             .consumed
             .get(&expr.hir_id)
             .map_or(vec![], |places| places.iter().cloned().collect());
         for place in places {
+            trace!(?place, "consuming place");
             for_each_consumable(self.hir, place, |value| self.record_drop(value));
         }
     }
index 20aad7aedf77580e84e1f1e2a2caaa3dd0383fa6..c0a0bfe8e1c00a98cb53dd41b5d1e6e9bb7ba82c 100644 (file)
@@ -2,6 +2,7 @@
 //! flow graph when needed for debugging.
 
 use rustc_graphviz as dot;
+use rustc_middle::ty::TyCtxt;
 
 use super::{DropRangesBuilder, PostOrderId};
 
 ///
 /// It is not normally called, but is kept around to easily add debugging
 /// code when needed.
-#[allow(dead_code)]
-pub(super) fn write_graph_to_file(drop_ranges: &DropRangesBuilder, filename: &str) {
-    dot::render(drop_ranges, &mut std::fs::File::create(filename).unwrap()).unwrap();
+pub(super) fn write_graph_to_file(
+    drop_ranges: &DropRangesBuilder,
+    filename: &str,
+    tcx: TyCtxt<'_>,
+) {
+    dot::render(
+        &DropRangesGraph { drop_ranges, tcx },
+        &mut std::fs::File::create(filename).unwrap(),
+    )
+    .unwrap();
 }
 
-impl<'a> dot::GraphWalk<'a> for DropRangesBuilder {
+struct DropRangesGraph<'a, 'tcx> {
+    drop_ranges: &'a DropRangesBuilder,
+    tcx: TyCtxt<'tcx>,
+}
+
+impl<'a> dot::GraphWalk<'a> for DropRangesGraph<'_, '_> {
     type Node = PostOrderId;
 
     type Edge = (PostOrderId, PostOrderId);
 
     fn nodes(&'a self) -> dot::Nodes<'a, Self::Node> {
-        self.nodes.iter_enumerated().map(|(i, _)| i).collect()
+        self.drop_ranges.nodes.iter_enumerated().map(|(i, _)| i).collect()
     }
 
     fn edges(&'a self) -> dot::Edges<'a, Self::Edge> {
-        self.nodes
+        self.drop_ranges
+            .nodes
             .iter_enumerated()
             .flat_map(|(i, node)| {
                 if node.successors.len() == 0 {
@@ -45,7 +59,7 @@ fn target(&'a self, edge: &Self::Edge) -> Self::Node {
     }
 }
 
-impl<'a> dot::Labeller<'a> for DropRangesBuilder {
+impl<'a> dot::Labeller<'a> for DropRangesGraph<'_, '_> {
     type Node = PostOrderId;
 
     type Edge = (PostOrderId, PostOrderId);
@@ -61,15 +75,15 @@ fn node_id(&'a self, n: &Self::Node) -> dot::Id<'a> {
     fn node_label(&'a self, n: &Self::Node) -> dot::LabelText<'a> {
         dot::LabelText::LabelStr(
             format!(
-                "{:?}, local_id: {}",
-                n,
-                self.post_order_map
+                "{n:?}: {}",
+                self.drop_ranges
+                    .post_order_map
                     .iter()
                     .find(|(_hir_id, &post_order_id)| post_order_id == *n)
-                    .map_or("<unknown>".into(), |(hir_id, _)| format!(
-                        "{}",
-                        hir_id.local_id.index()
-                    ))
+                    .map_or("<unknown>".into(), |(hir_id, _)| self
+                        .tcx
+                        .hir()
+                        .node_to_string(*hir_id))
             )
             .into(),
         )
index b22b791f629d7485a685f589911feef4ff79ff07..67cc46f21f00b0dce7bd725a2ef6405ff56c6484 100644 (file)
@@ -75,6 +75,7 @@ fn mark_consumed(&mut self, consumer: HirId, target: TrackedValue) {
         if !self.places.consumed.contains_key(&consumer) {
             self.places.consumed.insert(consumer, <_>::default());
         }
+        debug!(?consumer, ?target, "mark_consumed");
         self.places.consumed.get_mut(&consumer).map(|places| places.insert(target));
     }
 
@@ -136,13 +137,16 @@ fn consume(
         place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>,
         diag_expr_id: HirId,
     ) {
-        let parent = match self.tcx.hir().find_parent_node(place_with_id.hir_id) {
+        let hir = self.tcx.hir();
+        let parent = match hir.find_parent_node(place_with_id.hir_id) {
             Some(parent) => parent,
             None => place_with_id.hir_id,
         };
         debug!(
-            "consume {:?}; diag_expr_id={:?}, using parent {:?}",
-            place_with_id, diag_expr_id, parent
+            "consume {:?}; diag_expr_id={}, using parent {}",
+            place_with_id,
+            hir.node_to_string(diag_expr_id),
+            hir.node_to_string(parent)
         );
         place_with_id
             .try_into()
index 4061b7cae7c78348384d8050d226ef85162ecbb5..d8cdc9275f4356a87ff4412ff5d177e1ff74f156 100644 (file)
@@ -501,7 +501,7 @@ fn add_obligations(
         // the function type must also be well-formed (this is not
         // implied by the substs being well-formed because of inherent
         // impls and late-bound regions - see issue #28609).
-        self.register_wf_obligation(fty.into(), self.span, traits::MiscObligation);
+        self.register_wf_obligation(fty.into(), self.span, traits::WellFormed(None));
     }
 
     ///////////////////////////////////////////////////////////////////////////
index 4e1a105fc71cc0a308e91f07f3e84eac146e2532..7bf167426f7480cd5badf1b06051ecc2e1d1455d 100644 (file)
@@ -348,9 +348,7 @@ pub fn report_method_error(
                         let type_param = generics.type_param(param_type, self.tcx);
                         Some(self.tcx.def_span(type_param.def_id))
                     }
-                    ty::Adt(def, _) if def.did().is_local() => {
-                        tcx.def_ident_span(def.did()).map(|span| span)
-                    }
+                    ty::Adt(def, _) if def.did().is_local() => Some(tcx.def_span(def.did())),
                     _ => None,
                 };
 
@@ -621,12 +619,12 @@ pub fn report_method_error(
                     // Find all the requirements that come from a local `impl` block.
                     let mut skip_list: FxHashSet<_> = Default::default();
                     let mut spanned_predicates: FxHashMap<MultiSpan, _> = Default::default();
-                    for (data, p, parent_p, impl_def_id, cause_span) in unsatisfied_predicates
+                    for (data, p, parent_p, impl_def_id, cause) in unsatisfied_predicates
                         .iter()
                         .filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c)))
                         .filter_map(|(p, parent, c)| match c.code() {
                             ObligationCauseCode::ImplDerivedObligation(ref data) => {
-                                Some((&data.derived, p, parent, data.impl_def_id, data.span))
+                                Some((&data.derived, p, parent, data.impl_def_id, data))
                             }
                             _ => None,
                         })
@@ -695,9 +693,9 @@ pub fn report_method_error(
                                     let _ = format_pred(*pred);
                                 }
                                 skip_list.insert(p);
-                                let mut spans = if cause_span != *item_span {
-                                    let mut spans: MultiSpan = cause_span.into();
-                                    spans.push_span_label(cause_span, unsatisfied_msg);
+                                let mut spans = if cause.span != *item_span {
+                                    let mut spans: MultiSpan = cause.span.into();
+                                    spans.push_span_label(cause.span, unsatisfied_msg);
                                     spans
                                 } else {
                                     ident.span.into()
@@ -709,7 +707,10 @@ pub fn report_method_error(
 
                             // Unmet obligation coming from an `impl`.
                             Some(Node::Item(hir::Item {
-                                kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }),
+                                kind:
+                                    hir::ItemKind::Impl(hir::Impl {
+                                        of_trait, self_ty, generics, ..
+                                    }),
                                 span: item_span,
                                 ..
                             })) if !matches!(
@@ -725,14 +726,40 @@ pub fn report_method_error(
                                 Some(ExpnKind::Macro(MacroKind::Derive, _))
                             ) =>
                             {
+                                let sized_pred =
+                                    unsatisfied_predicates.iter().any(|(pred, _, _)| {
+                                        match pred.kind().skip_binder() {
+                                            ty::PredicateKind::Trait(pred) => {
+                                                Some(pred.def_id())
+                                                    == self.tcx.lang_items().sized_trait()
+                                                    && pred.polarity == ty::ImplPolarity::Positive
+                                            }
+                                            _ => false,
+                                        }
+                                    });
+                                for param in generics.params {
+                                    if param.span == cause.span && sized_pred {
+                                        let (sp, sugg) = match param.colon_span {
+                                            Some(sp) => (sp.shrink_to_hi(), " ?Sized +"),
+                                            None => (param.span.shrink_to_hi(), ": ?Sized"),
+                                        };
+                                        err.span_suggestion_verbose(
+                                            sp,
+                                            "consider relaxing the type parameter's implicit \
+                                             `Sized` bound",
+                                            sugg,
+                                            Applicability::MachineApplicable,
+                                        );
+                                    }
+                                }
                                 if let Some(pred) = parent_p {
                                     // Done to add the "doesn't satisfy" `span_label`.
                                     let _ = format_pred(*pred);
                                 }
                                 skip_list.insert(p);
-                                let mut spans = if cause_span != *item_span {
-                                    let mut spans: MultiSpan = cause_span.into();
-                                    spans.push_span_label(cause_span, unsatisfied_msg);
+                                let mut spans = if cause.span != *item_span {
+                                    let mut spans: MultiSpan = cause.span.into();
+                                    spans.push_span_label(cause.span, unsatisfied_msg);
                                     spans
                                 } else {
                                     let mut spans = Vec::with_capacity(2);
index 87f85a9842f341909b32e35cef3e7306a5b1d9b8..74546ed90808559b47d4f09eb0ebc27825fb6063 100644 (file)
@@ -747,14 +747,13 @@ fn perform_2229_migration_anaysis(
             let (migration_string, migrated_variables_concat) =
                 migration_suggestion_for_2229(self.tcx, &need_migrations);
 
-            let local_def_id = closure_def_id.expect_local();
-            let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
-            let closure_span = self.tcx.hir().span(closure_hir_id);
-            let closure_head_span = self.tcx.sess.source_map().guess_head_span(closure_span);
+            let closure_hir_id =
+                self.tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local());
+            let closure_head_span = self.tcx.def_span(closure_def_id);
             self.tcx.struct_span_lint_hir(
                 lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
                 closure_hir_id,
-                 closure_head_span,
+                closure_head_span,
                 |lint| {
                     let mut diagnostics_builder = lint.build(
                         &reasons.migration_message(),
@@ -827,12 +826,13 @@ fn perform_2229_migration_anaysis(
                         migrated_variables_concat
                     );
 
+                    let closure_span = self.tcx.hir().span_with_body(closure_hir_id);
                     let mut closure_body_span = {
                         // If the body was entirely expanded from a macro
                         // invocation, i.e. the body is not contained inside the
                         // closure span, then we walk up the expansion until we
                         // find the span before the expansion.
-                        let s = self.tcx.hir().span(body_id.hir_id);
+                        let s = self.tcx.hir().span_with_body(body_id.hir_id);
                         s.find_ancestor_inside(closure_span).unwrap_or(s)
                     };
 
index 84a8cc431f4d7b5e7cdf1d193d1414c30361415a..f93f567fb2054587428512281db25006a51b830c 100644 (file)
@@ -1180,7 +1180,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo
             fcx.register_bound(
                 item_ty,
                 tcx.require_lang_item(LangItem::Sized, None),
-                traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
+                traits::ObligationCause::new(ty_span, fcx.body_id, traits::WellFormed(None)),
             );
         }
 
index a0cbb7c2c5ae50b35a8c5b485d914af9e023e01f..44b9c8392f86bfb64cf7aefe0d2ee2a6e6898c20 100644 (file)
@@ -59,7 +59,7 @@
 // Main entry point
 
 fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
-    tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
+    tcx.hir().visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
 }
 
 pub fn provide(providers: &mut Providers) {
index 4392b9aada9783d324e0b6f81a224b514fd24683..81108fe0a479fea98e6ec1f2255933a53f1bf960 100644 (file)
@@ -72,7 +72,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
                 let cause = traits::ObligationCause::new(
                     ty.span,
                     self.hir_id,
-                    traits::ObligationCauseCode::MiscObligation,
+                    traits::ObligationCauseCode::WellFormed(None),
                 );
                 fulfill.register_predicate_obligation(
                     &infcx,
index ad9e80e117f1e016c3c1588a7a15757eb9863f48..649b4338772226762f67194e650621463d1075f6 100644 (file)
@@ -13,8 +13,6 @@
 /// on all futures.
 ///
 /// ```no_run
-/// #![feature(into_future)]
-///
 /// use std::future::IntoFuture;
 ///
 /// # async fn foo() {
@@ -33,8 +31,6 @@
 /// multiple times before being `.await`ed.
 ///
 /// ```rust
-/// #![feature(into_future)]
-///
 /// use std::future::{ready, Ready, IntoFuture};
 ///
 /// /// Eventually multiply two numbers
@@ -91,8 +87,6 @@
 /// `IntoFuture::into_future` to obtain an instance of `Future`:
 ///
 /// ```rust
-/// #![feature(into_future)]
-///
 /// use std::future::IntoFuture;
 ///
 /// /// Convert the output of a future to a string.
 ///     format!("{:?}", fut.await)
 /// }
 /// ```
-#[unstable(feature = "into_future", issue = "67644")]
+#[stable(feature = "into_future", since = "1.64.0")]
 pub trait IntoFuture {
     /// The output that the future will produce on completion.
-    #[unstable(feature = "into_future", issue = "67644")]
+    #[stable(feature = "into_future", since = "1.64.0")]
     type Output;
 
     /// Which kind of future are we turning this into?
-    #[unstable(feature = "into_future", issue = "67644")]
+    #[stable(feature = "into_future", since = "1.64.0")]
     type IntoFuture: Future<Output = Self::Output>;
 
     /// Creates a future from a value.
@@ -121,8 +115,6 @@ pub trait IntoFuture {
     /// Basic usage:
     ///
     /// ```no_run
-    /// #![feature(into_future)]
-    ///
     /// use std::future::IntoFuture;
     ///
     /// # async fn foo() {
@@ -131,12 +123,12 @@ pub trait IntoFuture {
     /// assert_eq!("meow", fut.await);
     /// # }
     /// ```
-    #[unstable(feature = "into_future", issue = "67644")]
+    #[stable(feature = "into_future", since = "1.64.0")]
     #[lang = "into_future"]
     fn into_future(self) -> Self::IntoFuture;
 }
 
-#[unstable(feature = "into_future", issue = "67644")]
+#[stable(feature = "into_future", since = "1.64.0")]
 impl<F: Future> IntoFuture for F {
     type Output = F::Output;
     type IntoFuture = F;
index 9b89f766c67bf648779c63e1ddd4df8a555232dc..90eecb9d4a0003e0a9507e3b28d8592e2346f1cb 100644 (file)
@@ -29,7 +29,7 @@
 #[unstable(feature = "future_join", issue = "91642")]
 pub use self::join::join;
 
-#[unstable(feature = "into_future", issue = "67644")]
+#[stable(feature = "into_future", since = "1.64.0")]
 pub use into_future::IntoFuture;
 
 #[stable(feature = "future_readiness_fns", since = "1.48.0")]
index a6b75493e6e6000837853df23f5b9a396b46b0c3..073168cf2d2091620206638420286a77c37ab324 100644 (file)
@@ -234,3 +234,26 @@ fn main_thread_handle(&self) -> BorrowedHandle<'_> {
         self.handle.main_thread_handle()
     }
 }
+
+/// Windows-specific extensions to [`process::ExitCode`].
+///
+/// This trait is sealed: it cannot be implemented outside the standard library.
+/// This is so that future additional methods are not breaking changes.
+#[unstable(feature = "windows_process_exit_code_from", issue = "none")]
+pub trait ExitCodeExt: Sealed {
+    /// Creates a new `ExitCode` from the raw underlying `u32` return value of
+    /// a process.
+    ///
+    /// The exit code should not be 259, as this conflicts with the `STILL_ACTIVE`
+    /// macro returned from the `GetExitCodeProcess` function to signal that the
+    /// process has yet to run to completion.
+    #[unstable(feature = "windows_process_exit_code_from", issue = "none")]
+    fn from_raw(raw: u32) -> Self;
+}
+
+#[unstable(feature = "windows_process_exit_code_from", issue = "none")]
+impl ExitCodeExt for process::ExitCode {
+    fn from_raw(raw: u32) -> Self {
+        process::ExitCode::from_inner(From::from(raw))
+    }
+}
index ab1a1e6c76fa4566c02aea580114d673e64150d8..d6cba7e7598f682be946c0446fcbc42f67ce2186 100644 (file)
@@ -1724,6 +1724,10 @@ impl crate::error::Error for ExitStatusError {}
 #[stable(feature = "process_exitcode", since = "1.61.0")]
 pub struct ExitCode(imp::ExitCode);
 
+/// Allows extension traits within `std`.
+#[unstable(feature = "sealed", issue = "none")]
+impl crate::sealed::Sealed for ExitCode {}
+
 #[stable(feature = "process_exitcode", since = "1.61.0")]
 impl ExitCode {
     /// The canonical `ExitCode` for successful termination on this platform.
@@ -1814,6 +1818,18 @@ fn from(code: u8) -> Self {
     }
 }
 
+impl AsInner<imp::ExitCode> for ExitCode {
+    fn as_inner(&self) -> &imp::ExitCode {
+        &self.0
+    }
+}
+
+impl FromInner<imp::ExitCode> for ExitCode {
+    fn from_inner(s: imp::ExitCode) -> ExitCode {
+        ExitCode(s)
+    }
+}
+
 impl Child {
     /// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
     /// error is returned.
index 9fd399f4ba1d3193061af53e8e13dcb1484a76ef..02d5af4719ae8fda9b72311724ce67bf3cf0342a 100644 (file)
@@ -707,6 +707,12 @@ fn from(code: u8) -> Self {
     }
 }
 
+impl From<u32> for ExitCode {
+    fn from(code: u32) -> Self {
+        ExitCode(c::DWORD::from(code))
+    }
+}
+
 fn zeroed_startupinfo() -> c::STARTUPINFO {
     c::STARTUPINFO {
         cb: 0,
index dc6a0f6f241462e3519118f6caf7ffe71b6a9e1b..fa6a5ee1668f8edf229af72c600e19cd35b03472 100644 (file)
@@ -346,11 +346,7 @@ fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) {
             eprintln!(
                 "note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`"
             );
-            #[cfg(not(test))]
-            std::process::exit(1);
-            #[cfg(test)]
-            // so we can use #[should_panic]
-            panic!()
+            crate::detail_exit(1);
         }
     }
 }
@@ -953,6 +949,7 @@ pub(crate) fn fix_bin_or_dylib(&self, fname: &Path) {
     }
 
     pub(crate) fn download_component(&self, url: &str, dest_path: &Path, help_on_error: &str) {
+        self.verbose(&format!("download {url}"));
         // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
         let tempfile = self.tempdir().join(dest_path.file_name().unwrap());
         // While bootstrap itself only supports http and https downloads, downstream forks might
@@ -1008,7 +1005,7 @@ fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error:
             if !help_on_error.is_empty() {
                 eprintln!("{}", help_on_error);
             }
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
     }
 
@@ -1437,7 +1434,7 @@ pub fn cargo(
                         "error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component"
                     );
                     eprintln!("help: try `rustup component add clippy`");
-                    std::process::exit(1);
+                    crate::detail_exit(1);
                 });
                 if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") {
                     rustflags.arg("--cfg=bootstrap");
index 399be26d5ac14e808a817ee7cc6c29b6adbd1794..ed5023ac61b0fdbf57923680cc21fa061ddbdd1e 100644 (file)
@@ -13,7 +13,7 @@
 use std::io::prelude::*;
 use std::io::BufReader;
 use std::path::{Path, PathBuf};
-use std::process::{exit, Command, Stdio};
+use std::process::{Command, Stdio};
 use std::str;
 
 use serde::Deserialize;
@@ -1377,7 +1377,7 @@ pub fn run_cargo(
     });
 
     if !ok {
-        exit(1);
+        crate::detail_exit(1);
     }
 
     // Ok now we need to actually find all the files listed in `toplevel`. We've
index 2fc18c9e79e32adb782c70b05e46327bcb446a34..ee3b072fe35f2944cf35938a7379973e9f012292 100644 (file)
@@ -11,7 +11,7 @@
 use std::fmt;
 use std::fs;
 use std::path::{Path, PathBuf};
-use std::process::{exit, Command};
+use std::process::Command;
 use std::str::FromStr;
 
 use crate::builder::{Builder, TaskPath};
@@ -805,8 +805,6 @@ pub fn parse(args: &[String]) -> Config {
         let get_toml = |_| TomlConfig::default();
         #[cfg(not(test))]
         let get_toml = |file: &Path| {
-            use std::process;
-
             let contents =
                 t!(fs::read_to_string(file), format!("config file {} not found", file.display()));
             // Deserialize to Value and then TomlConfig to prevent the Deserialize impl of
@@ -817,7 +815,7 @@ pub fn parse(args: &[String]) -> Config {
                 Ok(table) => table,
                 Err(err) => {
                     eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err);
-                    process::exit(2);
+                    crate::detail_exit(2);
                 }
             }
         };
@@ -1487,7 +1485,7 @@ fn download_ci_rustc_commit(
         println!("help: maybe your repository history is too shallow?");
         println!("help: consider disabling `download-rustc`");
         println!("help: or fetch enough history to include one upstream commit");
-        exit(1);
+        crate::detail_exit(1);
     }
 
     // Warn if there were changes to the compiler or standard library since the ancestor commit.
@@ -1560,7 +1558,7 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
         builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));
         builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustdoc"));
         let lib_dir = bin_root.join("lib");
-        for lib in t!(fs::read_dir(lib_dir)) {
+        for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
             let lib = t!(lib);
             if lib.path().extension() == Some(OsStr::new("so")) {
                 builder.fix_bin_or_dylib(&lib.path());
@@ -1636,6 +1634,7 @@ fn download_component(
         }
         Some(sha256)
     } else if tarball.exists() {
+        builder.unpack(&tarball, &bin_root, prefix);
         return;
     } else {
         None
index 7ebae55efc168010bae2e8f4d0620fe03f63076d..eec19ab4fc90f3e8eaeef10e371a725921ec61e6 100644 (file)
@@ -4,7 +4,6 @@
 //! has various flags to configure how it's run.
 
 use std::path::PathBuf;
-use std::process;
 
 use getopts::Options;
 
@@ -261,7 +260,7 @@ pub fn parse(args: &[String]) -> Flags {
                 // subcommand.
                 println!("{}\n", subcommand_help);
                 let exit_code = if args.is_empty() { 0 } else { 1 };
-                process::exit(exit_code);
+                crate::detail_exit(exit_code);
             }
         };
 
@@ -347,7 +346,7 @@ pub fn parse(args: &[String]) -> Flags {
             } else if verbose {
                 panic!("No paths available for subcommand `{}`", subcommand.as_str());
             }
-            process::exit(exit_code);
+            crate::detail_exit(exit_code);
         };
 
         // Done specifying what options are possible, so do the getopts parsing
@@ -379,7 +378,7 @@ pub fn parse(args: &[String]) -> Flags {
                 "Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
                  You may need to move some options to after the subcommand.\n"
             );
-            process::exit(1);
+            crate::detail_exit(1);
         }
         // Extra help text for some commands
         match subcommand {
@@ -600,7 +599,7 @@ pub fn parse(args: &[String]) -> Flags {
                         eprintln!("error: {}", err);
                         eprintln!("help: the available profiles are:");
                         eprint!("{}", Profile::all_for_help("- "));
-                        std::process::exit(1);
+                        crate::detail_exit(1);
                     })
                 } else {
                     t!(crate::setup::interactive_path())
@@ -614,7 +613,7 @@ pub fn parse(args: &[String]) -> Flags {
                 || matches.opt_str("keep-stage-std").is_some()
             {
                 eprintln!("--keep-stage not yet supported for x.py check");
-                process::exit(1);
+                crate::detail_exit(1);
             }
         }
 
@@ -805,7 +804,7 @@ fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
         Some("warn") => Some(false),
         Some(value) => {
             eprintln!(r#"invalid value for --warnings: {:?}, expected "warn" or "deny""#, value,);
-            process::exit(1);
+            crate::detail_exit(1);
         }
         None => None,
     }
index 60a53c28686b0b06cc2eb16646d6dc94b449965f..f25977c1d4636bfe4d073b858cce5849bd7c39eb 100644 (file)
@@ -32,7 +32,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
                         code, run `./x.py fmt` instead.",
                 cmd_debug,
             );
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
     }
 }
@@ -114,7 +114,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
 
     let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| {
         eprintln!("./x.py fmt is not supported on this channel");
-        std::process::exit(1);
+        crate::detail_exit(1);
     });
     assert!(rustfmt_path.exists(), "{}", rustfmt_path.display());
     let src = build.src.clone();
index 73bd588472df0f1ed5d78ea90ec2789f2dd34704..82025efcbe0e5f599ff959b8643cd889cc15b19e 100644 (file)
 use std::fs::{self, File};
 use std::io;
 use std::path::{Path, PathBuf};
-use std::process::{self, Command};
+use std::process::Command;
 use std::str;
 
 use filetime::FileTime;
@@ -711,7 +711,7 @@ pub fn build(&mut self) {
             for failure in failures.iter() {
                 eprintln!("  - {}\n", failure);
             }
-            process::exit(1);
+            detail_exit(1);
         }
 
         #[cfg(feature = "build-metrics")]
@@ -1617,7 +1617,7 @@ fn ninja(&self) -> bool {
 to download LLVM rather than building it.
 "
                 );
-                std::process::exit(1);
+                detail_exit(1);
             }
         }
 
@@ -1646,6 +1646,20 @@ fn chmod(path: &Path, perms: u32) {
 #[cfg(windows)]
 fn chmod(_path: &Path, _perms: u32) {}
 
+/// If code is not 0 (successful exit status), exit status is 101 (rust's default error code.)
+/// If the test is running and code is an error code, it will cause a panic.
+fn detail_exit(code: i32) -> ! {
+    // Successful exit
+    if code == 0 {
+        std::process::exit(0);
+    }
+    if cfg!(test) {
+        panic!("status code: {}", code);
+    } else {
+        std::panic::resume_unwind(Box::new(code));
+    }
+}
+
 impl Compiler {
     pub fn with_stage(mut self, stage: u32) -> Compiler {
         self.stage = stage;
index 64c5dd7aea7202ef50a4ba49cc3738c6727c7f16..cae41286f0871168f482844e570fc78e25455e6d 100644 (file)
@@ -104,7 +104,7 @@ pub fn check(build: &mut Build) {
 than building it.
 "
             );
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
     }
 
index 82f55440ce50c4e6f55f586e9f11e360d440812c..740c12ed725e1ee8e61d54b766e04da9a7c97fd1 100644 (file)
@@ -94,7 +94,7 @@ pub fn setup(config: &Config, profile: Profile) {
             "note: this will use the configuration in {}",
             profile.include_path(&config.src).display()
         );
-        std::process::exit(1);
+        crate::detail_exit(1);
     }
 
     let settings = format!(
@@ -287,7 +287,7 @@ fn parse_with_abbrev(input: &str) -> Result<Profile, String> {
         io::stdin().read_line(&mut input)?;
         if input.is_empty() {
             eprintln!("EOF on stdin, when expecting answer to question.  Giving up.");
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
         break match parse_with_abbrev(&input) {
             Ok(profile) => profile,
index 6be3da552919d734100af0f56a44357b022073a2..4c6b5ba0afc085c16761a2f56691eaa047a24ed8 100644 (file)
@@ -673,7 +673,7 @@ fn run(self, builder: &Builder<'_>) {
         }
 
         if !builder.config.cmd.bless() {
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
 
         let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
@@ -1021,7 +1021,7 @@ fn run(self, builder: &Builder<'_>) {
                     PATH = inferred_rustfmt_dir.display(),
                     CHAN = builder.config.channel,
                 );
-                std::process::exit(1);
+                crate::detail_exit(1);
             }
             crate::format::format(&builder, !builder.config.cmd.bless(), &[]);
         }
@@ -1251,7 +1251,7 @@ fn run(self, builder: &Builder<'_>) {
 help: to test the standard library, use `--stage 0 library/std` instead
 note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
             );
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
 
         let compiler = self.compiler;
index 74a793d257e22c6ae24b247b04ec4657a6b3f92f..23832b6c43e4216db4f5605080fedbf5515fae8f 100644 (file)
@@ -2,7 +2,7 @@
 use std::env;
 use std::fs;
 use std::path::{Path, PathBuf};
-use std::process::{exit, Command};
+use std::process::Command;
 
 use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
 use crate::channel::GitInfo;
@@ -204,7 +204,7 @@ fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
 
         if !is_expected {
             if !is_optional_tool {
-                exit(1);
+                crate::detail_exit(1);
             } else {
                 None
             }
index 3ee6a42d987a05385ee1f9156ea86e36ae668384..2cfeae7dc785852cf344d7772a6ffdc8be650e59 100644 (file)
@@ -93,7 +93,7 @@ fn print_error(tool: &str, submodule: &str) {
     eprintln!("If you do NOT intend to update '{}', please ensure you did not accidentally", tool);
     eprintln!("change the submodule at '{}'. You may ask your reviewer for the", submodule);
     eprintln!("proper steps.");
-    std::process::exit(3);
+    crate::detail_exit(3);
 }
 
 fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
@@ -108,7 +108,7 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
         Ok(o) => o,
         Err(e) => {
             eprintln!("Failed to get changed files: {:?}", e);
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
     };
 
@@ -179,7 +179,7 @@ fn run(self, builder: &Builder<'_>) {
         }
 
         if did_error {
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
 
         check_changed_files(&toolstates);
@@ -225,7 +225,7 @@ fn run(self, builder: &Builder<'_>) {
         }
 
         if did_error {
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
 
         if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {
index 6f4266a7f294e0febd5c18301282dd5bb3ebb01b..b627e50378994b1dbe64d6fedc4cfe3b076406d1 100644 (file)
@@ -336,7 +336,7 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
 
 pub fn run(cmd: &mut Command, print_cmd_on_fail: bool) {
     if !try_run(cmd, print_cmd_on_fail) {
-        std::process::exit(1);
+        crate::detail_exit(1);
     }
 }
 
@@ -375,7 +375,7 @@ pub fn check_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
 
 pub fn run_suppressed(cmd: &mut Command) {
     if !try_run_suppressed(cmd) {
-        std::process::exit(1);
+        crate::detail_exit(1);
     }
 }
 
@@ -465,7 +465,7 @@ fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
 
 fn fail(s: &str) -> ! {
     eprintln!("\n\n{}\n\n", s);
-    std::process::exit(1);
+    crate::detail_exit(1);
 }
 
 /// Copied from `std::path::absolute` until it stabilizes.
index 7ec6eb0be652744ed614ae105ed71857a785d409..272188f82994c05f2579490d89f6e9d15cafeb9e 100644 (file)
@@ -73,6 +73,8 @@ pub(crate) struct Options {
     pub(crate) proc_macro_crate: bool,
     /// How to format errors and warnings.
     pub(crate) error_format: ErrorOutputType,
+    /// Width of output buffer to truncate errors appropriately.
+    pub(crate) diagnostic_width: Option<usize>,
     /// Library search paths to hand to the compiler.
     pub(crate) libs: Vec<SearchPath>,
     /// Library search paths strings to hand to the compiler.
@@ -331,11 +333,12 @@ pub(crate) fn from_matches(
         let config::JsonConfig { json_rendered, json_unused_externs, .. } =
             config::parse_json(matches);
         let error_format = config::parse_error_format(matches, color, json_rendered);
+        let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_default();
 
         let codegen_options = CodegenOptions::build(matches, error_format);
         let debugging_opts = DebuggingOptions::build(matches, error_format);
 
-        let diag = new_handler(error_format, None, &debugging_opts);
+        let diag = new_handler(error_format, None, diagnostic_width, &debugging_opts);
 
         // check for deprecated options
         check_deprecated_options(matches, &diag);
@@ -699,6 +702,7 @@ fn println_condition(condition: Condition) {
             input,
             proc_macro_crate,
             error_format,
+            diagnostic_width,
             libs,
             lib_strs,
             externs,
index 51b245e36ba3b20de83143aa20344fc511b22a15..8c494ee28cc1f404963da09a9a58ac9e79b2e3e1 100644 (file)
@@ -154,6 +154,7 @@ pub(crate) fn with_all_trait_impls(&mut self, f: impl FnOnce(&mut Self, &[DefId]
 pub(crate) fn new_handler(
     error_format: ErrorOutputType,
     source_map: Option<Lrc<source_map::SourceMap>>,
+    diagnostic_width: Option<usize>,
     debugging_opts: &DebuggingOptions,
 ) -> rustc_errors::Handler {
     let fallback_bundle =
@@ -169,7 +170,7 @@ pub(crate) fn new_handler(
                     fallback_bundle,
                     short,
                     debugging_opts.teach,
-                    debugging_opts.terminal_width,
+                    diagnostic_width,
                     false,
                 )
                 .ui_testing(debugging_opts.ui_testing),
@@ -187,7 +188,7 @@ pub(crate) fn new_handler(
                     fallback_bundle,
                     pretty,
                     json_rendered,
-                    debugging_opts.terminal_width,
+                    diagnostic_width,
                     false,
                 )
                 .ui_testing(debugging_opts.ui_testing),
@@ -208,6 +209,7 @@ pub(crate) fn create_config(
         crate_name,
         proc_macro_crate,
         error_format,
+        diagnostic_width,
         libs,
         externs,
         mut cfgs,
@@ -266,6 +268,7 @@ pub(crate) fn create_config(
         actually_rustdoc: true,
         debugging_opts,
         error_format,
+        diagnostic_width,
         edition,
         describe_lints,
         crate_name,
index 0982c4b3acec868cf1cfc1d30272db46649daf14..84ab8d988bdb43303d595c587dac0bc86e8e1c24 100644 (file)
@@ -268,6 +268,12 @@ pub(crate) fn print<'a, 'tcx: 'a>(
     }
 }
 
+#[derive(Clone, Copy, PartialEq, Eq)]
+pub(crate) enum Ending {
+    Newline,
+    NoNewline,
+}
+
 /// * The Generics from which to emit a where-clause.
 /// * The number of spaces to indent each line with.
 /// * Whether the where-clause needs to add a comma and newline after the last bound.
@@ -275,7 +281,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
     gens: &'a clean::Generics,
     cx: &'a Context<'tcx>,
     indent: usize,
-    end_newline: bool,
+    ending: Ending,
 ) -> impl fmt::Display + 'a + Captures<'tcx> {
     use fmt::Write;
 
@@ -342,7 +348,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
 
         let where_preds = comma_sep(where_predicates, false);
         let clause = if f.alternate() {
-            if end_newline {
+            if ending == Ending::Newline {
                 // add a space so stripping <br> tags and breaking spaces still renders properly
                 format!(" where{where_preds}, ")
             } else {
@@ -356,7 +362,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
             }
             let where_preds = where_preds.to_string().replace("<br>", &br_with_padding);
 
-            if end_newline {
+            if ending == Ending::Newline {
                 let mut clause = "&nbsp;".repeat(indent.saturating_sub(1));
                 // add a space so stripping <br> tags and breaking spaces still renders properly
                 write!(
@@ -1167,7 +1173,7 @@ pub(crate) fn print<'a, 'tcx: 'a>(
                 fmt_type(&self.for_, f, use_absolute, cx)?;
             }
 
-            fmt::Display::fmt(&print_where_clause(&self.generics, cx, 0, true), f)?;
+            fmt::Display::fmt(&print_where_clause(&self.generics, cx, 0, Ending::Newline), f)?;
             Ok(())
         })
     }
index 796bd7715180cf1675c5c6d7b0f320f052024fa6..459b0fed6e872ddb34bace7d1fa30b2646dbaeb5 100644 (file)
@@ -70,7 +70,7 @@
 use crate::html::escape::Escape;
 use crate::html::format::{
     href, join_with_double_colon, print_abi_with_space, print_constness_with_space,
-    print_default_space, print_generic_bounds, print_where_clause, Buffer, HrefError,
+    print_default_space, print_generic_bounds, print_where_clause, Buffer, Ending, HrefError,
     PrintWithSpace,
 };
 use crate::html::highlight;
@@ -747,7 +747,7 @@ fn assoc_type(
     if !bounds.is_empty() {
         write!(w, ": {}", print_generic_bounds(bounds, cx))
     }
-    write!(w, "{}", print_where_clause(generics, cx, indent, false));
+    write!(w, "{}", print_where_clause(generics, cx, indent, Ending::NoNewline));
     if let Some(default) = default {
         write!(w, " = {}", default.print(cx))
     }
@@ -796,10 +796,10 @@ fn assoc_method(
         header_len += 4;
         let indent_str = "    ";
         render_attributes_in_pre(w, meth, indent_str);
-        (4, indent_str, false)
+        (4, indent_str, Ending::NoNewline)
     } else {
         render_attributes_in_code(w, meth);
-        (0, "", true)
+        (0, "", Ending::Newline)
     };
     w.reserve(header_len + "<a href=\"\" class=\"fnname\">{".len() + "</a>".len());
     write!(
index 86ee8e7acf6381476592964eef11dd88ccf1af72..daacc57a55a3ad5d925d9a1ba43ab7d7830a76b5 100644 (file)
@@ -29,7 +29,7 @@
 use crate::html::escape::Escape;
 use crate::html::format::{
     join_with_double_colon, print_abi_with_space, print_constness_with_space, print_where_clause,
-    Buffer, PrintWithSpace,
+    Buffer, Ending, PrintWithSpace,
 };
 use crate::html::highlight;
 use crate::html::layout::Page;
@@ -69,7 +69,7 @@ fn print_where_clause_and_check<'a, 'tcx: 'a>(
     cx: &'a Context<'tcx>,
 ) -> bool {
     let len_before = buffer.len();
-    write!(buffer, "{}", print_where_clause(gens, cx, 0, true));
+    write!(buffer, "{}", print_where_clause(gens, cx, 0, Ending::Newline));
     len_before != buffer.len()
 }
 
@@ -519,7 +519,7 @@ fn item_function(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, f: &cle
                 abi = abi,
                 name = name,
                 generics = f.generics.print(cx),
-                where_clause = print_where_clause(&f.generics, cx, 0, true),
+                where_clause = print_where_clause(&f.generics, cx, 0, Ending::Newline),
                 decl = f.decl.full_print(header_len, 0, header.asyncness, cx),
                 notable_traits = notable_traits_decl(&f.decl, cx),
             );
@@ -556,7 +556,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
             );
 
             if !t.generics.where_predicates.is_empty() {
-                write!(w, "{}", print_where_clause(&t.generics, cx, 0, true));
+                write!(w, "{}", print_where_clause(&t.generics, cx, 0, Ending::Newline));
             } else {
                 w.write_str(" ");
             }
@@ -1025,7 +1025,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &
                 "trait {}{}{} = {};",
                 it.name.unwrap(),
                 t.generics.print(cx),
-                print_where_clause(&t.generics, cx, 0, true),
+                print_where_clause(&t.generics, cx, 0, Ending::Newline),
                 bounds(&t.bounds, true, cx)
             );
         });
@@ -1049,7 +1049,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &cl
                 "type {}{}{where_clause} = impl {bounds};",
                 it.name.unwrap(),
                 t.generics.print(cx),
-                where_clause = print_where_clause(&t.generics, cx, 0, true),
+                where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
                 bounds = bounds(&t.bounds, false, cx),
             );
         });
@@ -1074,7 +1074,7 @@ fn write_content(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::
                 "type {}{}{where_clause} = {type_};",
                 it.name.unwrap(),
                 t.generics.print(cx),
-                where_clause = print_where_clause(&t.generics, cx, 0, true),
+                where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
                 type_ = t.type_.print(cx),
             );
         });
@@ -1784,7 +1784,7 @@ fn render_struct(
             }
             w.write_str(")");
             if let Some(g) = g {
-                write!(w, "{}", print_where_clause(g, cx, 0, false));
+                write!(w, "{}", print_where_clause(g, cx, 0, Ending::NoNewline));
             }
             // We only want a ";" when we are displaying a tuple struct, not a variant tuple struct.
             if structhead {
@@ -1794,7 +1794,7 @@ fn render_struct(
         CtorKind::Const => {
             // Needed for PhantomData.
             if let Some(g) = g {
-                write!(w, "{}", print_where_clause(g, cx, 0, false));
+                write!(w, "{}", print_where_clause(g, cx, 0, Ending::NoNewline));
             }
             w.write_str(";");
         }
index ded3d9951bd35d3a461b0d49e9076cbb3d4346f8..0d3ec7ecb6448052f90987cb3517c9f90c5f9971 100644 (file)
@@ -462,6 +462,14 @@ fn opts() -> Vec<RustcOptGroup> {
                 "human|json|short",
             )
         }),
+        unstable("diagnostic-width", |o| {
+            o.optopt(
+                "",
+                "diagnostic-width",
+                "Provide width of the output for truncated error messages",
+                "WIDTH",
+            )
+        }),
         stable("json", |o| {
             o.optopt("", "json", "Configure the structure of JSON diagnostics", "CONFIG")
         }),
@@ -733,7 +741,12 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
 }
 
 fn main_options(options: config::Options) -> MainResult {
-    let diag = core::new_handler(options.error_format, None, &options.debugging_opts);
+    let diag = core::new_handler(
+        options.error_format,
+        None,
+        options.diagnostic_width,
+        &options.debugging_opts,
+    );
 
     match (options.should_test, options.markdown_input()) {
         (true, true) => return wrap_return(&diag, markdown::test(options)),
index 8bf0971ccb5a566643eb30c30bfbb5cabbc3edd4..0172ef5700b62f480354682cac21b9df3353871d 100644 (file)
@@ -53,7 +53,8 @@ fn check_rust_syntax(&self, item: &clean::Item, dox: &str, code_block: RustCodeB
             None,
             None,
         );
-        let expn_id = LocalExpnId::fresh(expn_data, self.cx.tcx.create_stable_hashing_context());
+        let expn_id =
+            self.cx.tcx.with_stable_hashing_context(|hcx| LocalExpnId::fresh(expn_data, hcx));
         let span = DUMMY_SP.fresh_expansion(expn_id);
 
         let is_empty = rustc_driver::catch_fatal_errors(|| {
index f6c599297fcd679c2ffbea6b86c1d23b4ecf745c..c0fe8b49cfd1ba1357f9b989b98aafb9259b18fb 100644 (file)
@@ -303,7 +303,7 @@ pub(crate) fn run(
         // Run call-finder on all items
         let mut calls = FxHashMap::default();
         let mut finder = FindCalls { calls: &mut calls, tcx, map: tcx.hir(), cx, target_crates };
-        tcx.hir().deep_visit_all_item_likes(&mut finder);
+        tcx.hir().visit_all_item_likes_in_crate(&mut finder);
 
         // Sort call locations within a given file in document order
         for fn_calls in calls.values_mut() {
index c97223879ca3ab4c806918dfd8b51fc2adb3838a..260d9de867087696af0675fb36d1dab22c2aa68c 100644 (file)
@@ -10,7 +10,7 @@
 // CHECK: @STATIC = {{.*}}, align 4
 
 // This checks the constants from inline_enum_const
-// CHECK: @alloc14 = {{.*}}, align 2
+// CHECK: @alloc12 = {{.*}}, align 2
 
 // This checks the constants from {low,high}_align_const, they share the same
 // constant, but the alignment differs, so the higher one should be used
index 74b1eb948b0f77f07a341260aa7687473107fbea..033da80be16cc00fe0042634723110281aa1ffee 100644 (file)
@@ -27,11 +27,11 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: )
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant1", scope: [[GEN]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: )
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant2", scope: [[GEN]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: )
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant3", scope: [[GEN]],
index 3ec860f2cbc0681370b27d30788be1699d2fe1af..9c9f5518b6649dafbc0d2794c3af6cc166b071b8 100644 (file)
@@ -33,11 +33,11 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: )
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: )
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: )
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]],
index 84ccf25ef750e1e5adc0c95660156618578925e5..c78c345dec224e70a4a3938e78d3b7f7c964e715 100644 (file)
     },
 } */
 
-fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 13:6]) -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
-    let mut _2: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 10:17]) -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+    let mut _2: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     let _3: std::string::String;         // in scope 0 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
     let _4: ();                          // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
     let mut _5: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
     let mut _6: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:10:18: 10:18
-    let mut _7: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
-    let mut _8: u32;                     // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+    let mut _7: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+    let mut _8: u32;                     // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     scope 1 {
         debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
     }
 
     bb0: {
-        _8 = discriminant((*_1));        // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
-        switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        _8 = discriminant((*_1));        // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+        switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb1: {
@@ -44,11 +44,11 @@ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 1
     }
 
     bb3: {
-        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb4 (cleanup): {
-        resume;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        resume;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb5 (cleanup): {
@@ -57,11 +57,11 @@ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 1
     }
 
     bb6: {
-        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb7: {
-        goto -> bb9;                     // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        goto -> bb9;                     // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb8: {
@@ -69,16 +69,16 @@ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 1
     }
 
     bb9: {
-        goto -> bb6;                     // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        goto -> bb6;                     // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb10: {
-        StorageLive(_4);                 // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
-        StorageLive(_5);                 // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
-        goto -> bb1;                     // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        StorageLive(_4);                 // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+        StorageLive(_5);                 // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+        goto -> bb1;                     // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 
     bb11: {
-        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
     }
 }
index 739492d7d249f0ee48be466807c70d2608945203..9abb0cf2046bdeca53e89bc610bcfd9ffa7ed6be 100644 (file)
@@ -1,6 +1,6 @@
 // MIR for `main::{closure#0}` before StateTransform
 
-fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 28:6], _2: ()) -> ()
+fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 22:18], _2: ()) -> ()
 yields ()
  {
     let mut _0: ();                      // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 22:19
@@ -66,7 +66,7 @@ yields ()
     }
 
     bb4: {
-        return;                          // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:6: 28:6
+        return;                          // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:18: 22:18
     }
 
     bb5: {
@@ -82,7 +82,7 @@ yields ()
     }
 
     bb7: {
-        generator_drop;                  // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6
+        generator_drop;                  // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 22:18
     }
 
     bb8 (cleanup): {
@@ -104,7 +104,7 @@ yields ()
     }
 
     bb11 (cleanup): {
-        resume;                          // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6
+        resume;                          // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 22:18
     }
 
     bb12 (cleanup): {
index 7f5ebe2a59b55a24151860fdcc3d43dec709d014..ce587433617f5a98a3cd1e6b50214a8049cb907f 100644 (file)
     },
 } */
 
-fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]>, _2: u8) -> GeneratorState<(), ()> {
+fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> {
     debug _x => _10;                     // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
-    let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+    let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
     let _3: HasDrop;                     // in scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
     let mut _4: !;                       // in scope 0 at $DIR/generator-tiny.rs:21:9: 24:10
-    let mut _5: ();                      // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+    let mut _5: ();                      // in scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
     let _6: u8;                          // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:18
     let mut _7: ();                      // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:18
     let _8: ();                          // in scope 0 at $DIR/generator-tiny.rs:23:13: 23:21
     let mut _9: ();                      // in scope 0 at $DIR/generator-tiny.rs:19:25: 19:25
     let _10: u8;                         // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
-    let mut _11: u32;                    // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+    let mut _11: u32;                    // in scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
     scope 1 {
-        debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
+        debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
     }
 
     bb0: {
-        _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]))); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
-        switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+        _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+        switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
     }
 
     bb1: {
-        _10 = move _2;                   // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+        _10 = move _2;                   // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
         nop;                             // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
-        Deinit((((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6])) as variant#3).0: HasDrop)); // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25
+        Deinit((((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop)); // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25
         StorageLive(_4);                 // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
         goto -> bb2;                     // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
     }
@@ -50,7 +50,7 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]
         Deinit(_0);                      // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
         ((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
         discriminant(_0) = 0;            // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
-        discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
+        discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
         return;                          // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
     }
 
@@ -71,14 +71,14 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]
     }
 
     bb5: {
-        StorageLive(_4);                 // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
-        StorageLive(_6);                 // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
-        StorageLive(_7);                 // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
-        _6 = move _2;                    // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
-        goto -> bb3;                     // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+        StorageLive(_4);                 // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+        StorageLive(_6);                 // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+        StorageLive(_7);                 // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+        _6 = move _2;                    // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+        goto -> bb3;                     // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
     }
 
     bb6: {
-        unreachable;                     // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+        unreachable;                     // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
     }
 }
index c6b49b66dc5c0b7174745308dacf36ef92d0002b..fc8118d475adf761c617fab3e2fc99851d565ae1 100644 (file)
@@ -19,8 +19,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
             debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18
             let mut _10: i32;            // in scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
             let mut _11: T;              // in scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23
-            let mut _12: &i32;           // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:24
-            let mut _13: &T;             // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:24
+            let mut _12: &i32;           // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:17
+            let mut _13: &T;             // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:17
         }
     }
 
@@ -33,8 +33,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
         Deinit(_3);                      // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
         (_3.0: &i32) = move _4;          // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
         (_3.1: &T) = move _5;            // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
-        StorageDead(_5);                 // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
-        StorageDead(_4);                 // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
+        StorageDead(_5);                 // scope 0 at $DIR/inline-closure-captures.rs:11:16: 11:17
+        StorageDead(_4);                 // scope 0 at $DIR/inline-closure-captures.rs:11:16: 11:17
         StorageLive(_6);                 // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
         _6 = &_3;                        // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
         StorageLive(_7);                 // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
index 3e1c4a4670143e3f0da0c595ad4cc8291942f8a0..51994323c457f146b6a79fb2bb9609dfa5393775 100644 (file)
@@ -4,22 +4,22 @@
   fn main() -> () {
       let mut _0: ();                      // return place in scope 0 at $DIR/inline-generator.rs:8:11: 8:11
       let _1: std::ops::GeneratorState<i32, bool>; // in scope 0 at $DIR/inline-generator.rs:9:9: 9:11
-      let mut _2: std::pin::Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:32
-      let mut _3: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 0 at $DIR/inline-generator.rs:9:23: 9:31
-      let mut _4: [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 0 at $DIR/inline-generator.rs:9:28: 9:31
+      let mut _2: std::pin::Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:32
+      let mut _3: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline-generator.rs:9:23: 9:31
+      let mut _4: [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline-generator.rs:9:28: 9:31
 +     let mut _7: bool;                    // in scope 0 at $DIR/inline-generator.rs:9:14: 9:46
       scope 1 {
           debug _r => _1;                  // in scope 1 at $DIR/inline-generator.rs:9:9: 9:11
       }
 +     scope 2 (inlined g) {                // at $DIR/inline-generator.rs:9:28: 9:31
 +     }
-+     scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
++     scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
 +         debug pointer => _3;             // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
-+         let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
++         let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         scope 4 {
-+             scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL
++             scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL
 +                 debug pointer => _5;     // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
-+                 let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
++                 let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +             }
 +         }
 +     }
 +         let mut _9: bool;                // in scope 6 at $DIR/inline-generator.rs:15:20: 15:21
 +         let mut _10: bool;               // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9
 +         let _11: bool;                   // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7
-+         let mut _12: u32;                // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         let mut _12: u32;                // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
 +     }
   
       bb0: {
 +         Deinit(_4);                      // scope 2 at $DIR/inline-generator.rs:15:5: 15:41
 +         discriminant(_4) = 0;            // scope 2 at $DIR/inline-generator.rs:15:5: 15:41
           _3 = &mut _4;                    // scope 0 at $DIR/inline-generator.rs:9:23: 9:31
--         _2 = Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:32
+-         _2 = Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:32
 -                                          // mir::Constant
 -                                          // + span: $DIR/inline-generator.rs:9:14: 9:22
 -                                          // + user_ty: UserType(0)
--                                          // + literal: Const { ty: fn(&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) -> Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]> {Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new}, val: Value(Scalar(<ZST>)) }
+-                                          // + literal: Const { ty: fn(&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new}, val: Value(Scalar(<ZST>)) }
 -     }
 - 
 -     bb2: {
 +         StorageLive(_6);                 // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         _6 = move _5;                    // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         Deinit(_2);                      // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
-+         (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
++         (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         StorageDead(_6);                 // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         StorageDead(_5);                 // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL
           StorageDead(_3);                 // scope 0 at $DIR/inline-generator.rs:9:31: 9:32
--         _1 = <[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+-         _1 = <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
 -                                          // mir::Constant
 -                                          // + span: $DIR/inline-generator.rs:9:33: 9:39
--                                          // + literal: Const { ty: for<'r> fn(Pin<&'r mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) }
+-                                          // + literal: Const { ty: for<'r> fn(Pin<&'r mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) }
 +         StorageLive(_7);                 // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
 +         _7 = const false;                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
 +         StorageLive(_10);                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
 +         StorageLive(_11);                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
 +         StorageLive(_12);                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
-+         StorageLive(_13);                // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         _13 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         _12 = discriminant((*_13));      // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         StorageDead(_13);                // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         StorageLive(_13);                // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         _13 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         _12 = discriminant((*_13));      // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         StorageDead(_13);                // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
       }
   
 -     bb3: {
 +     }
 + 
 +     bb3: {
-+         _11 = move _7;                   // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         _11 = move _7;                   // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
 +         StorageLive(_8);                 // scope 6 at $DIR/inline-generator.rs:15:17: 15:39
 +         StorageLive(_9);                 // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
 +         _9 = _11;                        // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
 +         ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
 +         discriminant(_1) = 0;            // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
 +         StorageLive(_14);                // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+         _14 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
++         _14 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
 +         discriminant((*_14)) = 3;        // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
 +         StorageDead(_14);                // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
 +         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:11: 15:39
 +     }
 + 
 +     bb7: {
-+         StorageLive(_8);                 // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         _10 = move _7;                   // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         StorageLive(_8);                 // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++         _10 = move _7;                   // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
 +         StorageDead(_8);                 // scope 6 at $DIR/inline-generator.rs:15:38: 15:39
-+         Deinit(_1);                      // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         discriminant(_1) = 1;            // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         StorageLive(_15);                // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         _15 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         discriminant((*_15)) = 1;        // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         StorageDead(_15);                // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:41: 15:41
++         Deinit(_1);                      // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         discriminant(_1) = 1;            // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         StorageLive(_15);                // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         _15 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         discriminant((*_15)) = 1;        // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         StorageDead(_15);                // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:8: 15:8
 +     }
 + 
 +     bb8: {
-+         assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
 +     }
 + 
 +     bb9: {
-+         unreachable;                     // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         unreachable;                     // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
       }
   }
   
index 7c3048a69af615602d0ec7fe000e358902ad3b98..242073574f2b224027c1e7c83ec2805c7c815bb1 100644 (file)
@@ -2,8 +2,8 @@
 
 fn main() -> () {
     let mut _0: ();                      // return place in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:4:11: 4:11
-    let _1: [closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:33]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10
-    let mut _2: &[closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:33]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:6
+    let _1: [closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10
+    let mut _2: &[closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:6
     let mut _3: ((),);                   // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
     let mut _4: ();                      // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:7: 6:9
     let mut _5: ();                      // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
index 0b8c4d25d2d3c651383fd5f0631bc7b065f55b15..5808c607752522df3d0257947d780f67b4b31517 100644 (file)
@@ -9,14 +9,14 @@ fn main::{closure#0}(_1: &[closure@main::{closure#0}], _2: &i32) -> &i32 {
     }
 
     bb0: {
-        Retag([fn entry] _1);            // scope 0 at $DIR/retag.rs:40:31: 43:6
-        Retag([fn entry] _2);            // scope 0 at $DIR/retag.rs:40:31: 43:6
+        Retag([fn entry] _1);            // scope 0 at $DIR/retag.rs:40:31: 40:48
+        Retag([fn entry] _2);            // scope 0 at $DIR/retag.rs:40:31: 40:48
         StorageLive(_3);                 // scope 0 at $DIR/retag.rs:41:13: 41:15
         _3 = _2;                         // scope 0 at $DIR/retag.rs:41:18: 41:19
         Retag(_3);                       // scope 0 at $DIR/retag.rs:41:18: 41:19
         _0 = _2;                         // scope 1 at $DIR/retag.rs:42:9: 42:10
         Retag(_0);                       // scope 1 at $DIR/retag.rs:42:9: 42:10
         StorageDead(_3);                 // scope 0 at $DIR/retag.rs:43:5: 43:6
-        return;                          // scope 0 at $DIR/retag.rs:43:6: 43:6
+        return;                          // scope 0 at $DIR/retag.rs:40:48: 40:48
     }
 }
index 2fda8c949b00cd45a73630f530d843bf5baa62e5..89b1ded7f932f6be9262642fcde96891f14619e6 100644 (file)
@@ -121,7 +121,7 @@ fn main() -> () {
                                          // ]
         Retag(_14);                      // scope 1 at $DIR/retag.rs:40:31: 43:6
         _13 = move _14 as for<'r> fn(&'r i32) -> &'r i32 (Pointer(ClosureFnPointer(Normal))); // scope 1 at $DIR/retag.rs:40:31: 43:6
-        StorageDead(_14);                // scope 1 at $DIR/retag.rs:43:5: 43:6
+        StorageDead(_14);                // scope 1 at $DIR/retag.rs:40:47: 40:48
         StorageLive(_15);                // scope 6 at $DIR/retag.rs:44:9: 44:11
         StorageLive(_16);                // scope 6 at $DIR/retag.rs:44:14: 44:15
         _16 = _13;                       // scope 6 at $DIR/retag.rs:44:14: 44:15
index e463099a5ee4795186d28aab4710755993fabb4e..09ad276aa45ae0c2e4a079aa8ee97a54ccf1a21e 100644 (file)
@@ -37,7 +37,7 @@
    37|      0|            countdown = 10;
    38|      0|        }
    39|      0|        "alt string 2".to_owned()
-   40|      0|    };
+   40|       |    };
    41|      1|    println!(
    42|      1|        "The string or alt: {}"
    43|      1|        ,
@@ -79,7 +79,7 @@
    79|      0|            countdown = 10;
    80|      1|        }
    81|      1|        "alt string 4".to_owned()
-   82|      1|    };
+   82|       |    };
    83|      1|    println!(
    84|      1|        "The string or alt: {}"
    85|      1|        ,
   101|      0|            countdown = 10;
   102|      5|        }
   103|      5|        format!("'{}'", val)
-  104|      5|    };
+  104|       |    };
   105|      1|    println!(
   106|      1|        "Repeated, quoted string: {:?}"
   107|      1|        ,
   125|      0|            countdown = 10;
   126|      0|        }
   127|      0|        "closure should be unused".to_owned()
-  128|      0|    };
+  128|       |    };
   129|       |
   130|      1|    let mut countdown = 10;
   131|      1|    let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
   173|      0|            println!(
   174|      0|                "not called: {}",
   175|      0|                if is_true { "check" } else { "me" }
-  176|      0|            )
+  176|       |            )
   177|       |    ;
   178|       |
   179|      1|    let short_used_not_covered_closure_line_break_block_embedded_branch =
   183|      0|                "not called: {}",
   184|      0|                if is_true { "check" } else { "me" }
   185|       |            )
-  186|      0|        }
+  186|       |        }
   187|       |    ;
   188|       |
   189|      1|    let short_used_covered_closure_line_break_no_block_embedded_branch =
   192|      1|                "not called: {}",
   193|      1|                if is_true { "check" } else { "me" }
                                                             ^0
-  194|      1|            )
+  194|       |            )
   195|       |    ;
   196|       |
   197|      1|    let short_used_covered_closure_line_break_block_embedded_branch =
   202|      1|                if is_true { "check" } else { "me" }
                                                             ^0
   203|       |            )
-  204|      1|        }
+  204|       |        }
   205|       |    ;
   206|       |
   207|      1|    if is_false {
index 0fb3808ff2e30d33359a29183fc59ec2dc1fb937..d70e12e4128b479b4dda3c2f5a5bf5f955ff4a3b 100644 (file)
@@ -18,7 +18,7 @@
    17|      1|    let mut generator = || {
    18|      1|        yield get_u32(is_true);
    19|      1|        return "foo";
-   20|      1|    };
+   20|       |    };
    21|       |
    22|      1|    match Pin::new(&mut generator).resume(()) {
    23|      1|        GeneratorState::Yielded(Ok(1)) => {}
index 6e2f23ee77b8df0426ef4aba9b09bdb20dfc6d32..60a8d943f1fe8a1ca7895675f34487e6c18a2acf 100644 (file)
@@ -8,7 +8,7 @@
     8|      1|    let mut generator = || {
     9|      1|        yield 1;
    10|      1|        return "foo"
-   11|      1|    };
+   11|       |    };
    12|       |
    13|      1|    match Pin::new(&mut generator).resume(()) {
    14|      1|        GeneratorState::Yielded(1) => {}
@@ -24,7 +24,7 @@
    24|      1|        yield 2;
    25|      0|        yield 3;
    26|      0|        return "foo"
-   27|      0|    };
+   27|       |    };
    28|       |
    29|      1|    match Pin::new(&mut generator).resume(()) {
    30|      1|        GeneratorState::Yielded(1) => {}
index 6d16fe5673bc136e848ac1d8278738fdd5e40770..08877af92865742980f71988f10e2a814cc5a4ba 100644 (file)
@@ -110,6 +110,9 @@ Options:
                         never = never colorize output
         --error-format human|json|short
                         How errors and other messages are produced
+        --diagnostic-width WIDTH
+                        Provide width of the output for truncated error
+                        messages
         --json CONFIG   Configure the structure of JSON diagnostics
         --disable-minification 
                         Disable minification applied on JS files
diff --git a/src/test/rustdoc-ui/diagnostic-width.rs b/src/test/rustdoc-ui/diagnostic-width.rs
new file mode 100644 (file)
index 0000000..61961d5
--- /dev/null
@@ -0,0 +1,5 @@
+// compile-flags: -Zunstable-options --diagnostic-width=10
+#![deny(rustdoc::bare_urls)]
+
+/// This is a long line that contains a http://link.com
+pub struct Foo; //~^ ERROR
diff --git a/src/test/rustdoc-ui/diagnostic-width.stderr b/src/test/rustdoc-ui/diagnostic-width.stderr
new file mode 100644 (file)
index 0000000..fed049d
--- /dev/null
@@ -0,0 +1,15 @@
+error: this URL is not a hyperlink
+  --> $DIR/diagnostic-width.rs:4:41
+   |
+LL | ... a http://link.com
+   |       ^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://link.com>`
+   |
+note: the lint level is defined here
+  --> $DIR/diagnostic-width.rs:2:9
+   |
+LL | ...ny(rustdoc::bare_url...
+   |       ^^^^^^^^^^^^^^^^^^
+   = note: bare URLs are not automatically turned into clickable links
+
+error: aborting due to previous error
+
index e4d29754556c80ccdf8ae412db3b8f2ae60e8d44..aa12d4aa4b40c8326e2cc3476efedfb4db148bb8 100644 (file)
@@ -17,10 +17,10 @@ fn main() {
 
         let x: u64;
         asm!("{}", in(reg) x);
-        //~^ ERROR use of possibly-uninitialized variable: `x`
+        //~^ ERROR used binding `x` isn't initialized
         let mut y: u64;
         asm!("{}", inout(reg) y);
-        //~^ ERROR use of possibly-uninitialized variable: `y`
+        //~^ ERROR used binding `y` isn't initialized
         let _ = y;
 
         // Outputs require mutable places
index 37bbe394994e08c9e4d2dcd836b2f2d1bb24ad33..b2a695529f94818b35e714f50518173bb82071a1 100644 (file)
@@ -1,14 +1,18 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/type-check-2-2.rs:19:28
    |
+LL |         let x: u64;
+   |             - binding declared here but left uninitialized
 LL |         asm!("{}", in(reg) x);
-   |                            ^ use of possibly-uninitialized `x`
+   |                            ^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` isn't initialized
   --> $DIR/type-check-2-2.rs:22:9
    |
+LL |         let mut y: u64;
+   |             ----- binding declared here but left uninitialized
 LL |         asm!("{}", inout(reg) y);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^ `y` used here but it isn't initialized
 
 error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
   --> $DIR/type-check-2-2.rs:30:29
index 4b99652cd20bd0805e8644c1a063af4350e944b1..875df44ffab784696dce5243a542d80984297890 100644 (file)
@@ -22,7 +22,7 @@ LL |         asm!("{:v}", in(vreg) 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:41:28: 41:38]` for inline assembly
+error: cannot use value of type `[closure@$DIR/type-check-2.rs:41:28: 41:36]` for inline assembly
   --> $DIR/type-check-2.rs:41:28
    |
 LL |         asm!("{}", in(reg) |x: i32| x);
index 46baeb511ca775a99f0b779be416c4105ba57b2f..d9ca25519dc8a7b43473be4aba65cd3e36c89a0e 100644 (file)
@@ -30,7 +30,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:52:28: 52:38]` for inline assembly
+error: cannot use value of type `[closure@$DIR/type-check-2.rs:52:28: 52:36]` for inline assembly
   --> $DIR/type-check-2.rs:52:28
    |
 LL |         asm!("{}", in(reg) |x: i32| x);
index 474478f6a88e1bc50483a4ec02a9b1a143d88b8c..6190e0b52f4e9d4100fbc2c307f4ce097c3f7c8c 100644 (file)
@@ -13,10 +13,10 @@ fn main() {
 
         let x: u64;
         asm!("{}", in(reg) x);
-        //~^ ERROR use of possibly-uninitialized variable: `x`
+        //~^ ERROR E0381
         let mut y: u64;
         asm!("{}", inout(reg) y);
-        //~^ ERROR use of possibly-uninitialized variable: `y`
+        //~^ ERROR E0381
         let _ = y;
 
         // Outputs require mutable places
index 181ecaf58558563a9b3f7491be7c658bcc231e04..e9c93fea561a81b3717c9654b683a076e551acc4 100644 (file)
@@ -1,14 +1,18 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/type-check-5.rs:15:28
    |
+LL |         let x: u64;
+   |             - binding declared here but left uninitialized
 LL |         asm!("{}", in(reg) x);
-   |                            ^ use of possibly-uninitialized `x`
+   |                            ^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` isn't initialized
   --> $DIR/type-check-5.rs:18:9
    |
+LL |         let mut y: u64;
+   |             ----- binding declared here but left uninitialized
 LL |         asm!("{}", inout(reg) y);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^ `y` used here but it isn't initialized
 
 error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
   --> $DIR/type-check-5.rs:26:29
index a09b64aa2f5a538cad3b25ab828bda4ad66a9900..ebf3c5499a68ba429bbd417f49bb99c941fadc2b 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no variant or associated item named `mispellable` found for enum `
   --> $DIR/associated-item-enum.rs:17:11
    |
 LL | enum Enum { Variant }
-   |      ---- variant or associated item `mispellable` not found for this enum
+   | --------- variant or associated item `mispellable` not found for this enum
 ...
 LL |     Enum::mispellable();
    |           ^^^^^^^^^^^
@@ -14,7 +14,7 @@ error[E0599]: no variant or associated item named `mispellable_trait` found for
   --> $DIR/associated-item-enum.rs:18:11
    |
 LL | enum Enum { Variant }
-   |      ---- variant or associated item `mispellable_trait` not found for this enum
+   | --------- variant or associated item `mispellable_trait` not found for this enum
 ...
 LL |     Enum::mispellable_trait();
    |           ^^^^^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `
   --> $DIR/associated-item-enum.rs:19:11
    |
 LL | enum Enum { Variant }
-   |      ---- variant or associated item `MISPELLABLE` not found for this enum
+   | --------- variant or associated item `MISPELLABLE` not found for this enum
 ...
 LL |     Enum::MISPELLABLE;
    |           ^^^^^^^^^^^
index 6e1b155e181eea8cc84ef2580991e7754f4f3427..8bf1385b3c5cde4b0f1b105759a2c0151f6aaf34 100644 (file)
@@ -1,8 +1,6 @@
 // run-pass
 // aux-build: issue-72470-lib.rs
 // edition:2021
-#![feature(into_future)]
-
 extern crate issue_72470_lib;
 use std::{future::{Future, IntoFuture}, pin::Pin};
 
index e9b76b19dc4075d32d8100dd70b29dcef7b0b6ad..9b6917df45d2f9b3653c8855dc6383e2fd5c6c80 100644 (file)
@@ -9,11 +9,8 @@ LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send {
 note: required because it's used within this closure
   --> $DIR/issue-70935-complex-spans.rs:25:13
    |
-LL |           baz(|| async{
-   |  _____________^
-LL | |             foo(tx.clone());
-LL | |         }).await;
-   | |_________^
+LL |         baz(|| async{
+   |             ^^
 note: required because it's used within this `async fn` body
   --> $DIR/issue-70935-complex-spans.rs:9:67
    |
index 2174f260a713592e337d04630fff8ff0c9113d04..88b646d2792db8a088c111d343e7646c13f27e74 100644 (file)
@@ -14,7 +14,7 @@ LL | |             foo(tx.clone());
 LL | |         }).await;
    | |         - ^^^^^^ await occurs here, with the value maybe used later
    | |_________|
-   |           has type `[closure@$DIR/issue-70935-complex-spans.rs:25:13: 27:10]` which is not `Send`
+   |           has type `[closure@$DIR/issue-70935-complex-spans.rs:25:13: 25:15]` which is not `Send`
 note: the value is later dropped here
   --> $DIR/issue-70935-complex-spans.rs:27:17
    |
index ccdd9c57a0f552078c789064999ae2e3a69b820b..5cbbf89a222a7fcb4b7a08c19c08b15878766d0b 100644 (file)
@@ -24,15 +24,15 @@ LL | fn main() {
 LL |     (|_| 2333).await;
    |               ^^^^^^ only allowed inside `async` functions and blocks
 
-error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
+error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future
   --> $DIR/issue-62009-1.rs:12:15
    |
 LL |     (|_| 2333).await;
-   |               ^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
+   |               ^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future
    |
-   = help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
-   = note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
-   = note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
+   = help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]`
+   = note: [closure@$DIR/issue-62009-1.rs:12:6: 12:9] must be a future or must implement `IntoFuture` to be awaited
+   = note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]`
 help: remove the `.await`
    |
 LL -     (|_| 2333).await;
index 24070fe33083ca28fbfb0431d2c9264da6e2a72e..c4d81bf83a3c43caadb487b010526a1864b3d743 100644 (file)
@@ -6,8 +6,7 @@ async fn no_non_guaranteed_initialization(x: usize) -> usize {
     if x > 5 {
         y = echo(10).await;
     }
-    y
-    //~^ use of possibly-uninitialized variable: `y`
+    y //~ ERROR E0381
 }
 
 async fn echo(x: usize) -> usize { x + 1 }
index f5991f4bccac942e718f0ec725ef8862fca47c4f..12c15bf56ce22aa1b7b512b03e9922ed49d063c3 100644 (file)
@@ -1,8 +1,15 @@
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` is possibly-uninitialized
   --> $DIR/no-non-guaranteed-initialization.rs:9:5
    |
+LL |     let y;
+   |         - binding declared here but left uninitialized
+LL |     if x > 5 {
+   |        ----- if this `if` condition is `false`, `y` is not initialized
+LL |         y = echo(10).await;
+LL |     }
+   |      - an `else` arm might be missing here, initializing `y`
 LL |     y
-   |     ^ use of possibly-uninitialized `y`
+   |     ^ `y` used here but it is possibly-uninitialized
 
 error: aborting due to previous error
 
index 8a98a4b0f6bb41cdfd6ad3f17b5fc272b346971d..7577aee3fb7d6c77d852dd99f4b2b43a98168382 100644 (file)
@@ -10,8 +10,7 @@ async fn noop() {}
 
 async fn test_tuple() {
     let mut t: (i32, i32);
-    t.0 = 42;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    t.0 = 42; //~ ERROR E0381
     noop().await;
     t.1 = 88;
     let _ = t;
@@ -19,8 +18,7 @@ async fn test_tuple() {
 
 async fn test_tuple_struct() {
     let mut t: T;
-    t.0 = 42;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    t.0 = 42; //~ ERROR E0381
     noop().await;
     t.1 = 88;
     let _ = t;
@@ -28,8 +26,7 @@ async fn test_tuple_struct() {
 
 async fn test_struct() {
     let mut t: S;
-    t.x = 42;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    t.x = 42; //~ ERROR E0381
     noop().await;
     t.y = 88;
     let _ = t;
index 9a510c22c4b1e77e143c24308811dc6b74aff790..6a0eeffb946111f233da3316b5af026efc12fabc 100644 (file)
@@ -1,20 +1,32 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/partial-initialization-across-await.rs:13:5
    |
+LL |     let mut t: (i32, i32);
+   |         ----- binding declared here but left uninitialized
 LL |     t.0 = 42;
-   |     ^^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/partial-initialization-across-await.rs:22:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/partial-initialization-across-await.rs:21:5
    |
+LL |     let mut t: T;
+   |         ----- binding declared here but left uninitialized
 LL |     t.0 = 42;
-   |     ^^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/partial-initialization-across-await.rs:31:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/partial-initialization-across-await.rs:29:5
    |
+LL |     let mut t: S;
+   |         ----- binding declared here but left uninitialized
 LL |     t.x = 42;
-   |     ^^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 3 previous errors
 
index ba22b7aaf9828f426d0fef49dfae1d01bec26b8b..2e8723b2743a79062274a8c25f471193dcaec66a 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `poll` found for struct `Sleep` in the current sco
   --> $DIR/pin-needed-to-poll.rs:42:20
    |
 LL | struct Sleep;
-   |        ----- method `poll` not found for this struct
+   | ------------ method `poll` not found for this struct
 ...
 LL |         self.sleep.poll(cx)
    |                    ^^^^ method not found in `Sleep`
index e9ca0ad9029e6e0bdb69f9dbbd4a84c3e00453a2..37bad64c5bf68582efccf225470cfdb6e660e38d 100644 (file)
@@ -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:14]`
+                found closure `[closure@$DIR/issue-20862.rs:2:5: 2:8]`
 
 error[E0618]: expected function, found `()`
   --> $DIR/issue-20862.rs:7:13
index b215adfa593bde48d76e6c2287994f580599714e..899ff4261ba3bef961b4ffe2bb1db3950f9706b1 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no variant or associated item named `Hsl` found for enum `Color` i
   --> $DIR/bogus-tag.rs:7:16
    |
 LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), }
-   |      ----- variant or associated item `Hsl` not found for this enum
+   | ---------- variant or associated item `Hsl` not found for this enum
 ...
 LL |         Color::Hsl(h, s, l) => { println!("hsl"); }
    |                ^^^ variant or associated item not found in `Color`
index 40f1aae092dc6bd237569ec658fe50072a7ee698..1ed92865da55bdcc8238c9990b38a62aa03e61d2 100644 (file)
@@ -1,14 +1,22 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/assign_mutable_fields.rs:9:5
    |
+LL |     let mut x: (u32, u32);
+   |         ----- binding declared here but left uninitialized
 LL |     x.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/assign_mutable_fields.rs:17:5
    |
+LL |     let mut x: (u32, u32);
+   |         ----- binding declared here but left uninitialized
 LL |     x.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 2 previous errors
 
index 003c40d27736d5b3b43c7e689994fb2a381b4d24..6235e0db0da1895357e805e7607e658f07f7b3b0 100644 (file)
@@ -1,15 +1,13 @@
 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 || {
-LL | |         x += 1;
-   | |         ^^^^^^ cannot assign
-LL | |         x
-LL | |     }
-   | |_____- in this closure
+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
 
 error: aborting due to previous error
 
index a28cb7431e6a905abc07ab71dc3b8330279fff41..093589ed0921fced630d1efa12a21bdcf80fc161 100644 (file)
@@ -5,8 +5,9 @@ LL | fn to_fn<A, F: Fn<A>>(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`
 
 error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
@@ -16,8 +17,9 @@ LL | fn to_fn<A, F: Fn<A>>(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`
 
 error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
@@ -27,8 +29,9 @@ LL | fn to_fn<A, F: Fn<A>>(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`
 
 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
@@ -38,8 +41,9 @@ LL | fn to_fn<A, F: Fn<A>>(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`
 
 error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
@@ -49,8 +53,9 @@ LL | fn to_fn<A, F: Fn<A>>(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`
 
 error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
@@ -60,23 +65,21 @@ LL | fn to_fn<A, F: Fn<A>>(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<dyn Fn() -> 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
+LL | fn foo() -> Box<dyn Fn() -> 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
 
 error: aborting due to 7 previous errors
 
index ea74fb966846ff1f7ff8ed18a62a5633bbfbe828..869375cb2c61be2a0911f28e05e42e2c409b3cd2 100644 (file)
@@ -29,32 +29,28 @@ LL |     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: Fn()>(f: F) -> F { f }
-   |                          - change this to accept `FnMut` instead of `Fn`
+LL | fn make_fn<F: Fn()>(f: F) -> F { f }
+   |                        - change this to accept `FnMut` instead of `Fn`
 ...
-LL |       let f = make_fn(|| {
-   |  _____________-------_-
-   | |             |
-   | |             expects `Fn` instead of `FnMut`
-LL | |         let y = &raw mut x;
-   | |                 ^^^^^^^^^^ cannot borrow as mutable
-LL | |     });
-   | |_____- in this closure
+LL |     let f = make_fn(|| {
+   |             ------- -- in this closure
+   |             |
+   |             expects `Fn` instead of `FnMut`
+LL |         let y = &raw mut x;
+   |                 ^^^^^^^^^^ cannot borrow as mutable
 
 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: Fn()>(f: F) -> F { f }
-   |                          - change this to accept `FnMut` instead of `Fn`
+LL | fn make_fn<F: Fn()>(f: F) -> F { f }
+   |                        - change this to accept `FnMut` instead of `Fn`
 ...
-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
+LL |     let f = make_fn(move || {
+   |             ------- ------- in this closure
+   |             |
+   |             expects `Fn` instead of `FnMut`
+LL |         let y = &raw mut x;
+   |                 ^^^^^^^^^^ cannot borrow as mutable
 
 error: aborting due to 5 previous errors
 
index f11d44e2217ba9642c1e35daf12bf2edaf4bedd2..eeb4f05d60c963d1edd17fb122b164870d8c1322 100644 (file)
@@ -2,5 +2,5 @@ fn main() {
     let i: isize;
 
     println!("{}", false && { i = 5; true });
-    println!("{}", i); //~ ERROR borrow of possibly-uninitialized variable: `i`
+    println!("{}", i); //~ ERROR E0381
 }
index d2c7473c036b8769fbcfacccf3792b38cc637cef..7f3d27d6091d83e8aec5fe9122e7318629861bd7 100644 (file)
@@ -1,8 +1,13 @@
-error[E0381]: borrow of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` is possibly-uninitialized
   --> $DIR/borrowck-and-init.rs:5:20
    |
+LL |     let i: isize;
+   |         - binding declared here but left uninitialized
+LL |
+LL |     println!("{}", false && { i = 5; true });
+   |                               ----- binding initialized here in some conditions
 LL |     println!("{}", i);
-   |                    ^ use of possibly-uninitialized `i`
+   |                    ^ `i` used here but it is possibly-uninitialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 1e7306acaee98c744e42d2eac0d56eb073cd25b3..8d13b25a357560f14e1f9943a41a9b9b6787d28e 100644 (file)
@@ -1,7 +1,7 @@
 fn force<F>(f: F) where F: FnOnce() { f(); }
 fn main() {
     let x: isize;
-    force(|| {  //~ ERROR borrow of possibly-uninitialized variable: `x`
+    force(|| {  //~ ERROR E0381
         println!("{}", x);
     });
 }
index 578f89df46ce173ca0a4293bf1abed1d3f21fba9..e720db1c6961b275b230d4daf985a8a67ba3e83e 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-block-unint.rs:4:11
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     force(|| {
-   |           ^^ use of possibly-uninitialized `x`
+   |           ^^ `x` used here but it isn't initialized
 LL |         println!("{}", x);
    |                        - borrow occurs due to use in closure
 
index 126d991a51c6e6963e61d9fce3f5a2cefb592f02..3abca33a84add3f9c4fe8a04df94ac8dbd9e997b 100644 (file)
@@ -6,7 +6,7 @@ fn foo() -> isize {
         x = 0;
     }
 
-    println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+    println!("{}", x); //~ ERROR E0381
 
     return 17;
 }
index b134f5cc2d8e3d950e53c3ee966ae0d5aa458eeb..23ea1a2de7fc7d66f24e16cfe66807d0c639014c 100644 (file)
@@ -1,8 +1,11 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-break-uninit-2.rs:9:20
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
+...
 LL |     println!("{}", x);
-   |                    ^ use of possibly-uninitialized `x`
+   |                    ^ `x` used here but it isn't initialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 8ccb21ae8eebfb18716846741e8135dadbf3c735..824f91dbc62c2f88633cbfc5dd81c03c30a74bd0 100644 (file)
@@ -6,7 +6,7 @@ fn foo() -> isize {
         x = 0;
     }
 
-    println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+    println!("{}", x); //~ ERROR E0381
 
     return 17;
 }
index 652d7d3076fbda4494248b7573e58784e2ad3d8c..2b9b0a190f6c8ae5c1d9798e2a75c14476d220b8 100644 (file)
@@ -1,8 +1,11 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-break-uninit.rs:9:20
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
+...
 LL |     println!("{}", x);
-   |                    ^ use of possibly-uninitialized `x`
+   |                    ^ `x` used here but it isn't initialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 50edfb6ba2db16bff9620e6f5fcba6006798d6e1..03edf445ee97b41cde5111d7c54b7e1ca36617be 100644 (file)
@@ -78,20 +78,20 @@ fn fu_move_after_fu_move() {
 
 fn copy_after_field_assign_after_uninit() {
     let mut x: A;
-    x.a = 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
+    x.a = 1; //~ ERROR E0381
     drop(x.a);
 }
 
 fn borrow_after_field_assign_after_uninit() {
     let mut x: A;
-    x.a = 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
+    x.a = 1; //~ ERROR E0381
     let p = &x.a;
     drop(*p);
 }
 
 fn move_after_field_assign_after_uninit() {
     let mut x: A;
-    x.b = Box::new(1); //~ ERROR assign to part of possibly-uninitialized variable: `x`
+    x.b = Box::new(1); //~ ERROR E0381
     drop(x.b);
 }
 
index bb4d2f06016b9ecc5e3126fe662a79617d9892b3..e009f5913edd072c2026c35721bb3edd000e6cf9 100644 (file)
@@ -108,23 +108,35 @@ LL |     let _z = A { a: 4, .. x };
    |
    = note: move occurs because `x.b` has type `Box<isize>`, which does not implement the `Copy` trait
 
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/borrowck-field-sensitivity.rs:81:5
    |
+LL |     let mut x: A;
+   |         ----- binding declared here but left uninitialized
 LL |     x.a = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/borrowck-field-sensitivity.rs:87:5
    |
+LL |     let mut x: A;
+   |         ----- binding declared here but left uninitialized
 LL |     x.a = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/borrowck-field-sensitivity.rs:94:5
    |
+LL |     let mut x: A;
+   |         ----- binding declared here but left uninitialized
 LL |     x.b = Box::new(1);
-   |     ^^^ use of possibly-uninitialized `x`
+   |     ^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 14 previous errors
 
diff --git a/src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.rs b/src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.rs
new file mode 100644 (file)
index 0000000..f619c04
--- /dev/null
@@ -0,0 +1,7 @@
+fn f() -> isize {
+    let mut x: isize;
+    for _ in 0..0 { x = 10; }
+    return x; //~ ERROR E0381
+}
+
+fn main() { f(); }
diff --git a/src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.stderr b/src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.stderr
new file mode 100644 (file)
index 0000000..c08c93f
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0381]: used binding `x` is possibly-uninitialized
+  --> $DIR/borrowck-for-loop-uninitialized-binding.rs:4:12
+   |
+LL |     let mut x: isize;
+   |         ----- binding declared here but left uninitialized
+LL |     for _ in 0..0 { x = 10; }
+   |              ---- if the `for` loop runs 0 times, `x` is not initialized 
+LL |     return x;
+   |            ^ `x` used here but it is possibly-uninitialized
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0381`.
index f59bcad6f61d76f0f927115c29cce52a9967e6e5..534d771be1dfaf02bd6a73cf9e429b47146e5875 100644 (file)
@@ -2,5 +2,5 @@
 
 fn main() {
     let x: isize; if 1 > 2 { x = 10; }
-    foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
+    foo(x); //~ ERROR E0381
 }
index 3e9d3d4f6d513bc91a4e240893ac69a71837ee59..9eafc2c2a86e6b4051adef9e3e5a231c28e666c8 100644 (file)
@@ -1,8 +1,13 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` is possibly-uninitialized
   --> $DIR/borrowck-if-no-else.rs:5:9
    |
+LL |     let x: isize; if 1 > 2 { x = 10; }
+   |         -            -----            - an `else` arm might be missing here, initializing `x`
+   |         |            |
+   |         |            if this `if` condition is `false`, `x` is not initialized
+   |         binding declared here but left uninitialized
 LL |     foo(x);
-   |         ^ use of possibly-uninitialized `x`
+   |         ^ `x` used here but it is possibly-uninitialized
 
 error: aborting due to previous error
 
index c13318b16c2fa1f2f4c26ca1f1fae3c197aa4786..69d450c59891a9b1258a42ed7e3908aa0d35ea9d 100644 (file)
@@ -7,5 +7,5 @@ fn main() {
     } else {
         x = 10;
     }
-    foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
+    foo(x); //~ ERROR E0381
 }
index 53b8a6bba2c76263981a39260034ac7a68325dde..3f0fe291ca2508e44f723ca6ab88129117ad1bb3 100644 (file)
@@ -1,8 +1,13 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` is possibly-uninitialized
   --> $DIR/borrowck-if-with-else.rs:10:9
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
+LL |     if 1 > 2 {
+   |        ----- if this condition is `true`, `x` is not initialized
+...
 LL |     foo(x);
-   |         ^ use of possibly-uninitialized `x`
+   |         ^ `x` used here but it is possibly-uninitialized
 
 error: aborting due to previous error
 
index 30e74c5ec950c6044205afe52d09947b2f0ca66e..2033e4a5730146feae6d47b356500d547fb5ea53 100644 (file)
@@ -4,9 +4,8 @@ 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<i32>`, which does not implement the `Copy` trait
+   |              -- ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+   |              |
    |              captured by this `Fn` closure
 
 error: aborting due to previous error
index 9905e420f948d307d71627c1ca514dbf6f7297f2..e6476b9c1bef797e6a4163b9212c0790ae5963e4 100644 (file)
@@ -1,7 +1,7 @@
 fn main() {
     let j = || -> isize {
         let i: isize;
-        i //~ ERROR use of possibly-uninitialized variable: `i`
+        i //~ ERROR E0381
     };
     j();
 }
index 2d1d9bc8fa41d2734c83de893cd8b17064d64ff1..e8a2fbc91ea6430ebaac8d494676ccd8253c809a 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` isn't initialized
   --> $DIR/borrowck-init-in-called-fn-expr.rs:4:9
    |
+LL |         let i: isize;
+   |             - binding declared here but left uninitialized
 LL |         i
-   |         ^ use of possibly-uninitialized `i`
+   |         ^ `i` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 7dd3396c8c2cb4580a05a7a068939744cf7bfd82..7eb204a0d167268234f30cb0ccc674b240cc605d 100644 (file)
@@ -1,7 +1,7 @@
 fn main() {
     let f  = || -> isize {
         let i: isize;
-        i //~ ERROR use of possibly-uninitialized variable: `i`
+        i //~ ERROR E0381
     };
     println!("{}", f());
 }
index fd8b90eda603299f6e3b307ccc2d733c532f7d94..1e950d6a20defb7688834981a5b1d0320dd9e791 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` isn't initialized
   --> $DIR/borrowck-init-in-fn-expr.rs:4:9
    |
+LL |         let i: isize;
+   |             - binding declared here but left uninitialized
 LL |         i
-   |         ^ use of possibly-uninitialized `i`
+   |         ^ `i` used here but it isn't initialized
 
 error: aborting due to previous error
 
index d7ec2ed75c85c5dae6724523e1d7d78a23208f26..c07957ab13973535ae487a02a5a950625ad39755 100644 (file)
@@ -7,6 +7,6 @@ struct Point {
 fn main() {
     let mut origin: Point;
     origin = Point { x: 10, ..origin };
-    //~^ ERROR use of possibly-uninitialized variable: `origin` [E0381]
+    //~^ ERROR E0381
     origin.clone();
 }
index f01afe1466aef7564c2e971c7e592b6044757b81..83a3e3e0e3ae0b84619a87220168fb30080dbfe8 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `origin`
+error[E0381]: used binding `origin` isn't initialized
   --> $DIR/borrowck-init-in-fru.rs:9:14
    |
+LL |     let mut origin: Point;
+   |         ---------- binding declared here but left uninitialized
 LL |     origin = Point { x: 10, ..origin };
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `origin.y`
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^ `origin.y` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 784eb8cf85b8a01c68639663d466508ab5e9a21e..3d08c1b81a79bee077438784d1ad2b52e3565e84 100644 (file)
@@ -1,6 +1,6 @@
 fn test() {
     let v: isize;
-    v += 1; //~ ERROR use of possibly-uninitialized variable: `v`
+    v += 1; //~ ERROR E0381
     v.clone();
 }
 
index 6c88778ae0e5a288a0e4567e21fdc0a856dbee0e..74704b2abfee87d8c6750df0bf3f9ace74043ab6 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `v`
+error[E0381]: used binding `v` isn't initialized
   --> $DIR/borrowck-init-op-equal.rs:3:5
    |
+LL |     let v: isize;
+   |         - binding declared here but left uninitialized
 LL |     v += 1;
-   |     ^^^^^^ use of possibly-uninitialized `v`
+   |     ^^^^^^ `v` used here but it isn't initialized
 
 error: aborting due to previous error
 
index d9d20a2a9c14879b454c70b452cfb014fb129a6f..2a52a3f4e5eb1ad0c2eebcfe4bb4d884b7dd9cef 100644 (file)
@@ -1,6 +1,6 @@
 fn test() {
     let mut v: isize;
-    v = v + 1; //~ ERROR use of possibly-uninitialized variable: `v`
+    v = v + 1; //~ ERROR E0381
     v.clone();
 }
 
index fe09c8581df0e41c888ac2188cd0c1bb7b9d1d83..7542576d636be299238f6aedccff1e149a684af5 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `v`
+error[E0381]: used binding `v` isn't initialized
   --> $DIR/borrowck-init-plus-equal.rs:3:9
    |
+LL |     let mut v: isize;
+   |         ----- binding declared here but left uninitialized
 LL |     v = v + 1;
-   |         ^ use of possibly-uninitialized `v`
+   |         ^ `v` used here but it isn't initialized
 
 error: aborting due to previous error
 
index f81b34a641bf081c1121ea189dcdd929e2a2b626..8ddc48b2a99cdf0711a8f7812e1f1c4f9c2ee49f 100644 (file)
@@ -1,18 +1,16 @@
 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(|| {
-   |  ________________________-
-LL | |         let _h = to_fn_once(move || -> isize { *bar });
-   | |                             ^^^^^^^^^^^^^^^^   ----
-   | |                             |                  |
-   | |                             |                  variable moved due to use in closure
-   | |                             |                  move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
-   | |                             move out of `bar` occurs here
-LL | |     });
-   | |_____- captured by this `FnMut` closure
+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<isize>`, which does not implement the `Copy` trait
+   |                             move out of `bar` occurs here
 
 error: aborting due to previous error
 
index 81b0b80bf11b5da368505ae5ee9d407c2bd4395c..079cf899e6dbf5af2c00493685c90d8ca879c17f 100644 (file)
@@ -2,5 +2,5 @@ fn main() {
     let i: isize;
 
     println!("{}", false || { i = 5; true });
-    println!("{}", i); //~ ERROR borrow of possibly-uninitialized variable: `i`
+    println!("{}", i); //~ ERROR E0381
 }
index 6c757759f71344514af75d2a2b486bcc0324978f..0bc24f1b6932f2e56988f9d1f3d84a470ac37b55 100644 (file)
@@ -1,8 +1,13 @@
-error[E0381]: borrow of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` is possibly-uninitialized
   --> $DIR/borrowck-or-init.rs:5:20
    |
+LL |     let i: isize;
+   |         - binding declared here but left uninitialized
+LL |
+LL |     println!("{}", false || { i = 5; true });
+   |                               ----- binding initialized here in some conditions
 LL |     println!("{}", i);
-   |                    ^ use of possibly-uninitialized `i`
+   |                    ^ `i` used here but it is possibly-uninitialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 5e5a8cdf4232bcbbc7352655f517ff5d0ac194c5..a43a1936678ff7288ec55faa73ce4c00a00a41ab 100644 (file)
@@ -14,8 +14,7 @@ fn drop(&mut self) {}
 
 fn stuff() {
     let mut x : (Test2, Test2);
-    (x.0).0 = Some(Test);
-    //~^ ERROR assign of possibly-uninitialized variable: `x.0`
+    (x.0).0 = Some(Test); //~ ERROR E0381
 }
 
 fn main() {
index 218c4f2de5bc7c6a9ebc8e22ce88b1f810f7cc00..d12a482cb69a9ddd6afa1e2da14a9fd14670712e 100644 (file)
@@ -1,8 +1,12 @@
-error[E0381]: assign of possibly-uninitialized variable: `x.0`
+error[E0381]: assigned binding `x.0` isn't fully initialized
   --> $DIR/borrowck-partial-reinit-4.rs:17:5
    |
+LL |     let mut x : (Test2, Test2);
+   |         ----- binding declared here but left uninitialized
 LL |     (x.0).0 = Some(Test);
-   |     ^^^^^^^ use of possibly-uninitialized `x.0`
+   |     ^^^^^^^ `x.0` assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to previous error
 
index 8c623356f6c6b2aba47ed2e6dbc96648fe153161..a63ffcff732ee0c0c68d71b2b8f73a0f3f08d3d3 100644 (file)
@@ -1,6 +1,6 @@
 fn f() -> isize {
     let x: isize;
-    return x; //~ ERROR use of possibly-uninitialized variable: `x`
+    return x; //~ ERROR E0381
 }
 
 fn main() { f(); }
index bc74e8e343848f8dd52cf3c7f4f2f14feb9c5a39..1c916e223175c8424185e4428b5816db996174a2 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-return.rs:3:12
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     return x;
-   |            ^ use of possibly-uninitialized `x`
+   |            ^ `x` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 8e4932142f0dbfc69733039a3d3591346b7abded..2cea4392d6adb63b03ddfd8e06b6c2ea90bbebef 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-storage-dead.rs:16:17
    |
+LL |         let x: i32;
+   |             - binding declared here but left uninitialized
 LL |         let _ = x + 1;
-   |                 ^ use of possibly-uninitialized `x`
+   |                 ^ `x` used here but it isn't initialized
 
 error: aborting due to previous error
 
index e9a389657c8fd589b9e36f9a582317fafb93208a..e97ce6aa407ed15425bebd5c04afd7d62bbff68e 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
     let bar;
     fn baz(_x: isize) { }
-    baz(bar); //~ ERROR use of possibly-uninitialized variable: `bar`
+    baz(bar); //~ ERROR E0381
 }
index f7f069b81be022720d0f0c8c4ef9d40d6b4211f8..588b1b0c9729cc2c1ee7f32ba8d36ae9f24b26aa 100644 (file)
@@ -1,8 +1,11 @@
-error[E0381]: use of possibly-uninitialized variable: `bar`
+error[E0381]: used binding `bar` isn't initialized
   --> $DIR/borrowck-uninit-after-item.rs:4:9
    |
+LL |     let bar;
+   |         --- binding declared here but left uninitialized
+LL |     fn baz(_x: isize) { }
 LL |     baz(bar);
-   |         ^^^ use of possibly-uninitialized `bar`
+   |         ^^^ `bar` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 7951a5b1b5d70e6dfd2d236f4cadc78299608b7d..6a38a7989197087b695660d8a89b9823097e5526 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `a`
+error[E0381]: used binding `a` isn't initialized
   --> $DIR/borrowck-uninit-field-access.rs:21:13
    |
+LL |     let mut a: Point;
+   |         ----- binding declared here but left uninitialized
 LL |     let _ = a.x + 1;
-   |             ^^^ use of possibly-uninitialized `a.x`
+   |             ^^^ `a.x` used here but it isn't initialized
 
 error[E0382]: use of moved value: `line1.origin`
   --> $DIR/borrowck-uninit-field-access.rs:25:13
index 20350d61d5bb61776b56397f0b8ffbeaaca4f496..92c3692bd2f692094e64ba9038bef3469bea3f59 100644 (file)
@@ -3,32 +3,32 @@
 
 pub fn main() {
     let x: isize;
-    x += 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x += 1; //~ ERROR E0381
 
     let x: isize;
-    x -= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x -= 1; //~ ERROR E0381
 
     let x: isize;
-    x *= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x *= 1; //~ ERROR E0381
 
     let x: isize;
-    x /= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x /= 1; //~ ERROR E0381
 
     let x: isize;
-    x %= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x %= 1; //~ ERROR E0381
 
     let x: isize;
-    x ^= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x ^= 1; //~ ERROR E0381
 
     let x: isize;
-    x &= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x &= 1; //~ ERROR E0381
 
     let x: isize;
-    x |= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+    x |= 1; //~ ERROR E0381
 
     let x: isize;
-    x <<= 1;    //~ ERROR use of possibly-uninitialized variable: `x`
+    x <<= 1; //~ ERROR E0381
 
     let x: isize;
-    x >>= 1;    //~ ERROR use of possibly-uninitialized variable: `x`
+    x >>= 1; //~ ERROR E0381
 }
index f2036df3ce92a5a8a56b7a99948d107a97944443..744cb14e662b3bcf824b17c8962be85b1bea8901 100644 (file)
@@ -1,62 +1,82 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:6:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x += 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:9:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x -= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:12:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x *= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:15:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x /= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:18:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x %= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:21:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x ^= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:24:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x &= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:27:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x |= 1;
-   |     ^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:30:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x <<= 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-in-assignop.rs:33:5
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     x >>= 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` used here but it isn't initialized
 
 error: aborting due to 10 previous errors
 
index 0ccea49f329bb1030f8202a3d5c19b1077d509bc..c36b9707d2287e0fab1bfa67d6e23dd0fb67f9f7 100644 (file)
@@ -5,29 +5,29 @@ struct S<X, Y> {
 
 fn main() {
     let x: &&Box<i32>;
-    let _y = &**x; //~ [E0381]
+    let _y = &**x; //~ ERROR [E0381]
 
     let x: &&S<i32, i32>;
-    let _y = &**x; //~ [E0381]
+    let _y = &**x; //~ ERROR [E0381]
 
     let x: &&i32;
-    let _y = &**x; //~ [E0381]
+    let _y = &**x; //~ ERROR [E0381]
 
 
     let mut a: S<i32, i32>;
-    a.x = 0;            //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
+    a.x = 0; //~ ERROR [E0381]
     let _b = &a.x;
 
     let mut a: S<&&i32, &&i32>;
-    a.x = &&0;          //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
+    a.x = &&0; //~ ERROR [E0381]
     let _b = &**a.x;
 
 
     let mut a: S<i32, i32>;
-    a.x = 0;            //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
+    a.x = 0; //~ ERROR [E0381]
     let _b = &a.y;
 
     let mut a: S<&&i32, &&i32>;
-    a.x = &&0;          //~ assign to part of possibly-uninitialized variable: `a` [E0381]
+    a.x = &&0; //~ ERROR [E0381]
     let _b = &**a.y;
 }
index d99a50df75b8cf66625383b0851d5d8ac264f91e..c486cb6dd0cd338f4c01c11e21f750b5a1f95d4c 100644 (file)
@@ -1,44 +1,66 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:8:14
    |
+LL |     let x: &&Box<i32>;
+   |         - binding declared here but left uninitialized
 LL |     let _y = &**x;
-   |              ^^^^ use of possibly-uninitialized `**x`
+   |              ^^^^ `**x` used here but it isn't initialized
 
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:11:14
    |
+LL |     let x: &&S<i32, i32>;
+   |         - binding declared here but left uninitialized
 LL |     let _y = &**x;
-   |              ^^^^ use of possibly-uninitialized `**x`
+   |              ^^^^ `**x` used here but it isn't initialized
 
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:14:14
    |
+LL |     let x: &&i32;
+   |         - binding declared here but left uninitialized
 LL |     let _y = &**x;
-   |              ^^^^ use of possibly-uninitialized `**x`
+   |              ^^^^ `**x` used here but it isn't initialized
 
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:18:5
    |
+LL |     let mut a: S<i32, i32>;
+   |         ----- binding declared here but left uninitialized
 LL |     a.x = 0;
-   |     ^^^^^^^ use of possibly-uninitialized `a`
+   |     ^^^^^^^ `a` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:22:5
    |
+LL |     let mut a: S<&&i32, &&i32>;
+   |         ----- binding declared here but left uninitialized
 LL |     a.x = &&0;
-   |     ^^^^^^^^^ use of possibly-uninitialized `a`
+   |     ^^^^^^^^^ `a` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:27:5
    |
+LL |     let mut a: S<i32, i32>;
+   |         ----- binding declared here but left uninitialized
 LL |     a.x = 0;
-   |     ^^^^^^^ use of possibly-uninitialized `a`
+   |     ^^^^^^^ `a` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
   --> $DIR/borrowck-uninit-ref-chain.rs:31:5
    |
+LL |     let mut a: S<&&i32, &&i32>;
+   |         ----- binding declared here but left uninitialized
 LL |     a.x = &&0;
-   |     ^^^^^^^^^ use of possibly-uninitialized `a`
+   |     ^^^^^^^^^ `a` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 7 previous errors
 
index 017b955a39535f289b112acad8416af6da502355..5d0ebabb00872a1abb46741eccfed0b8801a243c 100644 (file)
@@ -2,5 +2,5 @@
 
 fn main() {
     let x: isize;
-    foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
+    foo(x); //~ ERROR E0381
 }
index effc209e81659169224090527179ca7340e80e27..d5566691a820040fe1add7e4b3da896a84d8677d 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-uninit.rs:5:9
    |
+LL |     let x: isize;
+   |         - binding declared here but left uninitialized
 LL |     foo(x);
-   |         ^ use of possibly-uninitialized `x`
+   |         ^ `x` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 3cc71e7cece0e6964fd56b2fe3ad9f9f713fe3bc..bbe9f22aac307c68a4ad094d2eba035a0902f589 100644 (file)
@@ -10,8 +10,8 @@ fn main() {
     unsafe {
         let mut s: S;
         let mut u: U;
-        s.a = 0; //~ ERROR assign to part of possibly-uninitialized variable: `s`
-        u.a = 0; //~ ERROR assign to part of possibly-uninitialized variable: `u`
+        s.a = 0; //~ ERROR E0381
+        u.a = 0; //~ ERROR E0381
         let sa = s.a;
         let ua = u.a;
     }
index bd9ec5e579ca92ccc9ff87417f79563abebabccc..b7ff5f3955ee5885ce0c3b7eaf1a84b78c0c0aac 100644 (file)
@@ -1,14 +1,24 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
+error[E0381]: partially assigned binding `s` isn't fully initialized
   --> $DIR/borrowck-union-uninitialized.rs:13:9
    |
+LL |         let mut s: S;
+   |             ----- binding declared here but left uninitialized
+LL |         let mut u: U;
 LL |         s.a = 0;
-   |         ^^^^^^^ use of possibly-uninitialized `s`
+   |         ^^^^^^^ `s` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `u`
+error[E0381]: partially assigned binding `u` isn't fully initialized
   --> $DIR/borrowck-union-uninitialized.rs:14:9
    |
+LL |         let mut u: U;
+   |             ----- binding declared here but left uninitialized
+LL |         s.a = 0;
 LL |         u.a = 0;
-   |         ^^^^^^^ use of possibly-uninitialized `u`
+   |         ^^^^^^^ `u` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 2 previous errors
 
index d1b396aba8257f246497becd0632935cdcf2aba6..459cf1398b750e74ec49879b68a41ae7d2e6a0bf 100644 (file)
@@ -1,14 +1,18 @@
-error[E0381]: use of possibly-uninitialized variable: `w`
+error[E0381]: used binding `w` isn't initialized
   --> $DIR/borrowck-use-in-index-lvalue.rs:3:5
    |
+LL |     let w: &mut [isize];
+   |         - binding declared here but left uninitialized
 LL |     w[5] = 0;
-   |     ^^^^ use of possibly-uninitialized `*w`
+   |     ^^^^ `*w` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `w`
+error[E0381]: used binding `w` isn't initialized
   --> $DIR/borrowck-use-in-index-lvalue.rs:6:5
    |
+LL |     let mut w: &mut [isize];
+   |         ----- binding declared here but left uninitialized
 LL |     w[5] = 0;
-   |     ^^^^ use of possibly-uninitialized `*w`
+   |     ^^^^ `*w` used here but it isn't initialized
 
 error: aborting due to 2 previous errors
 
index ca5227c98c862b45a5f58ad899c7dc53be8afad8..942ed4fc6cabf172cc6451c98442f5b901876d83 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13
    |
+LL |     let x: &i32;
+   |         - binding declared here but left uninitialized
 LL |     let y = x as *const dyn Foo;
-   |             ^ use of possibly-uninitialized `*x`
+   |             ^ `*x` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 24897a0f2dc9c895f761a670085117026c38fc94..f3289e239818a7c445a0a162035791ffb613a461 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13
    |
+LL |     let x: &i32;
+   |         - binding declared here but left uninitialized
 LL |     let y = x as *const i32;
-   |             ^ use of possibly-uninitialized `*x`
+   |             ^ `*x` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 48e422147022171e5203ccb950b8a071750a8dff..7100b713031d2375d5111a5c773e6ef09ed1770e 100644 (file)
@@ -4,7 +4,7 @@ fn test(cond: bool) {
         v = 3;
         break;
     }
-    println!("{}", v); //~ ERROR borrow of possibly-uninitialized variable: `v`
+    println!("{}", v); //~ ERROR E0381
 }
 
 fn main() {
index fc144a066bb2777fe14784b24128c3d880fef2b0..44674febf4973b4c3929e779e62e4a8554a7947d 100644 (file)
@@ -1,8 +1,13 @@
-error[E0381]: borrow of possibly-uninitialized variable: `v`
+error[E0381]: used binding `v` is possibly-uninitialized
   --> $DIR/borrowck-while-break.rs:7:20
    |
+LL |     let v;
+   |         - binding declared here but left uninitialized
+LL |     while cond {
+   |           ---- if this condition isn't met and the `while` loop runs 0 times, `v` is not initialized
+...
 LL |     println!("{}", v);
-   |                    ^ use of possibly-uninitialized `v`
+   |                    ^ `v` used here but it is possibly-uninitialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index b3ec20711c12b32ad05433b0dc8ce99e7fcf18c7..62a9bdd2020559817e7e6bf8c2fca085cfcd7d9c 100644 (file)
@@ -1,4 +1,4 @@
 fn main() {
     let x: bool;
-    while x { } //~ ERROR use of possibly-uninitialized variable: `x`
+    while x { } //~ ERROR E0381
 }
index 92937a9c5730e6f1c8afe18bf50272486d3b313e..e41c1c55e6024365c46873574341244938fe0a19 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/borrowck-while-cond.rs:3:11
    |
+LL |     let x: bool;
+   |         - binding declared here but left uninitialized
 LL |     while x { }
-   |           ^ use of possibly-uninitialized `x`
+   |           ^ `x` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 6b3220c7d8591970e90a89cc7b211a1fe5bb7dc9..f49a778eb6bbeb38c3ff8fc496e4dbaa961d4b79 100644 (file)
@@ -1,7 +1,7 @@
 fn f() -> isize {
     let mut x: isize;
     while 1 == 1 { x = 10; }
-    return x; //~ ERROR use of possibly-uninitialized variable: `x`
+    return x; //~ ERROR E0381
 }
 
 fn main() { f(); }
index a1f8f64725dcdfcc06fcb5ebfde19c9dbdc6908d..c45235990c383c56783321d61b0e665adab05bf8 100644 (file)
@@ -1,8 +1,12 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` is possibly-uninitialized
   --> $DIR/borrowck-while.rs:4:12
    |
+LL |     let mut x: isize;
+   |         ----- binding declared here but left uninitialized
+LL |     while 1 == 1 { x = 10; }
+   |           ------ if this condition isn't met and the `while` loop runs 0 times, `x` is not initialized
 LL |     return x;
-   |            ^ use of possibly-uninitialized `x`
+   |            ^ `x` used here but it is possibly-uninitialized
 
 error: aborting due to previous error
 
index 7043cb3a164e78b012a6adc668aa188f9aded18d..17de40d5ba9674ae5e1646df36c8fd28305272e5 100644 (file)
@@ -4,19 +4,19 @@
 fn main() {
     let mut t: (u64, u64);
     t.0 = 1;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    //~^ ERROR E0381
     t.1 = 1;
 
     let mut t: (u64, u64);
     t.1 = 1;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    //~^ ERROR E0381
     t.0 = 1;
 
     let mut t: (u64, u64);
     t.0 = 1;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    //~^ ERROR E0381
 
     let mut t: (u64,);
     t.0 = 1;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    //~^ ERROR E0381
 }
index 8d5b39341c109dfaa329419775d04585e010db49..9a84c6fefae59681474f06d7cac4ecc4cb1c79e3 100644 (file)
@@ -1,26 +1,42 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/disallow-possibly-uninitialized.rs:6:5
    |
+LL |     let mut t: (u64, u64);
+   |         ----- binding declared here but left uninitialized
 LL |     t.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/disallow-possibly-uninitialized.rs:11:5
    |
+LL |     let mut t: (u64, u64);
+   |         ----- binding declared here but left uninitialized
 LL |     t.1 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/disallow-possibly-uninitialized.rs:16:5
    |
+LL |     let mut t: (u64, u64);
+   |         ----- binding declared here but left uninitialized
 LL |     t.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/disallow-possibly-uninitialized.rs:20:5
    |
+LL |     let mut t: (u64,);
+   |         ----- binding declared here but left uninitialized
 LL |     t.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 4 previous errors
 
index d6809ee4143b0dd1465b75b1a210f56106edb309..c419c5840d9a850689c2539025c85634c0b25929 100644 (file)
@@ -9,11 +9,11 @@ pub fn main() {
 pub fn foo1() {
     let x: i32;
     loop { x = break; }
-    println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+    println!("{}", x); //~ ERROR E0381
 }
 
 pub fn foo2() {
     let x: i32;
     for _ in 0..10 { x = continue; }
-    println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+    println!("{}", x); //~ ERROR E0381
 }
index e29cf7a1a7519bb8abde2c717b71416354e0b235..d436e8ff9096c1e7499ae356d27721d5b97c2975 100644 (file)
@@ -1,16 +1,22 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/issue-24267-flow-exit.rs:12:20
    |
+LL |     let x: i32;
+   |         - binding declared here but left uninitialized
+LL |     loop { x = break; }
 LL |     println!("{}", x);
-   |                    ^ use of possibly-uninitialized `x`
+   |                    ^ `x` used here but it isn't initialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/issue-24267-flow-exit.rs:18:20
    |
+LL |     let x: i32;
+   |         - binding declared here but left uninitialized
+LL |     for _ in 0..10 { x = continue; }
 LL |     println!("{}", x);
-   |                    ^ use of possibly-uninitialized `x`
+   |                    ^ `x` used here but it isn't initialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index a7c3b9eec73c5624cb94f2c1718ae4e81299720a..d98b3bae4e0b343f097e5c59d99b0d2c1b90a46b 100644 (file)
@@ -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:15]` contains a lifetime `'2`
+   |                   |     return type of closure `[closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:11]` 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`
index f031a144443b3e1d1d4ecade06cce7fb7c286cd4..205ea10c90bf066aef50651d8aeaade9e255b1e3 100644 (file)
@@ -10,7 +10,7 @@ fn main() {
     {
         let mut t: Tuple;
         t.0 = S(1);
-        //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+        //~^ ERROR E0381
         t.1 = 2;
         println!("{:?} {:?}", t.0, t.1);
     }
@@ -18,7 +18,7 @@ fn main() {
     {
         let mut u: Tpair;
         u.0 = S(1);
-        //~^ ERROR assign to part of possibly-uninitialized variable: `u` [E0381]
+        //~^ ERROR E0381
         u.1 = 2;
         println!("{:?} {:?}", u.0, u.1);
     }
@@ -26,7 +26,7 @@ fn main() {
     {
         let mut v: Spair;
         v.x = S(1);
-        //~^ ERROR assign to part of possibly-uninitialized variable: `v` [E0381]
+        //~^ ERROR E0381
         v.y = 2;
         println!("{:?} {:?}", v.x, v.y);
     }
index 22c6c3964edc1087dc55632dde661d71dd6bd05c..2a0eba396f144a5ae8ea47aff72c7904b06c4c0b 100644 (file)
@@ -1,20 +1,32 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:12:9
    |
+LL |         let mut t: Tuple;
+   |             ----- binding declared here but left uninitialized
 LL |         t.0 = S(1);
-   |         ^^^^^^^^^^ use of possibly-uninitialized `t`
+   |         ^^^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `u`
+error[E0381]: partially assigned binding `u` isn't fully initialized
   --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:20:9
    |
+LL |         let mut u: Tpair;
+   |             ----- binding declared here but left uninitialized
 LL |         u.0 = S(1);
-   |         ^^^^^^^^^^ use of possibly-uninitialized `u`
+   |         ^^^^^^^^^^ `u` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `v`
+error[E0381]: partially assigned binding `v` isn't fully initialized
   --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:28:9
    |
+LL |         let mut v: Spair;
+   |             ----- binding declared here but left uninitialized
 LL |         v.x = S(1);
-   |         ^^^^^^^^^^ use of possibly-uninitialized `v`
+   |         ^^^^^^^^^^ `v` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 3 previous errors
 
index 660d9e85ef54eb4ff7f51164370c7776f8c95ea6..50d0c40fdf6f5c03dcb869daf86f8f699e674875 100644 (file)
@@ -10,7 +10,7 @@ fn main() {
     {
         let t: Tuple;
         t.0 = S(1);
-        //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+        //~^ ERROR E0381
         t.1 = 2;
         println!("{:?} {:?}", t.0, t.1);
     }
@@ -18,7 +18,7 @@ fn main() {
     {
         let u: Tpair;
         u.0 = S(1);
-        //~^ ERROR assign to part of possibly-uninitialized variable: `u` [E0381]
+        //~^ ERROR E0381
         u.1 = 2;
         println!("{:?} {:?}", u.0, u.1);
     }
@@ -26,7 +26,7 @@ fn main() {
     {
         let v: Spair;
         v.x = S(1);
-        //~^ ERROR assign to part of possibly-uninitialized variable: `v` [E0381]
+        //~^ ERROR E0381
         v.y = 2;
         println!("{:?} {:?}", v.x, v.y);
     }
index 5f9c978c342f64231f85df79f73e180a2a0b8501..67a62583057f64e97e62661cbc67302a81290ed3 100644 (file)
@@ -1,20 +1,32 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/issue-54499-field-mutation-of-never-init.rs:12:9
    |
+LL |         let t: Tuple;
+   |             - binding declared here but left uninitialized
 LL |         t.0 = S(1);
-   |         ^^^^^^^^^^ use of possibly-uninitialized `t`
+   |         ^^^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `u`
+error[E0381]: partially assigned binding `u` isn't fully initialized
   --> $DIR/issue-54499-field-mutation-of-never-init.rs:20:9
    |
+LL |         let u: Tpair;
+   |             - binding declared here but left uninitialized
 LL |         u.0 = S(1);
-   |         ^^^^^^^^^^ use of possibly-uninitialized `u`
+   |         ^^^^^^^^^^ `u` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `v`
+error[E0381]: partially assigned binding `v` isn't fully initialized
   --> $DIR/issue-54499-field-mutation-of-never-init.rs:28:9
    |
+LL |         let v: Spair;
+   |             - binding declared here but left uninitialized
 LL |         v.x = S(1);
-   |         ^^^^^^^^^^ use of possibly-uninitialized `v`
+   |         ^^^^^^^^^^ `v` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 3 previous errors
 
index f8efa8c891eb3609e1339893ec2c7e1a9961256d..93ce34d2fe535e4364c1564212faf23803605cb2 100644 (file)
@@ -1,7 +1,7 @@
 fn main() {
     let e: i32;
     match e {
-        //~^ ERROR use of possibly-uninitialized variable
+        //~^ ERROR E0381
         ref u if true => {}
         ref v if true => {
             let tx = 0;
index 0eca447b5515994634735e8fb292ed60876d4ff3..f5d2eecfa91a300ea0f46cdaa8f9acf7f9b8a044 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `e`
+error[E0381]: used binding `e` isn't initialized
   --> $DIR/issue-62107-match-arm-scopes.rs:3:11
    |
+LL |     let e: i32;
+   |         - binding declared here but left uninitialized
 LL |     match e {
-   |           ^ use of possibly-uninitialized `e`
+   |           ^ `e` used here but it isn't initialized
 
 error: aborting due to previous error
 
index 29288be49341c50c5a259575ac8046290da509fe..1acabefb893e3ce43699981a2a4b04c30d03676f 100644 (file)
@@ -8,7 +8,7 @@ LL |     panic!()
    |     ^^^^^^^^
    |     |
    |     the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:12:5
-   |     inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL
+   |     inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL
    |
    = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index fd38ad7bb0a7f16d7be0ebd385026b3a64fa62b5..039575a8d79a5633b3e37c6f0273760a4289a8d8 100644 (file)
@@ -1,21 +1,17 @@
 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(|| {
-   |  ______________-
-LL | |
-LL | |         let _foo: String = val;
-   | |                            ^^^
-   | |                            |
-   | |                            move occurs because `val` has type `String`, which does not implement the `Copy` trait
-   | |                            help: consider borrowing here: `&val`
-LL | |
-LL | |
-LL | |     })
-   | |_____- captured by this `FnMut` closure
+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
+   |                            help: consider borrowing here: `&val`
 
 error: aborting due to previous error
 
index daded200bd9204f112d29cf03e7395ac25ad038f..c7b5d773e82595a125739be7af33f94079669e65 100644 (file)
@@ -8,7 +8,7 @@ LL |     panic!()
    |     ^^^^^^^^
    |     |
    |     the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:11:5
-   |     inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:31]>` at $SRC_DIR/std/src/panic.rs:LL:COL
+   |     inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28]>` at $SRC_DIR/std/src/panic.rs:LL:COL
    |
    = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index ce6a37ee418f92a1841718917742c38b14a5c6d1..f4bb895e6b5a07498d2fe12b615ccd4ddabe3802 100644 (file)
@@ -8,7 +8,7 @@ LL |     panic!()
    |     ^^^^^^^^
    |     |
    |     the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:11:5
-   |     inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL
+   |     inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL
    |
    = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index edab22569b34f7e6aef5a290d2c333e6f8ac2b3b..dd29ae492d604fa758dfc593df29f24f0f969942 100644 (file)
@@ -119,146 +119,112 @@ 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+LL |     fn_ref(|| {
+   |     ------ -- in this closure
+   |     |
+   |     expects `Fn` instead of `FnMut`
+LL |         x = (1,);
+   |         ^^^^^^^^ cannot assign
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+LL |     fn_ref(|| {
+   |     ------ -- in this closure
+   |     |
+   |     expects `Fn` instead of `FnMut`
+LL |         x = (1,);
+LL |         x.0 = 1;
+   |         ^^^^^^^ cannot assign
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(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_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
+LL |         &mut x;
+   |         ^^^^^^ cannot borrow as mutable
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(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_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
+LL |         &mut x.0;
+   |         ^^^^^^^^ cannot borrow as mutable
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+LL |     fn_ref(move || {
+   |     ------ ------- in this closure
+   |     |
+   |     expects `Fn` instead of `FnMut`
+LL |         x = (1,);
+   |         ^^^^^^^^ cannot assign
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+LL |     fn_ref(move || {
+   |     ------ ------- in this closure
+   |     |
+   |     expects `Fn` instead of `FnMut`
+LL |         x = (1,);
+LL |         x.0 = 1;
+   |         ^^^^^^^ cannot assign
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(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_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
+LL |         &mut x;
+   |         ^^^^^^ cannot borrow as mutable
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(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_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
+LL |         &mut x.0;
+   |         ^^^^^^^^ cannot borrow as mutable
 
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/mutability-errors.rs:54:5
index f09db378a75b4a671364e922a1a45fe601ba54a4..e6b25573e7040206944fde9fb1a55492b57df648 100644 (file)
@@ -1,14 +1,22 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/reassignment_immutable_fields.rs:7:5
    |
+LL |     let x: (u32, u32);
+   |         - binding declared here but left uninitialized
 LL |     x.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/reassignment_immutable_fields.rs:15:5
    |
+LL |     let x: (u32, u32);
+   |         - binding declared here but left uninitialized
 LL |     x.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 2 previous errors
 
index 0eae2c71e4a199313c223a017246797420c74d9f..a3885b5f5caea4593bcaf8df52d32a95cf7dd63d 100644 (file)
@@ -1,8 +1,12 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/reassignment_immutable_fields_overlapping.rs:12:5
    |
+LL |     let x: Foo;
+   |         - binding declared here but left uninitialized
 LL |     x.a = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable
   --> $DIR/reassignment_immutable_fields_overlapping.rs:13:5
index f55e1a27f475e9211e8ee789b413637017d12c12..49c81adad49373c788f0e80ad693b131490c3954 100644 (file)
@@ -7,11 +7,15 @@ LL |     x = (22, 44);
 LL |     x.0 = 1;
    |     ^^^^^^^ cannot assign
 
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/reassignment_immutable_fields_twice.rs:12:5
    |
+LL |     let x: (u32, u32);
+   |         - binding declared here but left uninitialized
 LL |     x.0 = 1;
-   |     ^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 2 previous errors
 
index 3ea7226200362c77be54afd1e5b56fd1f584691b..0c151b097077ec0475c6669fedf1fa9c8ffec71f 100644 (file)
@@ -1,17 +1,14 @@
 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:11:9
    |
-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<String>`, which does not implement the `Copy` trait
-LL | |
-LL | |     });
-   | |_____- captured by this `Fn` closure
+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<String>`, which does not implement the `Copy` trait
    |
 note: this function takes ownership of the receiver `self`, which moves `y`
   --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
index 0f288ffa95a872a0936fca437c765bbabb5ba0ec..69cf920de94786691213fda435a0813ac9220212 100644 (file)
@@ -6,14 +6,14 @@
 fn test1() {
     let x: !;
     let c1 = || match x { };
-    //~^ ERROR: use of possibly-uninitialized variable: `x`
+    //~^ ERROR E0381
 }
 
 // Should fake read the discriminant and throw an error
 fn test2() {
     let x: !;
     let c2 = || match x { _ => () };
-    //~^ ERROR: borrow of possibly-uninitialized variable: `x`
+    //~^ ERROR E0381
 }
 
 // Testing single variant patterns
@@ -25,7 +25,7 @@ enum SingleVariant {
 fn test3() {
     let variant: !;
     let c = || {
-    //~^ ERROR: borrow of possibly-uninitialized variable: `variant`
+    //~^ ERROR E0381
         match variant {
             SingleVariant::Points(_) => {}
         }
@@ -36,8 +36,7 @@ fn test3() {
 // Should fake read the discriminant and throw an error
 fn test4() {
     let variant: !;
-    let c = || {
-    //~^ ERROR: borrow of possibly-uninitialized variable: `variant`
+    let c = || { //~ ERROR E0381
         match variant {
             SingleVariant::Points(a) => {
                 println!("{:?}", a);
@@ -52,11 +51,9 @@ fn test5() {
     let g: !;
 
     let a = || {
-        match g { };
-        //~^ ERROR: use of possibly-uninitialized variable: `g`
+        match g { }; //~ ERROR E0381
         let c = ||  {
-            match t { };
-            //~^ ERROR: use of possibly-uninitialized variable: `t`
+            match t { }; //~ ERROR E0381
         };
 
         c();
@@ -68,7 +65,7 @@ fn test5() {
 fn test6() {
     let x: u8;
     let c1 = || match x { };
-    //~^ ERROR: use of possibly-uninitialized variable: `x`
+    //~^ ERROR E0381
     //~| ERROR: non-exhaustive patterns: type `u8` is non-empty
 }
 
index e55fb7ce4bbe9528a70b259251de935fda539d20..fea5441ec673d063a8bbc644ad2da440057042c8 100644 (file)
@@ -1,5 +1,5 @@
 error[E0004]: non-exhaustive patterns: type `u8` is non-empty
-  --> $DIR/pattern-matching-should-fail.rs:70:23
+  --> $DIR/pattern-matching-should-fail.rs:67:23
    |
 LL |     let c1 = || match x { };
    |                       ^
@@ -12,55 +12,70 @@ LL +         _ => todo!(),
 LL ~     };
    |
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/pattern-matching-should-fail.rs:8:23
    |
+LL |     let x: !;
+   |         - binding declared here but left uninitialized
 LL |     let c1 = || match x { };
-   |                       ^ use of possibly-uninitialized `x`
+   |                       ^ `x` used here but it isn't initialized
 
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/pattern-matching-should-fail.rs:15:14
    |
+LL |     let x: !;
+   |         - binding declared here but left uninitialized
 LL |     let c2 = || match x { _ => () };
    |              ^^       - borrow occurs due to use in closure
    |              |
-   |              use of possibly-uninitialized `x`
+   |              `x` used here but it isn't initialized
 
-error[E0381]: borrow of possibly-uninitialized variable: `variant`
+error[E0381]: used binding `variant` isn't initialized
   --> $DIR/pattern-matching-should-fail.rs:27:13
    |
+LL |     let variant: !;
+   |         ------- binding declared here but left uninitialized
 LL |     let c = || {
-   |             ^^ use of possibly-uninitialized `variant`
+   |             ^^ `variant` used here but it isn't initialized
 LL |
 LL |         match variant {
    |               ------- borrow occurs due to use in closure
 
-error[E0381]: borrow of possibly-uninitialized variable: `variant`
+error[E0381]: used binding `variant` isn't initialized
   --> $DIR/pattern-matching-should-fail.rs:39:13
    |
+LL |     let variant: !;
+   |         ------- binding declared here but left uninitialized
 LL |     let c = || {
-   |             ^^ use of possibly-uninitialized `variant`
-LL |
+   |             ^^ `variant` used here but it isn't initialized
 LL |         match variant {
    |               ------- borrow occurs due to use in closure
 
-error[E0381]: use of possibly-uninitialized variable: `g`
-  --> $DIR/pattern-matching-should-fail.rs:55:15
+error[E0381]: used binding `g` isn't initialized
+  --> $DIR/pattern-matching-should-fail.rs:54:15
    |
+LL |     let g: !;
+   |         - binding declared here but left uninitialized
+...
 LL |         match g { };
-   |               ^ use of possibly-uninitialized `g`
+   |               ^ `g` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `t`
-  --> $DIR/pattern-matching-should-fail.rs:58:19
+error[E0381]: used binding `t` isn't initialized
+  --> $DIR/pattern-matching-should-fail.rs:56:19
    |
+LL |     let t: !;
+   |         - binding declared here but left uninitialized
+...
 LL |             match t { };
-   |                   ^ use of possibly-uninitialized `t`
+   |                   ^ `t` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `x`
-  --> $DIR/pattern-matching-should-fail.rs:70:23
+error[E0381]: used binding `x` isn't initialized
+  --> $DIR/pattern-matching-should-fail.rs:67:23
    |
+LL |     let x: u8;
+   |         - binding declared here but left uninitialized
 LL |     let c1 = || match x { };
-   |                       ^ use of possibly-uninitialized `x`
+   |                       ^ `x` used here but it isn't initialized
 
 error: aborting due to 8 previous errors
 
index a3c43690f1f32450039efbc31cd0e0257d1db0be..d7104bafeb1d0e627b4bd982e0eefa61a44b4637 100644 (file)
@@ -2,7 +2,7 @@ error: changes to closure capture in Rust 2021 will affect which traits the clos
   --> $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`
+   |                   ^^^^^^^ 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`
@@ -26,7 +26,7 @@ error: changes to closure capture in Rust 2021 will affect which traits the clos
   --> $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`
index 675ba0313d73e59588fb28b916319f70ea0b775c..c611daf13fda49e7d15a95a444339265d98419b3 100644 (file)
@@ -2,14 +2,10 @@ warning: changes to closure capture in Rust 2021 will affect drop order
   --> $DIR/closure-body-macro-fragment.rs:16:17
    |
 LL |           let f = || $body;
-   |  _________________^
-LL | |
-LL | |         f();
-LL | |     }};
-   | |     - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure
-LL | |     ($body:block) => {{
-LL | |         m!(@ $body);
-   | |__________________^
+   |                   ^^
+...
+LL |       }};
+   |       - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure
 ...
 LL | /     m!({
 LL | |
index 5046a4bcbb4b37fa009b59c965cc11eb93ecbc36..2d0c56aad8d6289361824ed42b9e7bb457b2b0cd 100644 (file)
@@ -2,9 +2,7 @@ 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
index 3589a6150d064b8e74731e0be1b8161eb45a7415..12760cc7256c91fa8ded5750079fde9592d62e0d 100644 (file)
@@ -26,9 +26,7 @@ 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
index fa6082cbb59b4c3c649b72692d23517eb2a6f9a3..96d5c936fa593bd05f38bf924e7f4f7b9450168d 100644 (file)
@@ -92,7 +92,7 @@ error: changes to closure capture in Rust 2021 will affect which traits the clos
   --> $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`
index fa1f83c37823f5e55f356904f81201cbef636ea6..0d9f09ee354edaddcefd8d29fba22480b0d2da3a 100644 (file)
@@ -199,9 +199,7 @@ 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
index cbc4e2e52315fe496cc687d3f42ce452e22b11f2..1086cfa2947a9ae3fb15adda6500f5b1fd7a88b7 100644 (file)
@@ -9,12 +9,8 @@ LL |     let t = thread::spawn(|| {
 note: required because it's used within this closure
   --> $DIR/closure-move-sync.rs:6:27
    |
-LL |       let t = thread::spawn(|| {
-   |  ___________________________^
-LL | |         recv.recv().unwrap();
-LL | |
-LL | |     });
-   | |_____^
+LL |     let t = thread::spawn(|| {
+   |                           ^^
 note: required by a bound in `spawn`
   --> $SRC_DIR/std/src/thread/mod.rs:LL:COL
    |
@@ -33,7 +29,7 @@ note: required because it's used within this closure
   --> $DIR/closure-move-sync.rs:18:19
    |
 LL |     thread::spawn(|| tx.send(()).unwrap());
-   |                   ^^^^^^^^^^^^^^^^^^^^^^^
+   |                   ^^
 note: required by a bound in `spawn`
   --> $SRC_DIR/std/src/thread/mod.rs:LL:COL
    |
index 2b53802fea793366b9b228d51e86e16d1eb261d7..eab7482e6c4a1817606f72e1e754b7e3ab7730ee 100644 (file)
@@ -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:50]`
+                 found closure `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:36]`
 note: closures can only be coerced to `fn` types if they do not capture any variables
   --> $DIR/closure-no-fn-1.rs:6:39
    |
index ed9f87a2c94a8cc5807f07b61a966aabe34e840f..e1f0143abfe0aa3d01c7b61df22f4c66cb46783f 100644 (file)
@@ -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:35]`
+                 found closure `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:29]`
 note: closures can only be coerced to `fn` types if they do not capture any variables
   --> $DIR/closure-no-fn-2.rs:6:32
    |
index 95683a786ba6a278824b6d2b468e7170559a67f4..6009389b1bb2c5739d90d8b264a3591562eedf5e 100644 (file)
@@ -1,4 +1,4 @@
-error[E0605]: non-primitive cast: `[closure@$DIR/closure-no-fn-3.rs:6:27: 6:37]` as `fn() -> u8`
+error[E0605]: non-primitive cast: `[closure@$DIR/closure-no-fn-3.rs:6:28: 6:30]` as `fn() -> u8`
   --> $DIR/closure-no-fn-3.rs:6:27
    |
 LL |     let baz: fn() -> u8 = (|| { b }) as fn() -> u8;
index 89798ec5dd34f4d947c829d8d1f32b805d297a14..d1b7048841a42208cbecf55646179538b478bea3 100644 (file)
@@ -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:27]`
+                 found closure `[closure@$DIR/closure-no-fn-4.rs:5:18: 5:21]`
 note: closures can only be coerced to `fn` types if they do not capture any variables
   --> $DIR/closure-no-fn-4.rs:5:26
    |
index 1f373f10489e634fbf44ce5118f806a3ebfa24fd..a33b847ea92d9ad65a80f598480476bcf1229356 100644 (file)
@@ -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:47]`
+                 found closure `[closure@$DIR/closure-no-fn-5.rs:10:27: 10:29]`
 note: closures can only be coerced to `fn` types if they do not capture any variables
   --> $DIR/closure-no-fn-5.rs:10:32
    |
index 534828ab348fd32e09ba5d6b0583698272329c4b..9dfff8499fdddf4fe4e771893fb801fbacd177fc 100644 (file)
@@ -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<'r> fn(&'r str)`
-                 found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50]`
+                 found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:22]`
 note: closures can only be coerced to `fn` types if they do not capture any variables
   --> $DIR/closure-reform-bad.rs:10:43
    |
index 65026128ae62226a02f5f49ebddb4d3effb38575..35caf71a5e8c78446b58da82bc2db3dc91d7569b 100644 (file)
@@ -2,9 +2,8 @@ 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
index e25b33bbcdb06d2713f7d1d48118a686917e03d4..ca8a43328a9e40fe3ea1cec4344fa4262bf2f01f 100644 (file)
@@ -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:43]`
+              found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:22]`
 
 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:37]`
+   | |                this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22]`
 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:37]`
-              found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:43]`
+   = 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: 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:43]`
+   | |                this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22]`
 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:43]`
-              found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:37]`
+   = 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: 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:43]`
+   | |                this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22]`
 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:43]`
-              found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:43]`
+   = 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: no two closures, even if identical, have the same type
    = help: consider boxing your closure and/or using it as a trait object
 
index 43a12f675f562578e88b085cd2d62cf8a7108bbd..b21734f02576701d58ae445e38675f579384edc5 100644 (file)
@@ -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: 14:6]`, which does not implement the `Copy` trait
+   |         - move occurs because `c` has type `[closure@$DIR/closure-print-generic-1.rs:12:24: 12:31]`, which does not implement the `Copy` trait
 ...
 LL |     c();
    |     --- `c` moved due to this call
index 9c75d5a9023edfea217c65d6fcb92912c28f7a83..e53277a9396f3fcab31717fdb34e45c8ee0184a2 100644 (file)
@@ -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:43]`
+                found closure `[closure@$DIR/closure-print-generic-2.rs:5:17: 5:19]`
 help: use parentheses to call this closure
    |
 LL |         let c1: () = c();
index aee782a1c5b8529bbd1b95747c55a05c031d975b..ff89dd340349b81ef11f9e0a720c8f790923b8bf 100644 (file)
@@ -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
    |                  |
index 6a994ce718eac75e4d6515ef2c2e36c93a6641f2..5bbf84f963d7e5ece9340f483a76c268ad907afc 100644 (file)
@@ -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
    |                  |
index f0109f22a2bc1ceef918fe21fb487582aa07617e..9d614e610ad86fd1fedabd237d7b149804c9d95f 100644 (file)
@@ -32,7 +32,7 @@ LL |     let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>;
    |             ^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure
    |
    = note: expected struct `Box<dyn Fn(i32) -> u8>`
-              found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`
+              found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:22]>`
 
 error[E0308]: mismatched types
   --> $DIR/coerce-expect-unsized-ascribed.rs:14:13
@@ -86,7 +86,7 @@ LL |     let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _;
    |             ^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure
    |
    = note: expected reference `&dyn Fn(i32) -> u8`
-              found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`
+              found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:19]`
 
 error[E0308]: mismatched types
   --> $DIR/coerce-expect-unsized-ascribed.rs:22:13
@@ -122,7 +122,7 @@ LL |     let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>;
    |             ^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure
    |
    = note: expected struct `Box<dyn Fn(i32) -> u8>`
-              found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`
+              found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:25]>`
 
 error: aborting due to 14 previous errors
 
index a6d4e80a50c05c2ff564b42d0dfc8d887cee1dff..1c9a6847ceb4f5c96f64bfdf7f19393f965e82e3 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `closure` found for struct `Obj` in the current sc
   --> $DIR/issue-18343.rs:7:7
    |
 LL | struct Obj<F> where F: FnMut() -> u32 {
-   |        --- method `closure` not found for this struct
+   | ------------- method `closure` not found for this struct
 ...
 LL |     o.closure();
    |       ^^^^^^^ field, not a method
index 795d0e286b3d3e60a7f69b56edf0cfc06c1827f1..440fbb27c0040ef1bea903cecd3856c8fee1d33f 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `closure` found for struct `Obj` in the current sc
   --> $DIR/issue-2392.rs:36:15
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
-   |        --- method `closure` not found for this struct
+   | ------------- method `closure` not found for this struct
 ...
 LL |     o_closure.closure();
    |               ^^^^^^^ field, not a method
@@ -16,7 +16,7 @@ error[E0599]: no method named `not_closure` found for struct `Obj` in the curren
   --> $DIR/issue-2392.rs:38:15
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
-   |        --- method `not_closure` not found for this struct
+   | ------------- method `not_closure` not found for this struct
 ...
 LL |     o_closure.not_closure();
    |               ^^^^^^^^^^^-- help: remove the arguments
@@ -27,7 +27,7 @@ error[E0599]: no method named `closure` found for struct `Obj` in the current sc
   --> $DIR/issue-2392.rs:42:12
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
-   |        --- method `closure` not found for this struct
+   | ------------- method `closure` not found for this struct
 ...
 LL |     o_func.closure();
    |            ^^^^^^^ field, not a method
@@ -41,7 +41,7 @@ error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the
   --> $DIR/issue-2392.rs:45:14
    |
 LL | struct BoxedObj {
-   |        -------- method `boxed_closure` not found for this struct
+   | --------------- method `boxed_closure` not found for this struct
 ...
 LL |     boxed_fn.boxed_closure();
    |              ^^^^^^^^^^^^^ field, not a method
@@ -55,7 +55,7 @@ error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the
   --> $DIR/issue-2392.rs:48:19
    |
 LL | struct BoxedObj {
-   |        -------- method `boxed_closure` not found for this struct
+   | --------------- method `boxed_closure` not found for this struct
 ...
 LL |     boxed_closure.boxed_closure();
    |                   ^^^^^^^^^^^^^ field, not a method
@@ -69,7 +69,7 @@ error[E0599]: no method named `closure` found for struct `Obj` in the current sc
   --> $DIR/issue-2392.rs:53:12
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
-   |        --- method `closure` not found for this struct
+   | ------------- method `closure` not found for this struct
 ...
 LL |     w.wrap.closure();
    |            ^^^^^^^ field, not a method
@@ -83,7 +83,7 @@ error[E0599]: no method named `not_closure` found for struct `Obj` in the curren
   --> $DIR/issue-2392.rs:55:12
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
-   |        --- method `not_closure` not found for this struct
+   | ------------- method `not_closure` not found for this struct
 ...
 LL |     w.wrap.not_closure();
    |            ^^^^^^^^^^^-- help: remove the arguments
@@ -94,7 +94,7 @@ error[E0599]: no method named `closure` found for struct `Obj` in the current sc
   --> $DIR/issue-2392.rs:58:24
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
-   |        --- method `closure` not found for this struct
+   | ------------- method `closure` not found for this struct
 ...
 LL |     check_expression().closure();
    |                        ^^^^^^^ field, not a method
@@ -108,7 +108,7 @@ error[E0599]: no method named `f1` found for struct `FuncContainer` in the curre
   --> $DIR/issue-2392.rs:64:31
    |
 LL | struct FuncContainer {
-   |        ------------- method `f1` not found for this struct
+   | -------------------- method `f1` not found for this struct
 ...
 LL |             (*self.container).f1(1);
    |                               ^^ field, not a method
@@ -122,7 +122,7 @@ error[E0599]: no method named `f2` found for struct `FuncContainer` in the curre
   --> $DIR/issue-2392.rs:65:31
    |
 LL | struct FuncContainer {
-   |        ------------- method `f2` not found for this struct
+   | -------------------- method `f2` not found for this struct
 ...
 LL |             (*self.container).f2(1);
    |                               ^^ field, not a method
@@ -136,7 +136,7 @@ error[E0599]: no method named `f3` found for struct `FuncContainer` in the curre
   --> $DIR/issue-2392.rs:66:31
    |
 LL | struct FuncContainer {
-   |        ------------- method `f3` not found for this struct
+   | -------------------- method `f3` not found for this struct
 ...
 LL |             (*self.container).f3(1);
    |                               ^^ field, not a method
index cad2697b52e927c87d06ded4b61fd652664883aa..4b96bce8d2e82d3b0a09f8f18db8b2af86169b91 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `example` found for struct `Example` in the curren
   --> $DIR/issue-32128.rs:12:10
    |
 LL | struct Example {
-   |        ------- method `example` not found for this struct
+   | -------------- method `example` not found for this struct
 ...
 LL |     demo.example(1);
    |          ^^^^^^^ field, not a method
index 7c2e6b015330f74315037981166a3d5e34650338..34debb6831734568330e7b6d8ccfaa32ae753e3f 100644 (file)
@@ -1,4 +1,4 @@
-error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
+error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:45]>` in the current scope
   --> $DIR/issue-33784.rs:27:7
    |
 LL |     p.closure();
@@ -9,7 +9,7 @@ help: to call the function stored in `closure`, surround the field access with p
 LL |     (p.closure)();
    |     +         +
 
-error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
+error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:45]>` in the current scope
   --> $DIR/issue-33784.rs:29:7
    |
 LL |     q.fn_ptr();
index 9e2f245597a4527931e3b168d609b6db354e831f..783378f8db58d67a225100c9eb121febee2f3a75 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `dog_age` found for struct `Dog` in the current sc
   --> $DIR/private-field.rs:16:23
    |
 LL |     pub struct Dog {
-   |                --- method `dog_age` not found for this struct
+   |     -------------- method `dog_age` not found for this struct
 ...
 LL |     let dog_age = dog.dog_age();
    |                       ^^^^^^^ private field, not a method
index bb5a2f1766f1b806a8fe1d325e123226baa33091..e64adacac9fd26ad6ac1c08240d352a41f704a07 100644 (file)
@@ -1,6 +1,5 @@
 struct X<const N: usize = {
-    let s: &'static str; s.len()
-    //~^ ERROR borrow of possibly-uninitialized variable
+    let s: &'static str; s.len() //~ ERROR E0381
 }>;
 
 fn main() {}
index 6c25019b0ceb367ad8b1ee8f45c482a318d095d9..c62f1d1d230617f86f1a35f540ca06e26ca03027 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: borrow of possibly-uninitialized variable: `s`
+error[E0381]: used binding `s` isn't initialized
   --> $DIR/const-generic-default-wont-borrowck.rs:2:26
    |
 LL |     let s: &'static str; s.len()
-   |                          ^^^^^^^ use of possibly-uninitialized `*s`
+   |         -                ^^^^^^^ `*s` used here but it isn't initialized
+   |         |
+   |         binding declared here but left uninitialized
 
 error: aborting due to previous error
 
index 576d037f3393d73f6c21e26c06a315198eeac882..77a3b77ad428b32b345f9edaeb0a263808a5d93e 100644 (file)
@@ -8,7 +8,7 @@ error[E0599]: the function or associated item `foo` exists for struct `Foo<{_: u
   --> $DIR/issue-69654.rs:17:10
    |
 LL | struct Foo<const N: usize> {}
-   |        --- function or associated item `foo` not found for this struct
+   | -------------------------- function or associated item `foo` not found for this struct
 ...
 LL |     Foo::foo();
    |          ^^^ function or associated item cannot be called on `Foo<{_: usize}>` due to unsatisfied trait bounds
index 7bfc09387b8a7f64c419fea9a4a89a044d76f69a..1b502642eb7d03f12f881017b5547aa13c8b51da 100644 (file)
@@ -16,7 +16,7 @@ error[E0599]: the function or associated item `new` exists for struct `Inline<dy
   --> $DIR/issue-80742.rs:30:36
    |
 LL | struct Inline<T>
-   |        ------ function or associated item `new` not found for this struct
+   | ---------------- function or associated item `new` not found for this struct
 ...
 LL |     let dst = Inline::<dyn Debug>::new(0);
    |                                    ^^^ function or associated item cannot be called on `Inline<dyn Debug>` due to unsatisfied trait bounds
index ab53d6cf09a744cf598208672a74524591e0d0aa..b1b359619dcfabb83144f4b2f563f4bef0f6d7b6 100644 (file)
@@ -16,7 +16,7 @@ error[E0599]: no method named `f` found for struct `S` in the current scope
   --> $DIR/invalid-const-arg-for-type-param.rs:9:7
    |
 LL | struct S;
-   |        - method `f` not found for this struct
+   | -------- method `f` not found for this struct
 ...
 LL |     S.f::<0>();
    |       ^ method not found in `S`
diff --git a/src/test/ui/const-generics/issue-70408.rs b/src/test/ui/const-generics/issue-70408.rs
new file mode 100644 (file)
index 0000000..f7557cb
--- /dev/null
@@ -0,0 +1,13 @@
+// build-pass
+
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
+
+pub fn function_with_bytes<const BYTES: &'static [u8; 4]>() -> &'static [u8] {
+    BYTES
+}
+
+pub fn main() {
+    assert_eq!(function_with_bytes::<b"AAAA">(), &[0x41, 0x41, 0x41, 0x41]);
+    assert_eq!(function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>(), b"AAAA");
+}
diff --git a/src/test/ui/const-generics/issue-80471.rs b/src/test/ui/const-generics/issue-80471.rs
new file mode 100644 (file)
index 0000000..d0af8a5
--- /dev/null
@@ -0,0 +1,13 @@
+#![feature(adt_const_params)]
+//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+
+#[derive(PartialEq, Eq)]
+enum Nat {
+    Z,
+    S(Box<Nat>),
+}
+
+fn foo<const N: Nat>() {}
+//~^ ERROR `Box<Nat>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
+
+fn main() {}
diff --git a/src/test/ui/const-generics/issue-80471.stderr b/src/test/ui/const-generics/issue-80471.stderr
new file mode 100644 (file)
index 0000000..dbcc0b7
--- /dev/null
@@ -0,0 +1,18 @@
+warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/issue-80471.rs:1:12
+   |
+LL | #![feature(adt_const_params)]
+   |            ^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
+
+error[E0741]: `Box<Nat>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
+  --> $DIR/issue-80471.rs:10:17
+   |
+LL | fn foo<const N: Nat>() {}
+   |                 ^^^
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0741`.
index 4399db11665629c9e9baa43fbc27507552255df2..0874a70ce392e3cda3790ce66c3365d2089c39a5 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `assert` found for struct `Bo
   --> $DIR/const-needs_drop-monomorphic.rs:11:46
    |
 LL | struct Bool<const B: bool> {}
-   |        ---- function or associated item `assert` not found for this struct
+   | -------------------------- function or associated item `assert` not found for this struct
 ...
 LL |     Bool::<{ std::mem::needs_drop::<T>() }>::assert();
    |                                              ^^^^^^ function or associated item cannot be called on `Bool<{ std::mem::needs_drop::<T>() }>` due to unsatisfied trait bounds
index b85e612992549fdd3f78eded1cb9fc4dca92b83d..82d2d7c21d859e87ada14ab3df1f97b6d42f97a6 100644 (file)
@@ -1,6 +1,6 @@
 const FOO: *const u32 = {
     let x;
-    &x //~ ERROR borrow of possibly-uninitialized variable: `x`
+    &x //~ ERROR E0381
 };
 
 fn main() {
index 734266a3453b580d2204657d1677d9635334417d..f5b1123e7f3431340f5d3773ba9cff0bc5799cf5 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/issue-78655.rs:3:5
    |
+LL |     let x;
+   |         - binding declared here but left uninitialized
 LL |     &x
-   |     ^^ use of possibly-uninitialized `x`
+   |     ^^ `x` used here but it isn't initialized
 
 error: could not evaluate constant pattern
   --> $DIR/issue-78655.rs:7:9
index 3909862ff1c8bfea413db2eab4c3347b47142ab1..128087f1e375522297267296a093509774bb30e1 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for struct `Foo` in the current scop
   --> $DIR/copy-a-resource.rs:18:16
    |
 LL | struct Foo {
-   |        --- method `clone` not found for this struct
+   | ---------- method `clone` not found for this struct
 ...
 LL |     let _y = x.clone();
    |                ^^^^^ method not found in `Foo`
index 60bfbe94a8a8b7055ad4ad41e64842e2a50e63cb..cfe1e62d9318fd59b605b917215d27f02dfe6087 100644 (file)
@@ -16,12 +16,6 @@ error: no path from `WillChange` to `trait_def`
 LL |     #[rustc_then_this_would_need(trait_def)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: OK
-  --> $DIR/dep-graph-struct-signature.rs:32:9
-   |
-LL |         #[rustc_then_this_would_need(fn_sig)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: OK
   --> $DIR/dep-graph-struct-signature.rs:36:5
    |
@@ -52,36 +46,12 @@ error: OK
 LL |     #[rustc_then_this_would_need(type_of)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: OK
-  --> $DIR/dep-graph-struct-signature.rs:48:9
-   |
-LL |         #[rustc_then_this_would_need(fn_sig)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: OK
-  --> $DIR/dep-graph-struct-signature.rs:49:9
-   |
-LL |         #[rustc_then_this_would_need(typeck)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: OK
   --> $DIR/dep-graph-struct-signature.rs:53:5
    |
 LL |     #[rustc_then_this_would_need(type_of)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: OK
-  --> $DIR/dep-graph-struct-signature.rs:55:9
-   |
-LL |         #[rustc_then_this_would_need(fn_sig)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: OK
-  --> $DIR/dep-graph-struct-signature.rs:56:9
-   |
-LL |         #[rustc_then_this_would_need(typeck)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: OK
   --> $DIR/dep-graph-struct-signature.rs:61:9
    |
@@ -106,12 +76,6 @@ error: no path from `WillChange` to `type_of`
 LL |     #[rustc_then_this_would_need(type_of)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: no path from `WillChange` to `fn_sig`
-  --> $DIR/dep-graph-struct-signature.rs:77:9
-   |
-LL |         #[rustc_then_this_would_need(fn_sig)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: no path from `WillChange` to `fn_sig`
   --> $DIR/dep-graph-struct-signature.rs:81:5
    |
@@ -130,5 +94,41 @@ error: no path from `WillChange` to `typeck`
 LL |     #[rustc_then_this_would_need(typeck)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:32:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `fn_sig`
+  --> $DIR/dep-graph-struct-signature.rs:77:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:48:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:49:9
+   |
+LL |         #[rustc_then_this_would_need(typeck)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:55:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:56:9
+   |
+LL |         #[rustc_then_this_would_need(typeck)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 error: aborting due to 22 previous errors
 
index c59cf8014c3d1dfe69a5b9117c2d211b1ac96e63..42ac803b22ece2b36eb37d65231a6320430da7f1 100644 (file)
@@ -28,30 +28,12 @@ error: no path from `TypeAlias` to `type_of`
 LL | #[rustc_then_this_would_need(type_of)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: OK
-  --> $DIR/dep-graph-type-alias.rs:36:5
-   |
-LL |     #[rustc_then_this_would_need(fn_sig)]
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: no path from `TypeAlias` to `type_of`
   --> $DIR/dep-graph-type-alias.rs:42:1
    |
 LL | #[rustc_then_this_would_need(type_of)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: OK
-  --> $DIR/dep-graph-type-alias.rs:44:5
-   |
-LL |     #[rustc_then_this_would_need(fn_sig)]
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: OK
-  --> $DIR/dep-graph-type-alias.rs:45:5
-   |
-LL |     #[rustc_then_this_would_need(typeck)]
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: OK
   --> $DIR/dep-graph-type-alias.rs:49:1
    |
@@ -70,5 +52,23 @@ error: OK
 LL | #[rustc_then_this_would_need(typeck)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:36:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:44:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:45:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 error: aborting due to 12 previous errors
 
index 55847aeec559f05012a5020eb97f9f1b20d166ce..c4fddcf5f2468e509db54676801735e274c27d2a 100644 (file)
@@ -3,8 +3,8 @@ error[E0599]: the method `clone` exists for struct `Bar<NotClone>`, but its trai
    |
 LL | struct Bar<T: Foo> {
    | ------------------
-   | |      |
-   | |      method `clone` not found for this struct
+   | |
+   | method `clone` not found for this struct
    | doesn't satisfy `Bar<NotClone>: Clone`
 ...
 LL | struct NotClone;
index 5b4feaeb52a329cb3f00a1b335021b7f678e7a5b..fbd48336d9126532ee6eb55e115deb088bd22cba 100644 (file)
@@ -37,7 +37,7 @@ LL | pub struct NoDerives;
    | -------------------- doesn't satisfy `NoDerives: Clone`
 ...
 LL | struct Object<T, A>(T, A);
-   |        ------ method `use_clone` not found for this struct
+   | ------------------- method `use_clone` not found for this struct
 ...
 LL |     foo.use_clone();
    |         ^^^^^^^^^ method cannot be called on `Object<NoDerives, SomeDerives>` due to unsatisfied trait bounds
index 3608052e2ffcfb5bdb9e0a14c38a95b92dc8d21b..12be269565da1233aa52cadb950d9a8d4f78278e 100644 (file)
@@ -25,7 +25,7 @@ LL | pub struct NoDerives;
    | -------------------- doesn't satisfy `NoDerives: Eq`
 LL |
 LL | struct Object<T>(T);
-   |        ------ method `use_eq` not found for this struct
+   | ---------------- method `use_eq` not found for this struct
 ...
 LL |     foo.use_eq();
    |         ^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
@@ -44,7 +44,7 @@ LL | pub struct NoDerives;
    | -------------------- doesn't satisfy `NoDerives: Ord`
 LL |
 LL | struct Object<T>(T);
-   |        ------ method `use_ord` not found for this struct
+   | ---------------- method `use_ord` not found for this struct
 ...
 LL |     foo.use_ord();
    |         ^^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
@@ -66,7 +66,7 @@ LL | pub struct NoDerives;
    | doesn't satisfy `NoDerives: PartialOrd`
 LL |
 LL | struct Object<T>(T);
-   |        ------ method `use_ord_and_partial_ord` not found for this struct
+   | ---------------- method `use_ord_and_partial_ord` not found for this struct
 ...
 LL |     foo.use_ord_and_partial_ord();
    |         ^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
index 028ed9c230524dc88ac717c8962b1b13a620812c..1a651b2074c59ee1292a03e2a74f51566b250a0d 100644 (file)
@@ -39,6 +39,16 @@ struct Big {
 #[repr(packed)]
 struct Packed(u32);
 
+// An empty enum.
+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
+enum Enum0 {}
+
+// A single-variant enum.
+#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
+enum Enum1 {
+    Single { x: u32 }
+}
+
 // A C-like, fieldless enum.
 #[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
 enum Fieldless {
@@ -66,3 +76,11 @@ enum Fielded {
     Y(bool),
     Z(Option<i32>),
 }
+
+// A union. Most builtin traits are not derivable for unions.
+#[derive(Clone, Copy)]
+pub union Union {
+    pub b: bool,
+    pub u: u32,
+    pub i: i32,
+}
index c24ed4237b8ee0fbc2ddf42c2d6f4aab6ca57fff..9b10192d75a132b8bd550b9d26ec1c5547a39a6d 100644 (file)
@@ -28,7 +28,7 @@ struct Empty;
 #[allow(unused_qualifications)]
 impl ::core::clone::Clone for Empty {
     #[inline]
-    fn clone(&self) -> Empty { { *self } }
+    fn clone(&self) -> Empty { *self }
 }
 #[automatically_derived]
 #[allow(unused_qualifications)]
@@ -49,7 +49,7 @@ impl ::core::default::Default for Empty {
 #[automatically_derived]
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Empty {
-    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { {} }
+    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
 }
 impl ::core::marker::StructuralPartialEq for Empty {}
 #[automatically_derived]
@@ -65,7 +65,7 @@ impl ::core::cmp::Eq for Empty {
     #[inline]
     #[doc(hidden)]
     #[no_coverage]
-    fn assert_receiver_is_total_eq(&self) -> () { {} }
+    fn assert_receiver_is_total_eq(&self) -> () {}
 }
 #[automatically_derived]
 #[allow(unused_qualifications)]
@@ -95,11 +95,8 @@ struct Point {
 impl ::core::clone::Clone for Point {
     #[inline]
     fn clone(&self) -> Point {
-        {
-            let _: ::core::clone::AssertParamIsClone<u32>;
-            let _: ::core::clone::AssertParamIsClone<u32>;
-            *self
-        }
+        let _: ::core::clone::AssertParamIsClone<u32>;
+        *self
     }
 }
 #[automatically_derived]
@@ -128,10 +125,8 @@ impl ::core::default::Default for Point {
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Point {
     fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-        {
-            ::core::hash::Hash::hash(&self.x, state);
-            ::core::hash::Hash::hash(&self.y, state)
-        }
+        ::core::hash::Hash::hash(&self.x, state);
+        ::core::hash::Hash::hash(&self.y, state)
     }
 }
 impl ::core::marker::StructuralPartialEq for Point {}
@@ -155,10 +150,7 @@ impl ::core::cmp::Eq for Point {
     #[doc(hidden)]
     #[no_coverage]
     fn assert_receiver_is_total_eq(&self) -> () {
-        {
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-        }
+        let _: ::core::cmp::AssertParamIsEq<u32>;
     }
 }
 #[automatically_derived]
@@ -169,13 +161,7 @@ impl ::core::cmp::PartialOrd for Point {
         -> ::core::option::Option<::core::cmp::Ordering> {
         match ::core::cmp::PartialOrd::partial_cmp(&self.x, &other.x) {
             ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
-                match ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y)
-                    {
-                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                        =>
-                        ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                    cmp => cmp,
-                },
+                ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y),
             cmp => cmp,
         }
     }
@@ -187,11 +173,7 @@ impl ::core::cmp::Ord for Point {
     fn cmp(&self, other: &Point) -> ::core::cmp::Ordering {
         match ::core::cmp::Ord::cmp(&self.x, &other.x) {
             ::core::cmp::Ordering::Equal =>
-                match ::core::cmp::Ord::cmp(&self.y, &other.y) {
-                    ::core::cmp::Ordering::Equal =>
-                        ::core::cmp::Ordering::Equal,
-                    cmp => cmp,
-                },
+                ::core::cmp::Ord::cmp(&self.y, &other.y),
             cmp => cmp,
         }
     }
@@ -229,15 +211,13 @@ impl ::core::clone::Clone for Big {
 #[allow(unused_qualifications)]
 impl ::core::fmt::Debug for Big {
     fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-        {
-            let names: &'static _ =
-                &["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8"];
-            let values: &[&dyn ::core::fmt::Debug] =
-                &[&&self.b1, &&self.b2, &&self.b3, &&self.b4, &&self.b5,
-                            &&self.b6, &&self.b7, &&self.b8];
-            ::core::fmt::Formatter::debug_struct_fields_finish(f, "Big",
-                names, values)
-        }
+        let names: &'static _ =
+            &["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8"];
+        let values: &[&dyn ::core::fmt::Debug] =
+            &[&&self.b1, &&self.b2, &&self.b3, &&self.b4, &&self.b5,
+                        &&self.b6, &&self.b7, &&self.b8];
+        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Big", names,
+            values)
     }
 }
 #[automatically_derived]
@@ -261,16 +241,14 @@ impl ::core::default::Default for Big {
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Big {
     fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-        {
-            ::core::hash::Hash::hash(&self.b1, state);
-            ::core::hash::Hash::hash(&self.b2, state);
-            ::core::hash::Hash::hash(&self.b3, state);
-            ::core::hash::Hash::hash(&self.b4, state);
-            ::core::hash::Hash::hash(&self.b5, state);
-            ::core::hash::Hash::hash(&self.b6, state);
-            ::core::hash::Hash::hash(&self.b7, state);
-            ::core::hash::Hash::hash(&self.b8, state)
-        }
+        ::core::hash::Hash::hash(&self.b1, state);
+        ::core::hash::Hash::hash(&self.b2, state);
+        ::core::hash::Hash::hash(&self.b3, state);
+        ::core::hash::Hash::hash(&self.b4, state);
+        ::core::hash::Hash::hash(&self.b5, state);
+        ::core::hash::Hash::hash(&self.b6, state);
+        ::core::hash::Hash::hash(&self.b7, state);
+        ::core::hash::Hash::hash(&self.b8, state)
     }
 }
 impl ::core::marker::StructuralPartialEq for Big {}
@@ -300,16 +278,7 @@ impl ::core::cmp::Eq for Big {
     #[doc(hidden)]
     #[no_coverage]
     fn assert_receiver_is_total_eq(&self) -> () {
-        {
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-        }
+        let _: ::core::cmp::AssertParamIsEq<u32>;
     }
 }
 #[automatically_derived]
@@ -344,13 +313,7 @@ impl ::core::cmp::PartialOrd for Big {
                                                                 &other.b7) {
                                                             ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                                                                 =>
-                                                                match ::core::cmp::PartialOrd::partial_cmp(&self.b8,
-                                                                        &other.b8) {
-                                                                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                                                        =>
-                                                                        ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                                                                    cmp => cmp,
-                                                                },
+                                                                ::core::cmp::PartialOrd::partial_cmp(&self.b8, &other.b8),
                                                             cmp => cmp,
                                                         },
                                                     cmp => cmp,
@@ -386,11 +349,7 @@ impl ::core::cmp::Ord for Big {
                                                     ::core::cmp::Ordering::Equal =>
                                                         match ::core::cmp::Ord::cmp(&self.b7, &other.b7) {
                                                             ::core::cmp::Ordering::Equal =>
-                                                                match ::core::cmp::Ord::cmp(&self.b8, &other.b8) {
-                                                                    ::core::cmp::Ordering::Equal =>
-                                                                        ::core::cmp::Ordering::Equal,
-                                                                    cmp => cmp,
-                                                                },
+                                                                ::core::cmp::Ord::cmp(&self.b8, &other.b8),
                                                             cmp => cmp,
                                                         },
                                                     cmp => cmp,
@@ -416,7 +375,8 @@ struct Packed(u32);
 impl ::core::clone::Clone for Packed {
     #[inline]
     fn clone(&self) -> Packed {
-        { let _: ::core::clone::AssertParamIsClone<u32>; *self }
+        let _: ::core::clone::AssertParamIsClone<u32>;
+        *self
     }
 }
 #[automatically_derived]
@@ -426,11 +386,9 @@ impl ::core::marker::Copy for Packed { }
 #[allow(unused_qualifications)]
 impl ::core::fmt::Debug for Packed {
     fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-        {
-            let Self(__self_0_0) = *self;
-            ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Packed",
-                &&__self_0_0)
-        }
+        let Self(__self_0_0) = *self;
+        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Packed",
+            &&__self_0_0)
     }
 }
 #[automatically_derived]
@@ -443,10 +401,8 @@ impl ::core::default::Default for Packed {
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Packed {
     fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-        {
-            let Self(__self_0_0) = *self;
-            { ::core::hash::Hash::hash(&__self_0_0, state) }
-        }
+        let Self(__self_0_0) = *self;
+        ::core::hash::Hash::hash(&__self_0_0, state)
     }
 }
 impl ::core::marker::StructuralPartialEq for Packed {}
@@ -455,19 +411,15 @@ impl ::core::marker::StructuralPartialEq for Packed {}
 impl ::core::cmp::PartialEq for Packed {
     #[inline]
     fn eq(&self, other: &Packed) -> bool {
-        {
-            let Self(__self_0_0) = *self;
-            let Self(__self_1_0) = *other;
-            __self_0_0 == __self_1_0
-        }
+        let Self(__self_0_0) = *self;
+        let Self(__self_1_0) = *other;
+        __self_0_0 == __self_1_0
     }
     #[inline]
     fn ne(&self, other: &Packed) -> bool {
-        {
-            let Self(__self_0_0) = *self;
-            let Self(__self_1_0) = *other;
-            __self_0_0 != __self_1_0
-        }
+        let Self(__self_0_0) = *self;
+        let Self(__self_1_0) = *other;
+        __self_0_0 != __self_1_0
     }
 }
 impl ::core::marker::StructuralEq for Packed {}
@@ -478,7 +430,7 @@ impl ::core::cmp::Eq for Packed {
     #[doc(hidden)]
     #[no_coverage]
     fn assert_receiver_is_total_eq(&self) -> () {
-        { let _: ::core::cmp::AssertParamIsEq<u32>; }
+        let _: ::core::cmp::AssertParamIsEq<u32>;
     }
 }
 #[automatically_derived]
@@ -487,16 +439,9 @@ impl ::core::cmp::PartialOrd for Packed {
     #[inline]
     fn partial_cmp(&self, other: &Packed)
         -> ::core::option::Option<::core::cmp::Ordering> {
-        {
-            let Self(__self_0_0) = *self;
-            let Self(__self_1_0) = *other;
-            match ::core::cmp::PartialOrd::partial_cmp(&__self_0_0,
-                    &__self_1_0) {
-                ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
-                    ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                cmp => cmp,
-            }
-        }
+        let Self(__self_0_0) = *self;
+        let Self(__self_1_0) = *other;
+        ::core::cmp::PartialOrd::partial_cmp(&__self_0_0, &__self_1_0)
     }
 }
 #[automatically_derived]
@@ -504,16 +449,167 @@ impl ::core::cmp::PartialOrd for Packed {
 impl ::core::cmp::Ord for Packed {
     #[inline]
     fn cmp(&self, other: &Packed) -> ::core::cmp::Ordering {
-        {
-            let Self(__self_0_0) = *self;
-            let Self(__self_1_0) = *other;
-            match ::core::cmp::Ord::cmp(&__self_0_0, &__self_1_0) {
-                ::core::cmp::Ordering::Equal => ::core::cmp::Ordering::Equal,
-                cmp => cmp,
+        let Self(__self_0_0) = *self;
+        let Self(__self_1_0) = *other;
+        ::core::cmp::Ord::cmp(&__self_0_0, &__self_1_0)
+    }
+}
+
+// An empty enum.
+enum Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Enum0 {
+    #[inline]
+    fn clone(&self) -> Enum0 { *self }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::marker::Copy for Enum0 { }
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::fmt::Debug for Enum0 {
+    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::hash::Hash for Enum0 {
+    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+impl ::core::marker::StructuralPartialEq for Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialEq for Enum0 {
+    #[inline]
+    fn eq(&self, other: &Enum0) -> bool {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+impl ::core::marker::StructuralEq for Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Eq for Enum0 {
+    #[inline]
+    #[doc(hidden)]
+    #[no_coverage]
+    fn assert_receiver_is_total_eq(&self) -> () {}
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialOrd for Enum0 {
+    #[inline]
+    fn partial_cmp(&self, other: &Enum0)
+        -> ::core::option::Option<::core::cmp::Ordering> {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Ord for Enum0 {
+    #[inline]
+    fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+
+// A single-variant enum.
+enum Enum1 {
+    Single {
+        x: u32,
+    },
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Enum1 {
+    #[inline]
+    fn clone(&self) -> Enum1 {
+        match &*self {
+            &Enum1::Single { x: ref __self_0 } =>
+                Enum1::Single { x: ::core::clone::Clone::clone(&*__self_0) },
+        }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::fmt::Debug for Enum1 {
+    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+        match &*self {
+            &Enum1::Single { x: ref __self_0 } =>
+                ::core::fmt::Formatter::debug_struct_field1_finish(f,
+                    "Single", "x", &&*__self_0),
+        }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::hash::Hash for Enum1 {
+    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+        match &*self {
+            &Enum1::Single { x: ref __self_0 } => {
+                ::core::hash::Hash::hash(&*__self_0, state)
             }
         }
     }
 }
+impl ::core::marker::StructuralPartialEq for Enum1 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialEq for Enum1 {
+    #[inline]
+    fn eq(&self, other: &Enum1) -> bool {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) => *__self_0 == *__arg_1_0,
+        }
+    }
+    #[inline]
+    fn ne(&self, other: &Enum1) -> bool {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) => *__self_0 != *__arg_1_0,
+        }
+    }
+}
+impl ::core::marker::StructuralEq for Enum1 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Eq for Enum1 {
+    #[inline]
+    #[doc(hidden)]
+    #[no_coverage]
+    fn assert_receiver_is_total_eq(&self) -> () {
+        let _: ::core::cmp::AssertParamIsEq<u32>;
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialOrd for Enum1 {
+    #[inline]
+    fn partial_cmp(&self, other: &Enum1)
+        -> ::core::option::Option<::core::cmp::Ordering> {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) =>
+                ::core::cmp::PartialOrd::partial_cmp(&*__self_0, &*__arg_1_0),
+        }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Ord for Enum1 {
+    #[inline]
+    fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) =>
+                ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+        }
+    }
+}
 
 // A C-like, fieldless enum.
 enum Fieldless {
@@ -527,7 +623,7 @@ enum Fieldless {
 #[allow(unused_qualifications)]
 impl ::core::clone::Clone for Fieldless {
     #[inline]
-    fn clone(&self) -> Fieldless { { *self } }
+    fn clone(&self) -> Fieldless { *self }
 }
 #[automatically_derived]
 #[allow(unused_qualifications)]
@@ -536,10 +632,10 @@ impl ::core::marker::Copy for Fieldless { }
 #[allow(unused_qualifications)]
 impl ::core::fmt::Debug for Fieldless {
     fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-        match (&*self,) {
-            (&Fieldless::A,) => ::core::fmt::Formatter::write_str(f, "A"),
-            (&Fieldless::B,) => ::core::fmt::Formatter::write_str(f, "B"),
-            (&Fieldless::C,) => ::core::fmt::Formatter::write_str(f, "C"),
+        match &*self {
+            &Fieldless::A => ::core::fmt::Formatter::write_str(f, "A"),
+            &Fieldless::B => ::core::fmt::Formatter::write_str(f, "B"),
+            &Fieldless::C => ::core::fmt::Formatter::write_str(f, "C"),
         }
     }
 }
@@ -553,7 +649,7 @@ impl ::core::default::Default for Fieldless {
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Fieldless {
     fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-        match (&*self,) {
+        match &*self {
             _ => {
                 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
                     state)
@@ -567,13 +663,11 @@ impl ::core::marker::StructuralPartialEq for Fieldless {}
 impl ::core::cmp::PartialEq for Fieldless {
     #[inline]
     fn eq(&self, other: &Fieldless) -> bool {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) { _ => true, }
-                } else { false }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) { _ => true, }
+            } else { false }
     }
 }
 impl ::core::marker::StructuralEq for Fieldless {}
@@ -583,7 +677,7 @@ impl ::core::cmp::Eq for Fieldless {
     #[inline]
     #[doc(hidden)]
     #[no_coverage]
-    fn assert_receiver_is_total_eq(&self) -> () { {} }
+    fn assert_receiver_is_total_eq(&self) -> () {}
 }
 #[automatically_derived]
 #[allow(unused_qualifications)]
@@ -591,19 +685,16 @@ impl ::core::cmp::PartialOrd for Fieldless {
     #[inline]
     fn partial_cmp(&self, other: &Fieldless)
         -> ::core::option::Option<::core::cmp::Ordering> {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        _ =>
-                            ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                    }
-                } else {
-                   ::core::cmp::PartialOrd::partial_cmp(&__self_vi,
-                       &__arg_1_vi)
-               }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    _ =>
+                        ::core::option::Option::Some(::core::cmp::Ordering::Equal),
+                }
+            } else {
+               ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi)
+           }
     }
 }
 #[automatically_derived]
@@ -611,15 +702,11 @@ impl ::core::cmp::PartialOrd for Fieldless {
 impl ::core::cmp::Ord for Fieldless {
     #[inline]
     fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        _ => ::core::cmp::Ordering::Equal,
-                    }
-                } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) { _ => ::core::cmp::Ordering::Equal, }
+            } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
     }
 }
 
@@ -640,12 +727,8 @@ enum Mixed {
 impl ::core::clone::Clone for Mixed {
     #[inline]
     fn clone(&self) -> Mixed {
-        {
-            let _: ::core::clone::AssertParamIsClone<u32>;
-            let _: ::core::clone::AssertParamIsClone<u32>;
-            let _: ::core::clone::AssertParamIsClone<u32>;
-            *self
-        }
+        let _: ::core::clone::AssertParamIsClone<u32>;
+        *self
     }
 }
 #[automatically_derived]
@@ -655,13 +738,13 @@ impl ::core::marker::Copy for Mixed { }
 #[allow(unused_qualifications)]
 impl ::core::fmt::Debug for Mixed {
     fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-        match (&*self,) {
-            (&Mixed::P,) => ::core::fmt::Formatter::write_str(f, "P"),
-            (&Mixed::Q,) => ::core::fmt::Formatter::write_str(f, "Q"),
-            (&Mixed::R(ref __self_0),) =>
+        match &*self {
+            &Mixed::P => ::core::fmt::Formatter::write_str(f, "P"),
+            &Mixed::Q => ::core::fmt::Formatter::write_str(f, "Q"),
+            &Mixed::R(ref __self_0) =>
                 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "R",
                     &&*__self_0),
-            (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },) =>
+            &Mixed::S { d1: ref __self_0, d2: ref __self_1 } =>
                 ::core::fmt::Formatter::debug_struct_field2_finish(f, "S",
                     "d1", &&*__self_0, "d2", &&*__self_1),
         }
@@ -677,13 +760,13 @@ impl ::core::default::Default for Mixed {
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Mixed {
     fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-        match (&*self,) {
-            (&Mixed::R(ref __self_0),) => {
+        match &*self {
+            &Mixed::R(ref __self_0) => {
                 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
                     state);
                 ::core::hash::Hash::hash(&*__self_0, state)
             }
-            (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },) => {
+            &Mixed::S { d1: ref __self_0, d2: ref __self_1 } => {
                 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
                     state);
                 ::core::hash::Hash::hash(&*__self_0, state);
@@ -702,37 +785,33 @@ impl ::core::marker::StructuralPartialEq for Mixed {}
 impl ::core::cmp::PartialEq for Mixed {
     #[inline]
     fn eq(&self, other: &Mixed) -> bool {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
-                            *__self_0 == *__arg_1_0,
-                        (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
-                            &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
-                            *__self_0 == *__arg_1_0 && *__self_1 == *__arg_1_1,
-                        _ => true,
-                    }
-                } else { false }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+                        *__self_0 == *__arg_1_0,
+                    (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+                        &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+                        *__self_0 == *__arg_1_0 && *__self_1 == *__arg_1_1,
+                    _ => true,
+                }
+            } else { false }
     }
     #[inline]
     fn ne(&self, other: &Mixed) -> bool {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
-                            *__self_0 != *__arg_1_0,
-                        (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
-                            &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
-                            *__self_0 != *__arg_1_0 || *__self_1 != *__arg_1_1,
-                        _ => false,
-                    }
-                } else { true }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+                        *__self_0 != *__arg_1_0,
+                    (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+                        &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+                        *__self_0 != *__arg_1_0 || *__self_1 != *__arg_1_1,
+                    _ => false,
+                }
+            } else { true }
     }
 }
 impl ::core::marker::StructuralEq for Mixed {}
@@ -743,11 +822,7 @@ impl ::core::cmp::Eq for Mixed {
     #[doc(hidden)]
     #[no_coverage]
     fn assert_receiver_is_total_eq(&self) -> () {
-        {
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-        }
+        let _: ::core::cmp::AssertParamIsEq<u32>;
     }
 }
 #[automatically_derived]
@@ -756,42 +831,29 @@ impl ::core::cmp::PartialOrd for Mixed {
     #[inline]
     fn partial_cmp(&self, other: &Mixed)
         -> ::core::option::Option<::core::cmp::Ordering> {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
-                            match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
-                                    &*__arg_1_0) {
-                                ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                    =>
-                                    ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                                cmp => cmp,
-                            },
-                        (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
-                            &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
-                            match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
-                                    &*__arg_1_0) {
-                                ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                    =>
-                                    match ::core::cmp::PartialOrd::partial_cmp(&*__self_1,
-                                            &*__arg_1_1) {
-                                        ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                            =>
-                                            ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                                        cmp => cmp,
-                                    },
-                                cmp => cmp,
-                            },
-                        _ =>
-                            ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                    }
-                } else {
-                   ::core::cmp::PartialOrd::partial_cmp(&__self_vi,
-                       &__arg_1_vi)
-               }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+                        ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+                            &*__arg_1_0),
+                    (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+                        &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+                        match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+                                &*__arg_1_0) {
+                            ::core::option::Option::Some(::core::cmp::Ordering::Equal)
+                                =>
+                                ::core::cmp::PartialOrd::partial_cmp(&*__self_1,
+                                    &*__arg_1_1),
+                            cmp => cmp,
+                        },
+                    _ =>
+                        ::core::option::Option::Some(::core::cmp::Ordering::Equal),
+                }
+            } else {
+               ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi)
+           }
     }
 }
 #[automatically_derived]
@@ -799,32 +861,22 @@ impl ::core::cmp::PartialOrd for Mixed {
 impl ::core::cmp::Ord for Mixed {
     #[inline]
     fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
-                            match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
-                                ::core::cmp::Ordering::Equal =>
-                                    ::core::cmp::Ordering::Equal,
-                                cmp => cmp,
-                            },
-                        (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
-                            &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
-                            match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
-                                ::core::cmp::Ordering::Equal =>
-                                    match ::core::cmp::Ord::cmp(&*__self_1, &*__arg_1_1) {
-                                        ::core::cmp::Ordering::Equal =>
-                                            ::core::cmp::Ordering::Equal,
-                                        cmp => cmp,
-                                    },
-                                cmp => cmp,
-                            },
-                        _ => ::core::cmp::Ordering::Equal,
-                    }
-                } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+                        ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+                    (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+                        &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+                        match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
+                            ::core::cmp::Ordering::Equal =>
+                                ::core::cmp::Ord::cmp(&*__self_1, &*__arg_1_1),
+                            cmp => cmp,
+                        },
+                    _ => ::core::cmp::Ordering::Equal,
+                }
+            } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
     }
 }
 
@@ -836,12 +888,12 @@ enum Fielded { X(u32), Y(bool), Z(Option<i32>), }
 impl ::core::clone::Clone for Fielded {
     #[inline]
     fn clone(&self) -> Fielded {
-        match (&*self,) {
-            (&Fielded::X(ref __self_0),) =>
+        match &*self {
+            &Fielded::X(ref __self_0) =>
                 Fielded::X(::core::clone::Clone::clone(&*__self_0)),
-            (&Fielded::Y(ref __self_0),) =>
+            &Fielded::Y(ref __self_0) =>
                 Fielded::Y(::core::clone::Clone::clone(&*__self_0)),
-            (&Fielded::Z(ref __self_0),) =>
+            &Fielded::Z(ref __self_0) =>
                 Fielded::Z(::core::clone::Clone::clone(&*__self_0)),
         }
     }
@@ -850,14 +902,14 @@ impl ::core::clone::Clone for Fielded {
 #[allow(unused_qualifications)]
 impl ::core::fmt::Debug for Fielded {
     fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-        match (&*self,) {
-            (&Fielded::X(ref __self_0),) =>
+        match &*self {
+            &Fielded::X(ref __self_0) =>
                 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "X",
                     &&*__self_0),
-            (&Fielded::Y(ref __self_0),) =>
+            &Fielded::Y(ref __self_0) =>
                 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y",
                     &&*__self_0),
-            (&Fielded::Z(ref __self_0),) =>
+            &Fielded::Z(ref __self_0) =>
                 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z",
                     &&*__self_0),
         }
@@ -867,18 +919,18 @@ impl ::core::fmt::Debug for Fielded {
 #[allow(unused_qualifications)]
 impl ::core::hash::Hash for Fielded {
     fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-        match (&*self,) {
-            (&Fielded::X(ref __self_0),) => {
+        match &*self {
+            &Fielded::X(ref __self_0) => {
                 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
                     state);
                 ::core::hash::Hash::hash(&*__self_0, state)
             }
-            (&Fielded::Y(ref __self_0),) => {
+            &Fielded::Y(ref __self_0) => {
                 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
                     state);
                 ::core::hash::Hash::hash(&*__self_0, state)
             }
-            (&Fielded::Z(ref __self_0),) => {
+            &Fielded::Z(ref __self_0) => {
                 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
                     state);
                 ::core::hash::Hash::hash(&*__self_0, state)
@@ -892,39 +944,35 @@ impl ::core::marker::StructuralPartialEq for Fielded {}
 impl ::core::cmp::PartialEq for Fielded {
     #[inline]
     fn eq(&self, other: &Fielded) -> bool {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
-                            *__self_0 == *__arg_1_0,
-                        (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
-                            *__self_0 == *__arg_1_0,
-                        (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
-                            *__self_0 == *__arg_1_0,
-                        _ => unsafe { ::core::intrinsics::unreachable() }
-                    }
-                } else { false }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+                        *__self_0 == *__arg_1_0,
+                    (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+                        *__self_0 == *__arg_1_0,
+                    (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+                        *__self_0 == *__arg_1_0,
+                    _ => unsafe { ::core::intrinsics::unreachable() }
+                }
+            } else { false }
     }
     #[inline]
     fn ne(&self, other: &Fielded) -> bool {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
-                            *__self_0 != *__arg_1_0,
-                        (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
-                            *__self_0 != *__arg_1_0,
-                        (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
-                            *__self_0 != *__arg_1_0,
-                        _ => unsafe { ::core::intrinsics::unreachable() }
-                    }
-                } else { true }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+                        *__self_0 != *__arg_1_0,
+                    (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+                        *__self_0 != *__arg_1_0,
+                    (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+                        *__self_0 != *__arg_1_0,
+                    _ => unsafe { ::core::intrinsics::unreachable() }
+                }
+            } else { true }
     }
 }
 impl ::core::marker::StructuralEq for Fielded {}
@@ -935,11 +983,9 @@ impl ::core::cmp::Eq for Fielded {
     #[doc(hidden)]
     #[no_coverage]
     fn assert_receiver_is_total_eq(&self) -> () {
-        {
-            let _: ::core::cmp::AssertParamIsEq<u32>;
-            let _: ::core::cmp::AssertParamIsEq<bool>;
-            let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
-        }
+        let _: ::core::cmp::AssertParamIsEq<u32>;
+        let _: ::core::cmp::AssertParamIsEq<bool>;
+        let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
     }
 }
 #[automatically_derived]
@@ -948,42 +994,24 @@ impl ::core::cmp::PartialOrd for Fielded {
     #[inline]
     fn partial_cmp(&self, other: &Fielded)
         -> ::core::option::Option<::core::cmp::Ordering> {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
-                            match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
-                                    &*__arg_1_0) {
-                                ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                    =>
-                                    ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                                cmp => cmp,
-                            },
-                        (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
-                            match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
-                                    &*__arg_1_0) {
-                                ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                    =>
-                                    ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                                cmp => cmp,
-                            },
-                        (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
-                            match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
-                                    &*__arg_1_0) {
-                                ::core::option::Option::Some(::core::cmp::Ordering::Equal)
-                                    =>
-                                    ::core::option::Option::Some(::core::cmp::Ordering::Equal),
-                                cmp => cmp,
-                            },
-                        _ => unsafe { ::core::intrinsics::unreachable() }
-                    }
-                } else {
-                   ::core::cmp::PartialOrd::partial_cmp(&__self_vi,
-                       &__arg_1_vi)
-               }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+                        ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+                            &*__arg_1_0),
+                    (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+                        ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+                            &*__arg_1_0),
+                    (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+                        ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+                            &*__arg_1_0),
+                    _ => unsafe { ::core::intrinsics::unreachable() }
+                }
+            } else {
+               ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi)
+           }
     }
 }
 #[automatically_derived]
@@ -991,32 +1019,37 @@ impl ::core::cmp::PartialOrd for Fielded {
 impl ::core::cmp::Ord for Fielded {
     #[inline]
     fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
-        {
-            let __self_vi = ::core::intrinsics::discriminant_value(&*self);
-            let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
-            if __self_vi == __arg_1_vi {
-                    match (&*self, &*other) {
-                        (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
-                            match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
-                                ::core::cmp::Ordering::Equal =>
-                                    ::core::cmp::Ordering::Equal,
-                                cmp => cmp,
-                            },
-                        (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
-                            match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
-                                ::core::cmp::Ordering::Equal =>
-                                    ::core::cmp::Ordering::Equal,
-                                cmp => cmp,
-                            },
-                        (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
-                            match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
-                                ::core::cmp::Ordering::Equal =>
-                                    ::core::cmp::Ordering::Equal,
-                                cmp => cmp,
-                            },
-                        _ => unsafe { ::core::intrinsics::unreachable() }
-                    }
-                } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
-        }
+        let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+        let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+        if __self_vi == __arg_1_vi {
+                match (&*self, &*other) {
+                    (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+                        ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+                    (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+                        ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+                    (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+                        ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+                    _ => unsafe { ::core::intrinsics::unreachable() }
+                }
+            } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
     }
 }
+
+// A union. Most builtin traits are not derivable for unions.
+pub union Union {
+    pub b: bool,
+    pub u: u32,
+    pub i: i32,
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Union {
+    #[inline]
+    fn clone(&self) -> Union {
+        let _: ::core::clone::AssertParamIsCopy<Self>;
+        *self
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::marker::Copy for Union { }
diff --git a/src/test/ui/diagnostic-width/flag-human.rs b/src/test/ui/diagnostic-width/flag-human.rs
new file mode 100644 (file)
index 0000000..289bfba
--- /dev/null
@@ -0,0 +1,9 @@
+// compile-flags: --diagnostic-width=20
+
+// This test checks that `-Z output-width` effects the human error output by restricting it to an
+// arbitrarily low value so that the effect is visible.
+
+fn main() {
+    let _: () = 42;
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/diagnostic-width/flag-human.stderr b/src/test/ui/diagnostic-width/flag-human.stderr
new file mode 100644 (file)
index 0000000..393dcf2
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/flag-human.rs:7:17
+   |
+LL | ..._: () = 42;
+   |       --   ^^ expected `()`, found integer
+   |       |
+   |       expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/diagnostic-width/flag-json.rs b/src/test/ui/diagnostic-width/flag-json.rs
new file mode 100644 (file)
index 0000000..51a1fb4
--- /dev/null
@@ -0,0 +1,9 @@
+// compile-flags: --diagnostic-width=20 --error-format=json
+
+// This test checks that `-Z output-width` effects the JSON error output by restricting it to an
+// arbitrarily low value so that the effect is visible.
+
+fn main() {
+    let _: () = 42;
+    //~^ ERROR arguments to this function are incorrect
+}
diff --git a/src/test/ui/diagnostic-width/flag-json.stderr b/src/test/ui/diagnostic-width/flag-json.stderr
new file mode 100644 (file)
index 0000000..b21391d
--- /dev/null
@@ -0,0 +1,40 @@
+{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.
+
+Erroneous code examples:
+
+```compile_fail,E0308
+fn plus_one(x: i32) -> i32 {
+    x + 1
+}
+
+plus_one(\"Not a number\");
+//       ^^^^^^^^^^^^^^ expected `i32`, found `&str`
+
+if \"Not a bool\" {
+// ^^^^^^^^^^^^ expected `bool`, found `&str`
+}
+
+let x: f32 = \"Not a float\";
+//     ---   ^^^^^^^^^^^^^ expected `f32`, found `&str`
+//     |
+//     expected due to this
+```
+
+This error occurs when an expression was used in a place where the compiler
+expected an expression of a different type. It can occur in several cases, the
+most common being when calling a function and passing an argument which has a
+different type than the matching type in the function declaration.
+"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":243,"byte_end":245,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":"    let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":238,"byte_end":240,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":"    let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
+  --> $DIR/flag-json.rs:7:17
+   |
+LL | ..._: () = 42;
+   |       --   ^^ expected `()`, found integer
+   |       |
+   |       expected due to this
+
+"}
+{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
+
+"}
+{"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.
+"}
diff --git a/src/test/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs b/src/test/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs
new file mode 100644 (file)
index 0000000..1989ea8
--- /dev/null
@@ -0,0 +1,7 @@
+// ignore-tidy-linelength
+
+fn main() {
+    let unicode_is_fun = "؁‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥";
+    let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
+    //~^ ERROR cannot add `&str` to `&str`
+}
diff --git a/src/test/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr b/src/test/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr
new file mode 100644 (file)
index 0000000..bf27736
--- /dev/null
@@ -0,0 +1,18 @@
+error[E0369]: cannot add `&str` to `&str`
+  --> $DIR/non-1-width-unicode-multiline-label.rs:5:260
+   |
+LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
+   |                                                  -------------- ^ -------------- &str
+   |                                                  |              |
+   |                                                  |              `+` cannot be used to concatenate two `&str` strings
+   |                                                  &str
+   |
+   = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
+   |                                                                                                                                                                                         +++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0369`.
diff --git a/src/test/ui/diagnostic-width/non-whitespace-trimming-2.rs b/src/test/ui/diagnostic-width/non-whitespace-trimming-2.rs
new file mode 100644 (file)
index 0000000..abd9e18
--- /dev/null
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+    let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15;
+//~^ ERROR mismatched types
+}
diff --git a/src/test/ui/diagnostic-width/non-whitespace-trimming-2.stderr b/src/test/ui/diagnostic-width/non-whitespace-trimming-2.stderr
new file mode 100644 (file)
index 0000000..5dbb9ce
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/non-whitespace-trimming-2.rs:4:311
+   |
+LL | ...13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let ...
+   |                                                     --   ^^ expected `()`, found integer
+   |                                                     |
+   |                                                     expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/diagnostic-width/non-whitespace-trimming-unicode.rs b/src/test/ui/diagnostic-width/non-whitespace-trimming-unicode.rs
new file mode 100644 (file)
index 0000000..8d4d1b1
--- /dev/null
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+    let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓  ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42;  let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓  ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
+//~^ ERROR mismatched types
+}
diff --git a/src/test/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr b/src/test/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr
new file mode 100644 (file)
index 0000000..1e5ff93
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/non-whitespace-trimming-unicode.rs:4:415
+   |
+LL | ...♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42;  let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓  ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄...
+   |                                            --   ^^ expected `()`, found integer
+   |                                            |
+   |                                            expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/diagnostic-width/non-whitespace-trimming.rs b/src/test/ui/diagnostic-width/non-whitespace-trimming.rs
new file mode 100644 (file)
index 0000000..f6c8d34
--- /dev/null
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+    let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
+//~^ ERROR mismatched types
+}
diff --git a/src/test/ui/diagnostic-width/non-whitespace-trimming.stderr b/src/test/ui/diagnostic-width/non-whitespace-trimming.stderr
new file mode 100644 (file)
index 0000000..c4ff0e1
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/non-whitespace-trimming.rs:4:241
+   |
+LL | ... () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ...
+   |                                                     --   ^^ expected `()`, found integer
+   |                                                     |
+   |                                                     expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/diagnostic-width/tabs-trimming.rs b/src/test/ui/diagnostic-width/tabs-trimming.rs
new file mode 100644 (file)
index 0000000..ade2175
--- /dev/null
@@ -0,0 +1,13 @@
+// Test for #78438: ensure underline alignment with many tabs on the left, long line on the right
+
+// ignore-tidy-linelength
+// ignore-tidy-tab
+
+                                       fn main() {
+                                               let money = 42i32;
+                                               match money {
+                                                       v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
+                                                       //~^ ERROR variable `v` is not bound in all patterns
+                                                       v => println!("Enough money {}", v),
+                                               }
+                                       }
diff --git a/src/test/ui/diagnostic-width/tabs-trimming.stderr b/src/test/ui/diagnostic-width/tabs-trimming.stderr
new file mode 100644 (file)
index 0000000..6c8d9af
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0408]: variable `v` is not bound in all patterns
+  --> $DIR/tabs-trimming.rs:9:16
+   |
+LL | ...   v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
+   |       -       ^   ^ pattern doesn't bind `v`
+   |       |       |
+   |       |       pattern doesn't bind `v`
+   |       variable not in all patterns
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0408`.
diff --git a/src/test/ui/diagnostic-width/whitespace-trimming-2.rs b/src/test/ui/diagnostic-width/whitespace-trimming-2.rs
new file mode 100644 (file)
index 0000000..c68f678
--- /dev/null
@@ -0,0 +1,8 @@
+// ignore-tidy-linelength
+
+fn foo() -> usize {
+                                                                                                                                                                                          ()
+//~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/diagnostic-width/whitespace-trimming-2.stderr b/src/test/ui/diagnostic-width/whitespace-trimming-2.stderr
new file mode 100644 (file)
index 0000000..97a64e6
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/whitespace-trimming-2.rs:4:187
+   |
+LL | ...-> usize {
+   |       ----- expected `usize` because of return type
+LL | ...                                                                                                                                                                                 ()
+   |                                                                                                                                                                                     ^^ expected `usize`, found `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/diagnostic-width/whitespace-trimming.rs b/src/test/ui/diagnostic-width/whitespace-trimming.rs
new file mode 100644 (file)
index 0000000..f747bcf
--- /dev/null
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+                                                                                                                                                                                    let _: () = 42;
+//~^ ERROR mismatched types
+}
diff --git a/src/test/ui/diagnostic-width/whitespace-trimming.stderr b/src/test/ui/diagnostic-width/whitespace-trimming.stderr
new file mode 100644 (file)
index 0000000..e296d48
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/whitespace-trimming.rs:4:193
+   |
+LL | ...                   let _: () = 42;
+   |                              --   ^^ expected `()`, found integer
+   |                              |
+   |                              expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
index bd5b9f4b49ee33adad6dfe51bdd26bf865c8e76f..bdbfa4dd7136b375dff7a7a9431a2177b6452807 100644 (file)
@@ -88,7 +88,7 @@ error[E0599]: no method named `hello_method` found for struct `S` in the current
   --> $DIR/issue-40006.rs:38:7
    |
 LL | struct S;
-   |        - method `hello_method` not found for this struct
+   | -------- method `hello_method` not found for this struct
 ...
 LL |     S.hello_method();
    |       ^^^^^^^^^^^^ method not found in `S`
index d85fd526d52b0a4dbb51a7c1331fb0802d8988ea..1492670dc63354daadb422556d82cb0e9156295c 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `new` found for struct `T` in
   --> $DIR/dont-suggest-private-trait-method.rs:4:8
    |
 LL | struct T;
-   |        - function or associated item `new` not found for this struct
+   | -------- function or associated item `new` not found for this struct
 ...
 LL |     T::new();
    |        ^^^ function or associated item not found in `T`
index 2e7855328ecbffa90e83ef9aaf333a38312b2ccb..59d5ef202051a2e589be3f708990f2b87a251829 100644 (file)
@@ -9,7 +9,7 @@ fn borrowck_catch() {
 
 fn must_be_init() {
     let x: u8;
-    let _ = [x; 0]; //~ ERROR: use of possibly-uninitialized variable: `x`
+    let _ = [x; 0]; //~ ERROR E0381
 }
 
 fn main() {}
index cdc58180c37b40847bc0c6fbdbf496c0da5310fe..48fa2bfa975c03dedbd6b3449b71d8ef0e75c0e8 100644 (file)
@@ -17,11 +17,13 @@ LL | const _: [String; 0] = [String::new(); 0];
    |                        |constants cannot evaluate destructors
    |                        value is dropped here
 
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/repeat-drop-2.rs:12:14
    |
+LL |     let x: u8;
+   |         - binding declared here but left uninitialized
 LL |     let _ = [x; 0];
-   |              ^ use of possibly-uninitialized `x`
+   |              ^ `x` used here but it isn't initialized
 
 error: aborting due to 3 previous errors
 
index 33bd0d240813990739daff593735713015e01870..1d7567e60a57c0a2629875de6c5d8f8e87fad820 100644 (file)
@@ -1,4 +1,4 @@
-pub enum Test { //~ HELP consider adding `#[derive(Default)]` to this enum
+pub enum Test { //~ HELP consider adding a derive
     #[default]
     //~^ ERROR cannot find attribute `default` in this scope
     First,
index 791f219e8f95f6c64e3d038f74c7ff2bba3f3053..fb830d3f78b64db1dd11330eab5b4dd38c1d1736 100644 (file)
@@ -4,11 +4,11 @@ error: cannot find attribute `default` in this scope
 LL |     #[default]
    |       ^^^^^^^
    |
-help: consider adding `#[derive(Default)]` to this enum
-  --> $DIR/suggest-default-attribute.rs:1:1
+help: consider adding a derive
+   |
+LL + #[derive(Default)]
+LL ~ pub enum Test {
    |
-LL | pub enum Test {
-   | ^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 49ca1d6353d15361583aa47840812184bfe6ccf1..a1fb58f483f6df6e4a66e6f2948f1c01b4e56bda 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no associated item named `NotEvenReal` found for struct `Foo` in t
   --> $DIR/E0599.rs:4:20
    |
 LL | struct Foo;
-   |        --- associated item `NotEvenReal` not found for this struct
+   | ---------- associated item `NotEvenReal` not found for this struct
 ...
 LL |     || if let Foo::NotEvenReal() = Foo {};
    |                    ^^^^^^^^^^^ associated item not found in `Foo`
index 0e427b9cf318f1b5802eddd0391e7d673d524cfd..97141886fe7381a314b521b104ecf7ecc1e72002 100644 (file)
@@ -6,6 +6,7 @@ pub fn foo() {
     //~^ ERROR cannot assign to `x`, as it is a captured variable in a `Fn` closure
     //~| NOTE cannot assign
     //~| NOTE expects `Fn` instead of `FnMut`
+    //~| NOTE in this closure
 }
 
 fn main() {}
index d23c363ae1582182ab8f30b6a9df41f7d3573aaa..03e3d545a99198a3750f9ef88b7b5d6354eef400 100644 (file)
@@ -5,8 +5,9 @@ LL | pub fn bar<F: Fn()>(_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`
 
 error: aborting due to previous error
index 3e42cb1fb6ec02d6f160894aa0a551501101ba28..06e29daef456ce7802d8eb0ad7111b461ce1c6bc 100644 (file)
@@ -10,11 +10,11 @@ error[E0599]: no method named `blablabla` found for struct `Arc<_>` in the curre
 LL |     arc.blablabla();
    |         ^^^^^^^^^ method not found in `Arc<_>`
 
-error[E0599]: no method named `blablabla` found for struct `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:40]>` in the current scope
+error[E0599]: no method named `blablabla` found for struct `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:38]>` in the current scope
   --> $DIR/fn-help-with-err.rs:12:10
    |
 LL |     arc2.blablabla();
-   |     ---- ^^^^^^^^^ method not found in `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:40]>`
+   |     ---- ^^^^^^^^^ method not found in `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:38]>`
    |     |
    |     this is a function, perhaps you wish to call it
 
index f821f2f40055f35dea715a44b55bd4f0870c787e..5bc6ea5600fc58769414aded57d688f22a1261c0 100644 (file)
@@ -4,7 +4,7 @@ error: generator cannot be sent between threads safely
 LL |     assert_send(|| {
    |     ^^^^^^^^^^^ generator is not `Send`
    |
-   = help: within `[generator@$DIR/drop-yield-twice.rs:7:17: 12:6]`, the trait `Send` is not implemented for `Foo`
+   = help: within `[generator@$DIR/drop-yield-twice.rs:7:17: 7:19]`, the trait `Send` is not implemented for `Foo`
 note: generator is not `Send` as this value is used across a yield
   --> $DIR/drop-yield-twice.rs:9:9
    |
index 62a7b37a5a387aaf975aa0a016ce91560ba27d5f..2a39a08ee39b26ff7e2d358508da7bd51c5b18e8 100644 (file)
@@ -1,4 +1,4 @@
-error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 19:6] as Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 19:6]`
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36] as Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36]`
   --> $DIR/generator-yielding-or-returning-itself.rs:15:5
    |
 LL |     want_cyclic_generator_return(|| {
@@ -16,7 +16,7 @@ LL | pub fn want_cyclic_generator_return<T>(_: T)
 LL |     where T: Generator<Yield = (), Return = T>
    |                                    ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return`
 
-error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 32:6] as Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 32:6]`
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35] as Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35]`
   --> $DIR/generator-yielding-or-returning-itself.rs:28:5
    |
 LL |     want_cyclic_generator_yield(|| {
index 83f068c2076438f769877a1d00a1e14e053aa8c3..1d5b97e984fd1d9a0552d624f1085533a354bea5 100644 (file)
@@ -33,11 +33,8 @@ LL |     require_send(send_gen);
 note: required because it's used within this generator
   --> $DIR/issue-68112.rs:48:5
    |
-LL | /     || {
-LL | |         yield;
-LL | |         t
-LL | |     }
-   | |_____^
+LL |     || {
+   |     ^^
 note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>`
   --> $DIR/issue-68112.rs:45:30
    |
@@ -52,12 +49,8 @@ LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>>
 note: required because it's used within this generator
   --> $DIR/issue-68112.rs:59:20
    |
-LL |       let send_gen = || {
-   |  ____________________^
-LL | |         let _non_send_gen = make_non_send_generator2();
-LL | |         yield;
-LL | |     };
-   | |_____^
+LL |     let send_gen = || {
+   |                    ^^
 note: required by a bound in `require_send`
   --> $DIR/issue-68112.rs:22:25
    |
index edf9ee628a2bc25200c8bb68e59c4ea56575d7e5..0b31bb4fdb1a0c6800614c8a498bb412398835a4 100644 (file)
@@ -9,13 +9,8 @@ LL |     assert_send(|| {
 note: required because it's used within this generator
   --> $DIR/not-send-sync.rs:16:17
    |
-LL |       assert_send(|| {
-   |  _________________^
-LL | |
-LL | |         drop(&a);
-LL | |         yield;
-LL | |     });
-   | |_____^
+LL |     assert_send(|| {
+   |                 ^^
 note: required by a bound in `assert_send`
   --> $DIR/not-send-sync.rs:7:23
    |
@@ -28,7 +23,7 @@ error: generator cannot be shared between threads safely
 LL |     assert_sync(|| {
    |     ^^^^^^^^^^^ generator is not `Sync`
    |
-   = help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6]`, the trait `Sync` is not implemented for `Cell<i32>`
+   = help: within `[generator@$DIR/not-send-sync.rs:9:17: 9:19]`, the trait `Sync` is not implemented for `Cell<i32>`
 note: generator is not `Sync` as this value is used across a yield
   --> $DIR/not-send-sync.rs:12:9
    |
index 16b34c917ece43395c24d729324f3d22188f11d9..1004fc64da93ad980d8e957b8054862c3342a414 100644 (file)
@@ -4,7 +4,7 @@ error: generator cannot be sent between threads safely
 LL |     assert_send(|| {
    |     ^^^^^^^^^^^ generator is not `Send`
    |
-   = help: within `[generator@$DIR/partial-drop.rs:14:17: 20:6]`, the trait `Send` is not implemented for `Foo`
+   = help: within `[generator@$DIR/partial-drop.rs:14:17: 14:19]`, the trait `Send` is not implemented for `Foo`
 note: generator is not `Send` as this value is used across a yield
   --> $DIR/partial-drop.rs:19:9
    |
@@ -27,7 +27,7 @@ error: generator cannot be sent between threads safely
 LL |     assert_send(|| {
    |     ^^^^^^^^^^^ generator is not `Send`
    |
-   = help: within `[generator@$DIR/partial-drop.rs:22:17: 30:6]`, the trait `Send` is not implemented for `Foo`
+   = help: within `[generator@$DIR/partial-drop.rs:22:17: 22:19]`, the trait `Send` is not implemented for `Foo`
 note: generator is not `Send` as this value is used across a yield
   --> $DIR/partial-drop.rs:29:9
    |
@@ -50,7 +50,7 @@ error: generator cannot be sent between threads safely
 LL |     assert_send(|| {
    |     ^^^^^^^^^^^ generator is not `Send`
    |
-   = help: within `[generator@$DIR/partial-drop.rs:32:17: 39:6]`, the trait `Send` is not implemented for `Foo`
+   = help: within `[generator@$DIR/partial-drop.rs:32:17: 32:19]`, the trait `Send` is not implemented for `Foo`
 note: generator is not `Send` as this value is used across a yield
   --> $DIR/partial-drop.rs:38:9
    |
index 8b757214203512c5f8cc1193b77d771cbf33c943..65d9e6d39ca5a8d960d9ff2f366447e015e11af9 100644 (file)
@@ -9,8 +9,7 @@ struct S { x: i32, y: i32 }
 fn test_tuple() {
     let _ = || {
         let mut t: (i32, i32);
-        t.0 = 42;
-        //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+        t.0 = 42; //~ ERROR E0381
         yield;
         t.1 = 88;
         let _ = t;
@@ -20,8 +19,7 @@ fn test_tuple() {
 fn test_tuple_struct() {
     let _ = || {
         let mut t: T;
-        t.0 = 42;
-        //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+        t.0 = 42; //~ ERROR E0381
         yield;
         t.1 = 88;
         let _ = t;
@@ -31,8 +29,7 @@ fn test_tuple_struct() {
 fn test_struct() {
     let _ = || {
         let mut t: S;
-        t.x = 42;
-        //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+        t.x = 42; //~ ERROR E0381
         yield;
         t.y = 88;
         let _ = t;
index 66b86488eaec766eb1e3b70b1c7ee4b079153e44..3f9f1c046ba4b1b3afe408ae4f2742b28ddcd3ca 100644 (file)
@@ -1,20 +1,32 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
   --> $DIR/partial-initialization-across-yield.rs:12:9
    |
+LL |         let mut t: (i32, i32);
+   |             ----- binding declared here but left uninitialized
 LL |         t.0 = 42;
-   |         ^^^^^^^^ use of possibly-uninitialized `t`
+   |         ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/partial-initialization-across-yield.rs:23:9
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/partial-initialization-across-yield.rs:22:9
    |
+LL |         let mut t: T;
+   |             ----- binding declared here but left uninitialized
 LL |         t.0 = 42;
-   |         ^^^^^^^^ use of possibly-uninitialized `t`
+   |         ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/partial-initialization-across-yield.rs:34:9
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/partial-initialization-across-yield.rs:32:9
    |
+LL |         let mut t: S;
+   |             ----- binding declared here but left uninitialized
 LL |         t.x = 42;
-   |         ^^^^^^^^ use of possibly-uninitialized `t`
+   |         ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error: aborting due to 3 previous errors
 
index 3ee4c1458bad38d1e5349878c83001ca2975c9f9..5b61f1e8f2dc130df5243a4925951a951a1b36a2 100644 (file)
@@ -31,11 +31,8 @@ LL |     require_send(send_gen);
 note: required because it's used within this generator
   --> $DIR/generator-print-verbose-1.rs:42:5
    |
-LL | /     || {
-LL | |         yield;
-LL | |         t
-LL | |     }
-   | |_____^
+LL |     || {
+   |     ^^
 note: required because it appears within the type `Opaque(DefId(0:39 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])`
   --> $DIR/generator-print-verbose-1.rs:41:30
    |
@@ -50,12 +47,8 @@ LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>>
 note: required because it's used within this generator
   --> $DIR/generator-print-verbose-1.rs:52:20
    |
-LL |       let send_gen = || {
-   |  ____________________^
-LL | |         let _non_send_gen = make_non_send_generator2();
-LL | |         yield;
-LL | |     };
-   | |_____^
+LL |     let send_gen = || {
+   |                    ^^
 note: required by a bound in `require_send`
   --> $DIR/generator-print-verbose-1.rs:26:25
    |
index 1356fa5f15295db37399e3eff7463df577b4761c..eb79d2e6eedbd90a5d00e77bfafc0b2d1e906cba 100644 (file)
@@ -9,13 +9,8 @@ LL |     assert_send(|| {
 note: required because it's used within this generator
   --> $DIR/generator-print-verbose-2.rs:19:17
    |
-LL |       assert_send(|| {
-   |  _________________^
-LL | |
-LL | |         drop(&a);
-LL | |         yield;
-LL | |     });
-   | |_____^
+LL |     assert_send(|| {
+   |                 ^^
 note: required by a bound in `assert_send`
   --> $DIR/generator-print-verbose-2.rs:10:23
    |
index 4ae745b0ffeacae0b44f51142e7d37db5e1c0246..e3859595fd2ce33002ad18721e3c8c9419e172cd 100644 (file)
@@ -1,8 +1,8 @@
-error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]` cannot be unpinned
+error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]` cannot be unpinned
   --> $DIR/static-not-unpin.rs:14:18
    |
 LL |     assert_unpin(generator);
-   |     ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]`
+   |     ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]`
    |     |
    |     required by a bound introduced by this call
    |
index d78a5929a896d8c2f3621a60c32ce283911078a8..7938fc8097cd2d54267a1b1f4d59b82005ffa240 100644 (file)
@@ -12,7 +12,7 @@ note: return type inferred to be `Result<{integer}, _>` here
 LL |             return Ok(6);
    |                    ^^^^^
 
-error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 15:6] as Generator>::Return == i32`
+error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7] as Generator>::Return == i32`
   --> $DIR/type-mismatch-signature-deduction.rs:5:13
    |
 LL | fn foo() -> impl Generator<Return = i32> {
index 2804364890f01371843dc0199ecd404a49ee5982..d9dc77ac8eb4032118bfc50301dddb49fd6205d6 100644 (file)
@@ -3,8 +3,8 @@ error[E0599]: the method `f` exists for struct `S`, but its trait bounds were no
    |
 LL | struct S;
    | --------
-   | |      |
-   | |      method `f` not found for this struct
+   | |
+   | method `f` not found for this struct
    | doesn't satisfy `<S as X>::Y<i32> = i32`
    | doesn't satisfy `S: M`
 ...
index 43e609cc59efb0eddd9b52e21acf8621ad23573e..c01ab8e347c6c11b3ab6a0490e93a05059962329 100644 (file)
@@ -4,7 +4,7 @@ error: higher-ranked lifetime error
 LL |     v.t(|| {});
    |     ^^^^^^^^^^
    |
-   = note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed`
+   = note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:11] well-formed`
 
 error: higher-ranked lifetime error
   --> $DIR/issue-59311.rs:17:9
index 0bfa7b3cc7c45e8acc440c359b5e2e72f52e344b..eebce827d1cae5419ae94dcf1dd2702973e6ce2d 100644 (file)
@@ -10,7 +10,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-71955.rs:45:24
    |
 LL |     foo(bar, "string", |s| s.len() == 5);
-   |                        ^^^^^^^^^^^^^^^^
+   |                        ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/issue-71955.rs:25:9
    |
@@ -29,7 +29,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-71955.rs:45:24
    |
 LL |     foo(bar, "string", |s| s.len() == 5);
-   |                        ^^^^^^^^^^^^^^^^
+   |                        ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/issue-71955.rs:25:44
    |
@@ -48,7 +48,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-71955.rs:48:24
    |
 LL |     foo(baz, "string", |s| s.0.len() == 5);
-   |                        ^^^^^^^^^^^^^^^^^^
+   |                        ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/issue-71955.rs:25:9
    |
@@ -67,7 +67,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-71955.rs:48:24
    |
 LL |     foo(baz, "string", |s| s.0.len() == 5);
-   |                        ^^^^^^^^^^^^^^^^^^
+   |                        ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/issue-71955.rs:25:44
    |
index 5a10a38d08ecdaaf494694eca8996d0a2b01a499..bc7b5e914e127956045de3e169eb5a3757759961 100644 (file)
@@ -1,19 +1,19 @@
-error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>`, but its trait bounds were not satisfied
+error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>`, but its trait bounds were not satisfied
   --> $DIR/issue-30786.rs:118:22
    |
 LL | pub struct Map<S, F> {
    | --------------------
-   | |          |
-   | |          method `filterx` not found for this struct
+   | |
+   | method `filterx` not found for this struct
    | doesn't satisfy `_: StreamExt`
 ...
 LL |     let filter = map.filterx(|x: &_| true);
-   |                      ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>` due to unsatisfied trait bounds
+   |                      ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>` due to unsatisfied trait bounds
    |
 note: the following trait bounds were not satisfied:
-      `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>: Stream`
-      `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>: Stream`
-      `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>: Stream`
+      `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
+      `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
+      `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
   --> $DIR/issue-30786.rs:96:50
    |
 LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
@@ -23,22 +23,22 @@ help: one of the expressions' fields has a method of the same name
 LL |     let filter = map.stream.filterx(|x: &_| true);
    |                      +++++++
 
-error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>`, but its trait bounds were not satisfied
+error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied
   --> $DIR/issue-30786.rs:130:24
    |
 LL | pub struct Filter<S, F> {
    | -----------------------
-   | |          |
-   | |          method `countx` not found for this struct
+   | |
+   | method `countx` not found for this struct
    | doesn't satisfy `_: StreamExt`
 ...
 LL |     let count = filter.countx();
-   |                        ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>` due to unsatisfied trait bounds
+   |                        ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds
    |
 note: the following trait bounds were not satisfied:
-      `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>: Stream`
-      `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>: Stream`
-      `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>: Stream`
+      `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
+      `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
+      `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
   --> $DIR/issue-30786.rs:96:50
    |
 LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
index 0ebba37e4ec70c60a876eef6eb360640e3332df5..79ef56b9fa5cb5d49594db090a9599dafbafd621 100644 (file)
@@ -1,8 +1,8 @@
-error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
+error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
   --> $DIR/issue-62203-hrtb-ice.rs:38:19
    |
 LL |     let v = Unit2.m(
-   |                   ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
+   |                   ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
    |
 note: expected this to be `<_ as Ty<'_>>::V`
   --> $DIR/issue-62203-hrtb-ice.rs:21:14
@@ -22,7 +22,7 @@ LL |     where
 LL |         F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
    |                                                   ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m`
 
-error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&'r u8,),)>>::Output == Unit3`
+error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20] as FnOnce<((&'r u8,),)>>::Output == Unit3`
   --> $DIR/issue-62203-hrtb-ice.rs:40:9
    |
 LL |       let v = Unit2.m(
@@ -34,7 +34,7 @@ LL | |             f : |x| { drop(x); Unit4 }
 LL | |         });
    | |_________^ expected struct `Unit3`, found struct `Unit4`
    |
-note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>`
+note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]>`
   --> $DIR/issue-62203-hrtb-ice.rs:17:16
    |
 LL | impl<'a, A, T> T0<'a, A> for L<T>
index d2452abab02549987b5352dfcd8624a60d307108..c2fbbf94fd66623678df17d392e4507993b2330e 100644 (file)
@@ -11,7 +11,6 @@ fn main() {
 // return type, which can't depend on the obligation.
 fn cycle1() -> impl Clone {
     //~^ ERROR cycle detected
-    //~| ERROR cycle detected
     send(cycle2().clone());
 
     Rc::new(Cell::new(5))
index 14db864f1c28af51ad3dcbf60085e9860f920818..634ff14869eb4d371384f31a382a5d4b93a66005 100644 (file)
@@ -30,129 +30,47 @@ note: ...which requires building MIR for `cycle1`...
 LL | fn cycle1() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires type-checking `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires computing type of `cycle2::{opaque#0}`...
-  --> $DIR/auto-trait-leak.rs:20:16
-   |
-LL | fn cycle2() -> impl Clone {
-   |                ^^^^^^^^^^
-note: ...which requires borrow-checking `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
-   |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
-   |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing MIR for `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
-   |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
-   |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
-   |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires type-checking `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
-   |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in top-level module
-  --> $DIR/auto-trait-leak.rs:1:1
-   |
-LL | / use std::cell::Cell;
-LL | | use std::rc::Rc;
-LL | |
-LL | | fn send<T: Send>(_: T) {}
-...  |
-LL | |     Rc::new(String::from("foo"))
-LL | | }
-   | |_^
-
-error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}`
-  --> $DIR/auto-trait-leak.rs:12:16
+  --> $DIR/auto-trait-leak.rs:14:5
    |
-LL | fn cycle1() -> impl Clone {
-   |                ^^^^^^^^^^
-   |
-note: ...which requires borrow-checking `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing MIR for `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires type-checking `cycle1`...
-  --> $DIR/auto-trait-leak.rs:12:1
-   |
-LL | fn cycle1() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     send(cycle2().clone());
+   |     ^^^^
+   = note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`...
 note: ...which requires computing type of `cycle2::{opaque#0}`...
-  --> $DIR/auto-trait-leak.rs:20:16
+  --> $DIR/auto-trait-leak.rs:19:16
    |
 LL | fn cycle2() -> impl Clone {
    |                ^^^^^^^^^^
 note: ...which requires borrow-checking `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
+  --> $DIR/auto-trait-leak.rs:19:1
    |
 LL | fn cycle2() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires processing `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
+  --> $DIR/auto-trait-leak.rs:19:1
    |
 LL | fn cycle2() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires processing MIR for `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
+  --> $DIR/auto-trait-leak.rs:19:1
    |
 LL | fn cycle2() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires unsafety-checking `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
+  --> $DIR/auto-trait-leak.rs:19:1
    |
 LL | fn cycle2() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires building MIR for `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
+  --> $DIR/auto-trait-leak.rs:19:1
    |
 LL | fn cycle2() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires type-checking `cycle2`...
-  --> $DIR/auto-trait-leak.rs:20:1
+  --> $DIR/auto-trait-leak.rs:20:5
    |
-LL | fn cycle2() -> impl Clone {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     send(cycle1().clone());
+   |     ^^^^
+   = note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`...
    = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
 note: cycle used when checking item types in top-level module
   --> $DIR/auto-trait-leak.rs:1:1
@@ -166,6 +84,6 @@ LL | |     Rc::new(String::from("foo"))
 LL | | }
    | |_^
 
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0391`.
index d825843492d49c3a5436e2d520c8cea4e5c7db08..52fa28145d6648cfb9d131a971bd1df090929bd0 100644 (file)
@@ -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
    |
index 8b671e7dbb3a783cfed67f25208691b5baf18acc..9150d957db76dc946b54d00eda84001a1f0a27c6 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for struct `Bar` in the current scope
   --> $DIR/issue-21659-show-relevant-trait-impls-3.rs:20:8
    |
 LL | struct Bar;
-   |        --- method `foo` not found for this struct
+   | ---------- method `foo` not found for this struct
 ...
 LL |     f1.foo(1usize);
    |        ^^^ method not found in `Bar`
index 2d14faf76775d67e6f33c86d10e85d88fd7a59bc..34f4dc2cef37dd3348af6f125f195abb12ea746d 100644 (file)
@@ -21,7 +21,7 @@ LL | pub struct RawImpl<T>(PhantomData<T>);
    | --------------------- doesn't satisfy `RawImpl<()>: Raw<()>`
 ...
 LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
-   |            -------- function or associated item `foo` not found for this struct
+   | ----------------------------------------- function or associated item `foo` not found for this struct
    |
    = note: the following trait bounds were not satisfied:
            `RawImpl<()>: Raw<()>`
index 0f855ef57927ad55856780dd5f0a212df309318e..5b05fb2810dff635554be485cc30b3e54faa16c6 100644 (file)
@@ -13,7 +13,7 @@ LL | |     })
    | |_____^ expected closure, found a different closure
    |
    = note: expected opaque type `Closure`
-                  found closure `[closure@$DIR/issue-74282.rs:8:15: 10:6]`
+                  found closure `[closure@$DIR/issue-74282.rs:8:15: 8:17]`
    = 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
index abd57d12d9e501bc22e07b16e233ea52c5bc7601..b727b2ca0cce313a0db163cb2e7ed1aaf4eee183 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `is_empty` found for struct `Foo` in the current s
   --> $DIR/method-suggestion-no-duplication.rs:7:15
    |
 LL | struct Foo;
-   |        --- method `is_empty` not found for this struct
+   | ---------- method `is_empty` not found for this struct
 ...
 LL |     foo(|s| s.is_empty());
    |               ^^^^^^^^ method not found in `Foo`
index f8ff2177bf5ac92729017ed366f47a17e2412720..586563c39061e34b2a3256a1ebe4cccf0520756e 100644 (file)
@@ -100,7 +100,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
   --> $DIR/must_outlive_least_region_or_bound.rs:38:5
    |
 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
-   |                              -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:31]` captures the lifetime `'b` as defined here
+   |                              -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:13]` captures the lifetime `'b` as defined here
 LL |     move |_| println!("{}", y)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
index 359fb909e5418e9271192872ee5b5732f2fa4c10..1079a86ce9e7345f504aa05a4ced95ac61ee008e 100644 (file)
@@ -5,7 +5,7 @@ LL | fn foo() -> impl Trait<Assoc = Sendable> {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `Sendable`
    |
    = help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:27:5: 27:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:27:5: 27:7]`
   --> $DIR/nested-return-type2-tait.rs:14:31
    |
 LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
index 3e19ad7b5c6cffc055fbda2f60bd31c8a8b18909..847b9400085313815233f834c27d13639eed6e73 100644 (file)
@@ -5,7 +5,7 @@ LL | fn foo() -> Traitable {
    |             ^^^^^^^^^ the trait `Duh` is not implemented for `Sendable`
    |
    = help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:28:5: 28:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:28:5: 28:7]`
   --> $DIR/nested-return-type2-tait2.rs:14:31
    |
 LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
index 6185e4872a5e368b49c05c66d37e6fa0fb1cc188..7b7f06b8e13e1d59f438d45275828156445d4e8a 100644 (file)
@@ -5,7 +5,7 @@ LL | fn foo() -> Traitable {
    |             ^^^^^^^^^ the trait `Duh` is not implemented for `impl Send`
    |
    = help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:27:5: 27:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:27:5: 27:7]`
   --> $DIR/nested-return-type2-tait3.rs:14:31
    |
 LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
index f996e99de074208a67bca89e474f2b6f0b4b974a..f28a084af89a427d6ba8515322ac7bea7645ffa6 100644 (file)
@@ -5,7 +5,7 @@ LL | fn foo() -> impl Trait<Assoc = impl Send> {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `impl Send`
    |
    = help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:23:5: 23:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:23:5: 23:7]`
   --> $DIR/nested-return-type2.rs:12:31
    |
 LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
index 1d24f428fb1e1bd075c30d1fc064dcb92d8e2dec..3d4ae11e5767039ab3659d58f60c79c32545ad86 100644 (file)
@@ -94,7 +94,7 @@ error[E0599]: no method named `method` found for struct `Foo` in the current sco
   --> $DIR/no-method-suggested-traits.rs:40:9
    |
 LL | struct Foo;
-   |        --- method `method` not found for this struct
+   | ---------- method `method` not found for this struct
 ...
 LL |     Foo.method();
    |         ^^^^^^ method not found in `Foo`
@@ -201,7 +201,7 @@ error[E0599]: no method named `method3` found for struct `Foo` in the current sc
   --> $DIR/no-method-suggested-traits.rs:59:9
    |
 LL | struct Foo;
-   |        --- method `method3` not found for this struct
+   | ---------- method `method3` not found for this struct
 ...
 LL |     Foo.method3();
    |         ^^^^^^^ method not found in `Foo`
@@ -224,7 +224,7 @@ error[E0599]: no method named `method3` found for enum `Bar` in the current scop
   --> $DIR/no-method-suggested-traits.rs:63:12
    |
 LL | enum Bar { X }
-   |      --- method `method3` not found for this enum
+   | -------- method `method3` not found for this enum
 ...
 LL |     Bar::X.method3();
    |            ^^^^^^^ method not found in `Bar`
index b9b2ce249f7bf5be81746a7399986fb943e98ab3..2e34d3d4275adef3a2fb335c362e233fe796b519 100644 (file)
@@ -54,7 +54,7 @@ LL |   fn closure_capture() -> impl Sized {
 LL | /     move || {
 LL | |         x;
 LL | |     }
-   | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 37:6]`
+   | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 35:12]`
 
 error[E0720]: cannot resolve opaque type
   --> $DIR/recursive-impl-trait-type-indirect.rs:40:29
@@ -65,7 +65,7 @@ LL |   fn closure_ref_capture() -> impl Sized {
 LL | /     move || {
 LL | |         &x;
 LL | |     }
-   | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 45:6]`
+   | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 43:12]`
 
 error[E0720]: cannot resolve opaque type
   --> $DIR/recursive-impl-trait-type-indirect.rs:48:21
@@ -74,7 +74,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:50:5: 50:21]`
+   |     ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:7]`
 
 error[E0720]: cannot resolve opaque type
   --> $DIR/recursive-impl-trait-type-indirect.rs:53:23
@@ -83,7 +83,7 @@ LL | fn generator_sig() -> impl Sized {
    |                       ^^^^^^^^^^ recursive opaque type
 LL |
 LL |     || generator_sig()
-   |     ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:23]`
+   |     ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:7]`
 
 error[E0720]: cannot resolve opaque type
   --> $DIR/recursive-impl-trait-type-indirect.rs:58:27
@@ -95,7 +95,7 @@ LL | /     move || {
 LL | |         yield;
 LL | |         x;
 LL | |     }
-   | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6]`
+   | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 61:12]`
 
 error[E0720]: cannot resolve opaque type
   --> $DIR/recursive-impl-trait-type-indirect.rs:67:35
@@ -117,7 +117,7 @@ LL | |         let x = generator_hold();
 LL | |         yield;
 LL | |         x;
 LL | |     }
-   | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6]`
+   | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 74:12]`
 
 error[E0720]: cannot resolve opaque type
   --> $DIR/recursive-impl-trait-type-indirect.rs:86:26
index bc8e39f9c504cf7380ce0cdbe7325a1735a694d6..951abb127c13fdbbb0164f5c7ae3ad19a84a2a1e 100644 (file)
@@ -2,7 +2,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
   --> $DIR/static-return-lifetime-infered.rs:7:9
    |
 LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
-   |                         ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34]>` captures the anonymous lifetime defined here
+   |                         ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here
 LL |         self.x.iter().map(|a| a.0)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
@@ -15,7 +15,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
   --> $DIR/static-return-lifetime-infered.rs:7:9
    |
 LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
-   |                         ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34]>` captures the anonymous lifetime defined here
+   |                         ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here
 LL |         self.x.iter().map(|a| a.0)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
@@ -28,7 +28,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
   --> $DIR/static-return-lifetime-infered.rs:12:9
    |
 LL |     fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
-   |                    -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:34]>` captures the lifetime `'a` as defined here
+   |                    -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:30]>` captures the lifetime `'a` as defined here
 LL |         self.x.iter().map(|a| a.0)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
@@ -41,7 +41,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
   --> $DIR/static-return-lifetime-infered.rs:12:9
    |
 LL |     fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
-   |                    -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:34]>` captures the lifetime `'a` as defined here
+   |                    -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:30]>` captures the lifetime `'a` as defined here
 LL |         self.x.iter().map(|a| a.0)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
index edf8a44b7e4a1750d4cf67b980fbb213f89d8059..51b61e3a66bb40652e60f1565cf7163a17a7c622 100644 (file)
@@ -43,7 +43,7 @@ error[E0599]: no method named `bar` found for struct `Foo` in the current scope
   --> $DIR/infinite-autoderef.rs:25:9
    |
 LL | struct Foo;
-   |        --- method `bar` not found for this struct
+   | ---------- method `bar` not found for this struct
 ...
 LL |     Foo.bar();
    |         ^^^ method not found in `Foo`
index 66fe3c74e2c872fc5ee1d8d2b264a2b5ce7af199..349fb6dafa36548d65390e0785f4d324fdfff9b9 100644 (file)
@@ -11,7 +11,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 `catch_unwind`
   --> $SRC_DIR/std/src/panic.rs:LL:COL
    |
index 79f6a5850b5efaf149f00a58370f99cc6338f799..1d3bff3a724ba73454dd350a5bdfa8bab3eab8c9 100644 (file)
@@ -1,18 +1,18 @@
-error[E0277]: the trait bound `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]: ~const FnOnce<()>` is not satisfied
+error[E0277]: the trait bound `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]: ~const FnOnce<()>` is not satisfied
   --> $DIR/const-eval-select-bad.rs:6:27
    |
 LL |     const_eval_select((), || {}, || {});
-   |     -----------------     ^^^^^ expected an `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
+   |     -----------------     ^^^^^ expected an `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]`
    |     |
    |     required by a bound introduced by this call
    |
-   = help: the trait `~const FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
-note: the trait `FnOnce<()>` is implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`, but that implementation is not `const`
+   = help: the trait `~const FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]`
+note: the trait `FnOnce<()>` is implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]`, but that implementation is not `const`
   --> $DIR/const-eval-select-bad.rs:6:27
    |
 LL |     const_eval_select((), || {}, || {});
    |                           ^^^^^
-   = note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]` in a closure with no arguments: `|| { /* code */ }`
+   = note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]` in a closure with no arguments: `|| { /* code */ }`
 note: required by a bound in `const_eval_select`
   --> $SRC_DIR/core/src/intrinsics.rs:LL:COL
    |
index ff78c252731bd1cd2113d64811ac116ec8108387..9322654b2928b3e14c81696cb126e6e84a2a2ac3 100644 (file)
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
   --> $DIR/intrinsic-raw_eq-const-padding.rs:6:5
    |
 LL |     std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16))
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading 4 bytes of memory starting at alloc3, but 1 byte is uninitialized starting at alloc3+0x1, and this operation requires initialized memory
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc3[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
 
 error: aborting due to previous error
 
index e1559ab2feaa7eccfa76648dce90d266d2662314..2c451b07fbe3acb4f88f173dd07c4777008bfe29 100644 (file)
@@ -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:41]`, which does not implement the `Copy` trait
+   = note: move occurs because `f` has type `[closure@$DIR/issue-12127.rs:8:24: 8:30]`, which does not implement the `Copy` trait
 
 error: aborting due to previous error
 
index 7a72a5ff11a45971ce4cd996e14fb3ac2b4e8418..9e888ed758a11617f2f646fb84908012f3af5543 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `kaname` found for struct `Homura` in the current
   --> $DIR/issue-19692.rs:4:40
    |
 LL | struct Homura;
-   |        ------ method `kaname` not found for this struct
+   | ------------- method `kaname` not found for this struct
 ...
 LL |     let Some(ref madoka) = Some(homura.kaname());
    |                                        ^^^^^^ method not found in `Homura`
index dab3c3d1797256b03dd7c005609f4a9ab557f22b..ea304f9367b05305991a0c267e252192e9dabf27 100644 (file)
@@ -5,29 +5,26 @@ LL | fn call_it<F>(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: F) where F: Fn() { f(); }
-   |                    - change this to accept `FnMut` instead of `Fn`
+LL | fn call_it<F>(f: F) where F: Fn() { f(); }
+   |                  - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 error: aborting due to 2 previous errors
 
index 4e010a13653e7796c0723c35125c33bdb5ce60b1..2d60b18b1f208eae86ab14800e0e4053f93304d4 100644 (file)
@@ -4,7 +4,13 @@ error[E0283]: type annotations needed: cannot satisfy `&'a T: Foo`
 LL |     where &'a T : Foo,
    |                   ^^^
    |
-   = note: cannot satisfy `&'a T: Foo`
+note: multiple `impl`s or `where` clauses satisfying `&'a T: Foo` found
+  --> $DIR/issue-21974.rs:11:19
+   |
+LL |     where &'a T : Foo,
+   |                   ^^^
+LL |           &'b T : Foo
+   |                   ^^^
 
 error: aborting due to previous error
 
index 648912a9690f4226bda2fb821c29ca3bd32cdb49..1a0e87e15d6bcefaf25cf93bbda10ddd3c43906c 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no variant or associated item named `PIE` found for enum `Deliciou
   --> $DIR/issue-22933-2.rs:4:55
    |
 LL | enum Delicious {
-   |      --------- variant or associated item `PIE` not found for this enum
+   | -------------- variant or associated item `PIE` not found for this enum
 ...
 LL |     ApplePie = Delicious::Apple as isize | Delicious::PIE as isize,
    |                                                       ^^^
index 052ccd07d411b85a87647e4f96f7fc844a6cf7b1..d07d1a7caaf2477bd51adc013f8d1539e4c6f4bf 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no variant or associated item named `Homura` found for enum `Token
   --> $DIR/issue-23173.rs:9:23
    |
 LL | enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ }
-   |      ----- variant or associated item `Homura` not found for this enum
+   | ---------- variant or associated item `Homura` not found for this enum
 ...
 LL |     use_token(&Token::Homura);
    |                       ^^^^^^ variant or associated item not found in `Token`
@@ -11,7 +11,7 @@ error[E0599]: no function or associated item named `method` found for struct `St
   --> $DIR/issue-23173.rs:10:13
    |
 LL | struct Struct {
-   |        ------ function or associated item `method` not found for this struct
+   | ------------- function or associated item `method` not found for this struct
 ...
 LL |     Struct::method();
    |             ^^^^^^ function or associated item not found in `Struct`
@@ -20,7 +20,7 @@ error[E0599]: no function or associated item named `method` found for struct `St
   --> $DIR/issue-23173.rs:11:13
    |
 LL | struct Struct {
-   |        ------ function or associated item `method` not found for this struct
+   | ------------- function or associated item `method` not found for this struct
 ...
 LL |     Struct::method;
    |             ^^^^^^ function or associated item not found in `Struct`
@@ -29,7 +29,7 @@ error[E0599]: no associated item named `Assoc` found for struct `Struct` in the
   --> $DIR/issue-23173.rs:12:13
    |
 LL | struct Struct {
-   |        ------ associated item `Assoc` not found for this struct
+   | ------------- associated item `Assoc` not found for this struct
 ...
 LL |     Struct::Assoc;
    |             ^^^^^ associated item not found in `Struct`
index c5906b8805dfe8adc9c70055dffa38aa5ef125db..5d3d8a4f808a8bd3910b2df6104bebdc442b6da7 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no variant or associated item named `A` found for enum `SomeEnum`
   --> $DIR/issue-23217.rs:2:19
    |
 LL | pub enum SomeEnum {
-   |          -------- variant or associated item `A` not found for this enum
+   | ----------------- variant or associated item `A` not found for this enum
 LL |     B = SomeEnum::A,
    |                   ^
    |                   |
index 4622501f33edae7a823ab372401f1d233f1a7a19..a42e35c4cad5c922f526b92b65dd202b08612179 100644 (file)
@@ -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:26]`
-              found closure `[closure@$DIR/issue-24036.rs:3:9: 3:18]`
+   = note: expected closure `[closure@$DIR/issue-24036.rs:2:17: 2:20]`
+              found closure `[closure@$DIR/issue-24036.rs:3:9: 3:12]`
    = note: no two closures, even if identical, have the same type
    = help: consider boxing your closure and/or using it as a trait object
 
index 8f3b2ac73199ccec1afced236ae6f1c0f0452522..50d7f988e194cdcd30d2fc72c9dd6a639eaebcd4 100644 (file)
@@ -4,7 +4,11 @@ error[E0283]: type annotations needed: cannot satisfy `T0: Trait0<'l0>`
 LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
    |                                                         ^^^^^^^^^^^
    |
-   = note: cannot satisfy `T0: Trait0<'l0>`
+note: multiple `impl`s or `where` clauses satisfying `T0: Trait0<'l0>` found
+  --> $DIR/issue-24424.rs:4:57
+   |
+LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
+   |                                                         ^^^^^^^^^^^       ^^^^^^^^^^^
 
 error: aborting due to previous error
 
index fcc007a4a8848a95f000ca5e23f90ebc9fb49a8e..b5a2b2f55a6d4905af0425b580efa1406101b0a9 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for struct `C` in the current scope
   --> $DIR/issue-2823.rs:13:16
    |
 LL | struct C {
-   |        - method `clone` not found for this struct
+   | -------- method `clone` not found for this struct
 ...
 LL |     let _d = c.clone();
    |                ^^^^^ method not found in `C`
index e0a65e33c445e15a50fe52579ea108a9ca3ae359..2eb8a1c2653c8794f52c0368cb75f5b99feb02ba 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no variant or associated item named `Baz` found for enum `Foo` in
   --> $DIR/issue-28971.rs:7:18
    |
 LL | enum Foo {
-   |      --- variant or associated item `Baz` not found for this enum
+   | -------- variant or associated item `Baz` not found for this enum
 ...
 LL |             Foo::Baz(..) => (),
    |                  ^^^
index 6dbe6b59391e369cb51c94ffb7c48242d57d3669..7230079dcffc1e225d769728334356068a47c198 100644 (file)
@@ -2,11 +2,13 @@ error[E0308]: mismatched types
   --> $DIR/issue-3044.rs:3:35
    |
 LL |       needlesArr.iter().fold(|x, y| {
-   |  ___________________________________^
+   |  ____________________________------_^
+   | |                            |
+   | |                            the expected closure
 LL | |     });
    | |_____^ expected closure, found `()`
    |
-   = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 4:6]`
+   = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 3:34]`
             found unit type `()`
 
 error[E0061]: this function takes 2 arguments but 1 argument was supplied
index 982b6118ce659bb2fe80aea8a5d4f0cfd53aa681..68337a715e14ff639343f5ad28a5ebbce7da5cd3 100644 (file)
@@ -1,4 +1,4 @@
-error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]> as Iterator>::Item == &_`
+error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item == &_`
   --> $DIR/issue-31173.rs:10:10
    |
 LL |         .cloned()
@@ -12,11 +12,11 @@ note: required by a bound in `cloned`
 LL |         Self: Sized + Iterator<Item = &'a T>,
    |                                ^^^^^^^^^^^^ required by this bound in `cloned`
 
-error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>`, but its trait bounds were not satisfied
+error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>`, but its trait bounds were not satisfied
   --> $DIR/issue-31173.rs:12:10
    |
 LL |         .collect();
-   |          ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` due to unsatisfied trait bounds
+   |          ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>` due to unsatisfied trait bounds
    |
   ::: $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL
    |
@@ -29,10 +29,10 @@ LL | pub struct TakeWhile<I, P> {
    | -------------------------- doesn't satisfy `<_ as Iterator>::Item = &_`
    |
    = note: the following trait bounds were not satisfied:
-           `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]> as Iterator>::Item = &_`
-           which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator`
-           `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator`
-           which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator`
+           `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item = &_`
+           which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
+           `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
+           which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
 
 error: aborting due to 2 previous errors
 
index a52dc0c9af0c68caeb711bd29e4bbd39d8b5a859..fd694df30457ec11998188b8c0d61946cfaab133 100644 (file)
@@ -2,10 +2,10 @@ error[E0599]: no method named `iter` found for struct `Iterate` in the current s
   --> $DIR/issue-41880.rs:27:24
    |
 LL | pub struct Iterate<T, F> {
-   |            ------- method `iter` not found for this struct
+   | ------------------------ method `iter` not found for this struct
 ...
 LL |     println!("{:?}", a.iter().take(10).collect::<Vec<usize>>());
-   |                        ^^^^ method not found in `Iterate<{integer}, [closure@$DIR/issue-41880.rs:26:24: 26:31]>`
+   |                        ^^^^ method not found in `Iterate<{integer}, [closure@$DIR/issue-41880.rs:26:24: 26:27]>`
 
 error: aborting due to previous error
 
index fa3b58e1279378353ddd0c6033eb9edee9518b0f..ecc1fa523989221b402247149869a8b8986cd092 100644 (file)
@@ -4,9 +4,8 @@ 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<dyn FnMut() -> 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
 
 error: aborting due to previous error
index 712a7bc33f840f33cf56ab4fa2310fd29a4f2249..3502af7028baa1d487553a6a32aaa3f0c4480774 100644 (file)
@@ -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:19]`
+           found closure `[closure@$DIR/issue-48838.rs:2:14: 2:17]`
 
 error: aborting due to previous error
 
index 08d9a8399200acb9e4105bd27478eafddb83464b..7fea7e5c0985ee9122eeeca55af5cb11d8f6522d 100644 (file)
@@ -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:23]`
+           found closure `[closure@$DIR/issue-50600.rs:2:13: 2:20]`
 
 error: aborting due to previous error
 
index 1f348c4cf1f66322e480871baec4eba8a3148cc4..6973ad271b40de76ee9a9957916ce83fa3d649d5 100644 (file)
@@ -5,7 +5,7 @@ LL |     [1; || {}];
    |         ^^^^^ expected `usize`, found closure
    |
    = note: expected type `usize`
-           found closure `[closure@$DIR/issue-50688.rs:2:9: 2:14]`
+           found closure `[closure@$DIR/issue-50688.rs:2:9: 2:11]`
 
 error: aborting due to previous error
 
index f2cbc3e6feb78d761f305a63b27de263003bbf5c..44ec626dea5fc7f2fc6248451a00c32d74eaf903 100644 (file)
@@ -9,7 +9,7 @@ LL |     let _: Box<F> = Box::new(|| ());
    |                     arguments to this function are incorrect
    |
    = note: expected type parameter `F`
-                     found closure `[closure@$DIR/issue-51154.rs:2:30: 2:35]`
+                     found closure `[closure@$DIR/issue-51154.rs:2:30: 2:32]`
    = 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
index a25b6b8802a9ce4dfc4485de6e977d0e3e12d622..b6b1f3a66c7855fd55f8b2a0c515d6550c9b0522 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `bar` found for struct `Foo` in the current scope
   --> $DIR/issue-64430.rs:7:9
    |
 LL | pub struct Foo;
-   |            --- method `bar` not found for this struct
+   | -------------- method `bar` not found for this struct
 ...
 LL |     Foo.bar()
    |         ^^^ method not found in `Foo`
index 2a683c2d55a3585732819ac14bd676bd0c5e7233..b8b0eb310cf3eade796c62c76f444dc4fed2c73a 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `bar` found for struct `Foo`
   --> $DIR/issue-7950.rs:6:10
    |
 LL | struct Foo;
-   |        --- function or associated item `bar` not found for this struct
+   | ---------- function or associated item `bar` not found for this struct
 ...
 LL |     Foo::bar();
    |          ^^^ function or associated item not found in `Foo`
index 727573a0be4edb753d7d8ab745c34f96e873f28d..eab003a1107829b4dc8ea4626805d109b59fce7d 100644 (file)
@@ -2,16 +2,16 @@ error[E0277]: `Rc<usize>` cannot be sent between threads safely
   --> $DIR/kindck-nonsendable-1.rs:9:5
    |
 LL |     bar(move|| foo(x));
-   |     ^^^ ------------- within this `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22]`
+   |     ^^^ ------ within this `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15]`
    |     |
    |     `Rc<usize>` cannot be sent between threads safely
    |
-   = help: within `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22]`, the trait `Send` is not implemented for `Rc<usize>`
+   = help: within `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15]`, the trait `Send` is not implemented for `Rc<usize>`
 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
    |
index 5832c4d173c10245c4574f5c47a058be2ad345eb..a78b3eaf6258de856afff0a18066d08824939ad1 100644 (file)
@@ -4,7 +4,13 @@ error[E0283]: type annotations needed: cannot satisfy `&'a (): Foo`
 LL |     &'a (): Foo,
    |             ^^^
    |
-   = note: cannot satisfy `&'a (): Foo`
+note: multiple `impl`s or `where` clauses satisfying `&'a (): Foo` found
+  --> $DIR/issue-34979.rs:6:13
+   |
+LL |     &'a (): Foo,
+   |             ^^^
+LL |     &'static (): Foo;
+   |                  ^^^
 
 error: aborting due to previous error
 
index 6d8f2f5668321072fbfc30822ffa7836c0939cbe..9322e617176a1f10e98f448d58cab829d3aa8488 100644 (file)
@@ -37,7 +37,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-79187-2.rs:8:14
    |
 LL |     take_foo(|a| a);
-   |              ^^^^^
+   |              ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/issue-79187-2.rs:5:21
    |
index 1d89d4dac5ed3a265ead3b3b6f0cb28533dfa308..3e75e7fed2cc14c51fe32a6a6d65d1245b72c77f 100644 (file)
@@ -10,7 +10,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-79187.rs:4:13
    |
 LL |     let f = |_| ();
-   |             ^^^^^^
+   |             ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/issue-79187.rs:1:18
    |
index 141703460ba0ee4fc844f39026d39f797e4c089d..8a216360f4e3bff5950b1139b3165e04b7c105ed 100644 (file)
@@ -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:25]` as `&dyn Fn(i32)`
+error: trivial cast: `&[closure@$DIR/trivial_casts.rs:72:13: 72:22]` as `&dyn Fn(i32)`
   --> $DIR/trivial_casts.rs:73:13
    |
 LL |     let _ = &x as &dyn Fn(i32);
index b242ec4296d664c68f312d07f1051ccfccce1bab..6546e397785caab6a6e5a96351275af157bfc589 100644 (file)
@@ -6,7 +6,7 @@ fn test1() {
     'a: loop {
         x = loop { break 'a };
     }
-    println!("{:?}", x); //~ ERROR borrow of possibly-uninitialized variable
+    println!("{:?}", x); //~ ERROR E0381
 }
 
 // test2 and test3 should not fail.
index 20d5c66a3f20581c789238f26c733a54c859c8d5..75041031736526066f90f1ef888d06fea637af7c 100644 (file)
@@ -1,8 +1,11 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/loop-proper-liveness.rs:9:22
    |
+LL |     let x: i32;
+   |         - binding declared here but left uninitialized
+...
 LL |     println!("{:?}", x);
-   |                      ^ use of possibly-uninitialized `x`
+   |                      ^ `x` used here but it isn't initialized
    |
    = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 4be588fe7f92ac9cb132837b3b88c170d62fcefa..690fe8fa7af1005d0e0e7eafd82ff8b405139ce1 100644 (file)
@@ -51,8 +51,8 @@ error[E0599]: `Foo` is not an iterator
    |
 LL | pub struct Foo;
    | --------------
-   | |          |
-   | |          method `take` not found for this struct
+   | |
+   | method `take` not found for this struct
    | doesn't satisfy `Foo: Iterator`
 ...
 LL |      .take()
index 045f9ab700420b2b244d450da90b2834a538a66d..040a65d168091c8e4b84b500d4278954c7c3d40a 100644 (file)
@@ -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<Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>`
+error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:23]>, [closure@$DIR/method-missing-call.rs:28:23: 28:28]>`
   --> $DIR/method-missing-call.rs:29:16
    |
 LL |               .filter_map;
index 492d480e13e86e535432180cff9d45c65ace48f1..56e1b5a0f44738cb339a0588d024ada8ef50a9d6 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `distance` found for struct `Point<i32>` in the cu
   --> $DIR/method-not-found-generic-arg-elision.rs:82:23
    |
 LL | struct Point<T> {
-   |        ----- method `distance` not found for this struct
+   | --------------- method `distance` not found for this struct
 ...
 LL |     let d = point_i32.distance();
    |                       ^^^^^^^^ method not found in `Point<i32>`
@@ -14,7 +14,7 @@ error[E0599]: no method named `other` found for struct `Point` in the current sc
   --> $DIR/method-not-found-generic-arg-elision.rs:84:23
    |
 LL | struct Point<T> {
-   |        ----- method `other` not found for this struct
+   | --------------- method `other` not found for this struct
 ...
 LL |     let d = point_i32.other();
    |                       ^^^^^ method not found in `Point<i32>`
@@ -23,13 +23,13 @@ error[E0599]: no method named `extend` found for struct `Map` in the current sco
   --> $DIR/method-not-found-generic-arg-elision.rs:87:29
    |
 LL |     v.iter().map(|x| x * x).extend(std::iter::once(100));
-   |                             ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@$DIR/method-not-found-generic-arg-elision.rs:87:18: 87:27]>`
+   |                             ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@$DIR/method-not-found-generic-arg-elision.rs:87:18: 87:21]>`
 
 error[E0599]: no method named `method` found for struct `Wrapper<bool>` in the current scope
   --> $DIR/method-not-found-generic-arg-elision.rs:90:13
    |
 LL | struct Wrapper<T>(T);
-   |        ------- method `method` not found for this struct
+   | ----------------- method `method` not found for this struct
 ...
 LL |     wrapper.method();
    |             ^^^^^^ method not found in `Wrapper<bool>`
@@ -45,7 +45,7 @@ error[E0599]: no method named `other` found for struct `Wrapper` in the current
   --> $DIR/method-not-found-generic-arg-elision.rs:92:13
    |
 LL | struct Wrapper<T>(T);
-   |        ------- method `other` not found for this struct
+   | ----------------- method `other` not found for this struct
 ...
 LL |     wrapper.other();
    |             ^^^^^ method not found in `Wrapper<bool>`
@@ -54,7 +54,7 @@ error[E0599]: no method named `method` found for struct `Wrapper2<'_, bool, 3_us
   --> $DIR/method-not-found-generic-arg-elision.rs:96:13
    |
 LL | struct Wrapper2<'a, T, const C: usize> {
-   |        -------- method `method` not found for this struct
+   | -------------------------------------- method `method` not found for this struct
 ...
 LL |     wrapper.method();
    |             ^^^^^^ method not found in `Wrapper2<'_, bool, 3_usize>`
@@ -68,7 +68,7 @@ error[E0599]: no method named `other` found for struct `Wrapper2` in the current
   --> $DIR/method-not-found-generic-arg-elision.rs:98:13
    |
 LL | struct Wrapper2<'a, T, const C: usize> {
-   |        -------- method `other` not found for this struct
+   | -------------------------------------- method `other` not found for this struct
 ...
 LL |     wrapper.other();
    |             ^^^^^ method not found in `Wrapper2<'_, bool, 3_usize>`
@@ -83,7 +83,7 @@ error[E0599]: the method `method` exists for struct `Struct<f64>`, but its trait
   --> $DIR/method-not-found-generic-arg-elision.rs:104:7
    |
 LL | struct Struct<T>{
-   |        ------ method `method` not found for this struct
+   | ---------------- method `method` not found for this struct
 ...
 LL |     s.method();
    |       ^^^^^^ method cannot be called on `Struct<f64>` due to unsatisfied trait bounds
index c44dd51a5ec86522bacfbb1eb8fa4250de10c7dd..fc7341a563bb2a9d6b9ab144c9df8d63b430429a 100644 (file)
@@ -6,7 +6,7 @@
     //~^ ERROR destructors cannot be evaluated at compile-time
     a[0] = String::new();
     //~^ ERROR destructors cannot be evaluated at compile-time
-    //~| ERROR use of possibly-uninitialized variable
+    //~| ERROR binding `a` isn't initialized
 };
 
 struct B<T>([T; 1]);
index 80d5fc7ec672c0df12754c3e0f8aa0a32b40d654..d8154f8d2cbc40ad33d0340fc660c2f19751d724 100644 (file)
@@ -16,11 +16,14 @@ LL |     let a: [String; 1];
 LL | };
    | - value is dropped here
 
-error[E0381]: use of possibly-uninitialized variable: `a`
+error[E0381]: used binding `a` isn't initialized
   --> $DIR/drop-elaboration-after-borrowck-error.rs:7:5
    |
+LL |     let a: [String; 1];
+   |         - binding declared here but left uninitialized
+LL |
 LL |     a[0] = String::new();
-   |     ^^^^ use of possibly-uninitialized `a`
+   |     ^^^^ `a` used here but it isn't initialized
 
 error[E0493]: destructors cannot be evaluated at compile-time
   --> $DIR/drop-elaboration-after-borrowck-error.rs:18:9
index 1f46229cb5a6a666f4a7345513f1b3f3178f1eb3..d9578f6c8dcf6e26a59873872da391c9af04bd63 100644 (file)
@@ -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 of `fn((u32, u32)) -> _`
+   |              ^^^ --------------- found signature of `fn((u32, u32)) -> _`
    |              |
    |              expected signature of `fn(&(u32, u32)) -> _`
    |
@@ -16,7 +16,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 of `for<'r> fn(&'r (u16, u16)) -> _`
+   |              ^^^ ---------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
    |              |
    |              expected signature of `fn(&(u32, u32)) -> _`
    |
@@ -30,7 +30,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 of `fn((u16, u16)) -> _`
+   |              ^^^ --------------- found signature of `fn((u16, u16)) -> _`
    |              |
    |              expected signature of `fn(&(u32, u32)) -> _`
    |
index c1a29dfc9339f140040ee2f74f9c07aed91f0409..ef76ec63fdaf85c51420f060bc9f0f6c53b6cb36 100644 (file)
@@ -19,7 +19,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/closure-mismatch.rs:8:9
    |
 LL |     baz(|_| ());
-   |         ^^^^^^
+   |         ^^^
 note: the lifetime requirement is introduced here
   --> $DIR/closure-mismatch.rs:5:11
    |
index a8bcdf5efe91e30214a5f24f844e1d80dfd2f79a..9d1ea70f8a4a4ae33cf9eeaf1838357af74d2e32 100644 (file)
@@ -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 of `for<'r> fn(&'r str) -> _`
+   |                                ^^^^^^ --------- found signature of `for<'r> fn(&'r str) -> _`
    |                                |
    |                                expected signature of `for<'r> fn(&'r &str) -> _`
    |
@@ -12,11 +12,11 @@ note: required by a bound in `filter`
 LL |         P: FnMut(&Self::Item) -> bool,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `filter`
 
-error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>`, but its trait bounds were not satisfied
+error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>`, but its trait bounds were not satisfied
   --> $DIR/issue-36053-2.rs:7:55
    |
 LL |     once::<&str>("str").fuse().filter(|a: &str| true).count();
-   |                                       --------------  ^^^^^ method cannot be called on `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` due to unsatisfied trait bounds
+   |                                       ---------       ^^^^^ method cannot be called on `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>` due to unsatisfied trait bounds
    |                                       |
    |                                       doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool`
    |                                       doesn't satisfy `_: FnMut<(&&str,)>`
@@ -27,12 +27,12 @@ LL | pub struct Filter<I, P> {
    | ----------------------- doesn't satisfy `_: Iterator`
    |
    = note: the following trait bounds were not satisfied:
-           `<[closure@$DIR/issue-36053-2.rs:7:39: 7:53] as FnOnce<(&&str,)>>::Output = bool`
-           which is required by `Filter<Fuse<std::iter::Once<&str>>, [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<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
-           `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
-           which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
+           `<[closure@$DIR/issue-36053-2.rs:7:39: 7:48] as FnOnce<(&&str,)>>::Output = bool`
+           which is required by `Filter<Fuse<std::iter::Once<&str>>, [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<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
+           `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
+           which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
 
 error: aborting due to 2 previous errors
 
index e6bc4e22ec22c2ada1bade54a5cdd8d4e8d8ca36..d76b69ecdc8bb15c0b553195281041bdcd6d2542 100644 (file)
@@ -57,17 +57,17 @@ fn moved_loop_2() {
 
 fn uninit_1() {
     loop {
-        let value: NonCopy;
-        let _used = value; //~ ERROR use of possibly-uninitialized variable: `value`
-        //~^ NOTE use of possibly-uninitialized `value`
+        let value: NonCopy; //~ NOTE declared here
+        let _used = value; //~ ERROR binding `value` isn't initialized
+        //~^ NOTE `value` used here but it isn't initialized
     }
 }
 
 fn uninit_2() {
-    let mut value: NonCopy;
+    let mut value: NonCopy; //~ NOTE declared here
     loop {
-        let _used = value; //~ ERROR use of possibly-uninitialized variable: `value`
-        //~^ NOTE use of possibly-uninitialized `value`
+        let _used = value; //~ ERROR binding `value` isn't initialized
+        //~^ NOTE `value` used here but it isn't initialized
     }
 }
 
index 076d3dff1408699dc7bc56df57f4f98d264773dd..c7373b5be9d8dc7471d2b14543fefb08ce4a5b71 100644 (file)
@@ -40,17 +40,22 @@ LL |     let mut value = NonCopy{};
 LL |         let _used2 = value;
    |                      ^^^^^ value moved here, in previous iteration of loop
 
-error[E0381]: use of possibly-uninitialized variable: `value`
+error[E0381]: used binding `value` isn't initialized
   --> $DIR/issue-72649-uninit-in-loop.rs:61:21
    |
+LL |         let value: NonCopy;
+   |             ----- binding declared here but left uninitialized
 LL |         let _used = value;
-   |                     ^^^^^ use of possibly-uninitialized `value`
+   |                     ^^^^^ `value` used here but it isn't initialized
 
-error[E0381]: use of possibly-uninitialized variable: `value`
+error[E0381]: used binding `value` isn't initialized
   --> $DIR/issue-72649-uninit-in-loop.rs:69:21
    |
+LL |     let mut value: NonCopy;
+   |         --------- binding declared here but left uninitialized
+LL |     loop {
 LL |         let _used = value;
-   |                     ^^^^^ use of possibly-uninitialized `value`
+   |                     ^^^^^ `value` used here but it isn't initialized
 
 error: aborting due to 6 previous errors
 
index 2d0ff58526393ac9d0c4935f1a159d237fde28a2..0b8d76def872c9587518e10ae4200258d12c1d49 100644 (file)
@@ -11,5 +11,5 @@ fn main() {
 
 fn foo(i: usize) {
     let mut a: [D; 4];
-    a[i] = d();        //~ ERROR use of possibly-uninitialized variable: `a`
+    a[i] = d(); //~ ERROR E0381
 }
index 5f20ccfeddf48f4fa059126d452395cd19d4d136..344a6bbf0c92c77b192298f983efc3e988d59efc 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: use of possibly-uninitialized variable: `a`
+error[E0381]: used binding `a` isn't initialized
   --> $DIR/move-into-dead-array-1.rs:14:5
    |
+LL |     let mut a: [D; 4];
+   |         ----- binding declared here but left uninitialized
 LL |     a[i] = d();
-   |     ^^^^ use of possibly-uninitialized `a`
+   |     ^^^^ `a` used here but it isn't initialized
 
 error: aborting due to previous error
 
index f2f64e43cd2de19ca60cb793aad389d721bb5692..19fd7028692d416efbd24898815380220581f730 100644 (file)
@@ -5,7 +5,7 @@
 
 fn main() {
     let mut x: S;
-    std::ptr::addr_of_mut!(x); //~ borrow of
+    std::ptr::addr_of_mut!(x); //~ ERROR E0381
 
     let y = x; // Should error here if `addr_of_mut` is ever allowed on uninitialized variables
     drop(y);
index ce8fb0283165c0b4f95cb38f6f4343965ab78590..e75f2b1c0894c63b17a3a5eedd53aeff5533cb28 100644 (file)
@@ -1,8 +1,10 @@
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/move-of-addr-of-mut.rs:8:5
    |
+LL |     let mut x: S;
+   |         ----- binding declared here but left uninitialized
 LL |     std::ptr::addr_of_mut!(x);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `x`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ `x` used here but it isn't initialized
    |
    = note: this error originates in the macro `std::ptr::addr_of_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index ce930eee2e919a8d336317f87d15aa2b7fc86c53..125e446c332590c8ca243b2416029b6da7289196 100644 (file)
@@ -4,9 +4,8 @@ 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<usize>`, which does not implement the `Copy` trait
+   |                    --      ^ move occurs because `i` has type `Box<usize>`, which does not implement the `Copy` trait
+   |                    |
    |                    captured by this `Fn` closure
 
 error: aborting due to previous error
index 6b9635d4a60bcd889b794d08db7625fbf898b597..2acf44432c65fde1073d4a4748fab12e4c612e8e 100644 (file)
@@ -1,4 +1,4 @@
-error[E0271]: type mismatch resolving `<[closure@$DIR/fallback-closure-wrap.rs:18:40: 21:6] as FnOnce<()>>::Output == ()`
+error[E0271]: type mismatch resolving `<[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47] as FnOnce<()>>::Output == ()`
   --> $DIR/fallback-closure-wrap.rs:18:31
    |
 LL |       let error = Closure::wrap(Box::new(move || {
@@ -10,7 +10,7 @@ LL | |     }) as Box<dyn FnMut()>);
    |
    = note: expected unit type `()`
                    found type `!`
-   = note: required for the cast from `[closure@$DIR/fallback-closure-wrap.rs:18:40: 21:6]` to the object type `dyn FnMut()`
+   = note: required for the cast from `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to the object type `dyn FnMut()`
 
 error: aborting due to previous error
 
index a59e553315ae68f2be162c465120c804091d7ab6..5233f0b246261378bd26cab860c12453ab1117e5 100644 (file)
@@ -37,36 +37,32 @@ LL |         x = 1;
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 error[E0594]: cannot assign to `x`, as it is not declared as mutable
   --> $DIR/closure-captures.rs:39:10
@@ -80,19 +76,17 @@ LL |          x = 1;}
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 error[E0594]: cannot assign to `x`, as it is not declared as mutable
   --> $DIR/closure-captures.rs:43:5
@@ -106,53 +100,47 @@ LL |     x = 1;});
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 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: Fn()>(f: F) -> F { f }
-   |                         - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+   |                       - change this to accept `FnMut` instead of `Fn`
 ...
-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
+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
 
 error: aborting due to 12 previous errors
 
index ff16bf0e078fc191aac6f4729b705846003415f8..f86a19fff8458b6734b23159673f6d795781a827 100644 (file)
@@ -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 substs [
                i16,
index 49ec0dd931ac0e42c5ebd910322277bba7ed346d..8cd8b43cabec6e59ad725bbac26859de67b7bb48 100644 (file)
@@ -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 substs [
                i16,
index f0ae4c7fb0492430dc6171bfa54401647dbdbb44..abf80e03928990643f4f283b2fdc6313a1e7cbc3 100644 (file)
@@ -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 substs [
                i16,
@@ -15,12 +15,8 @@ LL |             let mut closure1 = || p = &y;
 note: external requirements
   --> $DIR/escape-upvar-nested.rs:20:27
    |
-LL |           let mut closure = || {
-   |  ___________________________^
-LL | |             let mut closure1 = || p = &y;
-LL | |             closure1();
-LL | |         };
-   | |_________^
+LL |         let mut closure = || {
+   |                           ^^
    |
    = note: defining type: test::{closure#0} with closure substs [
                i16,
index e99fc4b43a23ddb050f7653c70ae323a21b2de31..bc7546421731a4496ad4ef0e9455297d8f82ad9b 100644 (file)
@@ -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 substs [
                i16,
index 11420efaa066eeecb1bdf521159525930ac5e63d..b9b0f3ad257898d46409894d82aaf7bbd2ef15b5 100644 (file)
@@ -1,12 +1,8 @@
 note: no external requirements
   --> $DIR/propagate-approximated-fail-no-postdom.rs:43:9
    |
-LL | /         |_outlives1, _outlives2, _outlives3, x, y| {
-LL | |             // Only works if 'x: 'y:
-LL | |             let p = x.get();
-LL | |             demand_y(x, y, p)
-LL | |         },
-   | |_________^
+LL |         |_outlives1, _outlives2, _outlives3, x, y| {
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 98c3c28fb43ff8382ee5c02e9dca9a78ff75f405..a2371ee314a775b9b6465920663c8bfd0df64dbb 100644 (file)
@@ -1,13 +1,8 @@
 note: external requirements
   --> $DIR/propagate-approximated-ref.rs:43:47
    |
-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 | |     });
-   | |_____^
+LL |     establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 3ab55b370c2318e7b3f991f5f97996d245698e87..e53ae167f12d6695732358867a09a5152fe723be 100644 (file)
@@ -1,12 +1,8 @@
 note: no external requirements
   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15
    |
-LL |       foo(cell, |cell_a, cell_x| {
-   |  _______________^
-LL | |         cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
-LL | |
-LL | |     })
-   | |_____^
+LL |     foo(cell, |cell_a, cell_x| {
+   |               ^^^^^^^^^^^^^^^^
    |
    = note: defining type: case1::{closure#0} with closure substs [
                i32,
@@ -41,11 +37,8 @@ LL | | }
 note: external requirements
   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15
    |
-LL |       foo(cell, |cell_a, cell_x| {
-   |  _______________^
-LL | |         cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
-LL | |     })
-   | |_____^
+LL |     foo(cell, |cell_a, cell_x| {
+   |               ^^^^^^^^^^^^^^^^
    |
    = note: defining type: case2::{closure#0} with closure substs [
                i32,
index ec2c220b6b8a044ea64a0a29c3253311a2e98c57..c3c7eb1bd9e5ed6f84a4747a8b024f1c365de03b 100644 (file)
@@ -1,14 +1,8 @@
 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 | |
-LL | |
-LL | |         // Only works if 'x: 'y:
-LL | |         demand_y(x, y, x.get())
-LL | |     });
-   | |_____^
+LL |     establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
+   |                                               ^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 234212c88767af4b5bfe34112dc9737a7a825cfb..846e5aedb3e73e0638108dc6e818c457afd24aad 100644 (file)
@@ -1,14 +1,8 @@
 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 | |
-LL | |
-LL | |         // Only works if 'x: 'y:
-LL | |         demand_y(x, y, x.get())
-LL | |     });
-   | |_____^
+LL |     establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 2ec9d4d8db1a6aa4d3b133b8bf171292bc1ce56e..a570932eda9adef27acaf5fb1b0a21c634b99ec3 100644 (file)
@@ -1,13 +1,8 @@
 note: external requirements
   --> $DIR/propagate-approximated-val.rs:36:45
    |
-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 | |     });
-   | |_____^
+LL |     establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
+   |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: defining type: test::{closure#0} with closure substs [
                i16,
index 21e4232c788fb928c4a64b2e1fe3b0d1c6ab327d..407bc6764d6da11d5d9d87d07259d43e545c4dfb 100644 (file)
@@ -1,12 +1,8 @@
 note: external requirements
   --> $DIR/propagate-despite-same-free-region.rs:42:9
    |
-LL | /         |_outlives1, _outlives2, x, y| {
-LL | |             // Only works if 'x: 'y:
-LL | |             let p = x.get();
-LL | |             demand_y(x, y, p)
-LL | |         },
-   | |_________^
+LL |         |_outlives1, _outlives2, x, y| {
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 8b9b0435420573c0dc5e7ec7f65c67bc3d50c4cc..fcb55d37f310a01c0ef83bb1e1bc3eb3227f26d2 100644 (file)
@@ -1,13 +1,8 @@
 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 | |         // Only works if 'x: 'y:
-LL | |         demand_y(x, y, x.get())
-LL | |
-LL | |     });
-   | |_____^
+LL |     establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
+   |                                               ^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 060ce690f0306ac492a5d366b9318869cb07be52..75beae39e2310e880280d1011920a0b4bad8dfe0 100644 (file)
@@ -1,13 +1,8 @@
 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 | |         // Only works if 'x: 'y:
-LL | |         demand_y(x, y, x.get())
-LL | |
-LL | |     });
-   | |_____^
+LL |     establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: defining type: supply::{closure#0} with closure substs [
                i16,
index 08605efa2ea9cba750e333d96162a8f7754f1d13..58aced2bfcdb18a438e798bd5102a443a662fb00 100644 (file)
@@ -1,15 +1,8 @@
 note: external requirements
   --> $DIR/propagate-from-trait-match.rs:32:36
    |
-LL |       establish_relationships(value, |value| {
-   |  ____________________________________^
-LL | |
-LL | |
-LL | |         // This function call requires that
-...  |
-LL | |         require(value);
-LL | |     });
-   | |_____^
+LL |     establish_relationships(value, |value| {
+   |                                    ^^^^^^^
    |
    = note: defining type: supply::<'_#1r, T>::{closure#0} with closure substs [
                i32,
index 5fc1d5c43618154f55ac5fc9644402799d72a4cd..1c9d0c835494d4005ba9a454ccf16d17eb943ea4 100644 (file)
@@ -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 substs [
                i16,
index ebea6d3d9d1ea8e4005558791701b560971d3b59..46a156d2af9eeaa083336a64748ea155f4f1b242 100644 (file)
@@ -25,14 +25,12 @@ fn drop(&mut self) { }
 
 fn cannot_partially_init_adt_with_drop() {
     let d: D;
-    d.x = 10;
-    //~^ ERROR assign of possibly-uninitialized variable: `d` [E0381]
+    d.x = 10; //~ ERROR E0381
 }
 
 fn cannot_partially_init_mutable_adt_with_drop() {
     let mut d: D;
-    d.x = 10;
-    //~^ ERROR assign of possibly-uninitialized variable: `d` [E0381]
+    d.x = 10; //~ ERROR E0381
 }
 
 fn cannot_partially_reinit_adt_with_drop() {
@@ -44,14 +42,12 @@ fn cannot_partially_reinit_adt_with_drop() {
 
 fn cannot_partially_init_inner_adt_via_outer_with_drop() {
     let d: D;
-    d.s.y = 20;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `d` [E0381]
+    d.s.y = 20; //~ ERROR E0381
 }
 
 fn cannot_partially_init_inner_adt_via_mutable_outer_with_drop() {
     let mut d: D;
-    d.s.y = 20;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `d` [E0381]
+    d.s.y = 20; //~ ERROR E0381
 }
 
 fn cannot_partially_reinit_inner_adt_via_outer_with_drop() {
index 1b66e034d37859a216c124dc5b80678a11c47746..63f230be7d4b3afdf26c31d2f35c24ad260575c3 100644 (file)
@@ -1,17 +1,25 @@
-error[E0381]: assign of possibly-uninitialized variable: `d`
+error[E0381]: assigned binding `d` isn't fully initialized
   --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:28:5
    |
+LL |     let d: D;
+   |         - binding declared here but left uninitialized
 LL |     d.x = 10;
-   |     ^^^^^^^^ use of possibly-uninitialized `d`
+   |     ^^^^^^^^ `d` assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign of possibly-uninitialized variable: `d`
-  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:34:5
+error[E0381]: assigned binding `d` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:33:5
    |
+LL |     let mut d: D;
+   |         ----- binding declared here but left uninitialized
 LL |     d.x = 10;
-   |     ^^^^^^^^ use of possibly-uninitialized `d`
+   |     ^^^^^^^^ `d` assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign of moved value: `d`
-  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:41:5
+  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:39:5
    |
 LL |     let mut d = D { x: 0, s: S{ y: 0, z: 0 } };
    |         ----- move occurs because `d` has type `D`, which does not implement the `Copy` trait
@@ -20,20 +28,28 @@ LL |     drop(d);
 LL |     d.x = 10;
    |     ^^^^^^^^ value assigned here after move
 
-error[E0381]: assign to part of possibly-uninitialized variable: `d`
-  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:47:5
+error[E0381]: partially assigned binding `d` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:45:5
    |
+LL |     let d: D;
+   |         - binding declared here but left uninitialized
 LL |     d.s.y = 20;
-   |     ^^^^^^^^^^ use of possibly-uninitialized `d.s`
+   |     ^^^^^^^^^^ `d.s` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `d`
-  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:53:5
+error[E0381]: partially assigned binding `d` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:50:5
    |
+LL |     let mut d: D;
+   |         ----- binding declared here but left uninitialized
 LL |     d.s.y = 20;
-   |     ^^^^^^^^^^ use of possibly-uninitialized `d.s`
+   |     ^^^^^^^^^^ `d.s` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign to part of moved value: `d`
-  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:60:5
+  --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:56:5
    |
 LL |     let mut d = D { x: 0, s: S{ y: 0, z: 0} };
    |         ----- move occurs because `d` has type `D`, which does not implement the `Copy` trait
index 1836f766cc7ef8a9a6ddd88ee0de134ac303fc28..4cd1e406f94400dc4b81b6b56b01126f983eb4ac 100644 (file)
@@ -94,15 +94,13 @@ macro_rules! use_part {
 
 fn test_0000_local_fully_init_and_use_struct() {
     let s: S<B>;
-    s.x = 10; s.y = Box::new(20);
-    //~^ ERROR assign to part of possibly-uninitialized variable: `s` [E0381]
+    s.x = 10; s.y = Box::new(20); //~ ERROR E0381
     use_fully!(struct s);
 }
 
 fn test_0001_local_fully_init_and_use_tuple() {
     let t: T;
-    t.0 = 10; t.1 = Box::new(20);
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    t.0 = 10; t.1 = Box::new(20); //~ ERROR E0381
     use_fully!(tuple t);
 }
 
@@ -122,15 +120,13 @@ fn test_0011_local_fully_reinit_and_use_tuple() {
 
 fn test_0100_local_partial_init_and_use_struct() {
     let s: S<B>;
-    s.x = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `s` [E0381]
+    s.x = 10; //~ ERROR E0381
     use_part!(struct s);
 }
 
 fn test_0101_local_partial_init_and_use_tuple() {
     let t: T;
-    t.0 = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    t.0 = 10; //~ ERROR E0381
     use_part!(tuple t);
 }
 
@@ -150,15 +146,13 @@ fn test_0111_local_partial_reinit_and_use_tuple() {
 
 fn test_0200_local_void_init_and_use_struct() {
     let s: S<Void>;
-    s.x = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `s` [E0381]
+    s.x = 10; //~ ERROR E0381
     use_part!(struct s);
 }
 
 fn test_0201_local_void_init_and_use_tuple() {
     let t: Tvoid;
-    t.0 = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+    t.0 = 10; //~ ERROR E0381
     use_part!(tuple t);
 }
 
@@ -173,15 +167,13 @@ fn test_0201_local_void_init_and_use_tuple() {
 
 fn test_1000_field_fully_init_and_use_struct() {
     let q: Q<S<B>>;
-    q.r.f.x = 10; q.r.f.y = Box::new(20);
-    //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+    q.r.f.x = 10; q.r.f.y = Box::new(20); //~ ERROR E0381
     use_fully!(struct q.r.f);
 }
 
 fn test_1001_field_fully_init_and_use_tuple() {
     let q: Q<T>;
-    q.r.f.0 = 10; q.r.f.1 = Box::new(20);
-    //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+    q.r.f.0 = 10; q.r.f.1 = Box::new(20); //~ ERROR E0381
     use_fully!(tuple q.r.f);
 }
 
@@ -201,15 +193,13 @@ fn test_1011_field_fully_reinit_and_use_tuple() {
 
 fn test_1100_field_partial_init_and_use_struct() {
     let q: Q<S<B>>;
-    q.r.f.x = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+    q.r.f.x = 10; //~ ERROR E0381
     use_part!(struct q.r.f);
 }
 
 fn test_1101_field_partial_init_and_use_tuple() {
     let q: Q<T>;
-    q.r.f.0 = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+    q.r.f.0 = 10; //~ ERROR E0381
     use_part!(tuple q.r.f);
 }
 
@@ -229,15 +219,13 @@ fn test_1111_field_partial_reinit_and_use_tuple() {
 
 fn test_1200_field_void_init_and_use_struct() {
     let mut q: Q<S<Void>>;
-    q.r.f.x = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+    q.r.f.x = 10; //~ ERROR E0381
     use_part!(struct q.r.f);
 }
 
 fn test_1201_field_void_init_and_use_tuple() {
     let mut q: Q<Tvoid>;
-    q.r.f.0 = 10;
-    //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+    q.r.f.0 = 10; //~ ERROR E0381
     use_part!(tuple q.r.f);
 }
 
index 77fa484c21d7e80129549f41a46fbe9b81c39776..947c9e29b4508e2a9466be663a1a1e57270977f0 100644 (file)
@@ -1,17 +1,25 @@
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
+error[E0381]: partially assigned binding `s` isn't fully initialized
   --> $DIR/issue-21232-partial-init-and-use.rs:97:5
    |
+LL |     let s: S<B>;
+   |         - binding declared here but left uninitialized
 LL |     s.x = 10; s.y = Box::new(20);
-   |     ^^^^^^^^ use of possibly-uninitialized `s`
+   |     ^^^^^^^^ `s` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/issue-21232-partial-init-and-use.rs:104:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:103:5
    |
+LL |     let t: T;
+   |         - binding declared here but left uninitialized
 LL |     t.0 = 10; t.1 = Box::new(20);
-   |     ^^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign to part of moved value: `s`
-  --> $DIR/issue-21232-partial-init-and-use.rs:111:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:109:5
    |
 LL |     let mut s: S<B> = S::new(); drop(s);
    |         -----                        - value moved here
@@ -21,7 +29,7 @@ LL |     s.x = 10; s.y = Box::new(20);
    |     ^^^^^^^^ value partially assigned here after move
 
 error[E0382]: assign to part of moved value: `t`
-  --> $DIR/issue-21232-partial-init-and-use.rs:118:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:116:5
    |
 LL |     let mut t: T = (0, Box::new(0)); drop(t);
    |         -----                             - value moved here
@@ -30,20 +38,28 @@ LL |     let mut t: T = (0, Box::new(0)); drop(t);
 LL |     t.0 = 10; t.1 = Box::new(20);
    |     ^^^^^^^^ value partially assigned here after move
 
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
-  --> $DIR/issue-21232-partial-init-and-use.rs:125:5
+error[E0381]: partially assigned binding `s` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:123:5
    |
+LL |     let s: S<B>;
+   |         - binding declared here but left uninitialized
 LL |     s.x = 10;
-   |     ^^^^^^^^ use of possibly-uninitialized `s`
+   |     ^^^^^^^^ `s` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/issue-21232-partial-init-and-use.rs:132:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:129:5
    |
+LL |     let t: T;
+   |         - binding declared here but left uninitialized
 LL |     t.0 = 10;
-   |     ^^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign to part of moved value: `s`
-  --> $DIR/issue-21232-partial-init-and-use.rs:139:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:135:5
    |
 LL |     let mut s: S<B> = S::new(); drop(s);
    |         -----                        - value moved here
@@ -53,7 +69,7 @@ LL |     s.x = 10;
    |     ^^^^^^^^ value partially assigned here after move
 
 error[E0382]: assign to part of moved value: `t`
-  --> $DIR/issue-21232-partial-init-and-use.rs:146:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:142:5
    |
 LL |     let mut t: T = (0, Box::new(0)); drop(t);
    |         -----                             - value moved here
@@ -62,32 +78,48 @@ LL |     let mut t: T = (0, Box::new(0)); drop(t);
 LL |     t.0 = 10;
    |     ^^^^^^^^ value partially assigned here after move
 
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
-  --> $DIR/issue-21232-partial-init-and-use.rs:153:5
+error[E0381]: partially assigned binding `s` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:149:5
    |
+LL |     let s: S<Void>;
+   |         - binding declared here but left uninitialized
 LL |     s.x = 10;
-   |     ^^^^^^^^ use of possibly-uninitialized `s`
+   |     ^^^^^^^^ `s` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
-  --> $DIR/issue-21232-partial-init-and-use.rs:160:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:155:5
    |
+LL |     let t: Tvoid;
+   |         - binding declared here but left uninitialized
 LL |     t.0 = 10;
-   |     ^^^^^^^^ use of possibly-uninitialized `t`
+   |     ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
-  --> $DIR/issue-21232-partial-init-and-use.rs:176:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:170:5
    |
+LL |     let q: Q<S<B>>;
+   |         - binding declared here but left uninitialized
 LL |     q.r.f.x = 10; q.r.f.y = Box::new(20);
-   |     ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+   |     ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
-  --> $DIR/issue-21232-partial-init-and-use.rs:183:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:176:5
    |
+LL |     let q: Q<T>;
+   |         - binding declared here but left uninitialized
 LL |     q.r.f.0 = 10; q.r.f.1 = Box::new(20);
-   |     ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+   |     ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign to part of moved value: `q.r`
-  --> $DIR/issue-21232-partial-init-and-use.rs:190:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:182:5
    |
 LL |     let mut q: Q<S<B>> = Q::new(S::new()); drop(q.r);
    |                                                 --- value moved here
@@ -97,7 +129,7 @@ LL |     q.r.f.x = 10; q.r.f.y = Box::new(20);
    = note: move occurs because `q.r` has type `R<S<Box<u32>>>`, which does not implement the `Copy` trait
 
 error[E0382]: assign to part of moved value: `q.r`
-  --> $DIR/issue-21232-partial-init-and-use.rs:197:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:189:5
    |
 LL |     let mut q: Q<T> = Q::new((0, Box::new(0))); drop(q.r);
    |                                                      --- value moved here
@@ -106,20 +138,28 @@ LL |     q.r.f.0 = 10; q.r.f.1 = Box::new(20);
    |
    = note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
 
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
-  --> $DIR/issue-21232-partial-init-and-use.rs:204:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:196:5
    |
+LL |     let q: Q<S<B>>;
+   |         - binding declared here but left uninitialized
 LL |     q.r.f.x = 10;
-   |     ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+   |     ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
-  --> $DIR/issue-21232-partial-init-and-use.rs:211:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:202:5
    |
+LL |     let q: Q<T>;
+   |         - binding declared here but left uninitialized
 LL |     q.r.f.0 = 10;
-   |     ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+   |     ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign to part of moved value: `q.r`
-  --> $DIR/issue-21232-partial-init-and-use.rs:218:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:208:5
    |
 LL |     let mut q: Q<S<B>> = Q::new(S::new()); drop(q.r);
    |                                                 --- value moved here
@@ -129,7 +169,7 @@ LL |     q.r.f.x = 10;
    = note: move occurs because `q.r` has type `R<S<Box<u32>>>`, which does not implement the `Copy` trait
 
 error[E0382]: assign to part of moved value: `q.r`
-  --> $DIR/issue-21232-partial-init-and-use.rs:225:5
+  --> $DIR/issue-21232-partial-init-and-use.rs:215:5
    |
 LL |     let mut q: Q<T> = Q::new((0, Box::new(0))); drop(q.r);
    |                                                      --- value moved here
@@ -138,20 +178,28 @@ LL |     q.r.f.0 = 10;
    |
    = note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
 
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
-  --> $DIR/issue-21232-partial-init-and-use.rs:232:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:222:5
    |
+LL |     let mut q: Q<S<Void>>;
+   |         ----- binding declared here but left uninitialized
 LL |     q.r.f.x = 10;
-   |     ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+   |     ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
-  --> $DIR/issue-21232-partial-init-and-use.rs:239:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+  --> $DIR/issue-21232-partial-init-and-use.rs:228:5
    |
+LL |     let mut q: Q<Tvoid>;
+   |         ----- binding declared here but left uninitialized
 LL |     q.r.f.0 = 10;
-   |     ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+   |     ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+   |
+   = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
 
 error[E0382]: assign to part of moved value: `c`
-  --> $DIR/issue-21232-partial-init-and-use.rs:257:13
+  --> $DIR/issue-21232-partial-init-and-use.rs:245:13
    |
 LL |     let mut c = (1, "".to_owned());
    |         ----- move occurs because `c` has type `(i32, String)`, which does not implement the `Copy` trait
@@ -162,7 +210,7 @@ LL |             c.0 = 2;
    |             ^^^^^^^ value partially assigned here after move
 
 error[E0382]: assign to part of moved value: `c`
-  --> $DIR/issue-21232-partial-init-and-use.rs:267:13
+  --> $DIR/issue-21232-partial-init-and-use.rs:255:13
    |
 LL |     let mut c = (1, (1, "".to_owned()));
    |         ----- move occurs because `c` has type `(i32, (i32, String))`, which does not implement the `Copy` trait
@@ -173,7 +221,7 @@ LL |             (c.1).0 = 2;
    |             ^^^^^^^^^^^ value partially assigned here after move
 
 error[E0382]: assign to part of moved value: `c.1`
-  --> $DIR/issue-21232-partial-init-and-use.rs:275:13
+  --> $DIR/issue-21232-partial-init-and-use.rs:263:13
    |
 LL |         c2 => {
    |         -- value moved here
index c9324f0422cdc4444d88921cff84884071898e92..fb61b30f09db29efc150594f1a6cc38b87ac51d5 100644 (file)
@@ -4,9 +4,8 @@ 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<i32>`, which does not implement the `Copy` trait
+   |                  --      ^^^ move occurs because `x.0` has type `Vec<i32>`, which does not implement the `Copy` trait
+   |                  |
    |                  captured by this `Fn` closure
 
 error: aborting due to previous error
index a5a0fc415bb3793d64ddac04be9ce935a6c81441..036a7a0abfdcc7eecd3b2d9b17ac628460ca1f8a 100644 (file)
@@ -10,7 +10,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<Rows<'_>, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>`
+   | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Map<Rows<'_>, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:19]>`
    |
    = 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
index 2e6d675fb641e7e940ef450fc06a72ae6401a239..252f7f8ba07cff05e8bbc6f3aed6e2779e001640 100644 (file)
@@ -18,7 +18,7 @@ fn guard_may_be_skipped(y: i32) {
     match y {
         _ if { x = 2; true } => 1,
         _ if {
-            x; //~ ERROR use of possibly-uninitialized variable: `x`
+            x; //~ ERROR E0381
             false
         } => 2,
         _ => 3,
index 4b3817929fd84e3ce53a356c49b87d08f1bf980a..250aa482e5c675012bb30ce48b460a7e6275181f 100644 (file)
@@ -1,8 +1,14 @@
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
   --> $DIR/match-cfg-fake-edges.rs:21:13
    |
+LL |     let x;
+   |         - binding declared here but left uninitialized
+...
+LL |         _ if { x = 2; true } => 1,
+   |                ----- binding initialized here in some conditions
+LL |         _ if {
 LL |             x;
-   |             ^ use of possibly-uninitialized `x`
+   |             ^ `x` used here but it isn't initialized
 
 error[E0382]: use of moved value: `x`
   --> $DIR/match-cfg-fake-edges.rs:35:13
index 2121b59b02da375c2bd06a65609f6a3f0f4d29dd..664f36f695cf3ce12b37dbf7741960c17a8cd16a 100644 (file)
@@ -33,11 +33,13 @@ LL |     match t {
 LL |     x;
    |     - borrow later used here
 
-error[E0381]: use of possibly-uninitialized variable: `n`
+error[E0381]: used binding `n` isn't initialized
   --> $DIR/match-on-borrowed.rs:93:11
    |
+LL |     let n: Never;
+   |         - binding declared here but left uninitialized
 LL |     match n {}
-   |           ^ use of possibly-uninitialized `n`
+   |           ^ `n` used here but it isn't initialized
 
 error: aborting due to 4 previous errors
 
index 8fe25181da1a035c8a7572ee0cebd352861123f7..feab2476970a12b9399e7f4bed98282af32d4e92 100644 (file)
@@ -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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -39,7 +39,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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -66,7 +66,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -103,7 +103,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
index caf2e3c47475564a69ef1dda33abc380a417441f..98063bd0a7674de4a7b1539c974eaf4f6e4d4c5c 100644 (file)
@@ -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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -56,7 +56,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -109,7 +109,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -137,7 +137,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
index 4eebe682d4fbcbb191ed6b8799ec3d8b0b382183..45e61bcbda85e87e0db91c8fd1fb492d14b26f8f 100644 (file)
@@ -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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -44,7 +44,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -85,7 +85,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -113,7 +113,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -141,7 +141,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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
index 46a02598e19bce96c4c966c39f087d2a31e14103..f2549205b812088af83c01e6fdbd6d173bded20a 100644 (file)
@@ -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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -28,7 +28,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -54,7 +54,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -80,7 +80,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -106,7 +106,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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
index 1ee788b40ab9ea296f965e32b8d523dc5801c150..8e1b6fa2e46306f8245b2a560975c67d6062f2ff 100644 (file)
@@ -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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -40,7 +40,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::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
                i32,
@@ -77,7 +77,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::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
                i32,
@@ -105,7 +105,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::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
                i32,
@@ -133,7 +133,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::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
                i32,
@@ -161,7 +161,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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -203,7 +203,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::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
@@ -231,7 +231,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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
index a4588730b3f8746d26c3dd1fb51e944509012405..12c76d198e78004cd93a278f454f8e1d448de95d 100644 (file)
@@ -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::<T>::{closure#0} with closure substs [
                i16,
@@ -27,7 +27,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::<T>::{closure#0} with closure substs [
                i16,
index 084dd93cb86b9b3376312c46d03ea202a0c201f9..35741859dffec16033addf686e7d15b9f132ab03 100644 (file)
@@ -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::<'_#1r, T>::{closure#0} with closure substs [
                i32,
index 11a737ba291f06670be5603f2556d8a35b27a795..0261bc39e7127d1d7fd6592ab640ebeb9b1b0068 100644 (file)
@@ -1,15 +1,8 @@
 note: external requirements
   --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26
    |
-LL |       with_signature(a, b, |x, y| {
-   |  __________________________^
-LL | |
-LL | |         //
-LL | |         // See `correct_region`, which explains the point of this
-...  |
-LL | |         require(&x, &y)
-LL | |     })
-   | |_____^
+LL |     with_signature(a, b, |x, y| {
+   |                          ^^^^^^
    |
    = note: defining type: no_region::<T>::{closure#0} with closure substs [
                i32,
@@ -55,15 +48,8 @@ LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) {
 note: external requirements
   --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26
    |
-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 | |     })
-   | |_____^
+LL |     with_signature(a, b, |x, y| {
+   |                          ^^^^^^
    |
    = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -90,13 +76,8 @@ LL | | }
 note: external requirements
   --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26
    |
-LL |       with_signature(a, b, |x, y| {
-   |  __________________________^
-LL | |
-LL | |         // See `correct_region`
-LL | |         require(&x, &y)
-LL | |     })
-   | |_____^
+LL |     with_signature(a, b, |x, y| {
+   |                          ^^^^^^
    |
    = note: defining type: wrong_region::<'_#1r, T>::{closure#0} with closure substs [
                i32,
@@ -140,12 +121,8 @@ LL |     T: 'b + 'a,
 note: external requirements
   --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26
    |
-LL |       with_signature(a, b, |x, y| {
-   |  __________________________^
-LL | |         // See `correct_region`
-LL | |         require(&x, &y)
-LL | |     })
-   | |_____^
+LL |     with_signature(a, b, |x, y| {
+   |                          ^^^^^^
    |
    = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
                i32,
index 3326fa521fc9cea4efc8e4d26b039fb90f1c7663..ee332278c30f553d1af704d736fc3b7216e6d43d 100644 (file)
@@ -30,15 +30,14 @@ error[E0597]: `c` does not live long enough
    |
 LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
    |                                              -- lifetime `'a` defined here
+LL |     let _closure = || {
+   |                     - `c` dropped here while still borrowed
 ...
 LL |             SomeEnum::SomeVariant(Cell::new(&c)),
    |                                   ----------^^-
    |                                   |         |
    |                                   |         borrowed value does not live long enough
    |                                   argument requires that `c` is borrowed for `'a`
-...
-LL |     };
-   |     - `c` dropped here while still borrowed
 
 error: aborting due to 3 previous errors
 
index 9664fb9f548317ea13151a99abb06665b64ab03b..95bbd62c4fb0d0e70bb5b2b4ba4a0fe3b2da9ea1 100644 (file)
@@ -28,28 +28,28 @@ error[E0597]: `c` does not live long enough
    |
 LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
    |                                              -- lifetime `'a` defined here
+LL |     let _closure = || {
+   |                     - `c` dropped here while still borrowed
 ...
 LL |         f(&c);
    |         --^^-
    |         | |
    |         | borrowed value does not live long enough
    |         argument requires that `c` is borrowed for `'a`
-LL |     };
-   |     - `c` dropped here while still borrowed
 
 error[E0597]: `c` does not live long enough
   --> $DIR/adt-tuple-struct-calls.rs:53:11
    |
 LL |     let f = SomeStruct::<&'a u32>;
    |         - lifetime `'1` appears in the type of `f`
-...
+LL |     let _closure = || {
+   |                     - `c` dropped here while still borrowed
+LL |         let c = 66;
 LL |         f(&c);
    |         --^^-
    |         | |
    |         | borrowed value does not live long enough
    |         argument requires that `c` is borrowed for `'1`
-LL |     };
-   |     - `c` dropped here while still borrowed
 
 error: aborting due to 4 previous errors
 
index e0640da39e2b62fb3211d3c89e7fdab35b910ab9..bd4d121d5691449d68ea1e9b444589148dd54c11 100644 (file)
@@ -28,14 +28,14 @@ error[E0597]: `c` does not live long enough
    |
 LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
    |                                              -- lifetime `'a` defined here
-...
+LL |     let _closure = || {
+   |                     - `c` dropped here while still borrowed
+LL |         let c = 66;
 LL |         some_fn::<&'a u32>(&c);
    |         -------------------^^-
    |         |                  |
    |         |                  borrowed value does not live long enough
    |         argument requires that `c` is borrowed for `'a`
-LL |     };
-   |     - `c` dropped here while still borrowed
 
 error: aborting due to 3 previous errors
 
index 10447e45a6d422de9a6ad372f19bf5083a0a1f77..fcaeb465d140e90880971ffa9a6f0cb9dcbef459 100644 (file)
@@ -29,13 +29,14 @@ error[E0597]: `c` does not live long enough
 LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
    |                                              -- lifetime `'a` defined here
 ...
+LL |     let _closure = || {
+   |                     - `c` dropped here while still borrowed
+LL |         let c = 66;
 LL |         a.method::<&'a u32>(b,  &c);
    |         ------------------------^^-
    |         |                       |
    |         |                       borrowed value does not live long enough
    |         argument requires that `c` is borrowed for `'a`
-LL |     };
-   |     - `c` dropped here while still borrowed
 
 error: aborting due to 3 previous errors
 
index e7851833e93b23a7f77a130197e6dd19f2dfb33d..328dde9805aaeda70fec35e0700eb01087180ce6 100644 (file)
@@ -29,13 +29,14 @@ error[E0597]: `c` does not live long enough
 LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
    |                                              -- lifetime `'a` defined here
 ...
+LL |     let _closure = || {
+   |                     - `c` dropped here while still borrowed
+LL |         let c = 66;
 LL |         <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c);
    |         -------------------------------------------^^-
    |         |                                          |
    |         |                                          borrowed value does not live long enough
    |         argument requires that `c` is borrowed for `'a`
-LL |     };
-   |     - `c` dropped here while still borrowed
 
 error: aborting due to 3 previous errors
 
index e4c57c04e7269d468d1be7a12761bf8a914e2266..249c2fe2fa74efe3aee0f1cce2ea6165293b3beb 100644 (file)
@@ -1,17 +1,12 @@
 error[E0277]: `Rc<()>` cannot be sent between threads safely
   --> $DIR/no-send-res-ports.rs:25:5
    |
-LL |       thread::spawn(move|| {
-   |  _____^^^^^^^^^^^^^_-
-   | |     |
-   | |     `Rc<()>` cannot be sent between threads safely
-LL | |
-LL | |         let y = x;
-LL | |         println!("{:?}", y);
-LL | |     });
-   | |_____- within this `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6]`
+LL |     thread::spawn(move|| {
+   |     ^^^^^^^^^^^^^ ------ within this `[closure@$DIR/no-send-res-ports.rs:25:19: 25:25]`
+   |     |
+   |     `Rc<()>` cannot be sent between threads safely
    |
-   = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6]`, the trait `Send` is not implemented for `Rc<()>`
+   = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 25:25]`, the trait `Send` is not implemented for `Rc<()>`
 note: required because it appears within the type `Port<()>`
   --> $DIR/no-send-res-ports.rs:5:8
    |
@@ -25,13 +20,8 @@ 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 | |
-LL | |         let y = x;
-LL | |         println!("{:?}", y);
-LL | |     });
-   | |_____^
+LL |     thread::spawn(move|| {
+   |                   ^^^^^^
 note: required by a bound in `spawn`
   --> $SRC_DIR/std/src/thread/mod.rs:LL:COL
    |
index 88e9cd6a9c08879767047aea628ba1227c23ad3a..0c696163a26c5cba2737b6bf51ae504c1e84af26 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for struct `Foo` in the current scop
   --> $DIR/noncopyable-class.rs:34:16
    |
 LL | struct Foo {
-   |        --- method `clone` not found for this struct
+   | ---------- method `clone` not found for this struct
 ...
 LL |     let _y = x.clone();
    |                ^^^^^ method not found in `Foo`
index bebf561b120b5280405d92aa73f1474399d05ea6..37d94cf0ebd8c515e7c1d1db7fb7a01ad1276c34 100644 (file)
@@ -1,23 +1,17 @@
-error[E0277]: the trait bound `S: Clone` is not satisfied in `[closure@$DIR/not-clone-closure.rs:7:17: 9:6]`
+error[E0277]: the trait bound `S: Clone` is not satisfied in `[closure@$DIR/not-clone-closure.rs:7:17: 7:24]`
   --> $DIR/not-clone-closure.rs:11:23
    |
-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`
+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`
    |
 note: required because it's used within this closure
   --> $DIR/not-clone-closure.rs:7:17
    |
-LL |       let hello = move || {
-   |  _________________^
-LL | |         println!("Hello {}", a.0);
-LL | |     };
-   | |_____^
+LL |     let hello = move || {
+   |                 ^^^^^^^
 help: consider annotating `S` with `#[derive(Clone)]`
    |
 LL | #[derive(Clone)]
index 40a85f7f74ca81c4a7a3346b69360afa1628e500..2550dc3d321d838d02f92c52376d9c4a17a9de9c 100644 (file)
@@ -77,7 +77,7 @@ error[E0599]: no function or associated item named `full_of✨` found for struct
   --> $DIR/emoji-identifiers.rs:9:8
    |
 LL | struct 👀;
-   |        -- function or associated item `full_of✨` not found for this struct
+   | --------- function or associated item `full_of✨` not found for this struct
 ...
 LL |     👀::full_of✨()
    |         ^^^^^^^^^
index d4f64a7de5bcff2096eada7938f4e57ae4ec2846..858b4e8db0547f2d1a3f6b1f0550af5008ad9d44 100644 (file)
@@ -200,7 +200,7 @@ LL |     { true } || { true }
    |              ^^^^^^^^^^^ expected `bool`, found closure
    |
    = note: expected type `bool`
-           found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:25]`
+           found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:16]`
 help: use parentheses to call this closure
    |
 LL |     { true } (|| { true })()
index e71f15ebfd2e7219870a555ce9cd0f2913a25020..0852c7cb4705d8c862bdf5ab4fd5ff69e8ddfdf7 100644 (file)
@@ -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: 14:11]`
+           found closure `[closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 12:13]`
 help: use parentheses to call this closure
    |
 LL ~     while (|| Foo {
index e9b56cdc05d010f68262954a172bfea050be17f3..45e16264973886cf78fa2da18a3224ac4bff20cd 100644 (file)
@@ -1,4 +1,4 @@
-error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used in patterns
+error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:19]` cannot be used in patterns
   --> $DIR/non-structural-match-types.rs:9:9
    |
 LL |         const { || {} } => {},
index f174215f257eb4aef305e771de54f45435d378b7..fdf817caea78508997742f27a46302ffd0cabb0e 100644 (file)
@@ -14,7 +14,7 @@ LL | pub fn unused<const T: usize>() -> 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<const T: usize>() -> 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<const T: usize>() -> 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
 
index 5edbb119f78690c54ede7789661bf60e0242c482..a24eee5fed1f1ae5159f083fd0982ec74010cb95 100644 (file)
@@ -10,16 +10,12 @@ LL | #![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)]
 error: item has unused generic parameters
   --> $DIR/generators.rs:35:5
    |
-LL |   pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
-   |                      - generic parameter `T` is unused
-LL | /     || {
-LL | |
-LL | |         yield 1;
-LL | |         2
-LL | |     }
-   | |_____^
+LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
+   |                    - generic parameter `T` is unused
+LL |     || {
+   |     ^^
 
-note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:35:5: 39:6], u32, u32>`
+note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:35:5: 35:7], u32, u32>`
   --> $DIR/generators.rs:86:5
    |
 LL |     finish(unused_type::<u32>());
@@ -28,16 +24,12 @@ LL |     finish(unused_type::<u32>());
 error: item has unused generic parameters
   --> $DIR/generators.rs:60:5
    |
-LL |   pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
-   |                       ------------ generic parameter `T` is unused
-LL | /     || {
-LL | |
-LL | |         yield 1;
-LL | |         2
-LL | |     }
-   | |_____^
+LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
+   |                     ------------ generic parameter `T` is unused
+LL |     || {
+   |     ^^
 
-note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:60:5: 64:6], u32, u32>`
+note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:60:5: 60:7], u32, u32>`
   --> $DIR/generators.rs:89:5
    |
 LL |     finish(unused_const::<1u32>());
index 2020256717c4de4763257ab5143c4318896d815e..4773dd4fa2ef18eae00d16c033d799b6c0414a3b 100644 (file)
@@ -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
 
index 6a74e63fdfe3bef9b616d1fb204b82d95bd8118d..e5af1d7515f6c91f5b250a5619574a507fa26b31 100644 (file)
@@ -19,7 +19,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
index 417feebbc5557d8d4788b2faf28b3810b15c9da2..94a4a08bd2fc286448208f01f163b66b6a5027f0 100644 (file)
@@ -5,7 +5,7 @@ LL | pub fn unused<T>() -> 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<T: Default>() -> 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<G: Default>() -> 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,16 +46,11 @@ LL |     pub fn unused_all<G: Default>() -> u32 {
 error: item has unused generic parameters
   --> $DIR/closures.rs:128:23
    |
-LL |       pub fn used_impl<G: Default>() -> u32 {
-   |                        - generic parameter `G` is unused
+LL |     pub fn used_impl<G: Default>() -> u32 {
+   |                      - generic parameter `G` is unused
 LL |
-LL |           let add_one = |x: u32| {
-   |  _______________________^
-LL | |
-LL | |             let _: F = Default::default();
-LL | |             x + 1
-LL | |         };
-   | |_________^
+LL |         let add_one = |x: u32| {
+   |                       ^^^^^^^^
 
 error: item has unused generic parameters
   --> $DIR/closures.rs:126:12
@@ -66,16 +61,11 @@ LL |     pub fn used_impl<G: Default>() -> u32 {
 error: item has unused generic parameters
   --> $DIR/closures.rs:115:23
    |
-LL |   impl<F: Default> Foo<F> {
-   |        - generic parameter `F` is unused
+LL | impl<F: Default> Foo<F> {
+   |      - generic parameter `F` is unused
 ...
-LL |           let add_one = |x: u32| {
-   |  _______________________^
-LL | |
-LL | |             let _: G = Default::default();
-LL | |             x + 1
-LL | |         };
-   | |_________^
+LL |         let add_one = |x: u32| {
+   |                       ^^^^^^^^
 
 error: item has unused generic parameters
   --> $DIR/closures.rs:113:12
index b51cc5c719f0b271d61ff68316243c4299809e40..27f88d281746439de53edd1060d62d003d51c06d 100644 (file)
@@ -5,16 +5,16 @@ LL | fn foo<T: Default>() {
    |        - generic parameter `T` is unused
 LL |     let _: T = Default::default();
 LL |     (|| Box::new(|| {}) as Box<dyn Fn()>)();
-   |                  ^^^^^
+   |                  ^^
 
 error: item has unused generic parameters
-  --> $DIR/unsized_cast.rs:11:5
+  --> $DIR/unsized_cast.rs:11:6
    |
 LL | fn foo<T: Default>() {
    |        - generic parameter `T` is unused
 LL |     let _: T = Default::default();
 LL |     (|| Box::new(|| {}) as Box<dyn Fn()>)();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |      ^^
 
 error: item has unused generic parameters
   --> $DIR/unsized_cast.rs:22:15
@@ -23,21 +23,16 @@ LL | fn foo2<T: Default>() {
    |         - generic parameter `T` is unused
 ...
 LL |         call(&|| {}, ());
-   |               ^^^^^
+   |               ^^
 
 error: item has unused generic parameters
-  --> $DIR/unsized_cast.rs:19:5
+  --> $DIR/unsized_cast.rs:19:6
    |
-LL |   fn foo2<T: Default>() {
-   |           - 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 | |     })();
-   | |______^
+LL | fn foo2<T: Default>() {
+   |         - generic parameter `T` is unused
+LL |     let _: T = Default::default();
+LL |     (|| {
+   |      ^^
 
 error: aborting due to 4 previous errors
 
index aaa5884c60c7782e21fde584afd5e74ad741c89c..89a832984712ad7c5bc6abd35b64fa1a11f119af 100644 (file)
@@ -9,10 +9,10 @@ LL |     func(&mut iter.map(|x| x + 1))
    = note: `#[warn(unconditional_recursion)]` on by default
    = help: a `loop` may express intention better if this is on purpose
 
-error[E0275]: overflow evaluating the requirement `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<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>: Iterator`
+error[E0275]: overflow evaluating the requirement `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<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>: Iterator`
    |
    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`)
-   = note: required because of the requirements on the impl of `Iterator` 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 std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>`
+   = note: required because of the requirements on the impl of `Iterator` 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 std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>`
 
 error: aborting due to previous error; 1 warning emitted
 
index a7e108d72d1ff92054f1cf32b9ec48cca4940585..e0dded1521760ed527626460a314a9c7d636b9c0 100644 (file)
@@ -1,19 +1,19 @@
 fn and_chain() {
     let z;
     if true && { z = 3; true} && z == 3 {}
-    //~^ ERROR use of possibly-uninitialized
+    //~^ ERROR E0381
 }
 
 fn and_chain_2() {
     let z;
     true && { z = 3; true} && z == 3;
-    //~^ ERROR use of possibly-uninitialized
+    //~^ ERROR E0381
 }
 
 fn or_chain() {
     let z;
     if false || { z = 3; false} || z == 3 {}
-    //~^ ERROR use of possibly-uninitialized
+    //~^ ERROR E0381
 }
 
 fn main() {
index 3c47040cc8c24ca28a9f75a2d893c269bad3fb1e..30d5a6779fcd7ba8de7b439272d0284c2a2905e4 100644 (file)
@@ -1,20 +1,32 @@
-error[E0381]: use of possibly-uninitialized variable: `z`
+error[E0381]: used binding `z` is possibly-uninitialized
   --> $DIR/chains-without-let.rs:3:34
    |
+LL |     let z;
+   |         - binding declared here but left uninitialized
 LL |     if true && { z = 3; true} && z == 3 {}
-   |                                  ^ use of possibly-uninitialized `z`
+   |                  -----           ^ `z` used here but it is possibly-uninitialized
+   |                  |
+   |                  binding initialized here in some conditions
 
-error[E0381]: use of possibly-uninitialized variable: `z`
+error[E0381]: used binding `z` is possibly-uninitialized
   --> $DIR/chains-without-let.rs:9:31
    |
+LL |     let z;
+   |         - binding declared here but left uninitialized
 LL |     true && { z = 3; true} && z == 3;
-   |                               ^ use of possibly-uninitialized `z`
+   |               -----           ^ `z` used here but it is possibly-uninitialized
+   |               |
+   |               binding initialized here in some conditions
 
-error[E0381]: use of possibly-uninitialized variable: `z`
+error[E0381]: used binding `z` is possibly-uninitialized
   --> $DIR/chains-without-let.rs:15:36
    |
+LL |     let z;
+   |         - binding declared here but left uninitialized
 LL |     if false || { z = 3; false} || z == 3 {}
-   |                                    ^ use of possibly-uninitialized `z`
+   |                   -----            ^ `z` used here but it is possibly-uninitialized
+   |                   |
+   |                   binding initialized here in some conditions
 
 error: aborting due to 3 previous errors
 
index 5cf06cf4b27cd42c60a28e63cbf42a599aa1bee1..93a1f691c8eefed2b3f01efb936c6c38e81785b6 100644 (file)
@@ -1249,7 +1249,7 @@ LL |     if let Range { start: F, end } = F..|| true {}
    |                                         ^^^^^^^ expected `bool`, found closure
    |
    = note: expected type `bool`
-           found closure `[closure@$DIR/disallowed-positions.rs:138:41: 138:48]`
+           found closure `[closure@$DIR/disallowed-positions.rs:138:41: 138:43]`
 help: use parentheses to call this closure
    |
 LL |     if let Range { start: F, end } = F..(|| true)() {}
@@ -1449,7 +1449,7 @@ LL |     while let Range { start: F, end } = F..|| true {}
    |                                            ^^^^^^^ expected `bool`, found closure
    |
    = note: expected type `bool`
-           found closure `[closure@$DIR/disallowed-positions.rs:203:44: 203:51]`
+           found closure `[closure@$DIR/disallowed-positions.rs:203:44: 203:46]`
 help: use parentheses to call this closure
    |
 LL |     while let Range { start: F, end } = F..(|| true)() {}
index edbea330a04b6f58708975f85c250387bc3d5fc5..b52720ae3d9de011bde3fab7f0c59141b92a2b04 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `deserialize` found for struc
   --> $DIR/issue-87932.rs:13:8
    |
 LL | pub struct A {}
-   |            - function or associated item `deserialize` not found for this struct
+   | ------------ function or associated item `deserialize` not found for this struct
 ...
 LL |     A::deserialize();
    |        ^^^^^^^^^^^ function or associated item not found in `A`
index 06ccc5b1afeeae609930b976e229dac863b30a03..3c7cccfc9a16ef017acba0e0b08010a8ccc7e302 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
   --> $DIR/point-at-arbitrary-self-type-method.rs:8:7
    |
 LL | struct A;
-   |        - method `foo` not found for this struct
+   | -------- method `foo` not found for this struct
 ...
 LL |     fn foo(self: Box<Self>) {}
    |        --- the method is available for `Box<A>` here
index bd77f67fb4e9bb7ce9cea68b65f87623953a9837..366c14f7616a37800d685c9ed35f374ef7944786 100644 (file)
@@ -6,7 +6,7 @@ LL | trait B { fn foo(self: Box<Self>); }
    |              |
    |              the method is available for `Box<A>` here
 LL | struct A;
-   |        - method `foo` not found for this struct
+   | -------- method `foo` not found for this struct
 ...
 LL |     A.foo()
    |       ^^^ method not found in `A`
index b4693b7242ae42132263a66518d0bbb369de84d9..6b43801b5e074fbdd4c1e3a80b57791b08e6eed2 100644 (file)
@@ -29,17 +29,14 @@ LL |     f.f.call_mut(())
 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<dyn FnMut(isize)>, b: isize| {
-   |           ----- captured outer variable
+LL |     let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
+   |         ----- captured outer variable
 ...
-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
+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
 
 error[E0505]: cannot move out of `f` because it is borrowed
   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16
index 912618555f4db05d5ab3f90cde9f319551b7bacb..4f30edb3f89d3d5e663d0a24b7373f3b5ed8979e 100644 (file)
@@ -42,7 +42,7 @@ error[E0599]: no method named `fff` found for struct `Myisize` in the current sc
   --> $DIR/issue-7575.rs:62:30
    |
 LL | struct Myisize(isize);
-   |        ------- method `fff` not found for this struct
+   | -------------- method `fff` not found for this struct
 ...
 LL |     u.f8(42) + u.f9(342) + m.fff(42)
    |                            --^^^
index 3e7041f02b388aaeca7ce0ee1b4fa85c151a8a4c..dcc6078969449de5301dd33abcac8835119b978e 100644 (file)
@@ -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:27]`
+                found closure `[closure@$DIR/move-closure.rs:5:17: 5:24]`
 help: use parentheses to call this closure
    |
 LL |     let x: () = (move || ())();
index 53a22305e816bc97fc0b5877269f0f6b278a3a65..d1004a690588701e812ddf3323ea9236defce5a2 100644 (file)
@@ -13,8 +13,8 @@ error[E0599]: the method `foo_one` exists for struct `MyStruct`, but its trait b
    |
 LL | struct MyStruct;
    | ---------------
-   | |      |
-   | |      method `foo_one` not found for this struct
+   | |
+   | method `foo_one` not found for this struct
    | doesn't satisfy `MyStruct: Foo`
 ...
 LL |     println!("{}", MyStruct.foo_one());
index 6f2ade0d0abf406a8ffe7b5e8efeea8cb81081c5..10978728fa365bf766d55f63e94c6a077c38521c 100644 (file)
@@ -4,12 +4,6 @@ error: function has missing const stability attribute
 LL | pub const fn foo() {}
    | ^^^^^^^^^^^^^^^^^^^^^
 
-error: associated function has missing const stability attribute
-  --> $DIR/missing-const-stability.rs:15:5
-   |
-LL |     pub const fn foo() {}
-   |     ^^^^^^^^^^^^^^^^^^^^^
-
 error: implementation has missing const stability attribute
   --> $DIR/missing-const-stability.rs:27:1
    |
@@ -19,5 +13,11 @@ LL | |     fn fun() {}
 LL | | }
    | |_^
 
+error: associated function has missing const stability attribute
+  --> $DIR/missing-const-stability.rs:15:5
+   |
+LL |     pub const fn foo() {}
+   |     ^^^^^^^^^^^^^^^^^^^^^
+
 error: aborting due to 3 previous errors
 
index 766db2a8356e7b9330cc6e4cb61e4c426e4769f7..c7d420e0aae83efaa353285f4e8c38b6ec81800f 100644 (file)
@@ -21,18 +21,18 @@ help: use parentheses to call the function
 LL |     bar(foo());
    |            ++
 
-error[E0277]: `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` is not a future
+error[E0277]: `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future
   --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9
    |
 LL |     let async_closure = async || ();
    |                         -------- consider calling this closure
 LL |     bar(async_closure);
-   |     --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` is not a future
+   |     --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future
    |     |
    |     required by a bound introduced by this call
    |
-   = help: the trait `Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
-   = note: [closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36] must be a future or must implement `IntoFuture` to be awaited
+   = help: the trait `Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]`
+   = note: [closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33] must be a future or must implement `IntoFuture` to be awaited
 note: required by a bound in `bar`
   --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16
    |
index 0ec57fabdad65210dc1c45dc681181d6fda3b6d4..7cc372f2422aebdd730376b951fe295834869466 100644 (file)
@@ -11,7 +11,7 @@ LL | enum CloneEnum {
    | -------------- doesn't satisfy `CloneEnum: Default`
 ...
 LL | struct Foo<X, Y> (X, Y);
-   |        --- method `test` not found for this struct
+   | ---------------- method `test` not found for this struct
 ...
 LL |     let y = x.test();
    |               ^^^^ method cannot be called on `Foo<Enum, CloneEnum>` due to unsatisfied trait bounds
@@ -43,7 +43,7 @@ LL | struct CloneStruct {
    | ------------------ doesn't satisfy `CloneStruct: Default`
 ...
 LL | struct Foo<X, Y> (X, Y);
-   |        --- method `test` not found for this struct
+   | ---------------- method `test` not found for this struct
 ...
 LL |     let y = x.test();
    |               ^^^^ method cannot be called on `Foo<Struct, CloneStruct>` due to unsatisfied trait bounds
@@ -65,7 +65,7 @@ error[E0599]: the method `test` exists for struct `Foo<Vec<Enum>, Instant>`, but
   --> $DIR/derive-trait-for-method-call.rs:40:15
    |
 LL | struct Foo<X, Y> (X, Y);
-   |        --- method `test` not found for this struct
+   | ---------------- method `test` not found for this struct
 ...
 LL |     let y = x.test();
    |               ^^^^ method cannot be called on `Foo<Vec<Enum>, Instant>` due to unsatisfied trait bounds
index fb1055c9c30931f9d307d13fb77aec747ceb2ece..e06ee4290abd801d35092d3f3f03f3c1ec3921a7 100644 (file)
 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(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-   | |               --    ^ help: consider borrowing here: `&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
+LL |     let x = X(Y);
+   |         - captured outer variable
+...
+LL |     consume_fn(|| {
+   |                -- captured by this `Fn` closure
+LL |         let X(_t) = x;
+   |               --    ^ help: consider borrowing here: `&x`
+   |               |
+   |               data moved here
+   |               move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:32:34
    |
-LL |       let e = Either::One(X(Y));
-   |           - captured outer variable
-...
-LL |       consume_fn(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-LL | |
-LL | |         if let Either::One(_t) = e { }
-   | |                            --    ^ help: consider borrowing here: `&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
+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 { }
+   |                            --    ^ help: consider borrowing here: `&e`
+   |                            |
+   |                            data moved here
+   |                            move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:36:37
    |
-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 { }
-   | |                               --    ^ help: consider borrowing here: `&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
+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 { }
+   |                               --    ^ help: consider borrowing here: `&e`
+   |                               |
+   |                               data moved here
+   |                               move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:40:15
    |
-LL |       let e = Either::One(X(Y));
-   |           - captured outer variable
-...
-LL |       consume_fn(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match e {
-   | |               ^ help: consider borrowing here: `&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
+LL |     let e = Either::One(X(Y));
+   |         - captured outer variable
+...
+LL |     consume_fn(|| {
+   |                -- captured by this `Fn` closure
+...
+LL |         match e {
+   |               ^ help: consider borrowing here: `&e`
+...
+LL |             Either::One(_t)
+   |                         --
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:47:15
    |
-LL |       let e = Either::One(X(Y));
-   |           - captured outer variable
-...
-LL |       consume_fn(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match e {
-   | |               ^ help: consider borrowing here: `&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
+LL |     let e = Either::One(X(Y));
+   |         - captured outer variable
+...
+LL |     consume_fn(|| {
+   |                -- captured by this `Fn` closure
+...
+LL |         match e {
+   |               ^ help: consider borrowing here: `&e`
+...
+LL |             Either::One(_t) => (),
+   |                         --
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:56:25
    |
-LL |       let x = X(Y);
-   |           - captured outer variable
-...
-LL |       consume_fn(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         let X(mut _t) = x;
-   | |               ------    ^ help: consider borrowing here: `&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
+LL |     let x = X(Y);
+   |         - captured outer variable
+...
+LL |     consume_fn(|| {
+   |                -- captured by this `Fn` closure
+...
+LL |         let X(mut _t) = x;
+   |               ------    ^ help: consider borrowing here: `&x`
+   |               |
+   |               data moved here
+   |               move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:60:38
    |
-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 { }
-   | |                            ------    ^^ help: consider borrowing here: `&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
+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 { }
+   |                            ------    ^^ help: consider borrowing here: `&em`
+   |                            |
+   |                            data moved here
+   |                            move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:64:41
    |
-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 { }
-   | |                               ------    ^^ help: consider borrowing here: `&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
+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 { }
+   |                               ------    ^^ help: consider borrowing here: `&em`
+   |                               |
+   |                               data moved here
+   |                               move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:68:15
    |
-LL |       let mut em = Either::One(X(Y));
-   |           ------ captured outer variable
-...
-LL |       consume_fn(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match em {
-   | |               ^^ help: consider borrowing here: `&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
+LL |     let mut em = Either::One(X(Y));
+   |         ------ captured outer variable
+...
+LL |     consume_fn(|| {
+   |                -- captured by this `Fn` closure
+...
+LL |         match em {
+   |               ^^ help: consider borrowing here: `&em`
+...
+LL |             Either::One(mut _t)
+   |                         ------
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
   --> $DIR/move-into-closure.rs:75:15
    |
-LL |       let mut em = Either::One(X(Y));
-   |           ------ captured outer variable
-...
-LL |       consume_fn(|| {
-   |  ________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match em {
-   | |               ^^ help: consider borrowing here: `&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
+LL |     let mut em = Either::One(X(Y));
+   |         ------ captured outer variable
+...
+LL |     consume_fn(|| {
+   |                -- captured by this `Fn` closure
+...
+LL |         match em {
+   |               ^^ help: consider borrowing here: `&em`
+...
+LL |             Either::One(mut _t) => (),
+   |                         ------
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:95:21
    |
-LL |       let x = X(Y);
-   |           - captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-   | |               --    ^ help: consider borrowing here: `&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
+LL |     let x = X(Y);
+   |         - captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+LL |         let X(_t) = x;
+   |               --    ^ help: consider borrowing here: `&x`
+   |               |
+   |               data moved here
+   |               move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:99:34
    |
-LL |       let e = Either::One(X(Y));
-   |           - captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-LL | |
-LL | |         if let Either::One(_t) = e { }
-   | |                            --    ^ help: consider borrowing here: `&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
+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 { }
+   |                            --    ^ help: consider borrowing here: `&e`
+   |                            |
+   |                            data moved here
+   |                            move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:103:37
    |
-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 { }
-   | |                               --    ^ help: consider borrowing here: `&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
+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 { }
+   |                               --    ^ help: consider borrowing here: `&e`
+   |                               |
+   |                               data moved here
+   |                               move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:107:15
    |
-LL |       let e = Either::One(X(Y));
-   |           - captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match e {
-   | |               ^ help: consider borrowing here: `&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
+LL |     let e = Either::One(X(Y));
+   |         - captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+...
+LL |         match e {
+   |               ^ help: consider borrowing here: `&e`
+...
+LL |             Either::One(_t)
+   |                         --
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:114:15
    |
-LL |       let e = Either::One(X(Y));
-   |           - captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match e {
-   | |               ^ help: consider borrowing here: `&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
+LL |     let e = Either::One(X(Y));
+   |         - captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+...
+LL |         match e {
+   |               ^ help: consider borrowing here: `&e`
+...
+LL |             Either::One(_t) => (),
+   |                         --
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:123:25
    |
-LL |       let x = X(Y);
-   |           - captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         let X(mut _t) = x;
-   | |               ------    ^ help: consider borrowing here: `&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
+LL |     let x = X(Y);
+   |         - captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+...
+LL |         let X(mut _t) = x;
+   |               ------    ^ help: consider borrowing here: `&x`
+   |               |
+   |               data moved here
+   |               move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:127:38
    |
-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 { }
-   | |                            ------    ^^ help: consider borrowing here: `&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
+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 { }
+   |                            ------    ^^ help: consider borrowing here: `&em`
+   |                            |
+   |                            data moved here
+   |                            move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:131:41
    |
-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 { }
-   | |                               ------    ^^ help: consider borrowing here: `&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
+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 { }
+   |                               ------    ^^ help: consider borrowing here: `&em`
+   |                               |
+   |                               data moved here
+   |                               move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:135:15
    |
-LL |       let mut em = Either::One(X(Y));
-   |           ------ captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match em {
-   | |               ^^ help: consider borrowing here: `&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
+LL |     let mut em = Either::One(X(Y));
+   |         ------ captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+...
+LL |         match em {
+   |               ^^ help: consider borrowing here: `&em`
+...
+LL |             Either::One(mut _t)
+   |                         ------
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:142:15
    |
-LL |       let mut em = Either::One(X(Y));
-   |           ------ captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match em {
-   | |               ^^ help: consider borrowing here: `&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
+LL |     let mut em = Either::One(X(Y));
+   |         ------ captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+...
+LL |         match em {
+   |               ^^ help: consider borrowing here: `&em`
+...
+LL |             Either::One(mut _t) => (),
+   |                         ------
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
   --> $DIR/move-into-closure.rs:150:15
    |
-LL |       let mut em = Either::One(X(Y));
-   |           ------ captured outer variable
-...
-LL |       consume_fnmut(|| {
-   |  ___________________-
-LL | |         let X(_t) = x;
-LL | |
-LL | |
-...  |
-LL | |         match em {
-   | |               ^^ help: consider borrowing here: `&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
+LL |     let mut em = Either::One(X(Y));
+   |         ------ captured outer variable
+...
+LL |     consume_fnmut(|| {
+   |                   -- captured by this `FnMut` closure
+...
+LL |         match em {
+   |               ^^ help: consider borrowing here: `&em`
+...
+LL |             Either::One(mut _t) => (),
+   |                         ------
+   |                         |
+   |                         data moved here
+   |                         move occurs because `_t` has type `X`, which does not implement the `Copy` trait
 
 error: aborting due to 21 previous errors
 
index d5af89e3547a14d19cc9cbe7f928683317864789..4658ecb3a7a95752ea42e58c4693853e0e8585ad 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `pick` found for struct `Chaenomeles` in the curre
   --> $DIR/dont-wrap-ambiguous-receivers.rs:18:25
    |
 LL |     pub struct Chaenomeles;
-   |                ----------- method `pick` not found for this struct
+   |     ---------------------- method `pick` not found for this struct
 ...
 LL |     banana::Chaenomeles.pick()
    |                         ^^^^ method not found in `Chaenomeles`
index 34b6230e19be2f2dbceec5b311c2f095d8322d4e..def16401750d5a61c508879aa7aec3b8ed4e477f 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `kind` found for struct `InferOk` in the current s
   --> $DIR/field-has-method.rs:19:15
    |
 LL | struct InferOk<T> {
-   |        ------- method `kind` not found for this struct
+   | ----------------- method `kind` not found for this struct
 ...
 LL |     let k = i.kind();
    |               ^^^^ method not found in `InferOk<Ty>`
index 101e7aecc0226dc431b3a9175da281c6e1920d00..fb0a6f70bfb46e051f9681541c81c257073af4fd 100644 (file)
@@ -19,13 +19,13 @@ help: use parentheses to call the 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:23]: 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:21]: T` is not satisfied
   --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9
    |
 LL |     let closure = || S;
    |                   -- consider calling this closure
 LL |     bar(closure);
-   |     --- ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
+   |     --- ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]`
    |     |
    |     required by a bound introduced by this call
    |
index 9aeb99ee2fa8f28f47e547d49f12ba7f1c628d70..e75ce0da82e51ef25f52b0469b336c39fdb65168 100644 (file)
@@ -278,14 +278,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:24]`
+           found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:21]`
 help: use parentheses to call this closure
    |
 LL |     let _: usize = closure();
index 5d8d688a073ca9951b2da1ddb49c41c7228f93ac..ae0d3efca4727330c16bfc121288e8605d5ed3be 100644 (file)
@@ -30,11 +30,11 @@ help: consider annotating `S` with `#[derive(Clone)]`
 LL | #[derive(Clone)]
    |
 
-error[E0277]: `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:33]` cannot be unpinned
+error[E0277]: `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22]` cannot be unpinned
   --> $DIR/issue-84973-blacklist.rs:17:5
    |
 LL |     f_unpin(static || { yield; });
-   |     ^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:33]`
+   |     ^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22]`
    |
    = note: consider using `Box::pin`
 note: required by a bound in `f_unpin`
index 85c534364b66e99f88e9d75432842f7073b12578..e3fe25d5f9c97e3e3484b3b6e61284a4ef36268f 100644 (file)
@@ -10,7 +10,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
   --> $DIR/missing-lifetimes-in-signature.rs:19:5
    |
 LL |   fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
-   |                            ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here
+   |                            ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12]` captures the anonymous lifetime defined here
 ...
 LL | /     move || {
 LL | |
index 16cbbaba512a4e0c0fe58b505ebc1f872f5bb2bb..1d3dff3be3476d4b0678d0881b06c855fc7ca905 100644 (file)
@@ -1,22 +1,19 @@
 error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
   --> $DIR/option-content-move2.rs:9:9
    |
-LL |       let mut var = None;
-   |           ------- captured outer variable
-LL |       func(|| {
-   |  __________-
-LL | |         // Shouldn't suggest `move ||.as_ref()` here
-LL | |         move || {
-   | |         ^^^^^^^ move out of `var` occurs here
-LL | |
-LL | |             var = Some(NotCopyable);
-   | |             ---
-   | |             |
-   | |             variable moved due to use in closure
-   | |             move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait
-LL | |         }
-LL | |     });
-   | |_____- captured by this `FnMut` closure
+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 || {
+   |         ^^^^^^^ move out of `var` occurs here
+LL |
+LL |             var = Some(NotCopyable);
+   |             ---
+   |             |
+   |             variable moved due to use in closure
+   |             move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait
 
 error: aborting due to previous error
 
index 3497c31826c5c4dcc81b760f97305583a8341e42..3fb418b1c0aac03b2219acdd070ce2d7462865e6 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `default_hello` found for struct `GenericAssocMeth
   --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:9:7
    |
 LL | struct GenericAssocMethod<T>(T);
-   |        ------------------ method `default_hello` not found for this struct
+   | ---------------------------- method `default_hello` not found for this struct
 ...
 LL |     x.default_hello();
    |     --^^^^^^^^^^^^^
index d5c49a477b028a2dfdcb02ef90629eea3b387b1e..2bdaa4e9780ebf3cae2cbd13dbe61cfa01294a11 100644 (file)
@@ -11,7 +11,7 @@ LL | |     };
    | |_____^ expected struct `Box`, found closure
    |
    = note: expected struct `Box<dyn Fn() -> Result<(), ()>>`
-             found closure `[closure@$DIR/suggest-box.rs:4:47: 7:6]`
+             found closure `[closure@$DIR/suggest-box.rs:4:47: 4:49]`
    = 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`
    |
index dd9010e32955ebb3bf843fe3975b4c8f09bfa658..97d7e6696a88cb25958b1f5072755eb42b39204c 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `bat` found for struct `Foo` in the current scope
   --> $DIR/suggest-methods.rs:18:7
    |
 LL | struct Foo;
-   |        --- method `bat` not found for this struct
+   | ---------- method `bat` not found for this struct
 ...
 LL |     f.bat(1.0);
    |       ^^^ help: there is an associated function with a similar name: `bar`
index 1a5833f6429ccbf0defe9bb8616c65686a714eac..0e2e41b85e2c6651e33cdbf64c872423fdecf430 100644 (file)
@@ -29,7 +29,7 @@ error[E0599]: no variant or associated item named `Squareee` found for enum `Sha
   --> $DIR/suggest-variants.rs:15:12
    |
 LL | enum Shape {
-   |      ----- variant or associated item `Squareee` not found for this enum
+   | ---------- variant or associated item `Squareee` not found for this enum
 ...
 LL |     Shape::Squareee;
    |            ^^^^^^^^
@@ -41,7 +41,7 @@ error[E0599]: no variant or associated item named `Circl` found for enum `Shape`
   --> $DIR/suggest-variants.rs:16:12
    |
 LL | enum Shape {
-   |      ----- variant or associated item `Circl` not found for this enum
+   | ---------- variant or associated item `Circl` not found for this enum
 ...
 LL |     Shape::Circl;
    |            ^^^^^
@@ -53,7 +53,7 @@ error[E0599]: no variant or associated item named `Rombus` found for enum `Shape
   --> $DIR/suggest-variants.rs:17:12
    |
 LL | enum Shape {
-   |      ----- variant or associated item `Rombus` not found for this enum
+   | ---------- variant or associated item `Rombus` not found for this enum
 ...
 LL |     Shape::Rombus;
    |            ^^^^^^ variant or associated item not found in `Shape`
index 6127446c83e3b68e830c23d33c58e019a388b7b7..de64269d1f191de29783161554364d28693b2d88 100644 (file)
@@ -19,7 +19,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
 LL | const C: _ = || 42;
    |          ^ not allowed in type signatures
    |
-note: however, the inferred type `[closure@$DIR/unnamable-types.rs:17:14: 17:19]` cannot be named
+note: however, the inferred type `[closure@$DIR/unnamable-types.rs:17:14: 17:16]` cannot be named
   --> $DIR/unnamable-types.rs:17:14
    |
 LL | const C: _ = || 42;
@@ -31,7 +31,7 @@ error: missing type for `const` item
 LL | const D = S { t: { let i = 0; move || -> i32 { i } } };
    |       ^
    |
-note: however, the inferred type `S<[closure@$DIR/unnamable-types.rs:23:31: 23:51]>` cannot be named
+note: however, the inferred type `S<[closure@$DIR/unnamable-types.rs:23:31: 23:45]>` cannot be named
   --> $DIR/unnamable-types.rs:23:11
    |
 LL | const D = S { t: { let i = 0; move || -> i32 { i } } };
@@ -55,7 +55,7 @@ error: missing type for `const` item
 LL | const G = || -> i32 { yield 0; return 1; };
    |       ^
    |
-note: however, the inferred type `[generator@$DIR/unnamable-types.rs:37:11: 37:43]` cannot be named
+note: however, the inferred type `[generator@$DIR/unnamable-types.rs:37:11: 37:20]` cannot be named
   --> $DIR/unnamable-types.rs:37:11
    |
 LL | const G = || -> i32 { yield 0; return 1; };
index aa9880a60b67c5ebd160fbe8db6944ff02adc948..3b2749773a13423a328a024f97e0d9a2962e48be 100644 (file)
@@ -8,7 +8,7 @@ LL |         fn abc(&self) {}
    |            --- the method is available for `S` here
 LL |     }
 LL |     pub struct S;
-   |                - method `abc` not found for this struct
+   |     ------------ method `abc` not found for this struct
    |
    = help: items from traits can only be used if the trait is in scope
 help: the following trait is implemented but not in scope; perhaps add a `use` for it:
diff --git a/src/test/ui/terminal-width/flag-human.rs b/src/test/ui/terminal-width/flag-human.rs
deleted file mode 100644 (file)
index e445a84..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// compile-flags: -Z terminal-width=20
-
-// This test checks that `-Z terminal-width` effects the human error output by restricting it to an
-// arbitrarily low value so that the effect is visible.
-
-fn main() {
-    let _: () = 42;
-    //~^ ERROR mismatched types
-}
diff --git a/src/test/ui/terminal-width/flag-human.stderr b/src/test/ui/terminal-width/flag-human.stderr
deleted file mode 100644 (file)
index 393dcf2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/flag-human.rs:7:17
-   |
-LL | ..._: () = 42;
-   |       --   ^^ expected `()`, found integer
-   |       |
-   |       expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/terminal-width/flag-json.rs b/src/test/ui/terminal-width/flag-json.rs
deleted file mode 100644 (file)
index 3d2530e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// compile-flags: -Z terminal-width=20 --error-format=json
-
-// This test checks that `-Z terminal-width` effects the JSON error output by restricting it to an
-// arbitrarily low value so that the effect is visible.
-
-fn main() {
-    let _: () = 42;
-    //~^ ERROR arguments to this function are incorrect
-}
diff --git a/src/test/ui/terminal-width/flag-json.stderr b/src/test/ui/terminal-width/flag-json.stderr
deleted file mode 100644 (file)
index 93c246c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.
-
-Erroneous code examples:
-
-```compile_fail,E0308
-fn plus_one(x: i32) -> i32 {
-    x + 1
-}
-
-plus_one(\"Not a number\");
-//       ^^^^^^^^^^^^^^ expected `i32`, found `&str`
-
-if \"Not a bool\" {
-// ^^^^^^^^^^^^ expected `bool`, found `&str`
-}
-
-let x: f32 = \"Not a float\";
-//     ---   ^^^^^^^^^^^^^ expected `f32`, found `&str`
-//     |
-//     expected due to this
-```
-
-This error occurs when an expression was used in a place where the compiler
-expected an expression of a different type. It can occur in several cases, the
-most common being when calling a function and passing an argument which has a
-different type than the matching type in the function declaration.
-"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":244,"byte_end":246,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":"    let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":239,"byte_end":241,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":"    let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
-  --> $DIR/flag-json.rs:7:17
-   |
-LL | ..._: () = 42;
-   |       --   ^^ expected `()`, found integer
-   |       |
-   |       expected due to this
-
-"}
-{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
-
-"}
-{"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.
-"}
diff --git a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.rs
deleted file mode 100644 (file)
index 1989ea8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// ignore-tidy-linelength
-
-fn main() {
-    let unicode_is_fun = "؁‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥";
-    let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
-    //~^ ERROR cannot add `&str` to `&str`
-}
diff --git a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr
deleted file mode 100644 (file)
index bf27736..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-error[E0369]: cannot add `&str` to `&str`
-  --> $DIR/non-1-width-unicode-multiline-label.rs:5:260
-   |
-LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
-   |                                                  -------------- ^ -------------- &str
-   |                                                  |              |
-   |                                                  |              `+` cannot be used to concatenate two `&str` strings
-   |                                                  &str
-   |
-   = note: string concatenation requires an owned `String` on the left
-help: create an owned `String` from a string reference
-   |
-LL |     let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
-   |                                                                                                                                                                                         +++++++++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0369`.
diff --git a/src/test/ui/terminal-width/non-whitespace-trimming-2.rs b/src/test/ui/terminal-width/non-whitespace-trimming-2.rs
deleted file mode 100644 (file)
index abd9e18..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// ignore-tidy-linelength
-
-fn main() {
-    let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15;
-//~^ ERROR mismatched types
-}
diff --git a/src/test/ui/terminal-width/non-whitespace-trimming-2.stderr b/src/test/ui/terminal-width/non-whitespace-trimming-2.stderr
deleted file mode 100644 (file)
index 5dbb9ce..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/non-whitespace-trimming-2.rs:4:311
-   |
-LL | ...13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let ...
-   |                                                     --   ^^ expected `()`, found integer
-   |                                                     |
-   |                                                     expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/terminal-width/non-whitespace-trimming-unicode.rs b/src/test/ui/terminal-width/non-whitespace-trimming-unicode.rs
deleted file mode 100644 (file)
index 8d4d1b1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// ignore-tidy-linelength
-
-fn main() {
-    let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓  ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42;  let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓  ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
-//~^ ERROR mismatched types
-}
diff --git a/src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr b/src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr
deleted file mode 100644 (file)
index 1e5ff93..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/non-whitespace-trimming-unicode.rs:4:415
-   |
-LL | ...♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42;  let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓  ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄...
-   |                                            --   ^^ expected `()`, found integer
-   |                                            |
-   |                                            expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/terminal-width/non-whitespace-trimming.rs b/src/test/ui/terminal-width/non-whitespace-trimming.rs
deleted file mode 100644 (file)
index f6c8d34..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// ignore-tidy-linelength
-
-fn main() {
-    let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
-//~^ ERROR mismatched types
-}
diff --git a/src/test/ui/terminal-width/non-whitespace-trimming.stderr b/src/test/ui/terminal-width/non-whitespace-trimming.stderr
deleted file mode 100644 (file)
index c4ff0e1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/non-whitespace-trimming.rs:4:241
-   |
-LL | ... () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ...
-   |                                                     --   ^^ expected `()`, found integer
-   |                                                     |
-   |                                                     expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/terminal-width/tabs-trimming.rs b/src/test/ui/terminal-width/tabs-trimming.rs
deleted file mode 100644 (file)
index ade2175..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// Test for #78438: ensure underline alignment with many tabs on the left, long line on the right
-
-// ignore-tidy-linelength
-// ignore-tidy-tab
-
-                                       fn main() {
-                                               let money = 42i32;
-                                               match money {
-                                                       v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
-                                                       //~^ ERROR variable `v` is not bound in all patterns
-                                                       v => println!("Enough money {}", v),
-                                               }
-                                       }
diff --git a/src/test/ui/terminal-width/tabs-trimming.stderr b/src/test/ui/terminal-width/tabs-trimming.stderr
deleted file mode 100644 (file)
index 6c8d9af..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0408]: variable `v` is not bound in all patterns
-  --> $DIR/tabs-trimming.rs:9:16
-   |
-LL | ...   v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
-   |       -       ^   ^ pattern doesn't bind `v`
-   |       |       |
-   |       |       pattern doesn't bind `v`
-   |       variable not in all patterns
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0408`.
diff --git a/src/test/ui/terminal-width/whitespace-trimming-2.rs b/src/test/ui/terminal-width/whitespace-trimming-2.rs
deleted file mode 100644 (file)
index c68f678..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// ignore-tidy-linelength
-
-fn foo() -> usize {
-                                                                                                                                                                                          ()
-//~^ ERROR mismatched types
-}
-
-fn main() {}
diff --git a/src/test/ui/terminal-width/whitespace-trimming-2.stderr b/src/test/ui/terminal-width/whitespace-trimming-2.stderr
deleted file mode 100644 (file)
index 97a64e6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/whitespace-trimming-2.rs:4:187
-   |
-LL | ...-> usize {
-   |       ----- expected `usize` because of return type
-LL | ...                                                                                                                                                                                 ()
-   |                                                                                                                                                                                     ^^ expected `usize`, found `()`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/terminal-width/whitespace-trimming.rs b/src/test/ui/terminal-width/whitespace-trimming.rs
deleted file mode 100644 (file)
index f747bcf..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// ignore-tidy-linelength
-
-fn main() {
-                                                                                                                                                                                    let _: () = 42;
-//~^ ERROR mismatched types
-}
diff --git a/src/test/ui/terminal-width/whitespace-trimming.stderr b/src/test/ui/terminal-width/whitespace-trimming.stderr
deleted file mode 100644 (file)
index e296d48..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/whitespace-trimming.rs:4:193
-   |
-LL | ...                   let _: () = 42;
-   |                              --   ^^ expected `()`, found integer
-   |                              |
-   |                              expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound-2.rs b/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound-2.rs
new file mode 100644 (file)
index 0000000..557d890
--- /dev/null
@@ -0,0 +1,33 @@
+struct Victim<'a, T: Perpetrator + ?Sized> {
+  value: u8,
+  perp: &'a T,
+}
+
+trait VictimTrait {
+  type Ret;
+  fn get(self) -> Self::Ret;
+}
+
+// Actual fix is here
+impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+  type Ret = u8;
+  fn get(self) -> Self::Ret {
+    self.value
+  }
+}
+
+trait Perpetrator {
+  fn getter<'a>(&'a self) -> Victim<'a, Self> {
+    Victim {
+      value: 0,
+      perp: self,
+    }
+  }
+
+  fn trigger(&self) {
+    self.getter().get();
+    //~^ ERROR the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+  }
+}
+
+fn main() {}
diff --git a/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound-2.stderr b/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound-2.stderr
new file mode 100644 (file)
index 0000000..543ceac
--- /dev/null
@@ -0,0 +1,31 @@
+error[E0599]: the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+  --> $DIR/impl-derived-implicit-sized-bound-2.rs:28:19
+   |
+LL | struct Victim<'a, T: Perpetrator + ?Sized> {
+   | ------------------------------------------
+   | |
+   | method `get` not found for this struct
+   | doesn't satisfy `Victim<'_, Self>: VictimTrait`
+...
+LL |     self.getter().get();
+   |                   ^^^ method cannot be called on `Victim<'_, Self>` due to unsatisfied trait bounds
+   |
+note: trait bound `Self: Sized` was not satisfied
+  --> $DIR/impl-derived-implicit-sized-bound-2.rs:12:10
+   |
+LL | impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+   |          ^                            -----------     -------------
+   |          |
+   |          unsatisfied trait bound introduced here
+help: consider relaxing the type parameter's implicit `Sized` bound
+   |
+LL | impl<'a, T: ?Sized + Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+   |             ++++++++
+help: consider restricting the type parameter to satisfy the trait bound
+   |
+LL | struct Victim<'a, T: Perpetrator + ?Sized> where Self: Sized {
+   |                                            +++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound.rs b/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound.rs
new file mode 100644 (file)
index 0000000..28da41a
--- /dev/null
@@ -0,0 +1,36 @@
+struct Victim<'a, T: Perpetrator + ?Sized>
+where
+  Self: Sized
+{
+  value: u8,
+  perp: &'a T,
+}
+
+trait VictimTrait {
+  type Ret;
+  fn get(self) -> Self::Ret;
+}
+
+// Actual fix is here
+impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+  type Ret = u8;
+  fn get(self) -> Self::Ret {
+    self.value
+  }
+}
+
+trait Perpetrator {
+  fn getter<'a>(&'a self) -> Victim<'a, Self> {
+    Victim {
+      value: 0,
+      perp: self,
+    }
+  }
+
+  fn trigger(&self) {
+    self.getter().get();
+    //~^ ERROR the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+  }
+}
+
+fn main() {}
diff --git a/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound.stderr b/src/test/ui/trait-bounds/impl-derived-implicit-sized-bound.stderr
new file mode 100644 (file)
index 0000000..f08d685
--- /dev/null
@@ -0,0 +1,31 @@
+error[E0599]: the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+  --> $DIR/impl-derived-implicit-sized-bound.rs:31:19
+   |
+LL | struct Victim<'a, T: Perpetrator + ?Sized>
+   | ------------------------------------------
+   | |
+   | method `get` not found for this struct
+   | doesn't satisfy `Victim<'_, Self>: VictimTrait`
+...
+LL |     self.getter().get();
+   |                   ^^^ method cannot be called on `Victim<'_, Self>` due to unsatisfied trait bounds
+   |
+note: trait bound `Self: Sized` was not satisfied
+  --> $DIR/impl-derived-implicit-sized-bound.rs:15:10
+   |
+LL | impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+   |          ^                            -----------     -------------
+   |          |
+   |          unsatisfied trait bound introduced here
+help: consider relaxing the type parameter's implicit `Sized` bound
+   |
+LL | impl<'a, T: ?Sized + Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+   |             ++++++++
+help: consider restricting the type parameter to satisfy the trait bound
+   |
+LL |   Self: Sized, Self: Sized
+   |              +++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
index 188125d248d18d822162939e8528a6f4ce38a46b..87ee08049300fd64b1487be99778c4b007172a33 100644 (file)
@@ -11,7 +11,7 @@ error[E0599]: no function or associated item named `new` found for struct `Point
   --> $DIR/issue-3973.rs:22:20
    |
 LL | struct Point {
-   |        ----- function or associated item `new` not found for this struct
+   | ------------ function or associated item `new` not found for this struct
 ...
 LL |     let p = Point::new(0.0, 0.0);
    |                    ^^^ function or associated item not found in `Point`
index fa280135beb2d98a99f1605dc79ea8c33b57b7fa..9e80497ca6e92a1cf95c3f58df7ca752a728e388 100644 (file)
@@ -4,7 +4,14 @@ error[E0283]: type annotations needed: cannot satisfy `T: FnMut<(&'a (),)>`
 LL |     T: FnMut(&'a ()),
    |        ^^^^^^^^^^^^^
    |
-   = note: cannot satisfy `T: FnMut<(&'a (),)>`
+note: multiple `impl`s or `where` clauses satisfying `T: FnMut<(&'a (),)>` found
+  --> $DIR/issue-85735.rs:7:8
+   |
+LL |     T: FnMut(&'a ()),
+   |        ^^^^^^^^^^^^^
+LL |
+LL |     T: FnMut(&'b ()),
+   |        ^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index f34e7d270f914577e979665b4091764c25ea48fa..86dbd0aac0310a3f7439a21d1076c6910f64d232 100644 (file)
@@ -18,7 +18,7 @@ error[E0275]: overflow evaluating the requirement `(): Sized`
    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`)
    = note: required because of the requirements on the impl of `Iterator` for `std::iter::Empty<()>`
    = note: 171 redundant requirements hidden
-   = note: required because of the requirements on the impl of `Iterator` for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, [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]>>`
+   = note: required because of the requirements on the impl of `Iterator` for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, [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]>>`
 
 error: aborting due to previous error; 1 warning emitted
 
index 06ed5ac081dce9bbbc4a8ad8f538d4b13de5bc2a..7f78b37ba841d1fcbf93ae6b590111e74733501f 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `a` found for struct `S` in the current scope
   --> $DIR/item-privacy.rs:67:7
    |
 LL | struct S;
-   |        - method `a` not found for this struct
+   | -------- method `a` not found for this struct
 ...
 LL |     S.a();
    |       ^ method not found in `S`
@@ -18,7 +18,7 @@ error[E0599]: no method named `b` found for struct `S` in the current scope
   --> $DIR/item-privacy.rs:68:7
    |
 LL | struct S;
-   |        - method `b` not found for this struct
+   | -------- method `b` not found for this struct
 ...
 LL |         fn b(&self) { }
    |            - the method is available for `S` here
@@ -45,7 +45,7 @@ error[E0599]: no function or associated item named `a` found for struct `S` in t
   --> $DIR/item-privacy.rs:78:8
    |
 LL | struct S;
-   |        - function or associated item `a` not found for this struct
+   | -------- function or associated item `a` not found for this struct
 ...
 LL |     S::a(&S);
    |        ^ function or associated item not found in `S`
@@ -61,7 +61,7 @@ error[E0599]: no function or associated item named `b` found for struct `S` in t
   --> $DIR/item-privacy.rs:80:8
    |
 LL | struct S;
-   |        - function or associated item `b` not found for this struct
+   | -------- function or associated item `b` not found for this struct
 ...
 LL |     S::b(&S);
    |        ^ function or associated item not found in `S`
@@ -85,7 +85,7 @@ error[E0599]: no associated item named `A` found for struct `S` in the current s
   --> $DIR/item-privacy.rs:97:8
    |
 LL | struct S;
-   |        - associated item `A` not found for this struct
+   | -------- associated item `A` not found for this struct
 ...
 LL |     S::A;
    |        ^ associated item not found in `S`
@@ -101,7 +101,7 @@ error[E0599]: no associated item named `B` found for struct `S` in the current s
   --> $DIR/item-privacy.rs:98:8
    |
 LL | struct S;
-   |        - associated item `B` not found for this struct
+   | -------- associated item `B` not found for this struct
 ...
 LL |     S::B;
    |        ^ associated item not found in `S`
index d8f2f8761ff94de57cc21b9d9d4ff7ad02cd74d8..b29442d7b8fb24af0fd7c48bdee7830c00d8b353 100644 (file)
@@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for struct `Qux` in the current scop
   --> $DIR/explicitly-unimplemented-error-message.rs:34:9
    |
 LL | struct Qux;
-   |        --- method `clone` not found for this struct
+   | ---------- method `clone` not found for this struct
 ...
 LL |     Qux.clone();
    |         ^^^^^ method not found in `Qux`
@@ -23,7 +23,7 @@ error[E0599]: no method named `foo` found for struct `Qux` in the current scope
   --> $DIR/explicitly-unimplemented-error-message.rs:44:9
    |
 LL | struct Qux;
-   |        --- method `foo` not found for this struct
+   | ---------- method `foo` not found for this struct
 ...
 LL |     Qux.foo();
    |         ^^^ method not found in `Qux`
index ef10b47fd1305343e32ba8100bb4bbf09f0eb81d..f4f45abcc75b1ad1037bdff3662cb203c8d67aac 100644 (file)
@@ -12,5 +12,5 @@ pub fn main() {
         Ok::<(), ()>(())?;
         use_val(cfg_res);
     };
-    assert_eq!(cfg_res, 5); //~ ERROR borrow of possibly-uninitialized variable: `cfg_res`
+    assert_eq!(cfg_res, 5); //~ ERROR E0381
 }
index bd145fd64e7655b5b4274aaf60438ec4a7628d42..c397385017ff487cdb2de28f6a57c40579394e12 100644 (file)
@@ -1,8 +1,14 @@
-error[E0381]: borrow of possibly-uninitialized variable: `cfg_res`
+error[E0381]: used binding `cfg_res` is possibly-uninitialized
   --> $DIR/try-block-opt-init.rs:15:5
    |
+LL |     let cfg_res;
+   |         ------- binding declared here but left uninitialized
+...
+LL |         cfg_res = 5;
+   |         ----------- binding initialized here in some conditions
+...
 LL |     assert_eq!(cfg_res, 5);
-   |     ^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `cfg_res`
+   |     ^^^^^^^^^^^^^^^^^^^^^^ `cfg_res` used here but it is possibly-uninitialized
    |
    = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 3645d11842f7d4dc605dd34f067cb0ea01837975..828ae21b4808d5299c169d637da9669834e3637d 100644 (file)
@@ -6,7 +6,7 @@ LL |       (|| {})(|| {
 LL | |
 LL | |         let b = 1;
 LL | |     });
-   | |_____- argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 5:6]` unexpected
+   | |_____- argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 2:15]` unexpected
    |
 note: closure defined here
   --> $DIR/wrong_argument_ice-4.rs:2:6
index b456b1445e7845ebbe29bf76a8514dd2bd57d4a6..5fb7a9473d3dfbc57cef2537e10e59729a553908 100644 (file)
@@ -6,7 +6,6 @@
 mod m {
     type Foo = impl std::fmt::Debug;
     //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
-    //~| ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
 
     pub fn foo() -> Foo {
         22_u32
index 4c44875b4a548eb85a4d3a51fbe115d571b87d78..1e9a45aac79e996e094b715d01a9aff30e85de5a 100644 (file)
@@ -5,10 +5,11 @@ LL |     type Foo = impl std::fmt::Debug;
    |                ^^^^^^^^^^^^^^^^^^^^
    |
 note: ...which requires type-checking `m::bar`...
-  --> $DIR/auto-trait-leakage3.rs:15:5
+  --> $DIR/auto-trait-leakage3.rs:15:9
    |
-LL |     pub fn bar() {
-   |     ^^^^^^^^^^^^
+LL |         is_send(foo());
+   |         ^^^^^^^
+   = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
    = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
 note: cycle used when checking item types in module `m`
   --> $DIR/auto-trait-leakage3.rs:6:1
@@ -16,24 +17,6 @@ note: cycle used when checking item types in module `m`
 LL | mod m {
    | ^^^^^
 
-error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
-  --> $DIR/auto-trait-leakage3.rs:7:16
-   |
-LL |     type Foo = impl std::fmt::Debug;
-   |                ^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...which requires type-checking `m::bar`...
-  --> $DIR/auto-trait-leakage3.rs:15:5
-   |
-LL |     pub fn bar() {
-   |     ^^^^^^^^^^^^
-   = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in module `m`
-  --> $DIR/auto-trait-leakage3.rs:6:1
-   |
-LL | mod m {
-   | ^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0391`.
index 608572978a3511028bd6aee0d4b00ae4eeb0471a..79caddf79132072124ae62c6e1a539229159f6ce 100644 (file)
@@ -4,7 +4,6 @@
 mod m {
     type Foo = impl std::fmt::Debug;
     //~^ ERROR cycle detected
-    //~| ERROR cycle detected
 
     // Cycle: error today, but it'd be nice if it eventually worked
 
index 3ed86fae8a18de54ec6d4c4ba3ba522a49360ae5..b9d646b927a6fb895392843190dc0b8b8f9ab18d 100644 (file)
@@ -5,10 +5,11 @@ LL |     type Foo = impl std::fmt::Debug;
    |                ^^^^^^^^^^^^^^^^^^^^
    |
 note: ...which requires type-checking `m::bar`...
-  --> $DIR/inference-cycle.rs:15:5
+  --> $DIR/inference-cycle.rs:15:9
    |
-LL |     pub fn bar() {
-   |     ^^^^^^^^^^^^
+LL |         is_send(foo()); // Today: error
+   |         ^^^^^^^
+   = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
    = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
 note: cycle used when checking item types in module `m`
   --> $DIR/inference-cycle.rs:4:1
@@ -16,24 +17,6 @@ note: cycle used when checking item types in module `m`
 LL | mod m {
    | ^^^^^
 
-error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
-  --> $DIR/inference-cycle.rs:5:16
-   |
-LL |     type Foo = impl std::fmt::Debug;
-   |                ^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...which requires type-checking `m::bar`...
-  --> $DIR/inference-cycle.rs:15:5
-   |
-LL |     pub fn bar() {
-   |     ^^^^^^^^^^^^
-   = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in module `m`
-  --> $DIR/inference-cycle.rs:4:1
-   |
-LL | mod m {
-   | ^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0391`.
index 6745b8ef69cc90b7bfbff655d5a3268ad10702dd..1b89d55711dbd690c37f78b37af5a46e868d4cdc 100644 (file)
@@ -30,7 +30,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
 LL | const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
    |                                         ^^^^^^^^^^^^^^^^^^^
    |
-   = note: source type: `[closure@$DIR/issue-53092-2.rs:6:61: 6:71]` (0 bits)
+   = note: source type: `[closure@$DIR/issue-53092-2.rs:6:61: 6:68]` (0 bits)
    = note: target type: `Bug<u8, ()>` (size can vary because of [type error])
 
 error[E0277]: the trait bound `U: From<T>` is not satisfied
index ed1cf1852e76ad632b6bc9f2caa5bce2e9dcf64b..f14bf6b0f7f5c23ba58790874d4742fc27994599 100644 (file)
@@ -10,7 +10,7 @@ note: this closure does not fulfill the lifetime requirements
   --> $DIR/issue-57611-trait-alias.rs:21:9
    |
 LL |         |x| x
-   |         ^^^^^
+   |         ^^^
 
 error: implementation of `FnOnce` is not general enough
   --> $DIR/issue-57611-trait-alias.rs:21:9
index 57fc660901cd8e428fb93972266918c898ac946e..110b8d1eea4d7655e83d2206c43ea779bee02f05 100644 (file)
@@ -23,7 +23,7 @@ LL |     || -> Closure { || () }
    |                     ^^^^^ expected `()`, found closure
    |
    = note: expected unit type `()`
-                found closure `[closure@$DIR/issue-63279.rs:9:21: 9:26]`
+                found closure `[closure@$DIR/issue-63279.rs:9:21: 9:23]`
 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:9:5: 9:28]`
+                found closure `[closure@$DIR/issue-63279.rs:9:5: 9:18]`
 help: use parentheses to call this closure
    |
 LL |     (|| -> Closure { || () })()
index 57550104087f78d73f595186218f2ff666bc6502..8d7f7a07b60c727b476d01b3b51b6c3446f95777 100644 (file)
@@ -1,4 +1,4 @@
-error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:17:9: 19:10] as Generator>::Yield == ()`
+error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:17:9: 17:16] as Generator>::Yield == ()`
   --> $DIR/issue-94429.rs:15:26
    |
 LL |     fn run(&mut self) -> Self::Gen {
diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.rs b/src/test/ui/type-alias-impl-trait/issue-98604.rs
new file mode 100644 (file)
index 0000000..a4fd8a8
--- /dev/null
@@ -0,0 +1,13 @@
+// edition:2018
+
+type AsyncFnPtr = Box<
+    dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>>,
+>;
+
+async fn test() {}
+
+#[allow(unused_must_use)]
+fn main() {
+    Box::new(test) as AsyncFnPtr;
+    //~^ ERROR type mismatch
+}
diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.stderr b/src/test/ui/type-alias-impl-trait/issue-98604.stderr
new file mode 100644 (file)
index 0000000..f04d1b4
--- /dev/null
@@ -0,0 +1,18 @@
+error[E0271]: type mismatch resolving `<fn() -> impl Future<Output = ()> {test} as FnOnce<()>>::Output == Pin<Box<(dyn Future<Output = ()> + 'static)>>`
+  --> $DIR/issue-98604.rs:11:5
+   |
+LL |     Box::new(test) as AsyncFnPtr;
+   |     ^^^^^^^^^^^^^^ expected struct `Pin`, found opaque type
+   |
+note: while checking the return type of the `async fn`
+  --> $DIR/issue-98604.rs:7:17
+   |
+LL | async fn test() {}
+   |                 ^ checked the `Output` of this `async fn`, found opaque type
+   = note:   expected struct `Pin<Box<(dyn Future<Output = ()> + 'static)>>`
+           found opaque type `impl Future<Output = ()>`
+   = note: required for the cast from `fn() -> impl Future<Output = ()> {test}` to the object type `dyn Fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.rs b/src/test/ui/type-alias-impl-trait/issue-98608.rs
new file mode 100644 (file)
index 0000000..d75762a
--- /dev/null
@@ -0,0 +1,9 @@
+fn hi() -> impl Sized { std::ptr::null::<u8>() }
+
+fn main() {
+    let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
+    //~^ ERROR type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>`
+    let boxed = b();
+    let null = *boxed;
+    println!("{null:?}");
+}
diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.stderr b/src/test/ui/type-alias-impl-trait/issue-98608.stderr
new file mode 100644 (file)
index 0000000..8f3ec7d
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0271]: type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>`
+  --> $DIR/issue-98608.rs:4:39
+   |
+LL | fn hi() -> impl Sized { std::ptr::null::<u8>() }
+   |            ---------- the found opaque type
+...
+LL |     let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
+   |                                       ^^^^^^^^^^^^ expected struct `Box`, found opaque type
+   |
+   = note:   expected struct `Box<u8>`
+           found opaque type `impl Sized`
+   = note: required for the cast from `fn() -> impl Sized {hi}` to the object type `dyn Fn() -> Box<u8>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
index 145186baa1faa6dc9e5e4d6ede1b74c0180a2b6c..7ecb553530106caf1c6d20d5c6927449b18a6484 100644 (file)
@@ -4,7 +4,6 @@
 
 type Foo = impl Debug;
 //~^ ERROR cycle detected
-//~| ERROR cycle detected
 
 fn is_send<T: Send>() { }
 
index 5d48dd5b2bf7341b8c49feedc6648ebf162b49c9..27fded3332921c92a22064f87471760763ae8f1b 100644 (file)
@@ -5,10 +5,11 @@ LL | type Foo = impl Debug;
    |            ^^^^^^^^^^
    |
 note: ...which requires type-checking `not_good`...
-  --> $DIR/reveal_local.rs:11:1
+  --> $DIR/reveal_local.rs:13:5
    |
-LL | fn not_good() {
-   | ^^^^^^^^^^^^^
+LL |     is_send::<Foo>();
+   |     ^^^^^^^^^^^^^^
+   = note: ...which requires evaluating trait selection obligation `Foo: core::marker::Send`...
    = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
 note: cycle used when checking item types in top-level module
   --> $DIR/reveal_local.rs:1:1
@@ -22,30 +23,6 @@ LL | |
 LL | | fn main() {}
    | |____________^
 
-error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
-  --> $DIR/reveal_local.rs:5:12
-   |
-LL | type Foo = impl Debug;
-   |            ^^^^^^^^^^
-   |
-note: ...which requires type-checking `not_gooder`...
-  --> $DIR/reveal_local.rs:17:1
-   |
-LL | fn not_gooder() {
-   | ^^^^^^^^^^^^^^^
-   = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in top-level module
-  --> $DIR/reveal_local.rs:1:1
-   |
-LL | / #![feature(type_alias_impl_trait)]
-LL | |
-LL | | use std::fmt::Debug;
-LL | |
-...  |
-LL | |
-LL | | fn main() {}
-   | |____________^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0391`.
index 75feb5698eb630ea2e868cfb5cf4ea6d0e0b1eb5..d15fd23418bb0be17020759ab5df157b6891b0b3 100644 (file)
@@ -4,7 +4,13 @@ error[E0283]: type annotations needed: cannot satisfy `&'a T: Foo`
 LL |     where &'a T : Foo,
    |                   ^^^
    |
-   = note: cannot satisfy `&'a T: Foo`
+note: multiple `impl`s or `where` clauses satisfying `&'a T: Foo` found
+  --> $DIR/issue-40294.rs:6:19
+   |
+LL |     where &'a T : Foo,
+   |                   ^^^
+LL |           &'b T : Foo
+   |                   ^^^
 
 error: aborting due to previous error
 
index 633c7b11aa2f89d6359fcc0cdd48db1d927c9726..8508f7a38e2399b054d079b300ad17b11bf5ffff 100644 (file)
@@ -43,7 +43,7 @@ LL | fn f(){||yield(((){),
    |       help: a return type might be missing here: `-> _`
    |
    = note: expected unit type `()`
-              found generator `[generator@$DIR/issue-91334.rs:10:8: 10:23]`
+              found generator `[generator@$DIR/issue-91334.rs:10:8: 10:10]`
 
 error: aborting due to 5 previous errors
 
index ae72b1477c8852954efd44baf880f9179dc266a5..101aee39559c3c05af984cc1602f09141be5dc41 100644 (file)
@@ -5,7 +5,7 @@ LL |     vec!['a'].iter().map(|c| c)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Map`
    |
    = note: expected unit type `()`
-                 found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:3:26: 3:31]>`
+                 found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:3:26: 3:29]>`
 help: consider using a semicolon here
    |
 LL |     vec!['a'].iter().map(|c| c);
index 482d3e44fe4ea7f0656ff49342c76ddb0e1c8905..bfa3061de0815a8ea4cc7e0499c16eb52394296e 100644 (file)
@@ -4,9 +4,8 @@ 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<i32>`, which does not implement the `Copy` trait
+   |                       --      ^ move occurs because `x` has type `Box<i32>`, 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
@@ -15,9 +14,8 @@ 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<i32>`, which does not implement the `Copy` trait
+   |                           --      ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+   |                           |
    |                           captured by this `FnMut` closure
 
 error[E0507]: cannot move out of `x`, a captured variable in an `Fn` closure
@@ -26,9 +24,8 @@ 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<i32>`, which does not implement the `Copy` trait
+   |                       -------      ^ move occurs because `x` has type `Box<i32>`, 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
@@ -37,9 +34,8 @@ 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<i32>`, which does not implement the `Copy` trait
+   |                           -------      ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+   |                           |
    |                           captured by this `FnMut` closure
 
 error: aborting due to 4 previous errors
index 68ec8d2ba8287c4c98a2139f40490a8a8e1d621a..85ff49d61a3fff949b9c8b77f7e9e30baeb1eea4 100644 (file)
@@ -2,9 +2,8 @@ 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
index 48ec620d92ea7429dfe9cd072174bee2a72453b8..d6e74b5b8b91413bac7326ea736a8300b4eaf411 100644 (file)
@@ -28,17 +28,15 @@ LL |         n += 1;
 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<A,F:Fn<A>>(f: F) -> F { f }
-   |                          - change this to accept `FnMut` instead of `Fn`
+LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
+   |                        - change this to accept `FnMut` instead of `Fn`
 ...
-LL |       let mut f = to_fn(move || {
-   |  _________________-----_-
-   | |                 |
-   | |                 expects `Fn` instead of `FnMut`
-LL | |         n += 1;
-   | |         ^^^^^^ cannot assign
-LL | |     });
-   | |_____- in this closure
+LL |     let mut f = to_fn(move || {
+   |                 ----- ------- in this closure
+   |                 |
+   |                 expects `Fn` instead of `FnMut`
+LL |         n += 1;
+   |         ^^^^^^ cannot assign
 
 error: aborting due to 4 previous errors
 
index 80e84fb7cad3f8e54b60366462951bccaf061091..7d15cd0c882a58edfa9845b1ff6427bae5706acf 100644 (file)
@@ -1,18 +1,15 @@
 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: F) where F : Fn() {
-   |                 - change this to accept `FnMut` instead of `Fn`
+LL | fn call<F>(f: F) where F : Fn() {
+   |               - change this to accept `FnMut` instead of `Fn`
 ...
-LL |       call(|| {
-   |  _____----_-
-   | |     |
-   | |     expects `Fn` instead of `FnMut`
-LL | |         counter += 1;
-   | |         ^^^^^^^^^^^^ cannot assign
-LL | |
-LL | |     });
-   | |_____- in this closure
+LL |     call(|| {
+   |     ---- -- in this closure
+   |     |
+   |     expects `Fn` instead of `FnMut`
+LL |         counter += 1;
+   |         ^^^^^^^^^^^^ cannot assign
 
 error: aborting due to previous error
 
index e9883903674ad47e1f3a2d657b5dd69ab0509f11..4f89afa320d706f1cd6b255628ed311db83dab77 100644 (file)
@@ -1,8 +1,8 @@
-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
+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
   --> $DIR/unboxed-closures-static-call-wrong-trait.rs:7:10
    |
 LL |     mut_.call((0, ));
-   |     ---- ^^^^ method not found in `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:31]`
+   |     ---- ^^^^ method not found in `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:29]`
    |     |
    |     this is a function, perhaps you wish to call it
 
index b37ec2696de2f95cbc6dc8980ec9a47e73d40e3f..2764bb563d30748046293437c1c05ad7363c2b2c 100644 (file)
@@ -25,5 +25,5 @@ fn main() {
     widget::Widget::new();
     // Error. Widget type is not known to be uninhabited here,
     // so the following code is considered reachable.
-    *y = 2; //~ ERROR use of possibly-uninitialized variable
+    *y = 2; //~ ERROR E0381
 }
index fb1953411685eb0dbdd9171d90a499da4a4a1629..95c209f47c92a450b236dd0ebfa3dd14ef5b0295 100644 (file)
@@ -1,8 +1,11 @@
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` isn't initialized
   --> $DIR/privately-uninhabited-mir-call.rs:28:5
    |
+LL |     let y: &mut u32;
+   |         - binding declared here but left uninitialized
+...
 LL |     *y = 2;
-   |     ^^^^^^ use of possibly-uninitialized `y`
+   |     ^^^^^^ `y` used here but it isn't initialized
 
 error: aborting due to previous error
 
index c277d5b761d8e5f068c9ce1ae9eb44e12d565703..a4d692f8497b0e9398328aa3c092a725c4f2ec5e 100644 (file)
@@ -3,8 +3,8 @@ error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its tra
    |
 LL | union U5<T> {
    | -----------
-   | |     |
-   | |     method `clone` not found for this union
+   | |
+   | method `clone` not found for this union
    | doesn't satisfy `U5<CloneNoCopy>: Clone`
 ...
 LL | struct CloneNoCopy;
index c277d5b761d8e5f068c9ce1ae9eb44e12d565703..a4d692f8497b0e9398328aa3c092a725c4f2ec5e 100644 (file)
@@ -3,8 +3,8 @@ error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its tra
    |
 LL | union U5<T> {
    | -----------
-   | |     |
-   | |     method `clone` not found for this union
+   | |
+   | method `clone` not found for this union
    | doesn't satisfy `U5<CloneNoCopy>: Clone`
 ...
 LL | struct CloneNoCopy;
index b9d51d21e9af246fb08c27bc6180bbec657ecc0d..c96c59afc5a54d77dd79d5e063e7f4710554361b 100644 (file)
@@ -14,8 +14,8 @@ LL | |
 LL | |     }
    | |_____- `if` and `else` have incompatible types
    |
-   = note: expected closure `[closure@$DIR/box-instead-of-dyn-fn.rs:8:9: 8:32]`
-               found struct `Box<[closure@$DIR/box-instead-of-dyn-fn.rs:10:18: 10:43]>`
+   = note: expected closure `[closure@$DIR/box-instead-of-dyn-fn.rs:8:9: 8:16]`
+               found struct `Box<[closure@$DIR/box-instead-of-dyn-fn.rs:10:18: 10:25]>`
 
 error[E0746]: return type cannot have an unboxed trait object
   --> $DIR/box-instead-of-dyn-fn.rs:5:56
index e854514958629fb4a988eaac5cb27e9879fdc0ba..8795aa1687f3de42a1fcc28a294016643d05966e 100644 (file)
@@ -5,7 +5,7 @@ LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) ->
    |                                                                             ^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
-help: use `impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a` as the return type, as all return paths are of type `Box<[closure@$DIR/issue-91801.rs:10:21: 12:6]>`, which implements `Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a`
+help: use `impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a` as the return type, as all return paths are of type `Box<[closure@$DIR/issue-91801.rs:10:21: 10:70]>`, which implements `Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a`
    |
 LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a {
    |                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index df2430ced6b621b11d7e442e83b1f9c1a6d16178..be7df08d89f0521de6f2bd871d415ded2e639c2d 100644 (file)
@@ -301,7 +301,7 @@ fn in_attributes_expansion(expr: &Expr<'_>) -> bool {
     use rustc_span::hygiene::MacroKind;
     if expr.span.from_expansion() {
         let data = expr.span.ctxt().outer_expn_data();
-        matches!(data.kind, ExpnKind::Macro(MacroKind::Attr, _))
+        matches!(data.kind, ExpnKind::Macro(MacroKind::Attr|MacroKind::Derive, _))
     } else {
         false
     }
index 77a3c2ba4ad09ba0286e9dc34a19e1b847e83805..8da2965c6351266b3e80fe480be82b02428e3924 100644 (file)
@@ -33,7 +33,7 @@ LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
    |                                            ^^^^^^^^^^^ expected `usize`, found closure
    |
    = note: expected type `usize`
-           found closure `[closure@$DIR/ice-6251.rs:4:44: 4:55]`
+           found closure `[closure@$DIR/ice-6251.rs:4:44: 4:53]`
 
 error: aborting due to 4 previous errors
 
index 21d66d5df79ecfa0a8b1727424d38ffb1134081f..d20977d55d29de60b79fe9202716b827c917c21b 100644 (file)
@@ -44,6 +44,12 @@ fn in_struct_field() {
     s._underscore_field += 1;
 }
 
+/// Tests that we do not lint if the struct field is used in code created with derive.
+#[derive(Clone, Debug)]
+pub struct UnderscoreInStruct {
+    _foo: u32,
+}
+
 /// Tests that we do not lint if the underscore is not a prefix
 fn non_prefix_underscore(some_foo: u32) -> u32 {
     some_foo + 1
index 790b849210c9b35875ff2c9b8c4d47f4c54017cd..61a9161d212da9a281d20bd840948e0dabc81763 100644 (file)
@@ -31,7 +31,7 @@ LL |     s._underscore_field += 1;
    |     ^^^^^^^^^^^^^^^^^^^
 
 error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
-  --> $DIR/used_underscore_binding.rs:99:16
+  --> $DIR/used_underscore_binding.rs:105:16
    |
 LL |         uses_i(_i);
    |                ^^
index f76ebd6feb9f59be993336f84ecfdc441ad33d81..cde87d18239b8d9afa9c6bf1051bf5573dbf326e 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f76ebd6feb9f59be993336f84ecfdc441ad33d81
+Subproject commit cde87d18239b8d9afa9c6bf1051bf5573dbf326e
index d7acae2ff2a88abe53d4c2545c57040622c4aefc..22c2d28d9f693bc2408dcf91c3c0671a2534a6bf 100644 (file)
@@ -79,6 +79,8 @@ crossbeam-utils = { version = "0.8.0", features = ["nightly"] }
 libc = { version = "0.2.79", features = ["align"] }
 # Ensure default features of libz-sys, which are disabled in some scenarios.
 libz-sys = { version = "1.1.2" }
+# same for regex
+regex = { version = "1.5.5" }
 proc-macro2 = { version = "1", features = ["default"] }
 quote = { version = "1", features = ["default"] }
 rand_core_0_5 = { package = "rand_core", version = "0.5.1", features = ["getrandom", "alloc", "std"] }