From 20431706a863f92cb37dc512fef6e48d192aaf2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc/src/main.rs | 4 +- compiler/rustc_ast/Cargo.toml | 1 - compiler/rustc_ast/src/ast.rs | 43 +- compiler/rustc_ast/src/lib.rs | 2 - compiler/rustc_ast/src/mut_visit.rs | 17 +- compiler/rustc_ast/src/token.rs | 49 +- compiler/rustc_ast/src/tokenstream.rs | 150 +- compiler/rustc_ast/src/util/parser.rs | 4 +- compiler/rustc_ast/src/visit.rs | 24 +- compiler/rustc_ast_lowering/src/asm.rs | 23 +- compiler/rustc_ast_lowering/src/errors.rs | 236 +- compiler/rustc_ast_lowering/src/expr.rs | 87 +- compiler/rustc_ast_lowering/src/index.rs | 22 +- compiler/rustc_ast_lowering/src/item.rs | 99 +- compiler/rustc_ast_lowering/src/lib.rs | 158 +- compiler/rustc_ast_lowering/src/pat.rs | 2 +- compiler/rustc_ast_lowering/src/path.rs | 10 +- compiler/rustc_ast_passes/src/ast_validation.rs | 127 +- compiler/rustc_ast_passes/src/errors.rs | 127 +- compiler/rustc_ast_passes/src/feature_gate.rs | 291 +- compiler/rustc_ast_passes/src/lib.rs | 1 - compiler/rustc_ast_pretty/Cargo.toml | 1 - compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 14 +- compiler/rustc_ast_pretty/src/pprust/state/item.rs | 2 +- compiler/rustc_attr/Cargo.toml | 1 - compiler/rustc_attr/src/lib.rs | 1 - compiler/rustc_attr/src/session_diagnostics.rs | 161 +- compiler/rustc_borrowck/Cargo.toml | 1 - .../rustc_borrowck/src/constraint_generation.rs | 12 +- compiler/rustc_borrowck/src/consumers.rs | 9 +- .../src/diagnostics/bound_region_errors.rs | 152 +- .../src/diagnostics/conflict_errors.rs | 148 +- .../src/diagnostics/explain_borrow.rs | 156 +- compiler/rustc_borrowck/src/diagnostics/mod.rs | 16 +- .../rustc_borrowck/src/diagnostics/move_errors.rs | 2 +- .../src/diagnostics/mutability_errors.rs | 5 +- .../src/diagnostics/region_errors.rs | 12 +- .../rustc_borrowck/src/diagnostics/region_name.rs | 109 +- compiler/rustc_borrowck/src/lib.rs | 22 +- compiler/rustc_borrowck/src/nll.rs | 14 +- compiler/rustc_borrowck/src/places_conflict.rs | 13 + compiler/rustc_borrowck/src/prefixes.rs | 1 + compiler/rustc_borrowck/src/region_infer/mod.rs | 41 +- .../src/region_infer/opaque_types.rs | 374 +-- compiler/rustc_borrowck/src/renumber.rs | 32 +- compiler/rustc_borrowck/src/session_diagnostics.rs | 71 +- .../rustc_borrowck/src/type_check/canonical.rs | 17 +- .../src/type_check/constraint_conversion.rs | 4 +- .../src/type_check/free_region_relations.rs | 17 +- .../rustc_borrowck/src/type_check/input_output.rs | 39 +- compiler/rustc_borrowck/src/type_check/mod.rs | 156 +- .../rustc_borrowck/src/type_check/relate_tys.rs | 19 +- compiler/rustc_borrowck/src/universal_regions.rs | 10 +- .../rustc_builtin_macros/src/assert/context.rs | 24 +- compiler/rustc_builtin_macros/src/cfg.rs | 10 +- compiler/rustc_builtin_macros/src/cfg_eval.rs | 73 +- .../rustc_builtin_macros/src/deriving/bounds.rs | 1 + .../rustc_builtin_macros/src/deriving/clone.rs | 1 + .../rustc_builtin_macros/src/deriving/cmp/eq.rs | 1 + .../rustc_builtin_macros/src/deriving/cmp/ord.rs | 1 + .../src/deriving/cmp/partial_eq.rs | 1 + .../src/deriving/cmp/partial_ord.rs | 1 + .../rustc_builtin_macros/src/deriving/debug.rs | 1 + .../rustc_builtin_macros/src/deriving/decodable.rs | 1 + .../rustc_builtin_macros/src/deriving/default.rs | 20 + .../rustc_builtin_macros/src/deriving/encodable.rs | 1 + .../src/deriving/generic/mod.rs | 13 +- compiler/rustc_builtin_macros/src/deriving/hash.rs | 1 + compiler/rustc_builtin_macros/src/deriving/mod.rs | 16 +- compiler/rustc_builtin_macros/src/format.rs | 1949 ++++------- compiler/rustc_builtin_macros/src/format/ast.rs | 240 ++ compiler/rustc_builtin_macros/src/format/expand.rs | 353 ++ compiler/rustc_builtin_macros/src/lib.rs | 2 +- compiler/rustc_builtin_macros/src/test.rs | 39 +- compiler/rustc_builtin_macros/src/test_harness.rs | 15 +- .../.github/workflows/main.yml | 99 +- .../rustc_codegen_cranelift/.vscode/settings.json | 6 +- compiler/rustc_codegen_cranelift/Cargo.lock | 62 +- compiler/rustc_codegen_cranelift/Cargo.toml | 14 +- .../build_sysroot/Cargo.lock | 38 +- .../build_system/abi_cafe.rs | 52 + .../build_system/abi_checker.rs | 60 - .../build_system/build_backend.rs | 16 +- .../build_system/build_sysroot.rs | 13 +- .../rustc_codegen_cranelift/build_system/config.rs | 3 +- .../rustc_codegen_cranelift/build_system/mod.rs | 21 +- .../build_system/prepare.rs | 186 +- .../build_system/rustc_info.rs | 2 +- .../rustc_codegen_cranelift/build_system/tests.rs | 179 +- .../rustc_codegen_cranelift/build_system/utils.rs | 46 + compiler/rustc_codegen_cranelift/clean_all.sh | 6 +- compiler/rustc_codegen_cranelift/config.txt | 2 +- .../example/issue-91827-extern-types.rs | 1 - .../rustc_codegen_cranelift/example/mini_core.rs | 6 + .../example/mini_core_hello_world.rs | 1 + .../rustc_codegen_cranelift/example/std_example.rs | 2 +- ...isable-some-test-on-x86_64-pc-windows-gnu.patch | 29 + .../0001-abi-checker-Disable-failing-tests.patch | 36 - ...1-portable-simd-Disable-unsupported-tests.patch | 96 +- .../0003-rand-Disable-rand-tests-on-mingw.patch | 47 + compiler/rustc_codegen_cranelift/rust-toolchain | 2 +- .../scripts/setup_rust_fork.sh | 6 + .../scripts/test_rustc_tests.sh | 8 +- compiler/rustc_codegen_cranelift/src/abi/mod.rs | 53 +- .../rustc_codegen_cranelift/src/abi/pass_mode.rs | 2 +- compiler/rustc_codegen_cranelift/src/allocator.rs | 4 +- compiler/rustc_codegen_cranelift/src/archive.rs | 2 + compiler/rustc_codegen_cranelift/src/base.rs | 26 +- .../src/concurrency_limiter.rs | 17 +- compiler/rustc_codegen_cranelift/src/constant.rs | 112 +- compiler/rustc_codegen_cranelift/src/driver/aot.rs | 2 +- compiler/rustc_codegen_cranelift/src/driver/jit.rs | 51 +- compiler/rustc_codegen_cranelift/src/inline_asm.rs | 22 +- .../rustc_codegen_cranelift/src/intrinsics/llvm.rs | 7 +- .../rustc_codegen_cranelift/src/intrinsics/mod.rs | 62 +- .../rustc_codegen_cranelift/src/intrinsics/simd.rs | 128 +- compiler/rustc_codegen_cranelift/src/lib.rs | 14 +- compiler/rustc_codegen_cranelift/src/main_shim.rs | 2 +- compiler/rustc_codegen_cranelift/src/num.rs | 61 +- compiler/rustc_codegen_cranelift/src/unsize.rs | 40 +- .../rustc_codegen_cranelift/src/value_and_place.rs | 56 + compiler/rustc_codegen_cranelift/src/vtable.rs | 26 +- compiler/rustc_codegen_gcc/src/abi.rs | 4 - compiler/rustc_codegen_gcc/src/archive.rs | 4 +- compiler/rustc_codegen_gcc/src/asm.rs | 5 +- compiler/rustc_codegen_gcc/src/builder.rs | 37 +- compiler/rustc_codegen_gcc/src/consts.rs | 6 +- compiler/rustc_codegen_gcc/src/context.rs | 24 +- compiler/rustc_codegen_gcc/src/errors.rs | 242 ++ compiler/rustc_codegen_gcc/src/intrinsic/mod.rs | 19 +- compiler/rustc_codegen_gcc/src/intrinsic/simd.rs | 204 +- compiler/rustc_codegen_gcc/src/lib.rs | 17 +- compiler/rustc_codegen_gcc/tests/run/asm.rs | 9 +- compiler/rustc_codegen_gcc/tests/run/int.rs | 2 +- compiler/rustc_codegen_llvm/Cargo.toml | 3 +- compiler/rustc_codegen_llvm/src/abi.rs | 4 - compiler/rustc_codegen_llvm/src/asm.rs | 8 +- compiler/rustc_codegen_llvm/src/back/archive.rs | 67 +- compiler/rustc_codegen_llvm/src/back/lto.rs | 99 +- compiler/rustc_codegen_llvm/src/back/write.rs | 261 +- compiler/rustc_codegen_llvm/src/base.rs | 13 +- compiler/rustc_codegen_llvm/src/builder.rs | 56 +- compiler/rustc_codegen_llvm/src/callee.rs | 3 +- compiler/rustc_codegen_llvm/src/consts.rs | 7 +- compiler/rustc_codegen_llvm/src/context.rs | 26 +- .../rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 2 +- compiler/rustc_codegen_llvm/src/declare.rs | 12 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 52 +- compiler/rustc_codegen_llvm/src/lib.rs | 8 - compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 110 +- compiler/rustc_codegen_llvm/src/llvm_util.rs | 36 +- compiler/rustc_codegen_ssa/src/back/link.rs | 241 +- compiler/rustc_codegen_ssa/src/back/linker.rs | 151 +- .../rustc_codegen_ssa/src/back/symbol_export.rs | 13 +- compiler/rustc_codegen_ssa/src/back/write.rs | 63 +- compiler/rustc_codegen_ssa/src/base.rs | 112 +- compiler/rustc_codegen_ssa/src/common.rs | 5 +- .../rustc_codegen_ssa/src/debuginfo/type_names.rs | 6 +- compiler/rustc_codegen_ssa/src/errors.rs | 356 ++ compiler/rustc_codegen_ssa/src/lib.rs | 3 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 104 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 20 +- compiler/rustc_codegen_ssa/src/mir/operand.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/place.rs | 16 + compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 28 +- compiler/rustc_codegen_ssa/src/target_features.rs | 208 +- compiler/rustc_codegen_ssa/src/traits/abi.rs | 3 - compiler/rustc_codegen_ssa/src/traits/backend.rs | 2 - compiler/rustc_codegen_ssa/src/traits/builder.rs | 6 +- compiler/rustc_codegen_ssa/src/traits/intrinsic.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/misc.rs | 4 - compiler/rustc_codegen_ssa/src/traits/type_.rs | 7 +- compiler/rustc_codegen_ssa/src/traits/write.rs | 1 - compiler/rustc_const_eval/Cargo.toml | 1 - compiler/rustc_const_eval/src/const_eval/error.rs | 78 +- .../src/const_eval/eval_queries.rs | 52 +- .../rustc_const_eval/src/const_eval/machine.rs | 16 +- compiler/rustc_const_eval/src/const_eval/mod.rs | 8 +- .../rustc_const_eval/src/const_eval/valtrees.rs | 4 +- compiler/rustc_const_eval/src/errors.rs | 104 +- compiler/rustc_const_eval/src/interpret/cast.rs | 108 +- .../rustc_const_eval/src/interpret/eval_context.rs | 25 +- compiler/rustc_const_eval/src/interpret/intern.rs | 14 +- .../src/interpret/intrinsics/caller_location.rs | 1 - .../src/interpret/intrinsics/type_name.rs | 6 +- compiler/rustc_const_eval/src/interpret/machine.rs | 2 +- compiler/rustc_const_eval/src/interpret/memory.rs | 2 +- compiler/rustc_const_eval/src/interpret/operand.rs | 75 +- compiler/rustc_const_eval/src/interpret/place.rs | 25 +- .../rustc_const_eval/src/interpret/projection.rs | 10 + .../rustc_const_eval/src/interpret/terminator.rs | 1 - .../rustc_const_eval/src/interpret/validity.rs | 9 +- compiler/rustc_const_eval/src/lib.rs | 10 +- .../rustc_const_eval/src/might_permit_raw_init.rs | 44 - .../src/transform/check_consts/check.rs | 81 +- .../src/transform/check_consts/ops.rs | 20 +- .../check_consts/post_drop_elaboration.rs | 12 +- .../src/transform/check_consts/qualifs.rs | 64 +- .../src/transform/check_consts/resolver.rs | 6 +- .../src/transform/promote_consts.rs | 9 +- .../rustc_const_eval/src/transform/validate.rs | 45 +- .../src/util/might_permit_raw_init.rs | 151 + compiler/rustc_const_eval/src/util/mod.rs | 2 + compiler/rustc_data_structures/Cargo.toml | 1 - compiler/rustc_data_structures/src/flock/linux.rs | 7 +- .../src/graph/vec_graph/mod.rs | 4 +- compiler/rustc_data_structures/src/lib.rs | 3 +- .../src/obligation_forest/mod.rs | 37 +- .../src/obligation_forest/tests.rs | 8 +- compiler/rustc_data_structures/src/profiling.rs | 64 +- compiler/rustc_data_structures/src/sorted_map.rs | 17 + compiler/rustc_data_structures/src/sso/set.rs | 2 +- .../src/transitive_relation.rs | 12 +- compiler/rustc_data_structures/src/unord.rs | 382 +++ compiler/rustc_driver/Cargo.toml | 2 +- compiler/rustc_driver/src/lib.rs | 61 +- compiler/rustc_driver/src/pretty.rs | 4 +- compiler/rustc_driver/src/session_diagnostics.rs | 30 +- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../rustc_error_codes/src/error_codes/E0045.md | 4 +- .../rustc_error_codes/src/error_codes/E0092.md | 2 +- .../rustc_error_codes/src/error_codes/E0094.md | 2 + .../rustc_error_codes/src/error_codes/E0161.md | 7 +- .../rustc_error_codes/src/error_codes/E0210.md | 2 - .../rustc_error_codes/src/error_codes/E0211.md | 2 + .../rustc_error_codes/src/error_codes/E0311.md | 42 + .../rustc_error_codes/src/error_codes/E0579.md | 4 +- .../rustc_error_codes/src/error_codes/E0591.md | 4 +- .../rustc_error_codes/src/error_codes/E0622.md | 2 +- .../rustc_error_codes/src/error_codes/E0732.md | 4 - .../rustc_error_codes/src/error_codes/E0743.md | 2 - compiler/rustc_error_messages/Cargo.toml | 1 - .../locales/en-US/ast_lowering.ftl | 4 +- .../locales/en-US/codegen_gcc.ftl | 68 + .../locales/en-US/codegen_ssa.ftl | 121 + .../locales/en-US/compiletest.ftl | 5 + .../rustc_error_messages/locales/en-US/errors.ftl | 13 + .../locales/en-US/hir_analysis.ftl | 152 + .../rustc_error_messages/locales/en-US/infer.ftl | 4 +- .../rustc_error_messages/locales/en-US/lint.ftl | 7 +- .../locales/en-US/metadata.ftl | 2 + .../rustc_error_messages/locales/en-US/middle.ftl | 12 + .../rustc_error_messages/locales/en-US/parser.ftl | 217 +- .../rustc_error_messages/locales/en-US/passes.ftl | 563 +++- .../rustc_error_messages/locales/en-US/privacy.ftl | 2 +- .../locales/en-US/query_system.ftl | 5 + .../rustc_error_messages/locales/en-US/session.ftl | 20 +- .../rustc_error_messages/locales/en-US/typeck.ftl | 135 - compiler/rustc_error_messages/src/lib.rs | 77 +- compiler/rustc_errors/Cargo.toml | 3 +- .../src/annotate_snippet_emitter_writer.rs | 4 +- compiler/rustc_errors/src/diagnostic.rs | 262 +- compiler/rustc_errors/src/diagnostic_builder.rs | 99 +- compiler/rustc_errors/src/diagnostic_impls.rs | 222 ++ compiler/rustc_errors/src/emitter.rs | 4 +- compiler/rustc_errors/src/json.rs | 4 +- compiler/rustc_errors/src/lib.rs | 81 +- compiler/rustc_errors/src/translation.rs | 34 +- compiler/rustc_expand/src/base.rs | 59 +- compiler/rustc_expand/src/build.rs | 4 + compiler/rustc_expand/src/config.rs | 10 +- compiler/rustc_expand/src/errors.rs | 26 +- compiler/rustc_expand/src/expand.rs | 72 +- compiler/rustc_expand/src/lib.rs | 1 - compiler/rustc_expand/src/mbe/macro_rules.rs | 26 +- compiler/rustc_expand/src/placeholders.rs | 8 + compiler/rustc_expand/src/proc_macro_server.rs | 146 +- compiler/rustc_expand/src/tokenstream/tests.rs | 18 +- compiler/rustc_feature/Cargo.toml | 1 - compiler/rustc_feature/src/accepted.rs | 6 + compiler/rustc_feature/src/active.rs | 10 +- compiler/rustc_feature/src/builtin_attrs.rs | 43 +- compiler/rustc_hir/Cargo.toml | 1 - compiler/rustc_hir/src/def.rs | 125 +- compiler/rustc_hir/src/hir.rs | 97 +- compiler/rustc_hir/src/hir_id.rs | 60 +- compiler/rustc_hir/src/intravisit.rs | 20 +- compiler/rustc_hir/src/lib.rs | 3 +- compiler/rustc_hir/src/stable_hash_impls.rs | 10 +- compiler/rustc_hir_analysis/Cargo.toml | 32 + compiler/rustc_hir_analysis/README.md | 5 + compiler/rustc_hir_analysis/src/astconv/errors.rs | 411 +++ .../rustc_hir_analysis/src/astconv/generics.rs | 662 ++++ compiler/rustc_hir_analysis/src/astconv/mod.rs | 3136 ++++++++++++++++++ compiler/rustc_hir_analysis/src/bounds.rs | 90 + compiler/rustc_hir_analysis/src/check/check.rs | 1443 +++++++++ .../rustc_hir_analysis/src/check/compare_method.rs | 1825 +++++++++++ compiler/rustc_hir_analysis/src/check/dropck.rs | 323 ++ compiler/rustc_hir_analysis/src/check/intrinsic.rs | 549 ++++ .../rustc_hir_analysis/src/check/intrinsicck.rs | 437 +++ compiler/rustc_hir_analysis/src/check/mod.rs | 515 +++ compiler/rustc_hir_analysis/src/check/region.rs | 856 +++++ compiler/rustc_hir_analysis/src/check/wfcheck.rs | 1990 ++++++++++++ compiler/rustc_hir_analysis/src/check_unused.rs | 192 ++ .../rustc_hir_analysis/src/coherence/builtin.rs | 572 ++++ .../src/coherence/inherent_impls.rs | 251 ++ .../src/coherence/inherent_impls_overlap.rs | 335 ++ compiler/rustc_hir_analysis/src/coherence/mod.rs | 237 ++ .../rustc_hir_analysis/src/coherence/orphan.rs | 503 +++ .../rustc_hir_analysis/src/coherence/unsafety.rs | 96 + compiler/rustc_hir_analysis/src/collect.rs | 2263 +++++++++++++ .../rustc_hir_analysis/src/collect/generics_of.rs | 481 +++ .../rustc_hir_analysis/src/collect/item_bounds.rs | 110 + .../rustc_hir_analysis/src/collect/lifetimes.rs | 1888 +++++++++++ .../src/collect/predicates_of.rs | 707 ++++ compiler/rustc_hir_analysis/src/collect/type_of.rs | 966 ++++++ .../src/constrained_generic_params.rs | 225 ++ compiler/rustc_hir_analysis/src/errors.rs | 282 ++ compiler/rustc_hir_analysis/src/hir_wf_check.rs | 186 ++ compiler/rustc_hir_analysis/src/impl_wf_check.rs | 193 ++ .../src/impl_wf_check/min_specialization.rs | 446 +++ compiler/rustc_hir_analysis/src/lib.rs | 552 ++++ .../rustc_hir_analysis/src/outlives/explicit.rs | 69 + .../src/outlives/implicit_infer.rs | 300 ++ compiler/rustc_hir_analysis/src/outlives/mod.rs | 129 + compiler/rustc_hir_analysis/src/outlives/test.rs | 21 + compiler/rustc_hir_analysis/src/outlives/utils.rs | 186 ++ .../rustc_hir_analysis/src/structured_errors.rs | 42 + .../missing_cast_for_variadic_arg.rs | 61 + .../src/structured_errors/sized_unsized_cast.rs | 62 + .../wrong_number_of_generic_args.rs | 1023 ++++++ .../rustc_hir_analysis/src/variance/constraints.rs | 445 +++ compiler/rustc_hir_analysis/src/variance/mod.rs | 63 + compiler/rustc_hir_analysis/src/variance/solve.rs | 135 + compiler/rustc_hir_analysis/src/variance/terms.rs | 145 + compiler/rustc_hir_analysis/src/variance/test.rs | 15 + compiler/rustc_hir_analysis/src/variance/xform.rs | 22 + compiler/rustc_hir_pretty/Cargo.toml | 1 - compiler/rustc_hir_pretty/src/lib.rs | 8 +- compiler/rustc_hir_typeck/Cargo.toml | 28 + compiler/rustc_hir_typeck/src/_match.rs | 560 ++++ compiler/rustc_hir_typeck/src/autoderef.rs | 78 + compiler/rustc_hir_typeck/src/callee.rs | 831 +++++ compiler/rustc_hir_typeck/src/cast.rs | 1105 +++++++ compiler/rustc_hir_typeck/src/check.rs | 324 ++ compiler/rustc_hir_typeck/src/closure.rs | 824 +++++ compiler/rustc_hir_typeck/src/coercion.rs | 1950 +++++++++++ compiler/rustc_hir_typeck/src/demand.rs | 1454 +++++++++ compiler/rustc_hir_typeck/src/diverges.rs | 78 + compiler/rustc_hir_typeck/src/errors.rs | 126 + compiler/rustc_hir_typeck/src/expectation.rs | 122 + compiler/rustc_hir_typeck/src/expr.rs | 2896 +++++++++++++++++ compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 908 ++++++ compiler/rustc_hir_typeck/src/fallback.rs | 398 +++ compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 1540 +++++++++ .../rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs | 383 +++ compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs | 2236 +++++++++++++ compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 312 ++ .../rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 1250 +++++++ compiler/rustc_hir_typeck/src/gather_locals.rs | 161 + .../generator_interior/drop_ranges/cfg_build.rs | 563 ++++ .../drop_ranges/cfg_propagate.rs | 92 + .../drop_ranges/cfg_visualize.rs | 91 + .../src/generator_interior/drop_ranges/mod.rs | 309 ++ .../drop_ranges/record_consumed_borrow.rs | 241 ++ .../rustc_hir_typeck/src/generator_interior/mod.rs | 647 ++++ compiler/rustc_hir_typeck/src/inherited.rs | 213 ++ compiler/rustc_hir_typeck/src/intrinsicck.rs | 108 + compiler/rustc_hir_typeck/src/lib.rs | 507 +++ .../rustc_hir_typeck/src/mem_categorization.rs | 786 +++++ compiler/rustc_hir_typeck/src/method/confirm.rs | 594 ++++ compiler/rustc_hir_typeck/src/method/mod.rs | 625 ++++ .../rustc_hir_typeck/src/method/prelude2021.rs | 415 +++ compiler/rustc_hir_typeck/src/method/probe.rs | 1926 +++++++++++ compiler/rustc_hir_typeck/src/method/suggest.rs | 2605 +++++++++++++++ compiler/rustc_hir_typeck/src/op.rs | 994 ++++++ compiler/rustc_hir_typeck/src/pat.rs | 2185 +++++++++++++ compiler/rustc_hir_typeck/src/place_op.rs | 451 +++ compiler/rustc_hir_typeck/src/rvalue_scopes.rs | 83 + compiler/rustc_hir_typeck/src/upvar.rs | 2274 +++++++++++++ compiler/rustc_hir_typeck/src/writeback.rs | 807 +++++ compiler/rustc_incremental/Cargo.toml | 1 - compiler/rustc_incremental/src/lib.rs | 1 - .../rustc_incremental/src/persist/dirty_clean.rs | 10 +- compiler/rustc_index/Cargo.toml | 1 - compiler/rustc_index/src/lib.rs | 2 - compiler/rustc_infer/src/errors/mod.rs | 178 +- .../rustc_infer/src/errors/note_and_explain.rs | 15 +- compiler/rustc_infer/src/infer/at.rs | 7 +- .../src/infer/canonical/canonicalizer.rs | 6 +- compiler/rustc_infer/src/infer/canonical/mod.rs | 2 +- .../src/infer/canonical/query_response.rs | 20 +- compiler/rustc_infer/src/infer/combine.rs | 57 +- compiler/rustc_infer/src/infer/equate.rs | 19 + .../rustc_infer/src/infer/error_reporting/mod.rs | 304 +- .../src/infer/error_reporting/need_type_info.rs | 88 +- .../nice_region_error/different_lifetimes.rs | 2 +- .../mismatched_static_lifetime.rs | 18 +- .../infer/error_reporting/nice_region_error/mod.rs | 18 +- .../nice_region_error/placeholder_error.rs | 4 +- .../nice_region_error/static_impl_trait.rs | 31 +- .../nice_region_error/trait_impl_difference.rs | 7 +- .../error_reporting/nice_region_error/util.rs | 2 +- .../rustc_infer/src/infer/error_reporting/note.rs | 31 +- compiler/rustc_infer/src/infer/freshen.rs | 4 +- compiler/rustc_infer/src/infer/fudge.rs | 4 +- compiler/rustc_infer/src/infer/glb.rs | 2 +- .../rustc_infer/src/infer/higher_ranked/mod.rs | 4 +- compiler/rustc_infer/src/infer/lattice.rs | 2 +- compiler/rustc_infer/src/infer/lub.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 300 +- compiler/rustc_infer/src/infer/nll_relate/mod.rs | 27 +- compiler/rustc_infer/src/infer/opaque_types.rs | 53 +- .../rustc_infer/src/infer/outlives/components.rs | 17 +- compiler/rustc_infer/src/infer/outlives/env.rs | 12 +- .../rustc_infer/src/infer/outlives/obligations.rs | 150 +- compiler/rustc_infer/src/infer/outlives/verify.rs | 111 +- compiler/rustc_infer/src/infer/projection.rs | 2 +- .../src/infer/region_constraints/leak_check.rs | 2 +- .../src/infer/region_constraints/mod.rs | 10 + compiler/rustc_infer/src/infer/resolve.rs | 25 +- compiler/rustc_infer/src/infer/sub.rs | 61 +- compiler/rustc_infer/src/lib.rs | 5 +- compiler/rustc_infer/src/traits/engine.rs | 15 +- .../rustc_infer/src/traits/error_reporting/mod.rs | 2 +- compiler/rustc_infer/src/traits/mod.rs | 10 + .../rustc_infer/src/traits/structural_impls.rs | 1 + compiler/rustc_infer/src/traits/util.rs | 12 +- compiler/rustc_interface/Cargo.toml | 4 +- compiler/rustc_interface/src/errors.rs | 58 +- compiler/rustc_interface/src/interface.rs | 109 +- compiler/rustc_interface/src/lib.rs | 1 - compiler/rustc_interface/src/passes.rs | 23 +- compiler/rustc_interface/src/proc_macro_decls.rs | 5 +- compiler/rustc_interface/src/queries.rs | 4 + compiler/rustc_interface/src/tests.rs | 43 +- compiler/rustc_interface/src/util.rs | 122 +- compiler/rustc_lexer/Cargo.toml | 1 - compiler/rustc_lexer/src/cursor.rs | 16 +- compiler/rustc_lexer/src/lib.rs | 76 +- compiler/rustc_lexer/src/unescape.rs | 27 +- compiler/rustc_lint/Cargo.toml | 2 +- compiler/rustc_lint/src/array_into_iter.rs | 62 +- compiler/rustc_lint/src/builtin.rs | 896 +++--- compiler/rustc_lint/src/context.rs | 91 +- compiler/rustc_lint/src/early.rs | 8 +- .../rustc_lint/src/enum_intrinsics_non_enums.rs | 26 +- compiler/rustc_lint/src/errors.rs | 90 +- compiler/rustc_lint/src/expect.rs | 14 +- .../rustc_lint/src/for_loops_over_fallibles.rs | 183 ++ .../rustc_lint/src/hidden_unicode_codepoints.rs | 94 +- compiler/rustc_lint/src/internal.rs | 215 +- compiler/rustc_lint/src/late.rs | 25 +- compiler/rustc_lint/src/let_underscore.rs | 67 +- compiler/rustc_lint/src/levels.rs | 957 ++++-- compiler/rustc_lint/src/lib.rs | 15 +- compiler/rustc_lint/src/methods.rs | 19 +- compiler/rustc_lint/src/non_ascii_idents.rs | 68 +- compiler/rustc_lint/src/non_fmt_panic.rs | 113 +- compiler/rustc_lint/src/nonstandard_style.rs | 111 +- compiler/rustc_lint/src/noop_method_call.rs | 27 +- .../rustc_lint/src/opaque_hidden_inferred_bound.rs | 163 + compiler/rustc_lint/src/pass_by_value.rs | 18 +- compiler/rustc_lint/src/redundant_semicolon.rs | 19 +- compiler/rustc_lint/src/traits.rs | 36 +- compiler/rustc_lint/src/types.rs | 389 +-- compiler/rustc_lint/src/unused.rs | 169 +- compiler/rustc_lint_defs/src/builtin.rs | 37 +- compiler/rustc_lint_defs/src/lib.rs | 34 +- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 260 +- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 47 +- .../rustc_macros/src/diagnostics/diagnostic.rs | 197 +- .../src/diagnostics/diagnostic_builder.rs | 743 ++--- compiler/rustc_macros/src/diagnostics/fluent.rs | 65 +- compiler/rustc_macros/src/diagnostics/mod.rs | 36 +- .../rustc_macros/src/diagnostics/subdiagnostic.rs | 492 ++- compiler/rustc_macros/src/diagnostics/utils.rs | 421 ++- compiler/rustc_macros/src/lib.rs | 5 +- compiler/rustc_macros/src/query.rs | 52 +- compiler/rustc_metadata/Cargo.toml | 1 - compiler/rustc_metadata/src/errors.rs | 384 ++- compiler/rustc_metadata/src/foreign_modules.rs | 6 +- compiler/rustc_metadata/src/lib.rs | 2 - compiler/rustc_metadata/src/native_libs.rs | 41 +- compiler/rustc_metadata/src/rmeta/decoder.rs | 79 +- .../src/rmeta/decoder/cstore_impl.rs | 27 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 518 +-- compiler/rustc_metadata/src/rmeta/mod.rs | 10 +- compiler/rustc_middle/Cargo.toml | 2 - compiler/rustc_middle/benches/lib.rs | 54 - compiler/rustc_middle/src/arena.rs | 5 +- compiler/rustc_middle/src/dep_graph/dep_node.rs | 152 +- compiler/rustc_middle/src/dep_graph/mod.rs | 52 +- compiler/rustc_middle/src/error.rs | 27 +- compiler/rustc_middle/src/hir/map/mod.rs | 129 +- compiler/rustc_middle/src/hir/mod.rs | 36 +- compiler/rustc_middle/src/infer/unify_key.rs | 2 +- compiler/rustc_middle/src/lib.rs | 6 +- compiler/rustc_middle/src/lint.rs | 329 +- compiler/rustc_middle/src/macros.rs | 13 +- compiler/rustc_middle/src/middle/limits.rs | 2 +- compiler/rustc_middle/src/middle/privacy.rs | 214 +- .../rustc_middle/src/middle/resolve_lifetime.rs | 15 +- compiler/rustc_middle/src/middle/stability.rs | 11 +- compiler/rustc_middle/src/mir/interpret/error.rs | 19 +- compiler/rustc_middle/src/mir/interpret/pointer.rs | 2 +- compiler/rustc_middle/src/mir/interpret/queries.rs | 42 +- compiler/rustc_middle/src/mir/mod.rs | 114 +- compiler/rustc_middle/src/mir/mono.rs | 6 +- compiler/rustc_middle/src/mir/pretty.rs | 3 +- compiler/rustc_middle/src/mir/query.rs | 9 +- compiler/rustc_middle/src/mir/syntax.rs | 26 +- compiler/rustc_middle/src/mir/tcx.rs | 5 +- compiler/rustc_middle/src/mir/type_foldable.rs | 28 +- compiler/rustc_middle/src/mir/type_visitable.rs | 19 - compiler/rustc_middle/src/mir/visit.rs | 7 +- compiler/rustc_middle/src/query/mod.rs | 302 +- compiler/rustc_middle/src/thir.rs | 9 +- compiler/rustc_middle/src/traits/mod.rs | 16 +- compiler/rustc_middle/src/traits/query.rs | 4 +- compiler/rustc_middle/src/traits/select.rs | 12 +- .../rustc_middle/src/traits/structural_impls.rs | 2 - compiler/rustc_middle/src/ty/abstract_const.rs | 12 +- compiler/rustc_middle/src/ty/adjustment.rs | 3 + compiler/rustc_middle/src/ty/adt.rs | 27 +- compiler/rustc_middle/src/ty/cast.rs | 28 +- compiler/rustc_middle/src/ty/codec.rs | 1 + compiler/rustc_middle/src/ty/consts.rs | 52 +- compiler/rustc_middle/src/ty/consts/kind.rs | 52 +- compiler/rustc_middle/src/ty/context.rs | 176 +- compiler/rustc_middle/src/ty/diagnostics.rs | 8 + compiler/rustc_middle/src/ty/erase_regions.rs | 5 - compiler/rustc_middle/src/ty/error.rs | 8 +- compiler/rustc_middle/src/ty/fast_reject.rs | 11 +- compiler/rustc_middle/src/ty/flags.rs | 18 +- compiler/rustc_middle/src/ty/fold.rs | 40 +- compiler/rustc_middle/src/ty/generics.rs | 3 +- .../src/ty/inhabitedness/def_id_forest.rs | 145 - .../src/ty/inhabitedness/inhabited_predicate.rs | 204 ++ compiler/rustc_middle/src/ty/inhabitedness/mod.rs | 258 +- compiler/rustc_middle/src/ty/instance.rs | 6 +- compiler/rustc_middle/src/ty/layout.rs | 2581 +-------------- .../rustc_middle/src/ty/layout_sanity_check.rs | 303 -- compiler/rustc_middle/src/ty/mod.rs | 141 +- .../src/ty/normalize_erasing_regions.rs | 24 +- compiler/rustc_middle/src/ty/opaque_types.rs | 218 ++ compiler/rustc_middle/src/ty/parameterized.rs | 7 + compiler/rustc_middle/src/ty/print/mod.rs | 13 +- compiler/rustc_middle/src/ty/print/pretty.rs | 230 +- compiler/rustc_middle/src/ty/query.rs | 24 +- compiler/rustc_middle/src/ty/relate.rs | 14 +- compiler/rustc_middle/src/ty/rvalue_scopes.rs | 2 +- compiler/rustc_middle/src/ty/structural_impls.rs | 55 +- compiler/rustc_middle/src/ty/sty.rs | 150 +- compiler/rustc_middle/src/ty/subst.rs | 134 +- compiler/rustc_middle/src/ty/util.rs | 41 +- compiler/rustc_middle/src/ty/visit.rs | 32 +- compiler/rustc_middle/src/ty/walk.rs | 16 + compiler/rustc_middle/src/values.rs | 180 +- compiler/rustc_mir_build/Cargo.toml | 1 - compiler/rustc_mir_build/src/build/block.rs | 37 +- .../rustc_mir_build/src/build/expr/as_constant.rs | 7 +- .../rustc_mir_build/src/build/expr/as_operand.rs | 5 +- .../rustc_mir_build/src/build/expr/as_place.rs | 76 +- .../rustc_mir_build/src/build/expr/as_rvalue.rs | 24 +- compiler/rustc_mir_build/src/build/expr/as_temp.rs | 5 +- compiler/rustc_mir_build/src/build/expr/into.rs | 5 +- compiler/rustc_mir_build/src/build/matches/mod.rs | 96 +- .../rustc_mir_build/src/build/matches/simplify.rs | 35 +- compiler/rustc_mir_build/src/build/matches/test.rs | 25 +- compiler/rustc_mir_build/src/build/matches/util.rs | 51 +- compiler/rustc_mir_build/src/build/mod.rs | 132 +- compiler/rustc_mir_build/src/build/scope.rs | 4 +- compiler/rustc_mir_build/src/check_unsafety.rs | 30 +- compiler/rustc_mir_build/src/lib.rs | 2 +- compiler/rustc_mir_build/src/lints.rs | 24 +- compiler/rustc_mir_build/src/thir/cx/expr.rs | 7 +- compiler/rustc_mir_build/src/thir/cx/mod.rs | 2 +- .../src/thir/pattern/check_match.rs | 117 +- .../src/thir/pattern/const_to_pat.rs | 57 +- .../src/thir/pattern/deconstruct_pat.rs | 20 +- compiler/rustc_mir_build/src/thir/pattern/mod.rs | 8 +- .../rustc_mir_build/src/thir/pattern/usefulness.rs | 19 +- compiler/rustc_mir_dataflow/Cargo.toml | 1 - compiler/rustc_mir_dataflow/src/elaborate_drops.rs | 5 +- compiler/rustc_mir_dataflow/src/errors.rs | 42 +- compiler/rustc_mir_dataflow/src/lib.rs | 1 - .../src/move_paths/abs_domain.rs | 1 + compiler/rustc_mir_transform/Cargo.toml | 1 - .../src/check_const_item_mutation.rs | 18 +- .../rustc_mir_transform/src/check_packed_ref.rs | 40 +- compiler/rustc_mir_transform/src/check_unsafety.rs | 24 +- compiler/rustc_mir_transform/src/const_prop.rs | 6 +- .../rustc_mir_transform/src/const_prop_lint.rs | 47 +- .../src/coverage/test_macros/Cargo.toml | 1 - .../rustc_mir_transform/src/deduce_param_attrs.rs | 248 ++ .../src/elaborate_box_derefs.rs | 1 - .../rustc_mir_transform/src/ffi_unwind_calls.rs | 14 +- .../src/function_item_references.rs | 22 +- compiler/rustc_mir_transform/src/generator.rs | 3 +- compiler/rustc_mir_transform/src/inline.rs | 47 +- compiler/rustc_mir_transform/src/lib.rs | 24 +- compiler/rustc_mir_transform/src/marker.rs | 20 - compiler/rustc_mir_transform/src/pass_manager.rs | 89 +- compiler/rustc_mir_transform/src/shim.rs | 8 +- compiler/rustc_monomorphize/Cargo.toml | 1 - compiler/rustc_monomorphize/src/collector.rs | 34 +- compiler/rustc_monomorphize/src/errors.rs | 37 +- compiler/rustc_monomorphize/src/lib.rs | 1 - .../rustc_monomorphize/src/partitioning/default.rs | 6 +- compiler/rustc_monomorphize/src/polymorphize.rs | 53 +- compiler/rustc_parse/Cargo.toml | 1 - compiler/rustc_parse/src/errors.rs | 1237 +++++++ compiler/rustc_parse/src/lexer/mod.rs | 397 +-- compiler/rustc_parse/src/lexer/tokentrees.rs | 428 ++- .../src/lexer/unescape_error_reporting.rs | 19 +- compiler/rustc_parse/src/lib.rs | 6 +- compiler/rustc_parse/src/parser/attr.rs | 159 +- compiler/rustc_parse/src/parser/attr_wrapper.rs | 33 +- compiler/rustc_parse/src/parser/diagnostics.rs | 946 ++---- compiler/rustc_parse/src/parser/expr.rs | 509 +-- compiler/rustc_parse/src/parser/generics.rs | 36 +- compiler/rustc_parse/src/parser/item.rs | 163 +- compiler/rustc_parse/src/parser/mod.rs | 151 +- compiler/rustc_parse/src/parser/pat.rs | 26 +- compiler/rustc_parse/src/parser/stmt.rs | 169 +- compiler/rustc_parse/src/parser/ty.rs | 11 +- compiler/rustc_parse_format/src/lib.rs | 30 +- compiler/rustc_parse_format/src/tests.rs | 15 + compiler/rustc_passes/src/check_attr.rs | 277 +- compiler/rustc_passes/src/check_const.rs | 17 +- compiler/rustc_passes/src/dead.rs | 136 +- compiler/rustc_passes/src/debugger_visualizer.rs | 15 +- compiler/rustc_passes/src/diagnostic_items.rs | 45 +- compiler/rustc_passes/src/entry.rs | 157 +- compiler/rustc_passes/src/errors.rs | 1095 ++++++- compiler/rustc_passes/src/hir_id_validator.rs | 23 +- compiler/rustc_passes/src/hir_stats.rs | 4 +- compiler/rustc_passes/src/lang_items.rs | 211 +- compiler/rustc_passes/src/layout_test.rs | 77 +- compiler/rustc_passes/src/lib.rs | 3 +- compiler/rustc_passes/src/lib_features.rs | 34 +- compiler/rustc_passes/src/liveness.rs | 65 +- compiler/rustc_passes/src/loops.rs | 161 +- compiler/rustc_passes/src/naked_functions.rs | 88 +- compiler/rustc_passes/src/reachable.rs | 53 +- compiler/rustc_passes/src/stability.rs | 230 +- compiler/rustc_passes/src/weak_lang_items.rs | 31 +- compiler/rustc_plugin_impl/Cargo.toml | 1 - compiler/rustc_plugin_impl/src/errors.rs | 10 +- compiler/rustc_privacy/Cargo.toml | 2 +- compiler/rustc_privacy/src/errors.rs | 42 +- compiler/rustc_privacy/src/lib.rs | 342 +- compiler/rustc_query_impl/src/keys.rs | 42 +- compiler/rustc_query_impl/src/lib.rs | 13 +- compiler/rustc_query_impl/src/on_disk_cache.rs | 13 +- compiler/rustc_query_impl/src/plumbing.rs | 188 +- compiler/rustc_query_impl/src/profiling_support.rs | 25 +- compiler/rustc_query_system/Cargo.toml | 1 - .../rustc_query_system/src/dep_graph/dep_node.rs | 73 + compiler/rustc_query_system/src/dep_graph/mod.rs | 45 +- compiler/rustc_query_system/src/error.rs | 73 +- compiler/rustc_query_system/src/ich/hcx.rs | 11 +- compiler/rustc_query_system/src/lib.rs | 5 +- compiler/rustc_query_system/src/query/config.rs | 2 - compiler/rustc_query_system/src/query/job.rs | 33 +- compiler/rustc_query_system/src/query/mod.rs | 15 +- compiler/rustc_query_system/src/query/plumbing.rs | 11 +- compiler/rustc_query_system/src/values.rs | 5 +- compiler/rustc_resolve/Cargo.toml | 1 - compiler/rustc_resolve/src/access_levels.rs | 185 -- compiler/rustc_resolve/src/build_reduced_graph.rs | 7 +- compiler/rustc_resolve/src/check_unused.rs | 2 +- compiler/rustc_resolve/src/def_collector.rs | 27 +- compiler/rustc_resolve/src/diagnostics.rs | 139 +- .../rustc_resolve/src/effective_visibilities.rs | 188 ++ compiler/rustc_resolve/src/ident.rs | 22 +- compiler/rustc_resolve/src/imports.rs | 32 +- compiler/rustc_resolve/src/late.rs | 366 ++- compiler/rustc_resolve/src/late/diagnostics.rs | 859 +++-- compiler/rustc_resolve/src/late/lifetimes.rs | 1855 ----------- compiler/rustc_resolve/src/lib.rs | 82 +- compiler/rustc_resolve/src/macros.rs | 25 +- compiler/rustc_save_analysis/src/dump_visitor.rs | 83 +- compiler/rustc_save_analysis/src/errors.rs | 6 +- compiler/rustc_save_analysis/src/lib.rs | 32 +- compiler/rustc_save_analysis/src/sig.rs | 12 +- compiler/rustc_serialize/src/lib.rs | 1 - compiler/rustc_serialize/src/opaque.rs | 4 +- compiler/rustc_session/src/config.rs | 6 +- compiler/rustc_session/src/config/sigpipe.rs | 13 +- compiler/rustc_session/src/errors.rs | 198 +- compiler/rustc_session/src/lib.rs | 1 - compiler/rustc_session/src/options.rs | 123 +- compiler/rustc_session/src/parse.rs | 46 +- compiler/rustc_session/src/session.rs | 191 +- compiler/rustc_session/src/utils.rs | 11 + compiler/rustc_span/Cargo.toml | 1 - compiler/rustc_span/src/def_id.rs | 20 +- compiler/rustc_span/src/lib.rs | 14 +- compiler/rustc_span/src/source_map.rs | 44 +- compiler/rustc_span/src/source_map/tests.rs | 45 + compiler/rustc_span/src/span_encoding.rs | 42 +- compiler/rustc_span/src/symbol.rs | 35 +- compiler/rustc_symbol_mangling/Cargo.toml | 1 - compiler/rustc_symbol_mangling/src/errors.rs | 6 +- compiler/rustc_symbol_mangling/src/test.rs | 8 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 2 +- compiler/rustc_symbol_mangling/src/v0.rs | 4 +- compiler/rustc_target/Cargo.toml | 3 +- compiler/rustc_target/src/abi/call/mod.rs | 5 +- compiler/rustc_target/src/abi/mod.rs | 70 +- compiler/rustc_target/src/lib.rs | 1 - .../src/spec/aarch64_apple_ios_macabi.rs | 4 +- .../spec/aarch64_nintendo_switch_freestanding.rs | 4 +- .../rustc_target/src/spec/aarch64_unknown_none.rs | 4 +- .../src/spec/aarch64_unknown_none_softfloat.rs | 4 +- .../rustc_target/src/spec/aarch64_unknown_uefi.rs | 4 +- compiler/rustc_target/src/spec/abi.rs | 138 + compiler/rustc_target/src/spec/android_base.rs | 4 +- compiler/rustc_target/src/spec/apple_base.rs | 22 +- .../rustc_target/src/spec/armebv7r_none_eabi.rs | 5 +- .../rustc_target/src/spec/armebv7r_none_eabihf.rs | 5 +- compiler/rustc_target/src/spec/armv4t_none_eabi.rs | 4 +- .../rustc_target/src/spec/armv5te_none_eabi.rs | 41 + .../rustc_target/src/spec/armv6k_nintendo_3ds.rs | 5 +- .../src/spec/armv7_linux_androideabi.rs | 4 +- compiler/rustc_target/src/spec/armv7a_none_eabi.rs | 4 +- .../rustc_target/src/spec/armv7a_none_eabihf.rs | 4 +- compiler/rustc_target/src/spec/armv7r_none_eabi.rs | 5 +- .../rustc_target/src/spec/armv7r_none_eabihf.rs | 5 +- compiler/rustc_target/src/spec/avr_gnu_base.rs | 9 +- compiler/rustc_target/src/spec/fuchsia_base.rs | 6 +- compiler/rustc_target/src/spec/hermit_base.rs | 6 +- .../src/spec/hexagon_unknown_linux_musl.rs | 4 +- compiler/rustc_target/src/spec/i386_apple_ios.rs | 3 +- .../rustc_target/src/spec/i686_apple_darwin.rs | 7 +- .../rustc_target/src/spec/i686_linux_android.rs | 3 +- .../rustc_target/src/spec/i686_pc_windows_gnu.rs | 9 +- .../rustc_target/src/spec/i686_pc_windows_msvc.rs | 4 +- .../rustc_target/src/spec/i686_unknown_freebsd.rs | 7 +- .../rustc_target/src/spec/i686_unknown_haiku.rs | 7 +- .../src/spec/i686_unknown_linux_gnu.rs | 8 +- .../src/spec/i686_unknown_linux_musl.rs | 7 +- .../rustc_target/src/spec/i686_unknown_netbsd.rs | 7 +- .../rustc_target/src/spec/i686_unknown_openbsd.rs | 7 +- .../rustc_target/src/spec/i686_uwp_windows_gnu.rs | 9 +- compiler/rustc_target/src/spec/i686_wrs_vxworks.rs | 7 +- compiler/rustc_target/src/spec/illumos_base.rs | 6 +- compiler/rustc_target/src/spec/l4re_base.rs | 5 +- .../rustc_target/src/spec/linux_kernel_base.rs | 3 +- compiler/rustc_target/src/spec/mipsel_sony_psp.rs | 10 +- .../rustc_target/src/spec/mipsel_unknown_none.rs | 5 +- compiler/rustc_target/src/spec/mod.rs | 244 +- compiler/rustc_target/src/spec/msp430_none_elf.rs | 4 +- compiler/rustc_target/src/spec/msvc_base.rs | 8 +- .../rustc_target/src/spec/nvptx64_nvidia_cuda.rs | 1 - .../src/spec/powerpc64_unknown_freebsd.rs | 5 +- .../src/spec/powerpc64_unknown_linux_gnu.rs | 9 +- .../src/spec/powerpc64_unknown_linux_musl.rs | 5 +- .../src/spec/powerpc64_unknown_openbsd.rs | 5 +- .../rustc_target/src/spec/powerpc64_wrs_vxworks.rs | 5 +- .../src/spec/powerpc64le_unknown_freebsd.rs | 5 +- .../src/spec/powerpc64le_unknown_linux_gnu.rs | 5 +- .../src/spec/powerpc64le_unknown_linux_musl.rs | 5 +- .../src/spec/powerpc_unknown_freebsd.rs | 8 +- .../src/spec/powerpc_unknown_linux_gnu.rs | 5 +- .../src/spec/powerpc_unknown_linux_gnuspe.rs | 5 +- .../src/spec/powerpc_unknown_linux_musl.rs | 5 +- .../src/spec/powerpc_unknown_netbsd.rs | 5 +- .../src/spec/powerpc_unknown_openbsd.rs | 3 +- .../rustc_target/src/spec/powerpc_wrs_vxworks.rs | 5 +- .../src/spec/powerpc_wrs_vxworks_spe.rs | 5 +- .../src/spec/riscv32i_unknown_none_elf.rs | 5 +- .../src/spec/riscv32im_unknown_none_elf.rs | 5 +- .../src/spec/riscv32imac_unknown_none_elf.rs | 5 +- .../src/spec/riscv32imac_unknown_xous_elf.rs | 5 +- .../rustc_target/src/spec/riscv32imc_esp_espidf.rs | 4 +- .../src/spec/riscv32imc_unknown_none_elf.rs | 5 +- .../src/spec/riscv64gc_unknown_none_elf.rs | 6 +- .../src/spec/riscv64imac_unknown_none_elf.rs | 6 +- .../src/spec/s390x_unknown_linux_gnu.rs | 11 +- .../src/spec/s390x_unknown_linux_musl.rs | 11 +- compiler/rustc_target/src/spec/solaris_base.rs | 4 +- .../src/spec/sparc64_unknown_netbsd.rs | 4 +- .../src/spec/sparc64_unknown_openbsd.rs | 4 +- .../src/spec/sparc_unknown_linux_gnu.rs | 4 +- .../rustc_target/src/spec/sparcv9_sun_solaris.rs | 4 +- compiler/rustc_target/src/spec/tests/tests_impl.rs | 85 +- compiler/rustc_target/src/spec/thumb_base.rs | 5 +- .../rustc_target/src/spec/thumbv4t_none_eabi.rs | 7 +- .../rustc_target/src/spec/thumbv5te_none_eabi.rs | 41 + .../src/spec/thumbv7a_pc_windows_msvc.rs | 4 +- .../src/spec/thumbv7neon_linux_androideabi.rs | 4 +- compiler/rustc_target/src/spec/uefi_msvc_base.rs | 7 +- .../src/spec/wasm32_unknown_unknown.rs | 8 +- compiler/rustc_target/src/spec/wasm32_wasi.rs | 6 +- .../src/spec/wasm64_unknown_unknown.rs | 8 +- compiler/rustc_target/src/spec/wasm_base.rs | 9 +- compiler/rustc_target/src/spec/windows_gnu_base.rs | 28 +- .../rustc_target/src/spec/windows_gnullvm_base.rs | 10 +- .../rustc_target/src/spec/windows_uwp_gnu_base.rs | 7 +- .../rustc_target/src/spec/windows_uwp_msvc_base.rs | 4 +- .../rustc_target/src/spec/x86_64_apple_darwin.rs | 9 +- compiler/rustc_target/src/spec/x86_64_apple_ios.rs | 3 +- .../src/spec/x86_64_apple_ios_macabi.rs | 7 +- .../rustc_target/src/spec/x86_64_apple_tvos.rs | 3 +- .../src/spec/x86_64_apple_watchos_sim.rs | 3 +- .../src/spec/x86_64_fortanix_unknown_sgx.rs | 8 +- compiler/rustc_target/src/spec/x86_64_fuchsia.rs | 3 +- .../rustc_target/src/spec/x86_64_linux_android.rs | 7 +- .../rustc_target/src/spec/x86_64_pc_solaris.rs | 7 +- .../rustc_target/src/spec/x86_64_pc_windows_gnu.rs | 9 +- .../src/spec/x86_64_pc_windows_gnullvm.rs | 4 +- .../rustc_target/src/spec/x86_64_sun_solaris.rs | 7 +- .../src/spec/x86_64_unknown_dragonfly.rs | 7 +- .../src/spec/x86_64_unknown_freebsd.rs | 7 +- .../rustc_target/src/spec/x86_64_unknown_haiku.rs | 7 +- .../rustc_target/src/spec/x86_64_unknown_hermit.rs | 3 +- .../src/spec/x86_64_unknown_illumos.rs | 4 +- .../src/spec/x86_64_unknown_linux_gnu.rs | 7 +- .../src/spec/x86_64_unknown_linux_gnux32.rs | 7 +- .../src/spec/x86_64_unknown_linux_musl.rs | 7 +- .../rustc_target/src/spec/x86_64_unknown_netbsd.rs | 7 +- .../rustc_target/src/spec/x86_64_unknown_none.rs | 7 +- .../src/spec/x86_64_unknown_none_linuxkernel.rs | 4 +- .../src/spec/x86_64_unknown_openbsd.rs | 7 +- .../rustc_target/src/spec/x86_64_unknown_redox.rs | 7 +- .../src/spec/x86_64_uwp_windows_gnu.rs | 9 +- .../rustc_target/src/spec/x86_64_wrs_vxworks.rs | 7 +- compiler/rustc_trait_selection/Cargo.toml | 1 - compiler/rustc_trait_selection/src/autoderef.rs | 4 +- compiler/rustc_trait_selection/src/errors.rs | 46 +- compiler/rustc_trait_selection/src/infer.rs | 26 +- compiler/rustc_trait_selection/src/lib.rs | 2 - .../rustc_trait_selection/src/traits/auto_trait.rs | 234 +- .../src/traits/chalk_fulfill.rs | 11 +- .../rustc_trait_selection/src/traits/codegen.rs | 89 +- .../rustc_trait_selection/src/traits/coherence.rs | 102 +- .../src/traits/const_evaluatable.rs | 63 +- .../rustc_trait_selection/src/traits/engine.rs | 6 +- .../src/traits/error_reporting/mod.rs | 871 +++-- .../src/traits/error_reporting/on_unimplemented.rs | 12 +- .../src/traits/error_reporting/suggestions.rs | 370 ++- .../rustc_trait_selection/src/traits/fulfill.rs | 84 +- compiler/rustc_trait_selection/src/traits/misc.rs | 111 +- compiler/rustc_trait_selection/src/traits/mod.rs | 175 +- .../src/traits/object_safety.rs | 176 +- .../src/traits/outlives_bounds.rs | 2 +- .../rustc_trait_selection/src/traits/project.rs | 142 +- .../src/traits/query/evaluate_obligation.rs | 2 +- .../src/traits/query/normalize.rs | 54 +- .../src/traits/query/type_op/custom.rs | 8 +- .../src/traits/query/type_op/mod.rs | 6 +- .../src/traits/relationships.rs | 2 +- .../src/traits/select/candidate_assembly.rs | 29 +- .../src/traits/select/confirmation.rs | 72 +- .../rustc_trait_selection/src/traits/select/mod.rs | 149 +- .../src/traits/specialize/mod.rs | 83 +- .../src/traits/specialize/specialization_graph.rs | 48 +- .../src/traits/structural_match.rs | 9 +- compiler/rustc_trait_selection/src/traits/util.rs | 14 +- compiler/rustc_trait_selection/src/traits/wf.rs | 46 +- compiler/rustc_traits/src/chalk/db.rs | 2 +- compiler/rustc_traits/src/dropck_outlives.rs | 220 +- compiler/rustc_traits/src/evaluate_obligation.rs | 20 +- .../rustc_traits/src/implied_outlives_bounds.rs | 7 +- compiler/rustc_traits/src/lib.rs | 1 - .../rustc_traits/src/normalize_erasing_regions.rs | 46 +- compiler/rustc_traits/src/type_op.rs | 10 +- compiler/rustc_transmute/src/layout/tree.rs | 22 +- compiler/rustc_transmute/src/lib.rs | 19 +- compiler/rustc_ty_utils/Cargo.toml | 2 + compiler/rustc_ty_utils/src/abi.rs | 551 ++++ compiler/rustc_ty_utils/src/assoc.rs | 18 +- compiler/rustc_ty_utils/src/common_traits.rs | 11 +- compiler/rustc_ty_utils/src/consts.rs | 15 +- compiler/rustc_ty_utils/src/errors.rs | 56 +- compiler/rustc_ty_utils/src/instance.rs | 75 +- compiler/rustc_ty_utils/src/layout.rs | 1803 +++++++++++ compiler/rustc_ty_utils/src/layout_sanity_check.rs | 303 ++ compiler/rustc_ty_utils/src/lib.rs | 10 +- compiler/rustc_ty_utils/src/needs_drop.rs | 5 +- compiler/rustc_ty_utils/src/representability.rs | 451 +-- compiler/rustc_ty_utils/src/ty.rs | 20 +- compiler/rustc_type_ir/Cargo.toml | 1 - compiler/rustc_type_ir/src/lib.rs | 6 +- compiler/rustc_type_ir/src/sty.rs | 4 +- compiler/rustc_typeck/Cargo.toml | 33 - compiler/rustc_typeck/README.md | 5 - compiler/rustc_typeck/src/astconv/errors.rs | 411 --- compiler/rustc_typeck/src/astconv/generics.rs | 663 ---- compiler/rustc_typeck/src/astconv/mod.rs | 3110 ------------------ compiler/rustc_typeck/src/bounds.rs | 90 - compiler/rustc_typeck/src/check/_match.rs | 557 ---- compiler/rustc_typeck/src/check/autoderef.rs | 78 - compiler/rustc_typeck/src/check/callee.rs | 694 ---- compiler/rustc_typeck/src/check/cast.rs | 1163 ------- compiler/rustc_typeck/src/check/check.rs | 1753 ---------- compiler/rustc_typeck/src/check/closure.rs | 825 ----- compiler/rustc_typeck/src/check/coercion.rs | 1885 ----------- compiler/rustc_typeck/src/check/compare_method.rs | 1792 ----------- compiler/rustc_typeck/src/check/demand.rs | 1415 -------- compiler/rustc_typeck/src/check/diverges.rs | 78 - compiler/rustc_typeck/src/check/dropck.rs | 329 -- compiler/rustc_typeck/src/check/expectation.rs | 122 - compiler/rustc_typeck/src/check/expr.rs | 2876 ----------------- compiler/rustc_typeck/src/check/fallback.rs | 398 --- compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs | 1512 --------- .../rustc_typeck/src/check/fn_ctxt/arg_matrix.rs | 383 --- compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 2222 ------------- compiler/rustc_typeck/src/check/fn_ctxt/mod.rs | 304 -- .../rustc_typeck/src/check/fn_ctxt/suggestions.rs | 1139 ------- compiler/rustc_typeck/src/check/gather_locals.rs | 160 - .../rustc_typeck/src/check/generator_interior.rs | 646 ---- .../src/check/generator_interior/drop_ranges.rs | 309 -- .../generator_interior/drop_ranges/cfg_build.rs | 563 ---- .../drop_ranges/cfg_propagate.rs | 92 - .../drop_ranges/cfg_visualize.rs | 91 - .../drop_ranges/record_consumed_borrow.rs | 232 -- compiler/rustc_typeck/src/check/inherited.rs | 209 -- compiler/rustc_typeck/src/check/intrinsic.rs | 533 --- compiler/rustc_typeck/src/check/intrinsicck.rs | 531 --- compiler/rustc_typeck/src/check/method/confirm.rs | 594 ---- compiler/rustc_typeck/src/check/method/mod.rs | 626 ---- .../rustc_typeck/src/check/method/prelude2021.rs | 418 --- compiler/rustc_typeck/src/check/method/probe.rs | 1927 ----------- compiler/rustc_typeck/src/check/method/suggest.rs | 2365 -------------- compiler/rustc_typeck/src/check/mod.rs | 967 ------ compiler/rustc_typeck/src/check/op.rs | 993 ------ compiler/rustc_typeck/src/check/pat.rs | 2187 ------------- compiler/rustc_typeck/src/check/place_op.rs | 451 --- compiler/rustc_typeck/src/check/region.rs | 852 ----- compiler/rustc_typeck/src/check/rvalue_scopes.rs | 83 - compiler/rustc_typeck/src/check/upvar.rs | 2276 ------------- compiler/rustc_typeck/src/check/wfcheck.rs | 1989 ------------ compiler/rustc_typeck/src/check/writeback.rs | 816 ----- compiler/rustc_typeck/src/check_unused.rs | 187 -- compiler/rustc_typeck/src/coherence/builtin.rs | 594 ---- .../rustc_typeck/src/coherence/inherent_impls.rs | 249 -- .../src/coherence/inherent_impls_overlap.rs | 307 -- compiler/rustc_typeck/src/coherence/mod.rs | 237 -- compiler/rustc_typeck/src/coherence/orphan.rs | 507 --- compiler/rustc_typeck/src/coherence/unsafety.rs | 66 - compiler/rustc_typeck/src/collect.rs | 3401 -------------------- compiler/rustc_typeck/src/collect/item_bounds.rs | 110 - compiler/rustc_typeck/src/collect/type_of.rs | 936 ------ .../rustc_typeck/src/constrained_generic_params.rs | 221 -- compiler/rustc_typeck/src/errors.rs | 347 -- compiler/rustc_typeck/src/expr_use_visitor.rs | 915 ------ compiler/rustc_typeck/src/hir_wf_check.rs | 188 -- compiler/rustc_typeck/src/impl_wf_check.rs | 228 -- .../src/impl_wf_check/min_specialization.rs | 444 --- compiler/rustc_typeck/src/lib.rs | 557 ---- compiler/rustc_typeck/src/mem_categorization.rs | 786 ----- compiler/rustc_typeck/src/outlives/explicit.rs | 69 - .../rustc_typeck/src/outlives/implicit_infer.rs | 300 -- compiler/rustc_typeck/src/outlives/mod.rs | 129 - compiler/rustc_typeck/src/outlives/test.rs | 21 - compiler/rustc_typeck/src/outlives/utils.rs | 169 - compiler/rustc_typeck/src/structured_errors.rs | 42 - .../missing_cast_for_variadic_arg.rs | 61 - .../src/structured_errors/sized_unsized_cast.rs | 62 - .../wrong_number_of_generic_args.rs | 1023 ------ compiler/rustc_typeck/src/variance/constraints.rs | 445 --- compiler/rustc_typeck/src/variance/mod.rs | 63 - compiler/rustc_typeck/src/variance/solve.rs | 135 - compiler/rustc_typeck/src/variance/terms.rs | 145 - compiler/rustc_typeck/src/variance/test.rs | 14 - compiler/rustc_typeck/src/variance/xform.rs | 22 - 960 files changed, 88544 insertions(+), 81351 deletions(-) create mode 100644 compiler/rustc_builtin_macros/src/format/ast.rs create mode 100644 compiler/rustc_builtin_macros/src/format/expand.rs create mode 100644 compiler/rustc_codegen_cranelift/build_system/abi_cafe.rs delete mode 100644 compiler/rustc_codegen_cranelift/build_system/abi_checker.rs create mode 100644 compiler/rustc_codegen_cranelift/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch delete mode 100644 compiler/rustc_codegen_cranelift/patches/0001-abi-checker-Disable-failing-tests.patch create mode 100644 compiler/rustc_codegen_cranelift/patches/0003-rand-Disable-rand-tests-on-mingw.patch create mode 100644 compiler/rustc_codegen_gcc/src/errors.rs create mode 100644 compiler/rustc_codegen_ssa/src/errors.rs delete mode 100644 compiler/rustc_const_eval/src/might_permit_raw_init.rs create mode 100644 compiler/rustc_const_eval/src/util/might_permit_raw_init.rs create mode 100644 compiler/rustc_data_structures/src/unord.rs create mode 100644 compiler/rustc_error_codes/src/error_codes/E0311.md create mode 100644 compiler/rustc_error_messages/locales/en-US/codegen_gcc.ftl create mode 100644 compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl create mode 100644 compiler/rustc_error_messages/locales/en-US/compiletest.ftl create mode 100644 compiler/rustc_error_messages/locales/en-US/errors.ftl create mode 100644 compiler/rustc_error_messages/locales/en-US/hir_analysis.ftl delete mode 100644 compiler/rustc_error_messages/locales/en-US/typeck.ftl create mode 100644 compiler/rustc_errors/src/diagnostic_impls.rs create mode 100644 compiler/rustc_hir_analysis/Cargo.toml create mode 100644 compiler/rustc_hir_analysis/README.md create mode 100644 compiler/rustc_hir_analysis/src/astconv/errors.rs create mode 100644 compiler/rustc_hir_analysis/src/astconv/generics.rs create mode 100644 compiler/rustc_hir_analysis/src/astconv/mod.rs create mode 100644 compiler/rustc_hir_analysis/src/bounds.rs create mode 100644 compiler/rustc_hir_analysis/src/check/check.rs create mode 100644 compiler/rustc_hir_analysis/src/check/compare_method.rs create mode 100644 compiler/rustc_hir_analysis/src/check/dropck.rs create mode 100644 compiler/rustc_hir_analysis/src/check/intrinsic.rs create mode 100644 compiler/rustc_hir_analysis/src/check/intrinsicck.rs create mode 100644 compiler/rustc_hir_analysis/src/check/mod.rs create mode 100644 compiler/rustc_hir_analysis/src/check/region.rs create mode 100644 compiler/rustc_hir_analysis/src/check/wfcheck.rs create mode 100644 compiler/rustc_hir_analysis/src/check_unused.rs create mode 100644 compiler/rustc_hir_analysis/src/coherence/builtin.rs create mode 100644 compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs create mode 100644 compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs create mode 100644 compiler/rustc_hir_analysis/src/coherence/mod.rs create mode 100644 compiler/rustc_hir_analysis/src/coherence/orphan.rs create mode 100644 compiler/rustc_hir_analysis/src/coherence/unsafety.rs create mode 100644 compiler/rustc_hir_analysis/src/collect.rs create mode 100644 compiler/rustc_hir_analysis/src/collect/generics_of.rs create mode 100644 compiler/rustc_hir_analysis/src/collect/item_bounds.rs create mode 100644 compiler/rustc_hir_analysis/src/collect/lifetimes.rs create mode 100644 compiler/rustc_hir_analysis/src/collect/predicates_of.rs create mode 100644 compiler/rustc_hir_analysis/src/collect/type_of.rs create mode 100644 compiler/rustc_hir_analysis/src/constrained_generic_params.rs create mode 100644 compiler/rustc_hir_analysis/src/errors.rs create mode 100644 compiler/rustc_hir_analysis/src/hir_wf_check.rs create mode 100644 compiler/rustc_hir_analysis/src/impl_wf_check.rs create mode 100644 compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs create mode 100644 compiler/rustc_hir_analysis/src/lib.rs create mode 100644 compiler/rustc_hir_analysis/src/outlives/explicit.rs create mode 100644 compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs create mode 100644 compiler/rustc_hir_analysis/src/outlives/mod.rs create mode 100644 compiler/rustc_hir_analysis/src/outlives/test.rs create mode 100644 compiler/rustc_hir_analysis/src/outlives/utils.rs create mode 100644 compiler/rustc_hir_analysis/src/structured_errors.rs create mode 100644 compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs create mode 100644 compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs create mode 100644 compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs create mode 100644 compiler/rustc_hir_analysis/src/variance/constraints.rs create mode 100644 compiler/rustc_hir_analysis/src/variance/mod.rs create mode 100644 compiler/rustc_hir_analysis/src/variance/solve.rs create mode 100644 compiler/rustc_hir_analysis/src/variance/terms.rs create mode 100644 compiler/rustc_hir_analysis/src/variance/test.rs create mode 100644 compiler/rustc_hir_analysis/src/variance/xform.rs create mode 100644 compiler/rustc_hir_typeck/Cargo.toml create mode 100644 compiler/rustc_hir_typeck/src/_match.rs create mode 100644 compiler/rustc_hir_typeck/src/autoderef.rs create mode 100644 compiler/rustc_hir_typeck/src/callee.rs create mode 100644 compiler/rustc_hir_typeck/src/cast.rs create mode 100644 compiler/rustc_hir_typeck/src/check.rs create mode 100644 compiler/rustc_hir_typeck/src/closure.rs create mode 100644 compiler/rustc_hir_typeck/src/coercion.rs create mode 100644 compiler/rustc_hir_typeck/src/demand.rs create mode 100644 compiler/rustc_hir_typeck/src/diverges.rs create mode 100644 compiler/rustc_hir_typeck/src/errors.rs create mode 100644 compiler/rustc_hir_typeck/src/expectation.rs create mode 100644 compiler/rustc_hir_typeck/src/expr.rs create mode 100644 compiler/rustc_hir_typeck/src/expr_use_visitor.rs create mode 100644 compiler/rustc_hir_typeck/src/fallback.rs create mode 100644 compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs create mode 100644 compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs create mode 100644 compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs create mode 100644 compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs create mode 100644 compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs create mode 100644 compiler/rustc_hir_typeck/src/gather_locals.rs create mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs create mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_propagate.rs create mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_visualize.rs create mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs create mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs create mode 100644 compiler/rustc_hir_typeck/src/generator_interior/mod.rs create mode 100644 compiler/rustc_hir_typeck/src/inherited.rs create mode 100644 compiler/rustc_hir_typeck/src/intrinsicck.rs create mode 100644 compiler/rustc_hir_typeck/src/lib.rs create mode 100644 compiler/rustc_hir_typeck/src/mem_categorization.rs create mode 100644 compiler/rustc_hir_typeck/src/method/confirm.rs create mode 100644 compiler/rustc_hir_typeck/src/method/mod.rs create mode 100644 compiler/rustc_hir_typeck/src/method/prelude2021.rs create mode 100644 compiler/rustc_hir_typeck/src/method/probe.rs create mode 100644 compiler/rustc_hir_typeck/src/method/suggest.rs create mode 100644 compiler/rustc_hir_typeck/src/op.rs create mode 100644 compiler/rustc_hir_typeck/src/pat.rs create mode 100644 compiler/rustc_hir_typeck/src/place_op.rs create mode 100644 compiler/rustc_hir_typeck/src/rvalue_scopes.rs create mode 100644 compiler/rustc_hir_typeck/src/upvar.rs create mode 100644 compiler/rustc_hir_typeck/src/writeback.rs create mode 100644 compiler/rustc_lint/src/for_loops_over_fallibles.rs create mode 100644 compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs delete mode 100644 compiler/rustc_middle/benches/lib.rs delete mode 100644 compiler/rustc_middle/src/ty/inhabitedness/def_id_forest.rs create mode 100644 compiler/rustc_middle/src/ty/inhabitedness/inhabited_predicate.rs delete mode 100644 compiler/rustc_middle/src/ty/layout_sanity_check.rs create mode 100644 compiler/rustc_middle/src/ty/opaque_types.rs create mode 100644 compiler/rustc_mir_transform/src/deduce_param_attrs.rs delete mode 100644 compiler/rustc_mir_transform/src/marker.rs create mode 100644 compiler/rustc_parse/src/errors.rs delete mode 100644 compiler/rustc_resolve/src/access_levels.rs create mode 100644 compiler/rustc_resolve/src/effective_visibilities.rs delete mode 100644 compiler/rustc_resolve/src/late/lifetimes.rs create mode 100644 compiler/rustc_target/src/spec/armv5te_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs create mode 100644 compiler/rustc_ty_utils/src/abi.rs create mode 100644 compiler/rustc_ty_utils/src/layout.rs create mode 100644 compiler/rustc_ty_utils/src/layout_sanity_check.rs delete mode 100644 compiler/rustc_typeck/Cargo.toml delete mode 100644 compiler/rustc_typeck/README.md delete mode 100644 compiler/rustc_typeck/src/astconv/errors.rs delete mode 100644 compiler/rustc_typeck/src/astconv/generics.rs delete mode 100644 compiler/rustc_typeck/src/astconv/mod.rs delete mode 100644 compiler/rustc_typeck/src/bounds.rs delete mode 100644 compiler/rustc_typeck/src/check/_match.rs delete mode 100644 compiler/rustc_typeck/src/check/autoderef.rs delete mode 100644 compiler/rustc_typeck/src/check/callee.rs delete mode 100644 compiler/rustc_typeck/src/check/cast.rs delete mode 100644 compiler/rustc_typeck/src/check/check.rs delete mode 100644 compiler/rustc_typeck/src/check/closure.rs delete mode 100644 compiler/rustc_typeck/src/check/coercion.rs delete mode 100644 compiler/rustc_typeck/src/check/compare_method.rs delete mode 100644 compiler/rustc_typeck/src/check/demand.rs delete mode 100644 compiler/rustc_typeck/src/check/diverges.rs delete mode 100644 compiler/rustc_typeck/src/check/dropck.rs delete mode 100644 compiler/rustc_typeck/src/check/expectation.rs delete mode 100644 compiler/rustc_typeck/src/check/expr.rs delete mode 100644 compiler/rustc_typeck/src/check/fallback.rs delete mode 100644 compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs delete mode 100644 compiler/rustc_typeck/src/check/fn_ctxt/arg_matrix.rs delete mode 100644 compiler/rustc_typeck/src/check/fn_ctxt/checks.rs delete mode 100644 compiler/rustc_typeck/src/check/fn_ctxt/mod.rs delete mode 100644 compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs delete mode 100644 compiler/rustc_typeck/src/check/gather_locals.rs delete mode 100644 compiler/rustc_typeck/src/check/generator_interior.rs delete mode 100644 compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs delete mode 100644 compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_build.rs delete mode 100644 compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_propagate.rs delete mode 100644 compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_visualize.rs delete mode 100644 compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs delete mode 100644 compiler/rustc_typeck/src/check/inherited.rs delete mode 100644 compiler/rustc_typeck/src/check/intrinsic.rs delete mode 100644 compiler/rustc_typeck/src/check/intrinsicck.rs delete mode 100644 compiler/rustc_typeck/src/check/method/confirm.rs delete mode 100644 compiler/rustc_typeck/src/check/method/mod.rs delete mode 100644 compiler/rustc_typeck/src/check/method/prelude2021.rs delete mode 100644 compiler/rustc_typeck/src/check/method/probe.rs delete mode 100644 compiler/rustc_typeck/src/check/method/suggest.rs delete mode 100644 compiler/rustc_typeck/src/check/mod.rs delete mode 100644 compiler/rustc_typeck/src/check/op.rs delete mode 100644 compiler/rustc_typeck/src/check/pat.rs delete mode 100644 compiler/rustc_typeck/src/check/place_op.rs delete mode 100644 compiler/rustc_typeck/src/check/region.rs delete mode 100644 compiler/rustc_typeck/src/check/rvalue_scopes.rs delete mode 100644 compiler/rustc_typeck/src/check/upvar.rs delete mode 100644 compiler/rustc_typeck/src/check/wfcheck.rs delete mode 100644 compiler/rustc_typeck/src/check/writeback.rs delete mode 100644 compiler/rustc_typeck/src/check_unused.rs delete mode 100644 compiler/rustc_typeck/src/coherence/builtin.rs delete mode 100644 compiler/rustc_typeck/src/coherence/inherent_impls.rs delete mode 100644 compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs delete mode 100644 compiler/rustc_typeck/src/coherence/mod.rs delete mode 100644 compiler/rustc_typeck/src/coherence/orphan.rs delete mode 100644 compiler/rustc_typeck/src/coherence/unsafety.rs delete mode 100644 compiler/rustc_typeck/src/collect.rs delete mode 100644 compiler/rustc_typeck/src/collect/item_bounds.rs delete mode 100644 compiler/rustc_typeck/src/collect/type_of.rs delete mode 100644 compiler/rustc_typeck/src/constrained_generic_params.rs delete mode 100644 compiler/rustc_typeck/src/errors.rs delete mode 100644 compiler/rustc_typeck/src/expr_use_visitor.rs delete mode 100644 compiler/rustc_typeck/src/hir_wf_check.rs delete mode 100644 compiler/rustc_typeck/src/impl_wf_check.rs delete mode 100644 compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs delete mode 100644 compiler/rustc_typeck/src/lib.rs delete mode 100644 compiler/rustc_typeck/src/mem_categorization.rs delete mode 100644 compiler/rustc_typeck/src/outlives/explicit.rs delete mode 100644 compiler/rustc_typeck/src/outlives/implicit_infer.rs delete mode 100644 compiler/rustc_typeck/src/outlives/mod.rs delete mode 100644 compiler/rustc_typeck/src/outlives/test.rs delete mode 100644 compiler/rustc_typeck/src/outlives/utils.rs delete mode 100644 compiler/rustc_typeck/src/structured_errors.rs delete mode 100644 compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs delete mode 100644 compiler/rustc_typeck/src/structured_errors/sized_unsized_cast.rs delete mode 100644 compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs delete mode 100644 compiler/rustc_typeck/src/variance/constraints.rs delete mode 100644 compiler/rustc_typeck/src/variance/mod.rs delete mode 100644 compiler/rustc_typeck/src/variance/solve.rs delete mode 100644 compiler/rustc_typeck/src/variance/terms.rs delete mode 100644 compiler/rustc_typeck/src/variance/test.rs delete mode 100644 compiler/rustc_typeck/src/variance/xform.rs (limited to 'compiler') diff --git a/compiler/rustc/src/main.rs b/compiler/rustc/src/main.rs index 0de1a7819..e21c9b660 100644 --- a/compiler/rustc/src/main.rs +++ b/compiler/rustc/src/main.rs @@ -1,3 +1,5 @@ +#![feature(unix_sigpipe)] + // A note about jemalloc: rustc uses jemalloc when built for CI and // distribution. The obvious way to do this is with the `#[global_allocator]` // mechanism. However, for complicated reasons (see @@ -23,6 +25,7 @@ // libraries. So we must reference jemalloc symbols one way or another, because // this file is the only object code in the rustc executable. +#[unix_sigpipe = "sig_dfl"] fn main() { // See the comment at the top of this file for an explanation of this. #[cfg(feature = "jemalloc-sys")] @@ -58,6 +61,5 @@ fn main() { } } - rustc_driver::set_sigpipe_handler(); rustc_driver::main() } diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index c24180bac..fcbf96818 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -4,7 +4,6 @@ version = "0.0.0" edition = "2021" [lib] -doctest = false [dependencies] bitflags = "1.2.1" diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index d86db8f8b..4ef43735a 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1112,24 +1112,6 @@ pub struct Expr { } impl Expr { - /// Returns `true` if this expression would be valid somewhere that expects a value; - /// for example, an `if` condition. - pub fn returns(&self) -> bool { - if let ExprKind::Block(ref block, _) = self.kind { - match block.stmts.last().map(|last_stmt| &last_stmt.kind) { - // Implicit return - Some(StmtKind::Expr(_)) => true, - // Last statement is an explicit return? - Some(StmtKind::Semi(expr)) => matches!(expr.kind, ExprKind::Ret(_)), - // This is a block that doesn't end in either an implicit or explicit return. - _ => false, - } - } else { - // This is not a block, it is a value. - true - } - } - /// Is this expr either `N`, or `{ N }`. /// /// If this is not the case, name resolution does not resolve `N` when using @@ -1338,14 +1320,13 @@ pub enum ExprKind { /// /// The `PathSegment` represents the method name and its generic arguments /// (within the angle brackets). - /// The first element of the vector of an `Expr` is the expression that evaluates - /// to the object on which the method is being called on (the receiver), - /// and the remaining elements are the rest of the arguments. - /// Thus, `x.foo::(a, b, c, d)` is represented as - /// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d])`. + /// The standalone `Expr` is the receiver expression. + /// The vector of `Expr` is the arguments. + /// `x.foo::(a, b, c, d)` is represented as + /// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, x, [a, b, c, d])`. /// This `Span` is the span of the function, without the dot and receiver /// (e.g. `foo(a, b)` in `x.foo(a, b)` - MethodCall(PathSegment, Vec>, Span), + MethodCall(PathSegment, P, Vec>, Span), /// A tuple (e.g., `(a, b, c, d)`). Tup(Vec>), /// A binary operation (e.g., `a + b`, `a * b`). @@ -2957,7 +2938,7 @@ pub enum AssocItemKind { /// An associated function. Fn(Box), /// An associated type. - TyAlias(Box), + Type(Box), /// A macro expanding to associated items. MacCall(P), } @@ -2967,7 +2948,7 @@ impl AssocItemKind { match *self { Self::Const(defaultness, ..) | Self::Fn(box Fn { defaultness, .. }) - | Self::TyAlias(box TyAlias { defaultness, .. }) => defaultness, + | Self::Type(box TyAlias { defaultness, .. }) => defaultness, Self::MacCall(..) => Defaultness::Final, } } @@ -2978,7 +2959,7 @@ impl From for ItemKind { match assoc_item_kind { AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c), AssocItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind), - AssocItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind), + AssocItemKind::Type(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind), AssocItemKind::MacCall(a) => ItemKind::MacCall(a), } } @@ -2991,7 +2972,7 @@ impl TryFrom for AssocItemKind { Ok(match item_kind { ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c), ItemKind::Fn(fn_kind) => AssocItemKind::Fn(fn_kind), - ItemKind::TyAlias(ty_alias_kind) => AssocItemKind::TyAlias(ty_alias_kind), + ItemKind::TyAlias(ty_kind) => AssocItemKind::Type(ty_kind), ItemKind::MacCall(a) => AssocItemKind::MacCall(a), _ => return Err(item_kind), }) @@ -3043,14 +3024,13 @@ pub type ForeignItem = Item; mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; - // These are in alphabetical order, which is easy to maintain. + // tidy-alphabetical-start static_assert_size!(AssocItem, 104); static_assert_size!(AssocItemKind, 32); static_assert_size!(Attribute, 32); static_assert_size!(Block, 48); static_assert_size!(Expr, 104); static_assert_size!(ExprKind, 72); - #[cfg(not(bootstrap))] static_assert_size!(Fn, 184); static_assert_size!(ForeignItem, 96); static_assert_size!(ForeignItemKind, 24); @@ -3065,11 +3045,12 @@ mod size_asserts { static_assert_size!(Local, 72); static_assert_size!(Param, 40); static_assert_size!(Pat, 120); - static_assert_size!(PatKind, 96); static_assert_size!(Path, 40); static_assert_size!(PathSegment, 24); + static_assert_size!(PatKind, 96); static_assert_size!(Stmt, 32); static_assert_size!(StmtKind, 16); static_assert_size!(Ty, 96); static_assert_size!(TyKind, 72); + // tidy-alphabetical-end } diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index bd7a85b07..eeb7e56e2 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -13,9 +13,7 @@ #![feature(const_default_impls)] #![feature(const_trait_impl)] #![feature(if_let_guard)] -#![cfg_attr(bootstrap, feature(label_break_value))] #![feature(let_chains)] -#![cfg_attr(bootstrap, feature(let_else))] #![feature(min_specialization)] #![feature(negative_impls)] #![feature(slice_internals)] diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 9fd0b63c4..b970e57e0 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -152,6 +152,12 @@ pub trait MutVisitor: Sized { noop_visit_expr(e, self); } + /// This method is a hack to workaround unstable of `stmt_expr_attributes`. + /// It can be removed once that feature is stabilized. + fn visit_method_receiver_expr(&mut self, ex: &mut P) { + self.visit_expr(ex) + } + fn filter_map_expr(&mut self, e: P) -> Option> { noop_filter_map_expr(e, self) } @@ -1106,7 +1112,7 @@ pub fn noop_flat_map_assoc_item( visit_fn_sig(sig, visitor); visit_opt(body, |body| visitor.visit_block(body)); } - AssocItemKind::TyAlias(box TyAlias { + AssocItemKind::Type(box TyAlias { defaultness, generics, where_clauses, @@ -1297,10 +1303,11 @@ pub fn noop_visit_expr( vis.visit_expr(f); visit_exprs(args, vis); } - ExprKind::MethodCall(PathSegment { ident, id, args }, exprs, span) => { + ExprKind::MethodCall(PathSegment { ident, id, args }, receiver, exprs, span) => { vis.visit_ident(ident); vis.visit_id(id); visit_opt(args, |args| vis.visit_generic_args(args)); + vis.visit_method_receiver_expr(receiver); visit_exprs(exprs, vis); vis.visit_span(span); } @@ -1588,3 +1595,9 @@ impl DummyAstNode for Crate { } } } + +impl DummyAstNode for crate::ast_traits::AstNodeWrapper { + fn dummy() -> Self { + crate::ast_traits::AstNodeWrapper::new(N::dummy(), T::dummy()) + } +} diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 97dfb7837..83b10d906 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -13,7 +13,7 @@ use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{self, edition::Edition, Span, DUMMY_SP}; use std::borrow::Cow; -use std::{fmt, mem}; +use std::fmt; #[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum CommentKind { @@ -256,10 +256,6 @@ pub enum TokenKind { Eof, } -// `TokenKind` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(TokenKind, 16); - #[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub struct Token { pub kind: TokenKind, @@ -335,11 +331,6 @@ impl Token { Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span) } - /// Return this token by value and leave a dummy token in its place. - pub fn take(&mut self) -> Self { - mem::replace(self, Token::dummy()) - } - /// For interpolated tokens, returns a span of the fragment to which the interpolated /// token refers. For all other tokens this is just a regular span. /// It is particularly important to use this for identifiers and lifetimes @@ -354,17 +345,14 @@ impl Token { } pub fn is_op(&self) -> bool { - !matches!( - self.kind, - OpenDelim(..) - | CloseDelim(..) - | Literal(..) - | DocComment(..) - | Ident(..) - | Lifetime(..) - | Interpolated(..) - | Eof - ) + match self.kind { + Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_) + | BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon + | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true, + + OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..) + | Lifetime(..) | Interpolated(..) | Eof => false, + } } pub fn is_like_plus(&self) -> bool { @@ -733,6 +721,7 @@ impl Token { } impl PartialEq for Token { + #[inline] fn eq(&self, rhs: &TokenKind) -> bool { self.kind == *rhs } @@ -756,10 +745,6 @@ pub enum Nonterminal { NtVis(P), } -// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(Nonterminal, 16); - #[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable)] pub enum NonterminalKind { Item, @@ -898,3 +883,17 @@ where panic!("interpolated tokens should not be present in the HIR") } } + +// Some types are used a lot. Make sure they don't unintentionally get bigger. +#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +mod size_asserts { + use super::*; + use rustc_data_structures::static_assert_size; + // tidy-alphabetical-start + static_assert_size!(Lit, 12); + static_assert_size!(LitKind, 2); + static_assert_size!(Nonterminal, 16); + static_assert_size!(Token, 24); + static_assert_size!(TokenKind, 16); + // tidy-alphabetical-end +} diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 875cd620d..015f5c1ee 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -47,10 +47,6 @@ pub enum TokenTree { Delimited(DelimSpan, Delimiter, TokenStream), } -// This type is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(TokenTree, 32); - // Ensure all fields of `TokenTree` is `Send` and `Sync`. #[cfg(parallel_compiler)] fn _dummy() @@ -249,12 +245,12 @@ impl AttrTokenStream { // properly implemented - we always synthesize fake tokens, // so we never reach this code. - let mut builder = TokenStreamBuilder::new(); + let mut stream = TokenStream::default(); for inner_attr in inner_attrs { - builder.push(inner_attr.tokens()); + stream.push_stream(inner_attr.tokens()); } - builder.push(delim_tokens.clone()); - *tree = TokenTree::Delimited(*span, *delim, builder.build()); + stream.push_stream(delim_tokens.clone()); + *tree = TokenTree::Delimited(*span, *delim, stream); found = true; break; } @@ -308,13 +304,20 @@ pub struct AttributesData { #[derive(Clone, Debug, Default, Encodable, Decodable)] pub struct TokenStream(pub(crate) Lrc>); -// `TokenStream` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(TokenStream, 8); - +/// Similar to `proc_macro::Spacing`, but for tokens. +/// +/// Note that all `ast::TokenTree::Token` instances have a `Spacing`, but when +/// we convert to `proc_macro::TokenTree` for proc macros only `Punct` +/// `TokenTree`s have a `proc_macro::Spacing`. #[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)] pub enum Spacing { + /// The token is not immediately followed by an operator token (as + /// determined by `Token::is_op`). E.g. a `+` token is `Alone` in `+ =`, + /// `+/*foo*/=`, `+ident`, and `+()`. Alone, + + /// The token is immediately followed by an operator token. E.g. a `+` + /// token is `Joint` in `+=` and `++`. Joint, } @@ -502,76 +505,49 @@ impl TokenStream { self.trees().map(|tree| TokenStream::flatten_token_tree(tree)).collect() } -} -// 99.5%+ of the time we have 1 or 2 elements in this vector. -#[derive(Clone)] -pub struct TokenStreamBuilder(SmallVec<[TokenStream; 2]>); - -impl TokenStreamBuilder { - pub fn new() -> TokenStreamBuilder { - TokenStreamBuilder(SmallVec::new()) - } - - pub fn push(&mut self, stream: TokenStream) { - self.0.push(stream); - } - - pub fn build(self) -> TokenStream { - let mut streams = self.0; - match streams.len() { - 0 => TokenStream::default(), - 1 => streams.pop().unwrap(), - _ => { - // We will extend the first stream in `streams` with the - // elements from the subsequent streams. This requires using - // `make_mut()` on the first stream, and in practice this - // doesn't cause cloning 99.9% of the time. - // - // One very common use case is when `streams` has two elements, - // where the first stream has any number of elements within - // (often 1, but sometimes many more) and the second stream has - // a single element within. - - // Determine how much the first stream will be extended. - // Needed to avoid quadratic blow up from on-the-fly - // reallocations (#57735). - let num_appends = streams.iter().skip(1).map(|ts| ts.len()).sum(); - - // Get the first stream, which will become the result stream. - // If it's `None`, create an empty stream. - let mut iter = streams.into_iter(); - let mut res_stream_lrc = iter.next().unwrap().0; - - // Append the subsequent elements to the result stream, after - // reserving space for them. - let res_vec_mut = Lrc::make_mut(&mut res_stream_lrc); - res_vec_mut.reserve(num_appends); - for stream in iter { - let stream_iter = stream.0.iter().cloned(); - - // If (a) `res_mut_vec` is not empty and the last tree - // within it is a token tree marked with `Joint`, and (b) - // `stream` is not empty and the first tree within it is a - // token tree, and (c) the two tokens can be glued - // together... - if let Some(TokenTree::Token(last_tok, Spacing::Joint)) = res_vec_mut.last() - && let Some(TokenTree::Token(tok, spacing)) = stream.0.first() - && let Some(glued_tok) = last_tok.glue(&tok) - { - // ...then overwrite the last token tree in - // `res_vec_mut` with the glued token, and skip the - // first token tree from `stream`. - *res_vec_mut.last_mut().unwrap() = TokenTree::Token(glued_tok, *spacing); - res_vec_mut.extend(stream_iter.skip(1)); - } else { - // Append all of `stream`. - res_vec_mut.extend(stream_iter); - } - } + // If `vec` is not empty, try to glue `tt` onto its last token. The return + // value indicates if gluing took place. + fn try_glue_to_last(vec: &mut Vec, tt: &TokenTree) -> bool { + if let Some(TokenTree::Token(last_tok, Spacing::Joint)) = vec.last() + && let TokenTree::Token(tok, spacing) = tt + && let Some(glued_tok) = last_tok.glue(&tok) + { + // ...then overwrite the last token tree in `vec` with the + // glued token, and skip the first token tree from `stream`. + *vec.last_mut().unwrap() = TokenTree::Token(glued_tok, *spacing); + true + } else { + false + } + } - TokenStream(res_stream_lrc) - } + // Push `tt` onto the end of the stream, possibly gluing it to the last + // token. Uses `make_mut` to maximize efficiency. + pub fn push_tree(&mut self, tt: TokenTree) { + let vec_mut = Lrc::make_mut(&mut self.0); + + if Self::try_glue_to_last(vec_mut, &tt) { + // nothing else to do + } else { + vec_mut.push(tt); + } + } + + // Push `stream` onto the end of the stream, possibly gluing the first + // token tree to the last token. (No other token trees will be glued.) + // Uses `make_mut` to maximize efficiency. + pub fn push_stream(&mut self, stream: TokenStream) { + let vec_mut = Lrc::make_mut(&mut self.0); + + let stream_iter = stream.0.iter().cloned(); + + if let Some(first) = stream.0.first() && Self::try_glue_to_last(vec_mut, first) { + // Now skip the first token tree from `stream`. + vec_mut.extend(stream_iter.skip(1)); + } else { + // Append all of `stream`. + vec_mut.extend(stream_iter); } } } @@ -664,3 +640,17 @@ impl DelimSpan { self.open.with_hi(self.close.hi()) } } + +// Some types are used a lot. Make sure they don't unintentionally get bigger. +#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +mod size_asserts { + use super::*; + use rustc_data_structures::static_assert_size; + // tidy-alphabetical-start + static_assert_size!(AttrTokenStream, 8); + static_assert_size!(AttrTokenTree, 32); + static_assert_size!(LazyAttrTokenStream, 8); + static_assert_size!(TokenStream, 8); + static_assert_size!(TokenTree, 32); + // tidy-alphabetical-end +} diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 6c5c7f66f..b40ad6f70 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -396,9 +396,9 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool { contains_exterior_struct_lit(&x) } - ast::ExprKind::MethodCall(.., ref exprs, _) => { + ast::ExprKind::MethodCall(_, ref receiver, _, _) => { // X { y: 1 }.bar(...) - contains_exterior_struct_lit(&exprs[0]) + contains_exterior_struct_lit(&receiver) } _ => false, diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 1d0de5a4b..6f56c1ef0 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -140,6 +140,11 @@ pub trait Visitor<'ast>: Sized { fn visit_expr(&mut self, ex: &'ast Expr) { walk_expr(self, ex) } + /// This method is a hack to workaround unstable of `stmt_expr_attributes`. + /// It can be removed once that feature is stabilized. + fn visit_method_receiver_expr(&mut self, ex: &'ast Expr) { + self.visit_expr(ex) + } fn visit_expr_post(&mut self, _ex: &'ast Expr) {} fn visit_ty(&mut self, t: &'ast Ty) { walk_ty(self, t) @@ -244,14 +249,12 @@ pub trait Visitor<'ast>: Sized { #[macro_export] macro_rules! walk_list { - ($visitor: expr, $method: ident, $list: expr) => { - for elem in $list { - $visitor.$method(elem) - } - }; - ($visitor: expr, $method: ident, $list: expr, $($extra_args: expr),*) => { - for elem in $list { - $visitor.$method(elem, $($extra_args,)*) + ($visitor: expr, $method: ident, $list: expr $(, $($extra_args: expr),* )?) => { + { + #[cfg_attr(not(bootstrap), allow(for_loops_over_fallibles))] + for elem in $list { + $visitor.$method(elem $(, $($extra_args,)* )?) + } } } } @@ -685,7 +688,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem, let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref()); visitor.visit_fn(kind, span, id); } - AssocItemKind::TyAlias(box TyAlias { generics, bounds, ty, .. }) => { + AssocItemKind::Type(box TyAlias { generics, bounds, ty, .. }) => { visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound); walk_list!(visitor, visit_ty, ty); @@ -795,8 +798,9 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { visitor.visit_expr(callee_expression); walk_list!(visitor, visit_expr, arguments); } - ExprKind::MethodCall(ref segment, ref arguments, _span) => { + ExprKind::MethodCall(ref segment, ref receiver, ref arguments, _span) => { visitor.visit_path_segment(segment); + visitor.visit_expr(receiver); walk_list!(visitor, visit_expr, arguments); } ExprKind::Binary(_, ref left_expression, ref right_expression) => { diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index 24672efc6..450cdf246 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -192,26 +192,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } InlineAsmOperand::Sym { ref sym } => { - if !self.tcx.features().asm_sym { - feature_err( - &sess.parse_sess, - sym::asm_sym, - *op_sp, - "sym operands for inline assembly are unstable", - ) - .emit(); - } - let static_def_id = self .resolver .get_partial_res(sym.id) - .filter(|res| res.unresolved_segments() == 0) - .and_then(|res| { - if let Res::Def(DefKind::Static(_), def_id) = res.base_res() { - Some(def_id) - } else { - None - } + .and_then(|res| res.full_res()) + .and_then(|res| match res { + Res::Def(DefKind::Static(_), def_id) => Some(def_id), + _ => None, }); if let Some(def_id) = static_def_id { @@ -237,7 +224,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { // Wrap the expression in an AnonConst. let parent_def_id = self.current_hir_id_owner; let node_id = self.next_node_id(); - self.create_def(parent_def_id, node_id, DefPathData::AnonConst); + self.create_def(parent_def_id.def_id, node_id, DefPathData::AnonConst); let anon_const = AnonConst { id: node_id, value: P(expr) }; hir::InlineAsmOperand::SymFn { anon_const: self.lower_anon_const(&anon_const), diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index c87d0ca96..157f46501 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -1,9 +1,9 @@ -use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay}; -use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; +use rustc_errors::DiagnosticArgFromDisplay; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{symbol::Ident, Span, Symbol}; -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::generic_type_with_parentheses, code = "E0214")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_generic_type_with_parentheses, code = "E0214")] pub struct GenericTypeWithParentheses { #[primary_span] #[label] @@ -12,35 +12,42 @@ pub struct GenericTypeWithParentheses { pub sub: Option, } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Subdiagnostic)] +#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")] pub struct UseAngleBrackets { + #[suggestion_part(code = "<")] pub open_param: Span, + #[suggestion_part(code = ">")] pub close_param: Span, } -impl AddSubdiagnostic for UseAngleBrackets { - fn add_to_diagnostic(self, diag: &mut Diagnostic) { - diag.multipart_suggestion( - fluent::ast_lowering::use_angle_brackets, - vec![(self.open_param, String::from("<")), (self.close_param, String::from(">"))], - Applicability::MaybeIncorrect, - ); - } -} - -#[derive(SessionDiagnostic)] -#[help] -#[diag(ast_lowering::invalid_abi, code = "E0703")] +#[derive(Diagnostic)] +#[diag(ast_lowering_invalid_abi, code = "E0703")] +#[note] pub struct InvalidAbi { #[primary_span] #[label] pub span: Span, pub abi: Symbol, - pub valid_abis: String, + pub command: String, + #[subdiagnostic] + pub suggestion: Option, +} + +#[derive(Subdiagnostic)] +#[suggestion( + ast_lowering_invalid_abi_suggestion, + code = "{suggestion}", + applicability = "maybe-incorrect" +)] +pub struct InvalidAbiSuggestion { + #[primary_span] + pub span: Span, + pub suggestion: String, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::assoc_ty_parentheses)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_assoc_ty_parentheses)] pub struct AssocTyParentheses { #[primary_span] pub span: Span, @@ -48,123 +55,116 @@ pub struct AssocTyParentheses { pub sub: AssocTyParenthesesSub, } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Subdiagnostic)] pub enum AssocTyParenthesesSub { - Empty { parentheses_span: Span }, - NotEmpty { open_param: Span, close_param: Span }, -} - -impl AddSubdiagnostic for AssocTyParenthesesSub { - fn add_to_diagnostic(self, diag: &mut Diagnostic) { - match self { - Self::Empty { parentheses_span } => diag.multipart_suggestion( - fluent::ast_lowering::remove_parentheses, - vec![(parentheses_span, String::new())], - Applicability::MaybeIncorrect, - ), - Self::NotEmpty { open_param, close_param } => diag.multipart_suggestion( - fluent::ast_lowering::use_angle_brackets, - vec![(open_param, String::from("<")), (close_param, String::from(">"))], - Applicability::MaybeIncorrect, - ), - }; - } -} - -#[derive(SessionDiagnostic)] -#[diag(ast_lowering::misplaced_impl_trait, code = "E0562")] + #[multipart_suggestion(ast_lowering_remove_parentheses)] + Empty { + #[suggestion_part(code = "")] + parentheses_span: Span, + }, + #[multipart_suggestion(ast_lowering_use_angle_brackets)] + NotEmpty { + #[suggestion_part(code = "<")] + open_param: Span, + #[suggestion_part(code = ">")] + close_param: Span, + }, +} + +#[derive(Diagnostic)] +#[diag(ast_lowering_misplaced_impl_trait, code = "E0562")] pub struct MisplacedImplTrait<'a> { #[primary_span] pub span: Span, pub position: DiagnosticArgFromDisplay<'a>, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::rustc_box_attribute_error)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_rustc_box_attribute_error)] pub struct RustcBoxAttributeError { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::underscore_expr_lhs_assign)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_underscore_expr_lhs_assign)] pub struct UnderscoreExprLhsAssign { #[primary_span] #[label] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::base_expression_double_dot)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_base_expression_double_dot)] pub struct BaseExpressionDoubleDot { #[primary_span] #[label] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::await_only_in_async_fn_and_blocks, code = "E0728")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = "E0728")] pub struct AwaitOnlyInAsyncFnAndBlocks { #[primary_span] #[label] pub dot_await_span: Span, - #[label(ast_lowering::this_not_async)] + #[label(ast_lowering_this_not_async)] pub item_span: Option, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::generator_too_many_parameters, code = "E0628")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_generator_too_many_parameters, code = "E0628")] pub struct GeneratorTooManyParameters { #[primary_span] pub fn_decl_span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::closure_cannot_be_static, code = "E0697")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_closure_cannot_be_static, code = "E0697")] pub struct ClosureCannotBeStatic { #[primary_span] pub fn_decl_span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] +#[derive(Diagnostic, Clone, Copy)] #[help] -#[diag(ast_lowering::async_non_move_closure_not_supported, code = "E0708")] +#[diag(ast_lowering_async_non_move_closure_not_supported, code = "E0708")] pub struct AsyncNonMoveClosureNotSupported { #[primary_span] pub fn_decl_span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::functional_record_update_destructuring_assignment)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_functional_record_update_destructuring_assignment)] pub struct FunctionalRecordUpdateDestructuringAssignemnt { #[primary_span] #[suggestion(code = "", applicability = "machine-applicable")] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::async_generators_not_supported, code = "E0727")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_async_generators_not_supported, code = "E0727")] pub struct AsyncGeneratorsNotSupported { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::inline_asm_unsupported_target, code = "E0472")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_inline_asm_unsupported_target, code = "E0472")] pub struct InlineAsmUnsupportedTarget { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::att_syntax_only_x86)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_att_syntax_only_x86)] pub struct AttSyntaxOnlyX86 { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::abi_specified_multiple_times)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_abi_specified_multiple_times)] pub struct AbiSpecifiedMultipleTimes { #[primary_span] pub abi_span: Span, @@ -175,24 +175,24 @@ pub struct AbiSpecifiedMultipleTimes { pub equivalent: Option<()>, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::clobber_abi_not_supported)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_clobber_abi_not_supported)] pub struct ClobberAbiNotSupported { #[primary_span] pub abi_span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[note] -#[diag(ast_lowering::invalid_abi_clobber_abi)] +#[diag(ast_lowering_invalid_abi_clobber_abi)] pub struct InvalidAbiClobberAbi { #[primary_span] pub abi_span: Span, pub supported_abis: String, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::invalid_register)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_invalid_register)] pub struct InvalidRegister<'a> { #[primary_span] pub op_span: Span, @@ -200,8 +200,8 @@ pub struct InvalidRegister<'a> { pub error: &'a str, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::invalid_register_class)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_invalid_register_class)] pub struct InvalidRegisterClass<'a> { #[primary_span] pub op_span: Span, @@ -209,61 +209,61 @@ pub struct InvalidRegisterClass<'a> { pub error: &'a str, } -#[derive(SessionDiagnostic)] -#[diag(ast_lowering::invalid_asm_template_modifier_reg_class)] +#[derive(Diagnostic)] +#[diag(ast_lowering_invalid_asm_template_modifier_reg_class)] pub struct InvalidAsmTemplateModifierRegClass { #[primary_span] - #[label(ast_lowering::template_modifier)] + #[label(ast_lowering_template_modifier)] pub placeholder_span: Span, - #[label(ast_lowering::argument)] + #[label(ast_lowering_argument)] pub op_span: Span, #[subdiagnostic] pub sub: InvalidAsmTemplateModifierRegClassSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum InvalidAsmTemplateModifierRegClassSub { - #[note(ast_lowering::support_modifiers)] + #[note(ast_lowering_support_modifiers)] SupportModifier { class_name: Symbol, modifiers: String }, - #[note(ast_lowering::does_not_support_modifiers)] + #[note(ast_lowering_does_not_support_modifiers)] DoesNotSupportModifier { class_name: Symbol }, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::invalid_asm_template_modifier_const)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_invalid_asm_template_modifier_const)] pub struct InvalidAsmTemplateModifierConst { #[primary_span] - #[label(ast_lowering::template_modifier)] + #[label(ast_lowering_template_modifier)] pub placeholder_span: Span, - #[label(ast_lowering::argument)] + #[label(ast_lowering_argument)] pub op_span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::invalid_asm_template_modifier_sym)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_invalid_asm_template_modifier_sym)] pub struct InvalidAsmTemplateModifierSym { #[primary_span] - #[label(ast_lowering::template_modifier)] + #[label(ast_lowering_template_modifier)] pub placeholder_span: Span, - #[label(ast_lowering::argument)] + #[label(ast_lowering_argument)] pub op_span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::register_class_only_clobber)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_register_class_only_clobber)] pub struct RegisterClassOnlyClobber { #[primary_span] pub op_span: Span, pub reg_class_name: Symbol, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::register_conflict)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_register_conflict)] pub struct RegisterConflict<'a> { #[primary_span] - #[label(ast_lowering::register1)] + #[label(ast_lowering_register1)] pub op_span1: Span, - #[label(ast_lowering::register2)] + #[label(ast_lowering_register2)] pub op_span2: Span, pub reg1_name: &'a str, pub reg2_name: &'a str, @@ -271,14 +271,14 @@ pub struct RegisterConflict<'a> { pub in_out: Option, } -#[derive(SessionDiagnostic, Clone, Copy)] +#[derive(Diagnostic, Clone, Copy)] #[help] -#[diag(ast_lowering::sub_tuple_binding)] +#[diag(ast_lowering_sub_tuple_binding)] pub struct SubTupleBinding<'a> { #[primary_span] #[label] #[suggestion_verbose( - ast_lowering::sub_tuple_binding_suggestion, + ast_lowering_sub_tuple_binding_suggestion, code = "..", applicability = "maybe-incorrect" )] @@ -288,57 +288,57 @@ pub struct SubTupleBinding<'a> { pub ctx: &'a str, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::extra_double_dot)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_extra_double_dot)] pub struct ExtraDoubleDot<'a> { #[primary_span] #[label] pub span: Span, - #[label(ast_lowering::previously_used_here)] + #[label(ast_lowering_previously_used_here)] pub prev_span: Span, pub ctx: &'a str, } -#[derive(SessionDiagnostic, Clone, Copy)] +#[derive(Diagnostic, Clone, Copy)] #[note] -#[diag(ast_lowering::misplaced_double_dot)] +#[diag(ast_lowering_misplaced_double_dot)] pub struct MisplacedDoubleDot { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::misplaced_relax_trait_bound)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_misplaced_relax_trait_bound)] pub struct MisplacedRelaxTraitBound { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::not_supported_for_lifetime_binder_async_closure)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_not_supported_for_lifetime_binder_async_closure)] pub struct NotSupportedForLifetimeBinderAsyncClosure { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::arbitrary_expression_in_pattern)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_arbitrary_expression_in_pattern)] pub struct ArbitraryExpressionInPattern { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::inclusive_range_with_no_end)] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_inclusive_range_with_no_end)] pub struct InclusiveRangeWithNoEnd { #[primary_span] pub span: Span, } -#[derive(SessionDiagnostic, Clone, Copy)] -#[diag(ast_lowering::trait_fn_async, code = "E0706")] +#[derive(Diagnostic, Clone, Copy)] +#[diag(ast_lowering_trait_fn_async, code = "E0706")] #[note] -#[note(ast_lowering::note2)] +#[note(note2)] pub struct TraitFnAsync { #[primary_span] pub fn_span: Span, diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 7b8070d3c..ec9c39350 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -60,7 +60,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ExprKind::Call(f, self.lower_exprs(args)) } } - ExprKind::MethodCall(ref seg, ref args, span) => { + ExprKind::MethodCall(ref seg, ref receiver, ref args, span) => { let hir_seg = self.arena.alloc(self.lower_path_segment( e.span, seg, @@ -68,9 +68,9 @@ impl<'hir> LoweringContext<'_, 'hir> { ParenthesizedGenericArgs::Err, &ImplTraitContext::Disallowed(ImplTraitPosition::Path), )); - let receiver = self.lower_expr(&args[0]); + let receiver = self.lower_expr(receiver); let args = - self.arena.alloc_from_iter(args[1..].iter().map(|x| self.lower_expr_mut(x))); + self.arena.alloc_from_iter(args.iter().map(|x| self.lower_expr_mut(x))); hir::ExprKind::MethodCall(hir_seg, receiver, args, self.lower_span(span)) } ExprKind::Binary(binop, ref lhs, ref rhs) => { @@ -359,7 +359,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let node_id = self.next_node_id(); // Add a definition for the in-band const def. - self.create_def(parent_def_id, node_id, DefPathData::AnonConst); + self.create_def(parent_def_id.def_id, node_id, DefPathData::AnonConst); let anon_const = AnonConst { id: node_id, value: arg }; generic_args.push(AngleBracketedArg::Arg(GenericArg::Const(anon_const))); @@ -387,32 +387,58 @@ impl<'hir> LoweringContext<'_, 'hir> { then: &Block, else_opt: Option<&Expr>, ) -> hir::ExprKind<'hir> { - let lowered_cond = self.lower_expr(cond); - let new_cond = self.manage_let_cond(lowered_cond); + let lowered_cond = self.lower_cond(cond); let then_expr = self.lower_block_expr(then); if let Some(rslt) = else_opt { - hir::ExprKind::If(new_cond, self.arena.alloc(then_expr), Some(self.lower_expr(rslt))) + hir::ExprKind::If( + lowered_cond, + self.arena.alloc(then_expr), + Some(self.lower_expr(rslt)), + ) } else { - hir::ExprKind::If(new_cond, self.arena.alloc(then_expr), None) + hir::ExprKind::If(lowered_cond, self.arena.alloc(then_expr), None) } } - // If `cond` kind is `let`, returns `let`. Otherwise, wraps and returns `cond` - // in a temporary block. - fn manage_let_cond(&mut self, cond: &'hir hir::Expr<'hir>) -> &'hir hir::Expr<'hir> { - fn has_let_expr<'hir>(expr: &'hir hir::Expr<'hir>) -> bool { - match expr.kind { - hir::ExprKind::Binary(_, lhs, rhs) => has_let_expr(lhs) || has_let_expr(rhs), - hir::ExprKind::Let(..) => true, + // Lowers a condition (i.e. `cond` in `if cond` or `while cond`), wrapping it in a terminating scope + // so that temporaries created in the condition don't live beyond it. + fn lower_cond(&mut self, cond: &Expr) -> &'hir hir::Expr<'hir> { + fn has_let_expr(expr: &Expr) -> bool { + match &expr.kind { + ExprKind::Binary(_, lhs, rhs) => has_let_expr(lhs) || has_let_expr(rhs), + ExprKind::Let(..) => true, _ => false, } } - if has_let_expr(cond) { - cond - } else { - let reason = DesugaringKind::CondTemporary; - let span_block = self.mark_span_with_reason(reason, cond.span, None); - self.expr_drop_temps(span_block, cond, AttrVec::new()) + + // We have to take special care for `let` exprs in the condition, e.g. in + // `if let pat = val` or `if foo && let pat = val`, as we _do_ want `val` to live beyond the + // condition in this case. + // + // In order to mantain the drop behavior for the non `let` parts of the condition, + // we still wrap them in terminating scopes, e.g. `if foo && let pat = val` essentially + // gets transformed into `if { let _t = foo; _t } && let pat = val` + match &cond.kind { + ExprKind::Binary(op @ Spanned { node: ast::BinOpKind::And, .. }, lhs, rhs) + if has_let_expr(cond) => + { + let op = self.lower_binop(*op); + let lhs = self.lower_cond(lhs); + let rhs = self.lower_cond(rhs); + + self.arena.alloc(self.expr( + cond.span, + hir::ExprKind::Binary(op, lhs, rhs), + AttrVec::new(), + )) + } + ExprKind::Let(..) => self.lower_expr(cond), + _ => { + let cond = self.lower_expr(cond); + let reason = DesugaringKind::CondTemporary; + let span_block = self.mark_span_with_reason(reason, cond.span, None); + self.expr_drop_temps(span_block, cond, AttrVec::new()) + } } } @@ -439,14 +465,13 @@ impl<'hir> LoweringContext<'_, 'hir> { body: &Block, opt_label: Option