From 023939b627b7dc93b01471f7d41fb8553ddb4ffa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:24 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/assembly/is_aligned.rs | 1 - tests/assembly/slice-is_ascii.rs | 1 - .../stack-protector-heuristics-effect.rs | 1 + .../stack-protector-target-support.rs | 26 +- tests/assembly/strict_provenance.rs | 1 - tests/assembly/wasm_exceptions.rs | 60 ++ tests/codegen/aarch64-struct-align-128.rs | 150 +++ tests/codegen/abi-main-signature-16bit-c-int.rs | 20 +- tests/codegen/abi-main-signature-32bit-c-int.rs | 3 +- tests/codegen/addr-of-mutate.rs | 7 +- tests/codegen/adjustments.rs | 6 +- tests/codegen/align-byval-vector.rs | 58 ++ tests/codegen/align-byval.rs | 342 +++++++ tests/codegen/align-enum.rs | 2 +- tests/codegen/align-offset.rs | 1 - tests/codegen/align-struct.rs | 4 +- tests/codegen/array-codegen.rs | 7 +- tests/codegen/array-equality.rs | 8 +- tests/codegen/array-map.rs | 1 - tests/codegen/atomic-operations.rs | 60 +- tests/codegen/avr/avr-func-addrspace.rs | 6 +- tests/codegen/box-maybe-uninit-llvm14.rs | 34 - tests/codegen/box-maybe-uninit.rs | 1 - tests/codegen/c-variadic-copy.rs | 16 - tests/codegen/c-variadic-opt.rs | 30 - tests/codegen/c-variadic.rs | 72 -- tests/codegen/cffi/c-variadic-copy.rs | 16 + tests/codegen/cffi/c-variadic-opt.rs | 30 + tests/codegen/cffi/c-variadic.rs | 72 ++ tests/codegen/cffi/ffi-const.rs | 13 + tests/codegen/cffi/ffi-out-of-bounds-loads.rs | 25 + tests/codegen/cffi/ffi-pure.rs | 13 + tests/codegen/cffi/ffi-returns-twice.rs | 11 + tests/codegen/comparison-operators-2-tuple.rs | 1 - tests/codegen/comparison-operators-newtype.rs | 1 - tests/codegen/consts.rs | 4 +- tests/codegen/drop-in-place-noalias.rs | 4 +- tests/codegen/enum-bounds-check-derived-idx.rs | 24 - tests/codegen/enum-bounds-check-issue-13926.rs | 18 - tests/codegen/enum-bounds-check-issue-82871.rs | 18 - tests/codegen/enum-bounds-check.rs | 26 - tests/codegen/enum-debug-clike.rs | 23 - tests/codegen/enum-debug-niche-2.rs | 50 - tests/codegen/enum-debug-niche.rs | 29 - tests/codegen/enum-debug-tagged.rs | 27 - tests/codegen/enum-discriminant-value.rs | 27 - tests/codegen/enum-match.rs | 112 --- tests/codegen/enum-u128.rs | 27 - .../codegen/enum/enum-bounds-check-derived-idx.rs | 24 + .../codegen/enum/enum-bounds-check-issue-13926.rs | 18 + .../codegen/enum/enum-bounds-check-issue-82871.rs | 18 + tests/codegen/enum/enum-bounds-check.rs | 26 + tests/codegen/enum/enum-debug-clike.rs | 23 + tests/codegen/enum/enum-debug-niche-2.rs | 50 + tests/codegen/enum/enum-debug-niche.rs | 29 + tests/codegen/enum/enum-debug-tagged.rs | 27 + tests/codegen/enum/enum-discriminant-value.rs | 27 + tests/codegen/enum/enum-match.rs | 112 +++ tests/codegen/enum/enum-u128.rs | 27 + tests/codegen/fastcall-inreg.rs | 2 +- tests/codegen/fewer-names.rs | 4 +- tests/codegen/ffi-const.rs | 13 - tests/codegen/ffi-out-of-bounds-loads.rs | 25 - tests/codegen/ffi-pure.rs | 13 - tests/codegen/ffi-returns-twice.rs | 11 - tests/codegen/function-arguments-noopt.rs | 10 +- tests/codegen/function-arguments.rs | 64 +- tests/codegen/global_asm.rs | 24 +- tests/codegen/global_asm_include.rs | 24 +- tests/codegen/global_asm_x2.rs | 24 +- tests/codegen/i686-macosx-deployment-target.rs | 27 - tests/codegen/i686-no-macosx-deployment-target.rs | 27 - tests/codegen/intrinsics/compare_bytes.rs | 34 + tests/codegen/intrinsics/mask.rs | 2 +- tests/codegen/intrinsics/nontemporal.rs | 2 +- tests/codegen/intrinsics/offset.rs | 1 - tests/codegen/intrinsics/transmute-niched.rs | 17 +- tests/codegen/intrinsics/transmute-x64.rs | 13 +- tests/codegen/intrinsics/transmute.rs | 91 +- .../codegen/issues/issue-105386-ub-in-debuginfo.rs | 5 +- tests/codegen/issues/issue-114312.rs | 2 +- tests/codegen/issues/issue-37945.rs | 8 +- tests/codegen/issues/issue-56267-2.rs | 2 +- tests/codegen/issues/issue-56267.rs | 2 +- tests/codegen/issues/issue-56927.rs | 14 +- tests/codegen/issues/issue-58881.rs | 2 +- .../codegen/issues/issue-85872-multiple-reverse.rs | 1 - tests/codegen/issues/issue-86106.rs | 1 - tests/codegen/issues/issue-96274.rs | 1 - .../issues/issue-96497-slice-size-nowrap.rs | 1 - .../issue-98294-get-mut-copy-from-slice-opt.rs | 1 - tests/codegen/iter-repeat-n-trivial-drop.rs | 3 +- tests/codegen/lifetime_start_end.rs | 8 +- tests/codegen/llvm-ident.rs | 15 + tests/codegen/loads.rs | 34 +- .../codegen/macos/i686-macosx-deployment-target.rs | 27 + .../macos/i686-no-macosx-deployment-target.rs | 27 + .../macos/x86_64-macosx-deployment-target.rs | 27 + .../macos/x86_64-no-macosx-deployment-target.rs | 27 + tests/codegen/match-optimized.rs | 6 +- tests/codegen/mem-replace-big-type.rs | 4 +- tests/codegen/mem-replace-simple-type.rs | 5 +- tests/codegen/method-declaration.rs | 26 + tests/codegen/move-operands.rs | 7 +- tests/codegen/naked-fn/naked-functions.rs | 32 + tests/codegen/naked-fn/naked-nocoverage.rs | 19 + tests/codegen/naked-fn/naked-noinline.rs | 31 + tests/codegen/naked-functions.rs | 32 - tests/codegen/naked-nocoverage.rs | 19 - tests/codegen/naked-noinline.rs | 31 - tests/codegen/no_builtins-at-crate.rs | 24 + tests/codegen/option-nonzero-eq.rs | 2 +- tests/codegen/packed.rs | 40 +- tests/codegen/personality_lifetimes.rs | 2 +- tests/codegen/ptr-arithmetic.rs | 34 + tests/codegen/refs.rs | 6 +- tests/codegen/repeat-trusted-len.rs | 4 +- tests/codegen/repr-transparent-aggregates-1.rs | 88 -- tests/codegen/repr-transparent-aggregates-2.rs | 90 -- tests/codegen/repr-transparent-aggregates-3.rs | 79 -- tests/codegen/repr-transparent-sysv64.rs | 28 - tests/codegen/repr-transparent.rs | 171 ---- tests/codegen/repr/transparent-imm-array.rs | 86 ++ tests/codegen/repr/transparent-mips64.rs | 79 ++ tests/codegen/repr/transparent-struct-ptr.rs | 87 ++ tests/codegen/repr/transparent-sysv64.rs | 28 + tests/codegen/repr/transparent.rs | 174 ++++ .../riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs | 10 +- ...sanitizer-cfi-add-canonical-jump-tables-flag.rs | 11 - ...sanitizer-cfi-add-enable-split-lto-unit-flag.rs | 11 - ...itizer-cfi-emit-type-checks-attr-no-sanitize.rs | 18 - tests/codegen/sanitizer-cfi-emit-type-checks.rs | 19 - ...zer-cfi-emit-type-metadata-attr-cfi-encoding.rs | 48 - ...er-cfi-emit-type-metadata-id-itanium-cxx-abi.rs | 604 ------------ ...it-type-metadata-itanium-cxx-abi-generalized.rs | 31 - ...adata-itanium-cxx-abi-normalized-generalized.rs | 31 - ...mit-type-metadata-itanium-cxx-abi-normalized.rs | 31 - ...tizer-cfi-emit-type-metadata-itanium-cxx-abi.rs | 31 - ...nitizer-cfi-emit-type-metadata-trait-objects.rs | 120 --- tests/codegen/sanitizer-cfi-generalize-pointers.rs | 46 - tests/codegen/sanitizer-cfi-normalize-integers.rs | 83 -- .../sanitizer-kasan-emits-instrumentation.rs | 47 - tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs | 11 - ...fi-emit-kcfi-operand-bundle-attr-no-sanitize.rs | 30 - ...i-operand-bundle-itanium-cxx-abi-generalized.rs | 44 - ...undle-itanium-cxx-abi-normalized-generalized.rs | 44 - ...fi-operand-bundle-itanium-cxx-abi-normalized.rs | 44 - ...cfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs | 44 - .../sanitizer-kcfi-emit-kcfi-operand-bundle.rs | 27 - ...itizer-kcfi-emit-type-metadata-trait-objects.rs | 144 --- tests/codegen/sanitizer-memory-track-orgins.rs | 30 - tests/codegen/sanitizer-no-sanitize-inlining.rs | 30 - tests/codegen/sanitizer-no-sanitize.rs | 29 - tests/codegen/sanitizer-recover.rs | 49 - tests/codegen/sanitizer-safestack-attr-check.rs | 11 - .../cfi-add-canonical-jump-tables-flag.rs | 11 + .../cfi-add-enable-split-lto-unit-flag.rs | 11 + .../cfi-emit-type-checks-attr-no-sanitize.rs | 18 + tests/codegen/sanitizer/cfi-emit-type-checks.rs | 19 + .../cfi-emit-type-metadata-attr-cfi-encoding.rs | 48 + .../cfi-emit-type-metadata-id-itanium-cxx-abi.rs | 604 ++++++++++++ ...it-type-metadata-itanium-cxx-abi-generalized.rs | 31 + ...adata-itanium-cxx-abi-normalized-generalized.rs | 31 + ...mit-type-metadata-itanium-cxx-abi-normalized.rs | 31 + .../cfi-emit-type-metadata-itanium-cxx-abi.rs | 31 + .../cfi-emit-type-metadata-trait-objects.rs | 149 +++ tests/codegen/sanitizer/cfi-generalize-pointers.rs | 46 + tests/codegen/sanitizer/cfi-normalize-integers.rs | 83 ++ .../sanitizer/kasan-emits-instrumentation.rs | 47 + tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs | 11 + ...fi-emit-kcfi-operand-bundle-attr-no-sanitize.rs | 30 + ...i-operand-bundle-itanium-cxx-abi-generalized.rs | 44 + ...undle-itanium-cxx-abi-normalized-generalized.rs | 44 + ...fi-operand-bundle-itanium-cxx-abi-normalized.rs | 44 + ...cfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs | 44 + .../sanitizer/kcfi-emit-kcfi-operand-bundle.rs | 27 + .../kcfi-emit-type-metadata-trait-objects.rs | 174 ++++ tests/codegen/sanitizer/memory-track-origins.rs | 30 + tests/codegen/sanitizer/memtag-attr-check.rs | 12 + tests/codegen/sanitizer/no-sanitize-inlining.rs | 30 + tests/codegen/sanitizer/no-sanitize.rs | 29 + tests/codegen/sanitizer/safestack-attr-check.rs | 11 + tests/codegen/sanitizer/sanitizer-recover.rs | 49 + tests/codegen/sanitizer/scs-attr-check.rs | 17 + tests/codegen/sanitizer_memtag_attr_check.rs | 12 - tests/codegen/sanitizer_scs_attr_check.rs | 17 - ...simd-intrinsic-generic-arithmetic-saturating.rs | 166 ++-- .../simd-intrinsic-generic-extract-insert.rs | 4 +- .../simd-intrinsic-generic-gather.rs | 4 +- .../simd-intrinsic-generic-scatter.rs | 4 +- .../simd-intrinsic-transmute-array.rs | 13 +- tests/codegen/simd-wide-sum.rs | 55 -- tests/codegen/simd/simd-wide-sum.rs | 59 ++ tests/codegen/simd/simd_arith_offset.rs | 26 + tests/codegen/simd/swap-simd-types.rs | 41 + tests/codegen/simd/unpadded-simd.rs | 14 + tests/codegen/simd_arith_offset.rs | 26 - tests/codegen/slice-init.rs | 22 +- tests/codegen/slice-iter-len-eq-zero.rs | 8 +- tests/codegen/slice-iter-nonnull.rs | 39 + tests/codegen/slice-ref-equality.rs | 12 +- tests/codegen/slice_as_from_ptr_range.rs | 1 - tests/codegen/sroa-fragment-debuginfo.rs | 46 + tests/codegen/stores.rs | 8 +- tests/codegen/swap-large-types.rs | 6 +- tests/codegen/swap-simd-types.rs | 41 - tests/codegen/target-feature-inline-closure.rs | 33 + tests/codegen/trailing_zeros.rs | 22 + tests/codegen/transmute-optimized.rs | 1 - tests/codegen/transmute-scalar.rs | 21 +- tests/codegen/try_question_mark_nop.rs | 1 - tests/codegen/unchecked_shifts.rs | 1 - tests/codegen/uninit-consts.rs | 10 +- tests/codegen/union-abi.rs | 12 +- tests/codegen/unpadded-simd.rs | 14 - tests/codegen/unwind-abis/thiscall-unwind-abi.rs | 2 +- tests/codegen/var-names.rs | 4 +- tests/codegen/vec-as-ptr.rs | 4 +- tests/codegen/vec-calloc-llvm14.rs | 144 --- tests/codegen/vec-calloc.rs | 1 - tests/codegen/wasm_exceptions.rs | 51 + tests/codegen/x86_64-macosx-deployment-target.rs | 27 - .../codegen/x86_64-no-macosx-deployment-target.rs | 27 - tests/debuginfo/rc_arc.rs | 24 +- tests/debuginfo/thread-names.rs | 13 +- tests/debuginfo/thread.rs | 2 +- tests/incremental/hashes/call_expressions.rs | 2 +- tests/incremental/hashes/match_expressions.rs | 2 +- tests/incremental/hashes/trait_defs.rs | 4 +- tests/incremental/issue-61530.rs | 6 +- .../basic_assignment.main.ElaborateDrops.diff | 10 +- ...sync_await.a-{closure#0}.generator_resume.0.mir | 2 +- ...sync_await.b-{closure#0}.generator_resume.0.mir | 2 +- tests/mir-opt/building/custom/terminators.rs | 4 +- tests/mir-opt/casts.redundant.InstSimplify.diff | 2 +- ...const_allocation.main.ConstProp.after.32bit.mir | 16 +- ...const_allocation.main.ConstProp.after.64bit.mir | 16 +- .../aggregate.main.ConstProp.panic-abort.diff | 3 +- .../aggregate.main.ConstProp.panic-unwind.diff | 3 +- ...aggregate.main.PreCodegen.after.panic-abort.mir | 2 +- ...ggregate.main.PreCodegen.after.panic-unwind.mir | 2 +- ...ray_index.main.ConstProp.32bit.panic-abort.diff | 2 +- ...ay_index.main.ConstProp.32bit.panic-unwind.diff | 2 +- ...ray_index.main.ConstProp.64bit.panic-abort.diff | 2 +- ...ay_index.main.ConstProp.64bit.panic-unwind.diff | 2 +- ..._op_div_by_zero.main.ConstProp.panic-abort.diff | 5 +- ...op_div_by_zero.main.ConstProp.panic-unwind.diff | 5 +- ..._op_mod_by_zero.main.ConstProp.panic-abort.diff | 5 +- ...op_mod_by_zero.main.ConstProp.panic-unwind.diff | 5 +- ...or_slices.main.ConstProp.32bit.panic-abort.diff | 2 +- ...r_slices.main.ConstProp.32bit.panic-unwind.diff | 2 +- ...or_slices.main.ConstProp.64bit.panic-abort.diff | 2 +- ...r_slices.main.ConstProp.64bit.panic-unwind.diff | 2 +- .../boxes.main.ConstProp.panic-abort.diff | 3 +- .../boxes.main.ConstProp.panic-unwind.diff | 3 +- ...simplification.hello.ConstProp.panic-abort.diff | 3 +- ...implification.hello.ConstProp.panic-unwind.diff | 3 +- .../indirect.main.ConstProp.panic-abort.diff | 2 +- .../indirect.main.ConstProp.panic-unwind.diff | 2 +- ...nherit_overflow.main.ConstProp.panic-abort.diff | 2 +- ...herit_overflow.main.ConstProp.panic-unwind.diff | 2 +- .../invalid_constant.main.ConstProp.diff | 3 +- .../issue_66971.main.ConstProp.panic-abort.diff | 6 +- .../issue_66971.main.ConstProp.panic-unwind.diff | 6 +- .../issue_67019.main.ConstProp.panic-abort.diff | 6 +- .../issue_67019.main.ConstProp.panic-unwind.diff | 6 +- ...ray_index.main.ConstProp.32bit.panic-abort.diff | 2 +- ...ay_index.main.ConstProp.32bit.panic-unwind.diff | 2 +- ...ray_index.main.ConstProp.64bit.panic-abort.diff | 2 +- ...ay_index.main.ConstProp.64bit.panic-unwind.diff | 2 +- .../offset_of.concrete.ConstProp.panic-abort.diff | 12 +- .../offset_of.concrete.ConstProp.panic-unwind.diff | 12 +- .../repeat.main.ConstProp.32bit.panic-abort.diff | 2 +- .../repeat.main.ConstProp.32bit.panic-unwind.diff | 2 +- .../repeat.main.ConstProp.64bit.panic-abort.diff | 2 +- .../repeat.main.ConstProp.64bit.panic-unwind.diff | 2 +- ...ral_propagation.main.ConstProp.panic-abort.diff | 3 +- ...al_propagation.main.ConstProp.panic-unwind.diff | 3 +- ...slice_len.main.ConstProp.32bit.panic-abort.diff | 2 +- ...lice_len.main.ConstProp.32bit.panic-unwind.diff | 2 +- ...slice_len.main.ConstProp.64bit.panic-abort.diff | 2 +- ...lice_len.main.ConstProp.64bit.panic-unwind.diff | 2 +- ...ral_propagation.main.ConstProp.panic-abort.diff | 3 +- ...al_propagation.main.ConstProp.panic-unwind.diff | 3 +- tests/mir-opt/copy-prop/borrowed_local.rs | 4 +- tests/mir-opt/copy-prop/custom_move_arg.rs | 4 +- tests/mir-opt/copy-prop/move_projection.rs | 4 +- tests/mir-opt/copy-prop/mutate_through_pointer.rs | 2 + .../coverage_graphviz.bar.InstrumentCoverage.0.dot | 2 +- ...coverage_graphviz.main.InstrumentCoverage.0.dot | 4 +- ...ve_simple.DeadStoreElimination.panic-abort.diff | 23 + ...e_simple.DeadStoreElimination.panic-unwind.diff | 23 + .../dead-store-elimination/call_arg_copy.rs | 15 + .../mir-opt/inline/cycle.g.Inline.panic-abort.diff | 8 +- .../inline/cycle.g.Inline.panic-unwind.diff | 20 +- .../inline/cycle.main.Inline.panic-abort.diff | 18 +- .../inline/cycle.main.Inline.panic-unwind.diff | 30 +- ..._generic_rust_call.call.Inline.panic-abort.diff | 29 + ...generic_rust_call.call.Inline.panic-unwind.diff | 37 + .../inline/dont_ice_on_generic_rust_call.rs | 11 + .../dyn_trait.get_query.Inline.panic-abort.diff | 2 +- .../dyn_trait.get_query.Inline.panic-unwind.diff | 2 +- ...trait.try_execute_query.Inline.panic-abort.diff | 2 +- ...rait.try_execute_query.Inline.panic-unwind.diff | 2 +- .../inline_box_fn.call.Inline.panic-abort.diff | 32 + .../inline_box_fn.call.Inline.panic-unwind.diff | 40 + tests/mir-opt/inline/inline_box_fn.rs | 8 + .../inline_cycle.two.Inline.panic-abort.diff | 18 +- .../inline_cycle.two.Inline.panic-unwind.diff | 18 +- .../inline_diverging.h.Inline.panic-abort.diff | 24 +- .../inline_diverging.h.Inline.panic-unwind.diff | 40 +- ...ine_into_box_place.main.Inline.panic-abort.diff | 74 +- ...ne_into_box_place.main.Inline.panic-unwind.diff | 74 +- ...ait_method_2.test2.Inline.after.panic-abort.mir | 2 +- ...it_method_2.test2.Inline.after.panic-unwind.mir | 2 +- .../inline/issue_78442.bar.Inline.panic-abort.diff | 20 +- .../issue_78442.bar.Inline.panic-unwind.diff | 41 +- ...ed_shl_unsigned_smaller.Inline.panic-abort.diff | 6 +- ...d_shl_unsigned_smaller.Inline.panic-unwind.diff | 6 +- ...signed_smaller.PreCodegen.after.panic-abort.mir | 16 +- ...igned_smaller.PreCodegen.after.panic-unwind.mir | 16 +- ...cked_shr_signed_smaller.Inline.panic-abort.diff | 6 +- ...ked_shr_signed_smaller.Inline.panic-unwind.diff | 6 +- ...signed_smaller.PreCodegen.after.panic-abort.mir | 16 +- ...igned_smaller.PreCodegen.after.panic-unwind.mir | 16 +- ...instrument_coverage.bar.InstrumentCoverage.diff | 2 +- ...nstrument_coverage.main.InstrumentCoverage.diff | 10 +- .../issue_101973.inner.ConstProp.panic-abort.diff | 2 +- .../issue_101973.inner.ConstProp.panic-unwind.diff | 2 +- ...ssue_41110.test.ElaborateDrops.panic-abort.diff | 13 +- ...sue_41110.test.ElaborateDrops.panic-unwind.diff | 13 +- ...ssue_41888.main.ElaborateDrops.panic-abort.diff | 38 +- ...sue_41888.main.ElaborateDrops.panic-unwind.diff | 38 +- ...est.SimplifyComparisonIntegral.panic-abort.diff | 54 +- ...st.SimplifyComparisonIntegral.panic-unwind.diff | 54 +- tests/mir-opt/issue_99325.main.built.after.mir | 4 +- ...2.num_to_digit.PreCodegen.after.panic-abort.mir | 37 +- ....num_to_digit.PreCodegen.after.panic-unwind.mir | 37 +- .../checked_ops.checked_shl.PreCodegen.after.mir | 48 +- .../checked_ops.step_forward.PreCodegen.after.mir | 43 +- .../intrinsics.f_u64.PreCodegen.after.mir | 8 +- .../loops.filter_mapped.PreCodegen.after.mir | 43 +- .../loops.int_range.PreCodegen.after.mir | 93 +- .../pre-codegen/loops.mapped.PreCodegen.after.mir | 4 +- .../loops.vec_move.PreCodegen.after.mir | 4 +- .../mem_replace.mem_replace.PreCodegen.after.mir | 32 +- ...r.forward_loop.PreCodegen.after.panic-abort.mir | 109 ++- ....forward_loop.PreCodegen.after.panic-unwind.mir | 109 ++- ...inclusive_loop.PreCodegen.after.panic-abort.mir | 4 +- ...nclusive_loop.PreCodegen.after.panic-unwind.mir | 4 +- ...sive_iter_next.PreCodegen.after.panic-abort.mir | 2 +- ...ive_iter_next.PreCodegen.after.panic-unwind.mir | 2 +- ...ange_iter_next.PreCodegen.after.panic-abort.mir | 56 +- ...nge_iter_next.PreCodegen.after.panic-unwind.mir | 56 +- .../simple_option_map.ezmap.PreCodegen.after.mir | 18 +- ...lter.variant_a-{closure#0}.PreCodegen.after.mir | 252 +++-- ..._get_mut_usize.PreCodegen.after.panic-abort.mir | 68 +- ...get_mut_usize.PreCodegen.after.panic-unwind.mir | 68 +- ...cked_mut_range.PreCodegen.after.panic-abort.mir | 87 +- ...ked_mut_range.PreCodegen.after.panic-unwind.mir | 87 +- ...ce_index_range.PreCodegen.after.panic-abort.mir | 2 +- ...e_index_range.PreCodegen.after.panic-unwind.mir | 2 +- ...numerated_loop.PreCodegen.after.panic-abort.mir | 23 +- ...umerated_loop.PreCodegen.after.panic-unwind.mir | 23 +- ...r.forward_loop.PreCodegen.after.panic-abort.mir | 23 +- ....forward_loop.PreCodegen.after.panic-unwind.mir | 23 +- ...ter.range_loop.PreCodegen.after.panic-abort.mir | 125 ++- ...er.range_loop.PreCodegen.after.panic-unwind.mir | 125 ++- ...r.reverse_loop.PreCodegen.after.panic-abort.mir | 68 +- ....reverse_loop.PreCodegen.after.panic-unwind.mir | 68 +- ..._mut_next_back.PreCodegen.after.panic-abort.mir | 2 +- ...mut_next_back.PreCodegen.after.panic-unwind.mir | 2 +- ...lice_iter_next.PreCodegen.after.panic-abort.mir | 2 +- ...ice_iter_next.PreCodegen.after.panic-unwind.mir | 2 +- .../spans.outer.PreCodegen.after.panic-abort.mir | 6 +- .../spans.outer.PreCodegen.after.panic-unwind.mir | 6 +- ...erence_prop.debuginfo.ReferencePropagation.diff | 59 +- ....mut_raw_then_mut_shr.ReferencePropagation.diff | 9 +- ...reference_propagation.ReferencePropagation.diff | 51 +- ...propagation_const_ptr.ReferencePropagation.diff | 68 +- ...rence_propagation_mut.ReferencePropagation.diff | 51 +- ...e_propagation_mut_ptr.ReferencePropagation.diff | 51 +- tests/mir-opt/reference_prop.rs | 10 +- tests/run-coverage-rustdoc/doctest.coverage | 216 ++--- tests/run-coverage/abort.coverage | 132 +-- tests/run-coverage/assert.coverage | 64 +- tests/run-coverage/async.coverage | 256 ++--- tests/run-coverage/async2.coverage | 210 ++-- tests/run-coverage/closure.coverage | 430 ++++----- tests/run-coverage/closure_macro.coverage | 80 +- tests/run-coverage/closure_macro_async.coverage | 162 ++-- tests/run-coverage/conditions.coverage | 174 ++-- tests/run-coverage/continue.coverage | 138 +-- tests/run-coverage/dead_code.coverage | 74 +- tests/run-coverage/drop_trait.coverage | 66 +- tests/run-coverage/generator.coverage | 60 +- tests/run-coverage/generics.coverage | 120 +-- tests/run-coverage/if.coverage | 56 +- tests/run-coverage/if_else.coverage | 80 +- tests/run-coverage/inline-dead.coverage | 54 +- tests/run-coverage/inline.coverage | 102 +- tests/run-coverage/inner_items.coverage | 114 +-- tests/run-coverage/issue-83601.coverage | 28 +- tests/run-coverage/issue-84561.coverage | 364 +++---- tests/run-coverage/issue-85461.coverage | 64 +- tests/run-coverage/issue-93054.coverage | 56 +- tests/run-coverage/lazy_boolean.coverage | 122 +-- tests/run-coverage/loop_break_value.coverage | 26 +- tests/run-coverage/loops_branches.coverage | 122 +-- tests/run-coverage/match_or_pattern.coverage | 90 +- tests/run-coverage/nested_loops.coverage | 50 +- tests/run-coverage/no_cov_crate.coverage | 172 ++-- tests/run-coverage/overflow.coverage | 126 +-- tests/run-coverage/panic_unwind.coverage | 62 +- tests/run-coverage/partial_eq.coverage | 92 +- tests/run-coverage/partial_eq.rs | 2 +- tests/run-coverage/simple_loop.coverage | 70 +- tests/run-coverage/simple_match.coverage | 86 +- tests/run-coverage/sort_groups.coverage | 76 +- tests/run-coverage/test_harness.coverage | 20 +- tests/run-coverage/tight_inf_loop.coverage | 10 +- tests/run-coverage/try_error_result.coverage | 236 ++--- tests/run-coverage/unused.coverage | 106 +-- tests/run-coverage/unused_mod.coverage | 18 +- tests/run-coverage/uses_crate.coverage | 286 +++--- tests/run-coverage/uses_crate.rs | 4 +- tests/run-coverage/uses_inline_crate.coverage | 272 +++--- tests/run-coverage/uses_inline_crate.rs | 4 +- tests/run-coverage/while.coverage | 10 +- tests/run-coverage/while_early_ret.coverage | 84 +- tests/run-coverage/yield.coverage | 74 +- tests/run-make-fulldeps/issue-19371/foo.rs | 3 +- tests/run-make/comment-section/Makefile | 15 + .../coverage-llvmir/filecheck.testprog.txt | 4 +- tests/run-make/doctests-keep-binaries/Makefile | 13 +- tests/run-make/doctests-runtool/Makefile | 20 + tests/run-make/doctests-runtool/runtool.rs | 3 + tests/run-make/doctests-runtool/t.rs | 11 + tests/run-make/dump-ice-to-disk/Makefile | 10 + tests/run-make/dump-ice-to-disk/check.sh | 58 ++ tests/run-make/dump-ice-to-disk/src/lib.rs | 7 + tests/run-make/exit-code/Makefile | 2 +- tests/run-make/extern-flag-pathless/Makefile | 27 +- tests/run-make/extern-flag-pathless/bar-dynamic.rs | 3 - tests/run-make/extern-flag-pathless/bar-static.rs | 3 - tests/run-make/extern-flag-pathless/bar.rs | 1 + tests/run-make/extern-fn-explicit-align/Makefile | 6 + tests/run-make/extern-fn-explicit-align/test.c | 93 ++ tests/run-make/extern-fn-explicit-align/test.rs | 89 ++ tests/run-make/extern-fn-struct-passing-abi/test.c | 36 + .../run-make/extern-fn-struct-passing-abi/test.rs | 21 + tests/run-make/libtest-json/output-default.json | 2 +- .../libtest-json/output-stdout-success.json | 4 +- tests/run-make/libtest-junit/output-default.xml | 2 +- .../libtest-junit/output-stdout-success.xml | 2 +- tests/run-make/llvm-ident/Makefile | 19 + tests/run-make/mixing-libs/Makefile | 8 +- tests/run-make/no-builtins-attribute/Makefile | 9 + .../no-builtins-attribute/filecheck.main.txt | 5 + tests/run-make/no-builtins-attribute/main.rs | 10 + .../run-make/no-builtins-attribute/no_builtins.rs | 5 + tests/run-make/no-cdylib-as-rdylib/Makefile | 16 + tests/run-make/no-cdylib-as-rdylib/bar.rs | 1 + tests/run-make/no-cdylib-as-rdylib/foo.rs | 5 + .../run-make/optimization-remarks-dir-pgo/Makefile | 21 + tests/run-make/optimization-remarks-dir-pgo/foo.rs | 6 + tests/run-make/panic-abort-eh_frame/Makefile | 2 +- tests/run-make/panic-abort-eh_frame/foo.rs | 24 + .../filecheck-patterns.txt | 4 +- tests/run-make/pretty-print-with-dep-file/Makefile | 9 + .../pretty-print-with-dep-file/with-dep.rs | 1 + tests/run-make/print-cfg/Makefile | 19 +- tests/run-make/print-native-static-libs/Makefile | 6 +- tests/run-make/print-native-static-libs/bar.rs | 6 + tests/run-make/rmeta-preferred/Makefile | 16 + tests/run-make/rmeta-preferred/lib.rs | 14 + tests/run-make/rmeta-preferred/rmeta_aux.rs | 3 + tests/run-make/short-ice/Makefile | 1 + tests/run-make/short-ice/check.sh | 6 +- tests/run-make/tools.mk | 2 +- tests/run-make/unknown-mod-stdin/Makefile | 15 + .../run-make/unknown-mod-stdin/unknown-mod.stderr | 11 + .../run-make/unknown-mod-stdin/unknown-mod.stdout | 0 tests/run-make/wasm-exceptions-nostd/Makefile | 12 + .../wasm-exceptions-nostd/src/arena_alloc.rs | 67 ++ tests/run-make/wasm-exceptions-nostd/src/lib.rs | 60 ++ .../run-make/wasm-exceptions-nostd/src/logging.rs | 9 + .../wasm-exceptions-nostd/src/panicking.rs | 29 + tests/run-make/wasm-exceptions-nostd/verify.mjs | 75 ++ tests/rustdoc-gui/anchors.goml | 22 +- tests/rustdoc-gui/basic-code.goml | 2 +- tests/rustdoc-gui/code-sidebar-toggle.goml | 4 +- tests/rustdoc-gui/headings.goml | 20 +- tests/rustdoc-gui/item-decl-colors.goml | 49 +- tests/rustdoc-gui/jump-to-def-background.goml | 4 +- tests/rustdoc-gui/label-next-to-symbol.goml | 4 +- tests/rustdoc-gui/links-color.goml | 72 +- tests/rustdoc-gui/pocket-menu.goml | 73 +- tests/rustdoc-gui/run-on-hover.goml | 12 +- tests/rustdoc-gui/rust-logo.goml | 16 +- tests/rustdoc-gui/scrape-examples-toggle.goml | 12 +- tests/rustdoc-gui/search-error.goml | 6 +- tests/rustdoc-gui/search-form-elements.goml | 386 +++----- tests/rustdoc-gui/search-reexport.goml | 2 +- tests/rustdoc-gui/search-result-color.goml | 4 +- tests/rustdoc-gui/search-tab.goml | 52 +- tests/rustdoc-gui/sidebar-links-color.goml | 126 +-- tests/rustdoc-gui/sidebar-source-code-display.goml | 42 +- tests/rustdoc-gui/sidebar-source-code.goml | 14 +- tests/rustdoc-gui/source-anchor-scroll.goml | 6 +- tests/rustdoc-gui/source-code-page.goml | 36 +- tests/rustdoc-gui/src-font-size.goml | 6 +- tests/rustdoc-gui/src/staged_api/lib.rs | 1 + tests/rustdoc-gui/src/test_docs/lib.rs | 1 + tests/rustdoc-gui/unsafe-fn.goml | 6 +- tests/rustdoc-json/enums/field_order.rs | 40 + tests/rustdoc-json/enums/variant_order.rs | 38 + .../impls/issue-112852-dangling-trait-impl-id-2.rs | 15 + .../impls/issue-112852-dangling-trait-impl-id-3.rs | 14 + .../impls/issue-112852-dangling-trait-impl-id.rs | 21 + tests/rustdoc-json/structs/field_order.rs | 38 + tests/rustdoc-json/traits/private_supertrait.rs | 15 + .../type/inherent_associated_type_bound.rs | 17 +- .../type/inherent_associated_type_projections.rs | 12 +- tests/rustdoc-json/unions/field_order.rs | 38 + .../doctest/failed-doctest-output-windows.stdout | 3 +- .../doctest/failed-doctest-output.stdout | 3 +- tests/rustdoc-ui/ice-bug-report-url.rs | 3 +- tests/rustdoc-ui/ice-bug-report-url.stderr | 5 +- .../intra-doc/broken-link-in-unused-doc-string.rs | 16 + .../broken-link-in-unused-doc-string.stderr | 27 + .../issue-110629-private-type-cycle-dyn.stderr | 1 + tests/rustdoc-ui/lints/inline-doc-link.rs | 13 + tests/rustdoc-ui/lints/invalid-doc-attr.rs | 15 + tests/rustdoc-ui/lints/invalid-doc-attr.stderr | 49 +- tests/rustdoc-ui/lints/no-redundancy.rs | 7 + .../lints/redundant_explicit_links-utf8.rs | 18 + .../lints/redundant_explicit_links.fixed | 158 +++ tests/rustdoc-ui/lints/redundant_explicit_links.rs | 158 +++ .../lints/redundant_explicit_links.stderr | 1007 ++++++++++++++++++++ tests/rustdoc-ui/unescaped_backticks.rs | 1 + tests/rustdoc-ui/unescaped_backticks.stderr | 128 +-- tests/rustdoc/alias-reexport.rs | 1 + tests/rustdoc/alias-reexport2.rs | 1 + tests/rustdoc/anchors.no_const_anchor.html | 2 +- tests/rustdoc/anchors.no_const_anchor2.html | 2 +- tests/rustdoc/anchors.no_method_anchor.html | 2 +- tests/rustdoc/anchors.no_trait_method_anchor.html | 2 +- tests/rustdoc/anchors.no_tymethod_anchor.html | 2 +- tests/rustdoc/anchors.no_type_anchor.html | 2 +- .../issue-113982-doc_auto_cfg-reexport-foreign.rs | 3 + .../auxiliary/jump-to-def-res-err-handling-aux.rs | 1 + tests/rustdoc/check-source-code-urls-to-def.rs | 19 +- tests/rustdoc/default-trait-method.rs | 43 +- tests/rustdoc/description.rs | 1 + tests/rustdoc/display-hidden-items.rs | 71 ++ tests/rustdoc/ensure-src-link.rs | 2 +- tests/rustdoc/extern-impl-trait.rs | 2 +- tests/rustdoc/generic-const-items.rs | 38 + tests/rustdoc/impl-everywhere.rs | 2 +- tests/rustdoc/inherent-projections.rs | 10 +- .../inline_cross/auxiliary/generic-const-items.rs | 22 + tests/rustdoc/inline_cross/auxiliary/impl-sized.rs | 21 + .../auxiliary/ret-pos-impl-trait-in-trait.rs | 35 + tests/rustdoc/inline_cross/generic-const-items.rs | 26 + tests/rustdoc/inline_cross/impl-sized.rs | 27 + .../inline_cross/ret-pos-impl-trait-in-trait.rs | 35 + tests/rustdoc/intra-doc/basic.rs | 2 + tests/rustdoc/intra-doc/generic-params.rs | 1 + tests/rustdoc/intra-doc/issue-108459.rs | 1 + tests/rustdoc/intra-doc/nested-use.rs | 16 + .../rustdoc/issue-105735-overlapping-reexport-2.rs | 25 + tests/rustdoc/issue-105735-overlapping-reexport.rs | 21 + .../issue-113982-doc_auto_cfg-reexport-foreign.rs | 19 + tests/rustdoc/issue-18199.rs | 1 + tests/rustdoc/issue-33178.rs | 9 +- ...issue-81141-private-reexport-in-public-api-2.rs | 13 + ...1141-private-reexport-in-public-api-generics.rs | 13 + ...-81141-private-reexport-in-public-api-hidden.rs | 16 + ...81141-private-reexport-in-public-api-private.rs | 32 + .../issue-81141-private-reexport-in-public-api.rs | 124 +++ tests/rustdoc/jump-to-def-doc-links.rs | 51 + tests/rustdoc/private-use.rs | 13 + tests/rustdoc/source-file.rs | 2 +- tests/rustdoc/src-links-auto-impls.rs | 6 +- tests/rustdoc/static-root-path.rs | 8 +- tests/ui-fulldeps/missing-rustc-driver-error.rs | 4 +- .../ui-fulldeps/missing-rustc-driver-error.stderr | 12 +- .../session-diagnostic/diagnostic-derive.rs | 8 +- .../session-diagnostic/diagnostic-derive.stderr | 52 +- .../session-diagnostic/subdiagnostic-derive.rs | 30 +- .../session-diagnostic/subdiagnostic-derive.stderr | 273 +++--- tests/ui/abi/relocation_model_pic.rs | 9 + .../riscv-discoverability-guidance.riscv32.stderr | 27 + .../riscv-discoverability-guidance.riscv64.stderr | 27 + tests/ui/abi/riscv-discoverability-guidance.rs | 27 + tests/ui/abi/stack-probes-lto.rs | 12 +- tests/ui/abi/stack-probes.rs | 11 +- tests/ui/abi/stack-protector.rs | 2 + tests/ui/abi/unsupported.aarch64.stderr | 26 +- tests/ui/abi/unsupported.arm.stderr | 24 +- tests/ui/abi/unsupported.i686.stderr | 20 +- tests/ui/abi/unsupported.riscv32.stderr | 61 ++ tests/ui/abi/unsupported.riscv64.stderr | 61 ++ tests/ui/abi/unsupported.rs | 41 +- tests/ui/abi/unsupported.x64.stderr | 24 +- tests/ui/annotate-snippet/auxiliary/other_file.rs | 6 + tests/ui/annotate-snippet/multiple-files.rs | 8 + tests/ui/annotate-snippet/multiple-files.stderr | 11 + tests/ui/anonymous-higher-ranked-lifetime.stderr | 22 +- tests/ui/argument-suggestions/extra_arguments.rs | 26 +- .../ui/argument-suggestions/extra_arguments.stderr | 148 ++- tests/ui/array-slice-vec/infer_array_len.rs | 4 +- tests/ui/array-slice-vec/infer_array_len.stderr | 14 - tests/ui/array-slice-vec/slice-2.stderr | 16 +- .../array-slice-vec/slice-pat-type-mismatches.rs | 15 +- .../slice-pat-type-mismatches.stderr | 2 +- .../ui/array-slice-vec/vec-mut-iter-borrow.stderr | 2 +- tests/ui/asm/issue-113788.rs | 7 + tests/ui/asm/issue-113788.stderr | 9 + tests/ui/asm/x86_64/issue-96797.rs | 1 - .../associated-consts/defaults-cyclic-fail.stderr | 1 + tests/ui/associated-consts/issue-105330.stderr | 12 +- ...-24949-assoc-const-static-recursion-impl.stderr | 1 + ...soc-const-static-recursion-trait-default.stderr | 1 + ...24949-assoc-const-static-recursion-trait.stderr | 1 + .../bugs/cycle-iat-inside-of-adt.stderr | 1 + .../cycle-iat-inside-of-where-predicate.stderr | 1 + tests/ui/associated-inherent-types/inference.rs | 2 + .../ui/associated-inherent-types/issue-111879-0.rs | 4 +- .../issue-111879-0.stderr | 6 +- .../late-bound-regions.rs | 4 +- .../late-bound-regions.stderr | 2 +- .../not-found-self-type-differs.alias.stderr | 16 - .../not-found-self-type-differs.local.stderr | 16 - .../not-found-self-type-differs.rs | 9 +- .../not-found-self-type-differs.stderr | 29 + .../substitute-params-bad.rs | 2 +- .../associated-inherent-types/substitute-params.rs | 3 +- .../type-alias-bounds-are-enforced.rs | 4 +- .../type-alias-bounds-are-enforced.stderr | 55 ++ .../ambiguous-associated-type2.rs | 2 + .../ambiguous-associated-type2.stderr | 1 + tests/ui/associated-type-bounds/consts.rs | 10 + tests/ui/associated-type-bounds/consts.stderr | 10 + .../return-type-notation/bad-inputs-and-output.rs | 2 - .../bad-inputs-and-output.stderr | 48 + .../return-type-notation/basic.rs | 14 +- .../return-type-notation/equality.rs | 2 - .../return-type-notation/equality.stderr | 17 + .../dont-suggest-cyclic-constraint.rs | 2 +- tests/ui/associated-types/issue-20825.stderr | 1 + .../await-keyword/incorrect-syntax-suggestions.rs | 11 +- .../incorrect-syntax-suggestions.stderr | 78 +- tests/ui/async-await/clone-suggestion.stderr | 2 +- .../ui/async-await/edition-deny-async-fns-2015.rs | 2 - .../async-await/edition-deny-async-fns-2015.stderr | 98 ++ .../async-await/in-trait/async-associated-types.rs | 2 - .../in-trait/async-default-fn-overridden.rs | 2 - ...example-desugared-boxed-in-trait.current.stderr | 17 - ...nc-example-desugared-boxed-in-trait.next.stderr | 17 - .../async-example-desugared-boxed-in-trait.rs | 2 - .../async-example-desugared-boxed-in-trait.stderr | 17 + .../async-example-desugared-boxed.current.stderr | 11 - .../async-example-desugared-boxed.next.stderr | 11 - .../in-trait/async-example-desugared-boxed.rs | 2 - .../in-trait/async-example-desugared-boxed.stderr | 11 + .../in-trait/async-example-desugared-extra.rs | 2 - .../in-trait/async-example-desugared-in-trait.rs | 2 - .../async-example-desugared-manual.current.stderr | 11 - .../async-example-desugared-manual.next.stderr | 11 - .../in-trait/async-example-desugared-manual.rs | 2 - .../in-trait/async-example-desugared-manual.stderr | 11 + .../in-trait/async-example-desugared.rs | 2 - .../async-generics-and-bounds.current.stderr | 37 - .../in-trait/async-generics-and-bounds.next.stderr | 37 - .../in-trait/async-generics-and-bounds.rs | 2 - .../in-trait/async-generics-and-bounds.stderr | 37 + .../in-trait/async-generics.current.stderr | 37 - .../in-trait/async-generics.next.stderr | 37 - tests/ui/async-await/in-trait/async-generics.rs | 2 - .../ui/async-await/in-trait/async-generics.stderr | 37 + .../in-trait/async-lifetimes-and-bounds.rs | 2 - tests/ui/async-await/in-trait/async-lifetimes.rs | 2 - .../async-recursive-generic.current.stderr | 12 - .../in-trait/async-recursive-generic.next.stderr | 12 - .../in-trait/async-recursive-generic.rs | 2 - .../in-trait/async-recursive-generic.stderr | 12 + .../in-trait/async-recursive.current.stderr | 12 - .../in-trait/async-recursive.next.stderr | 12 - tests/ui/async-await/in-trait/async-recursive.rs | 2 - .../ui/async-await/in-trait/async-recursive.stderr | 12 + .../in-trait/bad-signatures.current.stderr | 17 - .../in-trait/bad-signatures.next.stderr | 17 - tests/ui/async-await/in-trait/bad-signatures.rs | 2 - .../ui/async-await/in-trait/bad-signatures.stderr | 17 + ...ject-to-specializable-projection.current.stderr | 10 - ...project-to-specializable-projection.next.stderr | 25 - .../dont-project-to-specializable-projection.rs | 2 - ...dont-project-to-specializable-projection.stderr | 25 + tests/ui/async-await/in-trait/early-bound-1.rs | 2 - tests/ui/async-await/in-trait/early-bound-2.rs | 2 - .../in-trait/fn-not-async-err2.current.stderr | 12 - .../in-trait/fn-not-async-err2.next.stderr | 12 - tests/ui/async-await/in-trait/fn-not-async-err2.rs | 2 - .../async-await/in-trait/fn-not-async-err2.stderr | 12 + .../in-trait/generics-mismatch.current.stderr | 16 - .../in-trait/generics-mismatch.next.stderr | 16 - tests/ui/async-await/in-trait/implied-bounds.rs | 2 - tests/ui/async-await/in-trait/issue-102138.rs | 2 - tests/ui/async-await/in-trait/issue-102219.rs | 2 - tests/ui/async-await/in-trait/issue-102310.rs | 2 - tests/ui/async-await/in-trait/issue-104678.rs | 2 - .../in-trait/lifetime-mismatch.current.stderr | 12 - .../in-trait/lifetime-mismatch.next.stderr | 12 - tests/ui/async-await/in-trait/lifetime-mismatch.rs | 2 - .../async-await/in-trait/lifetime-mismatch.stderr | 12 + .../in-trait/missing-feature-flag.current.stderr | 30 - .../in-trait/missing-feature-flag.next.stderr | 30 - .../async-await/in-trait/missing-feature-flag.rs | 2 - .../in-trait/missing-feature-flag.stderr | 30 + .../in-trait/missing-send-bound.current.stderr | 20 - .../in-trait/missing-send-bound.next.stderr | 20 - .../ui/async-await/in-trait/missing-send-bound.rs | 2 - .../async-await/in-trait/missing-send-bound.stderr | 20 + .../in-trait/object-safety.current.stderr | 18 - .../async-await/in-trait/object-safety.next.stderr | 18 - tests/ui/async-await/in-trait/object-safety.rs | 2 - tests/ui/async-await/in-trait/object-safety.stderr | 18 + .../return-not-existing-pair.current.stderr | 39 - .../in-trait/return-not-existing-pair.next.stderr | 39 - .../in-trait/return-not-existing-pair.rs | 2 - .../in-trait/return-not-existing-pair.stderr | 39 + ...ot-existing-type-wrapping-rpitit.current.stderr | 9 - ...n-not-existing-type-wrapping-rpitit.next.stderr | 9 - .../return-not-existing-type-wrapping-rpitit.rs | 2 - ...return-not-existing-type-wrapping-rpitit.stderr | 9 + .../in-trait/return-type-suggestion.current.stderr | 14 - .../in-trait/return-type-suggestion.next.stderr | 14 - .../async-await/in-trait/return-type-suggestion.rs | 3 - .../in-trait/return-type-suggestion.stderr | 12 + tests/ui/async-await/issue-61452.stderr | 2 +- tests/ui/async-await/issues/issue-61187.stderr | 2 +- ...issue-65419-async-fn-resume-after-completion.rs | 3 +- .../issue-65419-async-fn-resume-after-panic.rs | 3 +- .../normalize-output-in-signature-deduction.rs | 19 + .../return-type-notation/issue-110963-early.rs | 2 - .../return-type-notation/issue-110963-early.stderr | 37 + .../return-type-notation/issue-110963-late.rs | 2 - .../return-type-notation/issue-110963-late.stderr | 11 + .../return-type-notation/super-method-bound.rs | 2 - .../return-type-notation/super-method-bound.stderr | 11 + .../return-type-notation/supertrait-bound.rs | 2 - .../return-type-notation/supertrait-bound.stderr | 11 + .../return-type-notation/ty-or-ct-params.rs | 2 - .../return-type-notation/ty-or-ct-params.stderr | 29 + .../track-caller/async-block.afn.stderr | 30 + .../track-caller/async-block.nofeat.stderr | 30 + tests/ui/async-await/track-caller/async-block.rs | 18 + .../ui/async-await/track-caller/async-block.stderr | 12 - .../track-caller/async-closure-gate.afn.stderr | 57 ++ .../track-caller/async-closure-gate.nofeat.stderr | 57 ++ .../async-await/track-caller/async-closure-gate.rs | 41 + .../track-caller/async-closure-gate.stderr | 12 - .../track-caller/panic-track-caller.cls.stderr | 31 + .../track-caller/panic-track-caller.nofeat.stderr | 14 +- .../async-await/track-caller/panic-track-caller.rs | 46 +- .../auxiliary/rustc_confusables_across_crate.rs | 11 + tests/ui/attributes/invalid-doc-attr.rs | 32 - tests/ui/attributes/invalid-doc-attr.stderr | 78 -- tests/ui/attributes/macro_export_on_decl_macro.rs | 9 + .../attributes/macro_export_on_decl_macro.stderr | 16 + tests/ui/attributes/rustc_confusables.rs | 47 + tests/ui/attributes/rustc_confusables.stderr | 68 ++ tests/ui/auto-traits/issue-83857-ub.rs | 33 + tests/ui/auto-traits/issue-83857-ub.stderr | 22 + tests/ui/binop/binop-move-semantics.stderr | 2 +- tests/ui/binop/borrow-suggestion-109352-2.rs | 27 + tests/ui/binop/borrow-suggestion-109352-2.stderr | 64 ++ tests/ui/binop/borrow-suggestion-109352.fixed | 27 + tests/ui/binop/borrow-suggestion-109352.rs | 27 + tests/ui/binop/borrow-suggestion-109352.stderr | 45 + tests/ui/borrowck/borrow-tuple-fields.stderr | 12 +- tests/ui/borrowck/borrowck-argument.stderr | 8 +- .../borrowck-auto-mut-ref-to-immut-var.stderr | 2 +- ...orrowck-borrow-immut-deref-of-box-as-mut.stderr | 2 +- .../borrowck-borrow-mut-object-twice.stderr | 6 +- .../borrowck-borrow-overloaded-auto-deref.stderr | 14 +- .../borrowck-borrowed-uniq-rvalue-2.stderr | 6 +- .../borrowck/borrowck-borrowed-uniq-rvalue.stderr | 2 +- .../borrowck/borrowck-closures-unique-imm.stderr | 2 +- tests/ui/borrowck/borrowck-describe-lvalue.stderr | 12 +- .../ui/borrowck/borrowck-insert-during-each.stderr | 20 +- tests/ui/borrowck/borrowck-issue-2657-1.stderr | 2 +- tests/ui/borrowck/borrowck-lend-flow-if.stderr | 2 +- tests/ui/borrowck/borrowck-lend-flow.stderr | 2 +- .../borrowck/borrowck-loan-blocks-move-cc.stderr | 4 +- tests/ui/borrowck/borrowck-loan-blocks-move.stderr | 2 +- .../borrowck/borrowck-loan-in-overloaded-op.stderr | 2 +- .../borrowck-loan-rcvr-overloaded-op.stderr | 2 +- tests/ui/borrowck/borrowck-loan-rcvr.stderr | 18 +- ...rowck-move-from-subpath-of-borrowed-path.stderr | 2 +- .../ui/borrowck/borrowck-move-mut-base-ptr.stderr | 2 +- ...rrowck-move-out-of-overloaded-auto-deref.stderr | 7 +- .../borrowck-mut-borrow-linear-errors.stderr | 15 +- .../borrowck-mut-borrow-of-mut-base-ptr.stderr | 4 +- tests/ui/borrowck/borrowck-object-lifetime.stderr | 8 +- .../borrowck-overloaded-index-autoderef.stderr | 16 +- .../borrowck-report-with-custom-diagnostic.stderr | 6 +- .../ui/borrowck/borrowck-swap-mut-base-ptr.stderr | 2 +- .../borrowck/borrowck-union-borrow-nested.stderr | 2 +- tests/ui/borrowck/borrowck-uniq-via-lend.stderr | 4 +- .../borrowck-vec-pattern-loan-from-mut.stderr | 5 +- .../borrowck/borrowck-vec-pattern-nesting.stderr | 4 +- tests/ui/borrowck/clone-span-on-try-operator.fixed | 11 + tests/ui/borrowck/clone-span-on-try-operator.rs | 11 + .../ui/borrowck/clone-span-on-try-operator.stderr | 21 + tests/ui/borrowck/copy-suggestion-region-vid.rs | 1 + .../ui/borrowck/copy-suggestion-region-vid.stderr | 9 +- tests/ui/borrowck/index-mut-help-with-impl.stderr | 2 +- tests/ui/borrowck/index-mut-help.stderr | 7 +- .../issue-109271-pass-self-into-closure.stderr | 28 +- tests/ui/borrowck/issue-42344.stderr | 2 +- tests/ui/borrowck/issue-47646.stderr | 2 +- tests/ui/borrowck/issue-51117.stderr | 2 +- tests/ui/borrowck/issue-81365-10.stderr | 2 +- tests/ui/borrowck/issue-81365-5.stderr | 2 +- tests/ui/borrowck/issue-82032.stderr | 2 +- tests/ui/borrowck/issue-85581.stderr | 2 +- tests/ui/borrowck/issue-85765-closure.rs | 31 + tests/ui/borrowck/issue-85765-closure.stderr | 48 + tests/ui/borrowck/issue-85765.stderr | 2 +- tests/ui/borrowck/issue-91206.stderr | 2 +- tests/ui/borrowck/issue-93078.stderr | 2 +- tests/ui/borrowck/many-mutable-borrows.stderr | 18 +- tests/ui/borrowck/mut-borrow-of-mut-ref.stderr | 2 +- tests/ui/borrowck/mut-borrow-outside-loop.stderr | 4 +- .../borrowck/suggest-as-ref-on-mut-closure.stderr | 5 +- .../borrowck/suggest-local-var-double-mut.stderr | 5 +- .../borrowck/suggest-local-var-for-vector.stderr | 12 +- .../borrowck/suggest-local-var-imm-and-mut.stderr | 5 +- .../suggest-storing-local-var-for-vector.stderr | 12 +- tests/ui/borrowck/two-phase-across-loop.stderr | 5 +- .../two-phase-cannot-nest-mut-self-calls.stderr | 19 +- tests/ui/borrowck/two-phase-multi-mut.stderr | 5 +- .../borrowck/two-phase-nonrecv-autoref.base.stderr | 28 +- tests/ui/borrowck/two-phase-sneaky.stderr | 2 +- .../borrowck/two-phase-surprise-no-conflict.stderr | 37 +- ...res-move-upvar-from-non-once-ref-closure.stderr | 2 +- tests/ui/box/leak-alloc.stderr | 2 +- tests/ui/btreemap/btreemap-index-mut-2.rs | 8 + tests/ui/btreemap/btreemap-index-mut-2.stderr | 19 + tests/ui/cannot-mutate-captured-non-mut-var.stderr | 2 +- tests/ui/check-cfg/compact-values.stderr | 2 +- tests/ui/check-cfg/values-target-json.stderr | 2 +- tests/ui/check-cfg/well-known-values.stderr | 2 +- .../closures/binder/nested-closures-regions.stderr | 4 +- tests/ui/closures/multiple-fn-bounds.stderr | 2 +- ...closure-print-generic-trim-off-verbose-2.stderr | 2 +- .../print/closure-print-generic-verbose-2.stderr | 2 +- .../ui/closures/print/closure-print-verbose.stderr | 2 +- tests/ui/codegen/issue-55976.rs | 2 - tests/ui/codegen/target-cpus.rs | 4 + tests/ui/codegen/target-cpus.stdout | 4 + tests/ui/codemap_tests/issue-11715.stderr | 2 +- tests/ui/codemap_tests/one_line.stderr | 5 +- tests/ui/codemap_tests/tab_3.stderr | 2 +- tests/ui/coercion/coerce-block-tail-83783.fixed | 13 + tests/ui/coercion/coerce-block-tail-83783.rs | 2 +- tests/ui/coercion/coerce-block-tail-83783.stderr | 4 + .../coherence-doesnt-use-infcx-evaluate.rs | 24 + .../coherence-doesnt-use-infcx-evaluate.stderr | 12 + .../coherence-inherited-assoc-ty-cycle-err.stderr | 1 + .../warn-when-cycle-is-error-in-coherence.rs | 35 + .../warn-when-cycle-is-error-in-coherence.stderr | 23 + tests/ui/command/need-crate-arg-ignore-tidy.x.rs | 2 + .../ui/command/need-crate-arg-ignore-tidy.x.stderr | 6 + .../conditional-compilation/cfg-arg-invalid-1.rs | 2 +- .../conditional-compilation/cfg-arg-invalid-2.rs | 2 +- .../conditional-compilation/cfg-arg-invalid-4.rs | 2 +- .../conditional-compilation/cfg-arg-invalid-6.rs | 2 +- .../conditional-compilation/cfg-arg-invalid-8.rs | 2 +- .../conditional-compilation/cfg-arg-invalid-9.rs | 2 +- .../conditional-compilation/cfg-empty-codemap.rs | 2 +- .../const-generic-default-wont-borrowck.stderr | 2 +- .../const-generics/const_trait_fn-issue-88433.rs | 2 +- .../generic_const_exprs/closures.stderr | 1 + .../generic_const_exprs/issue-109141.stderr | 2 +- .../generic_const_exprs/issue-80742.rs | 8 +- .../generic_const_exprs/issue-80742.stderr | 75 +- .../unify-op-with-fn-call.stderr | 42 +- tests/ui/const-generics/issue-93647.rs | 1 - tests/ui/const-generics/issue-93647.stderr | 19 +- tests/ui/const-generics/issues/issue-100313.rs | 1 + tests/ui/const-generics/issues/issue-100313.stderr | 12 +- .../const-generics/issues/issue-67375.full.stderr | 2 +- tests/ui/const-generics/issues/issue-83765.stderr | 1 + .../const-generics/late-bound-vars/in_closure.rs | 6 +- .../late-bound-vars/in_closure.stderr | 7 +- tests/ui/const-generics/late-bound-vars/simple.rs | 4 +- .../const-generics/late-bound-vars/simple.stderr | 3 +- tests/ui/const-generics/lifetime-in-const-param.rs | 9 + .../const-generics/lifetime-in-const-param.stderr | 18 + tests/ui/const-generics/slice-const-param.rs | 21 + tests/ui/const-generics/transmute-fail.stderr | 24 +- tests/ui/const-generics/type_mismatch.stderr | 12 +- tests/ui/const-ptr/forbidden_slices.stderr | 12 +- tests/ui/const_prop/apfloat-f64-roundtrip.rs | 9 + .../ui/const_prop/apfloat-remainder-regression.rs | 15 + tests/ui/const_prop/ice-issue-111353.rs | 7 + tests/ui/const_prop/ice-issue-96944.rs | 26 + tests/ui/consts/const-block-const-bound.rs | 4 +- tests/ui/consts/const-block-const-bound.stderr | 20 +- tests/ui/consts/const-compare-bytes-ub.rs | 41 + tests/ui/consts/const-compare-bytes-ub.stderr | 54 ++ tests/ui/consts/const-compare-bytes.rs | 27 + .../ui/consts/const-eval/const-eval-query-stack.rs | 4 +- ...st-pointer-values-in-various-types.64bit.stderr | 54 +- .../consts/const-eval/const_fn_target_feature.rs | 17 + .../const-eval/const_fn_target_feature.stderr | 9 + .../heap/dealloc_intrinsic_dangling.stderr | 4 +- .../heap/dealloc_intrinsic_duplicate.stderr | 2 +- tests/ui/consts/const-eval/issue-49296.stderr | 2 +- tests/ui/consts/const-eval/nonnull_as_ref.rs | 8 + tests/ui/consts/const-eval/nonnull_as_ref_ub.rs | 6 + .../ui/consts/const-eval/nonnull_as_ref_ub.stderr | 16 + tests/ui/consts/const-eval/raw-bytes.32bit.stderr | 23 +- tests/ui/consts/const-eval/raw-bytes.64bit.stderr | 23 +- .../const-eval/ref_to_int_match.32bit.stderr | 2 +- .../const-eval/ref_to_int_match.64bit.stderr | 2 +- tests/ui/consts/const-eval/ub-enum.32bit.stderr | 33 +- tests/ui/consts/const-eval/ub-enum.64bit.stderr | 33 +- tests/ui/consts/const-eval/ub-enum.rs | 12 +- .../ui/consts/const-eval/ub-int-array.32bit.stderr | 39 +- .../ui/consts/const-eval/ub-int-array.64bit.stderr | 39 +- tests/ui/consts/const-eval/ub-int-array.rs | 84 +- tests/ui/consts/const-eval/ub-ref-ptr.stderr | 8 +- tests/ui/consts/const-eval/ub-wide-ptr.stderr | 12 +- tests/ui/consts/const-float-classify.rs | 3 +- tests/ui/consts/const-float-classify.stderr | 11 + tests/ui/consts/const-size_of-cycle.stderr | 1 + tests/ui/consts/const-try.stderr | 33 +- tests/ui/consts/const_cmp_type_id.stderr | 44 +- tests/ui/consts/const_discriminant.rs | 7 - tests/ui/consts/const_let_assign3.stderr | 2 +- .../constifconst-call-in-const-position.stderr | 18 +- tests/ui/consts/drop-maybe_uninit.rs | 17 + tests/ui/consts/extra-const-ub/detect-extra-ub.rs | 61 ++ .../detect-extra-ub.with_flag.stderr | 38 +- .../ui/consts/invalid-inline-const-in-match-arm.rs | 1 - .../invalid-inline-const-in-match-arm.stderr | 19 +- tests/ui/consts/issue-103790.stderr | 2 + tests/ui/consts/issue-28113.rs | 1 - tests/ui/consts/issue-28113.stderr | 19 +- tests/ui/consts/issue-36163.stderr | 1 + tests/ui/consts/issue-44415.stderr | 1 + tests/ui/consts/issue-56164.rs | 1 - tests/ui/consts/issue-56164.stderr | 21 +- .../ui/consts/issue-68542-closure-in-array-len.rs | 1 - .../consts/issue-68542-closure-in-array-len.stderr | 19 +- tests/ui/consts/issue-73976-monomorphic.stderr | 18 +- tests/ui/consts/issue-83182.rs | 9 - tests/ui/consts/issue-83182.stderr | 15 - tests/ui/consts/issue-94675.rs | 8 +- tests/ui/consts/issue-94675.stderr | 24 +- tests/ui/consts/issue-miri-1910.stderr | 2 +- tests/ui/consts/miri_unleashed/ptr_arith.rs | 4 +- tests/ui/consts/miri_unleashed/ptr_arith.stderr | 2 +- tests/ui/consts/precise-drop-with-promoted.rs | 8 +- tests/ui/consts/precise-drop-with-promoted.stderr | 6 + tests/ui/consts/promoted_const_call.rs | 14 +- tests/ui/consts/promoted_const_call.stderr | 25 +- tests/ui/consts/ptr_comparisons.rs | 36 +- tests/ui/consts/ptr_comparisons.stderr | 40 - tests/ui/consts/ptr_is_null.rs | 1 + .../ui/consts/recursive-zst-static.default.stderr | 1 + .../ui/consts/recursive-zst-static.unleash.stderr | 1 + tests/ui/consts/rustc-impl-const-stability.rs | 2 +- tests/ui/consts/rustc-impl-const-stability.stderr | 12 +- tests/ui/consts/unstable-const-fn-in-libcore.rs | 1 + .../ui/consts/unstable-const-fn-in-libcore.stderr | 17 +- .../ui/consts/write-to-static-mut-in-static.stderr | 1 + tests/ui/cross-crate/auxiliary/static_init_aux.rs | 4 + tests/ui/cross-crate/static-init.rs | 3 + .../cycle-trait-default-type-trait.stderr | 1 + .../cycle-trait-supertrait-direct.stderr | 1 + .../cycle-trait-supertrait-indirect.stderr | 1 + tests/ui/cycle-trait/issue-12511.stderr | 1 + tests/ui/debuginfo/sroa-fragment-debuginfo.rs | 31 + tests/ui/deriving/deriving-all-codegen.stdout | 14 +- .../slice_destructure_fail.rs | 10 +- .../slice_destructure_fail.stderr | 22 +- .../diagnostic-flags/colored-session-opt-error.rs | 4 + .../colored-session-opt-error.stderr | 2 + tests/ui/diagnostic-width/E0271.stderr | 3 +- tests/ui/diagnostic-width/long-E0308.rs | 2 +- .../auxiliary/proc-macro-helper.rs | 12 + .../can_use_the_diagnostic_name_in_other_places.rs | 13 + .../diagnostic_namespace/existing_proc_macros.rs | 24 + .../feature-gate-diagnostic_namespace.rs | 13 + .../feature-gate-diagnostic_namespace.stderr | 35 + .../non_existing_attributes_accepted.rs | 13 + .../non_existing_attributes_accepted.stderr | 16 + tests/ui/diagnostic_namespace/requires_path.rs | 9 + tests/ui/diagnostic_namespace/requires_path.stderr | 8 + tests/ui/did_you_mean/compatible-variants.stderr | 2 + tests/ui/did_you_mean/issue-114112.rs | 11 + tests/ui/did_you_mean/issue-114112.stderr | 13 + tests/ui/did_you_mean/issue-34126.stderr | 5 +- tests/ui/did_you_mean/issue-35937.stderr | 2 +- tests/ui/did_you_mean/issue-38147-1.stderr | 2 +- tests/ui/did_you_mean/issue-38147-2.stderr | 4 +- tests/ui/did_you_mean/issue-38147-3.stderr | 2 +- tests/ui/did_you_mean/issue-38147-4.stderr | 2 +- tests/ui/did_you_mean/issue-40823.stderr | 2 +- tests/ui/dropck/drop-with-active-borrows-1.stderr | 2 +- tests/ui/dropck/drop-with-active-borrows-2.stderr | 2 +- tests/ui/dropck/explicit-drop-bounds.bad1.stderr | 4 +- tests/ui/dropck/explicit-drop-bounds.bad2.stderr | 4 +- tests/ui/dst/issue-113447.fixed | 25 + tests/ui/dst/issue-113447.rs | 25 + tests/ui/dst/issue-113447.stderr | 25 + .../issue-90528-unsizing-not-suggestion-110063.rs | 13 + ...sue-90528-unsizing-not-suggestion-110063.stderr | 29 + tests/ui/dyn-star/llvm-old-style-ptrs.rs | 23 - .../dyn-star/param-env-region-infer.current.stderr | 2 +- .../ui/dyn-star/param-env-region-infer.next.stderr | 29 - tests/ui/dyn-star/param-env-region-infer.rs | 9 +- tests/ui/error-codes/E0161.base.stderr | 2 +- tests/ui/error-codes/E0275.stderr | 3 +- tests/ui/error-codes/E0283.stderr | 2 +- tests/ui/error-codes/E0499.stderr | 2 +- tests/ui/error-codes/E0502.stderr | 2 +- tests/ui/error-codes/E0503.stderr | 2 +- tests/ui/error-codes/E0505.stderr | 2 +- tests/ui/error-codes/E0507.stderr | 5 +- tests/ui/error-codes/E0608.stderr | 4 +- tests/ui/error-codes/E0790.stderr | 2 +- tests/ui/extern/extern-thiscall.rs | 2 - .../feature-gate-abi-riscv-interrupt.rs | 33 + .../feature-gate-abi-riscv-interrupt.stderr | 57 ++ .../feature-gate-cfg-relocation-model.rs | 4 + .../feature-gate-cfg-relocation-model.stderr | 12 + .../feature-gate-extern_absolute_paths.stderr | 9 + .../feature-gate-return_type_notation.rs | 24 +- tests/ui/feature-gates/feature-gate-thiscall.rs | 38 - .../ui/feature-gates/feature-gate-thiscall.stderr | 115 --- .../feature-gate-unsafe_pin_internals.rs | 4 +- .../feature-gate-unsafe_pin_internals.stderr | 7 +- tests/ui/feature-gates/print-with-path.cfg.stderr | 2 + tests/ui/feature-gates/print-with-path.rs | 7 + .../print-with-path.target-cpus.stderr | 2 + .../print-with-path.target-features.stderr | 2 + tests/ui/fmt/closing-brace-as-fill.rs | 8 + tests/ui/fmt/closing-brace-as-fill.stderr | 12 + tests/ui/fmt/format-string-error-2.stderr | 26 +- tests/ui/fmt/format-string-error.stderr | 2 +- tests/ui/fmt/format-string-wrong-order.stderr | 4 +- tests/ui/fmt/ifmt-bad-arg.stderr | 2 +- tests/ui/fmt/suggest-inline-args.rs | 28 + tests/ui/fmt/suggest-inline-args.stderr | 57 ++ tests/ui/for/issue-20605.next.stderr | 12 +- tests/ui/generator/auto-trait-regions.rs | 6 +- tests/ui/generator/dropck-resume.stderr | 2 +- tests/ui/generator/dropck.stderr | 2 +- tests/ui/generator/issue-113279.rs | 27 + tests/ui/generator/issue-113279.stderr | 16 + .../issue-102114.current.stderr | 12 + .../issue-102114.next.stderr | 12 + tests/ui/generic-associated-types/issue-102114.rs | 3 + .../generic-associated-types/issue-102114.stderr | 12 - tests/ui/generic-associated-types/issue-86218.rs | 1 - .../generic-associated-types/issue-90014-tait.rs | 1 - .../issue-90014-tait.stderr | 8 +- .../generic-associated-types/issue-90014-tait2.rs | 19 +- .../issue-90014-tait2.stderr | 13 +- .../generic-associated-types/streaming_iterator.rs | 3 +- .../associated-const-equality.rs | 22 + tests/ui/generic-const-items/basic.rs | 61 ++ tests/ui/generic-const-items/compare-impl-item.rs | 30 + .../generic-const-items/compare-impl-item.stderr | 66 ++ tests/ui/generic-const-items/const-trait-impl.rs | 25 + .../ui/generic-const-items/const-trait-impl.stderr | 11 + .../generic-const-items/duplicate-where-clause.rs | 27 + .../duplicate-where-clause.stderr | 27 + tests/ui/generic-const-items/elided-lifetimes.rs | 18 + .../ui/generic-const-items/elided-lifetimes.stderr | 35 + tests/ui/generic-const-items/evaluatable-bounds.rs | 31 + .../evaluatable-bounds.unconstrained.stderr | 10 + .../feature-gate-generic_const_items.rs | 37 + .../feature-gate-generic_const_items.stderr | 77 ++ tests/ui/generic-const-items/inference-failure.rs | 15 + .../generic-const-items/inference-failure.stderr | 20 + .../misplaced-where-clause.fixed | 18 + .../generic-const-items/misplaced-where-clause.rs | 20 + .../misplaced-where-clause.stderr | 36 + tests/ui/generic-const-items/parameter-defaults.rs | 14 + .../generic-const-items/parameter-defaults.stderr | 8 + tests/ui/generic-const-items/recursive.rs | 12 + .../reference-outlives-referent.rs | 9 + .../reference-outlives-referent.stderr | 20 + .../trivially-unsatisfied-bounds-0.rs | 12 + .../trivially-unsatisfied-bounds-0.stderr | 18 + .../trivially-unsatisfied-bounds-1.rs | 12 + .../trivially-unsatisfied-bounds-1.stderr | 11 + tests/ui/generic-const-items/unsatisfied-bounds.rs | 34 + .../generic-const-items/unsatisfied-bounds.stderr | 62 ++ .../unsatisfied-evaluatable-bounds.rs | 12 + .../unsatisfied-evaluatable-bounds.stderr | 9 + .../unsatisfied-outlives-bounds.rs | 17 + .../unsatisfied-outlives-bounds.stderr | 18 + tests/ui/generics/issue-94923.rs | 1 - .../ui/hashmap/hashmap-iter-value-lifetime.stderr | 2 +- tests/ui/hashmap/hashmap-lifetimes.stderr | 2 +- tests/ui/hello_world/main.rs | 2 +- .../subtype/placeholder-pattern-fail.stderr | 4 +- tests/ui/higher-ranked/trait-bounds/future.rs | 2 +- .../trait-bounds/hang-on-deeply-nested-dyn.stderr | 3 +- .../trait-bounds/hrtb-debruijn-in-receiver.stderr | 4 +- .../trait-bounds/hrtb-exists-forall-fn.stderr | 4 +- .../higher-ranked/trait-bounds/issue-30786.stderr | 1 - .../extern-prelude-from-opaque-fail-2018.rs | 29 + .../extern-prelude-from-opaque-fail-2018.stderr | 53 ++ .../ui/hygiene/extern-prelude-from-opaque-fail.rs | 1 + .../hygiene/extern-prelude-from-opaque-fail.stderr | 20 +- tests/ui/hygiene/fields-numeric-borrowck.stderr | 2 +- tests/ui/hygiene/panic-location.run.stderr | 3 +- tests/ui/impl-trait/auto-trait-leak.stderr | 2 + tests/ui/impl-trait/autoderef.rs | 2 +- .../fresh-lifetime-from-bare-trait-obj-114664.rs | 22 + ...resh-lifetime-from-bare-trait-obj-114664.stderr | 42 + tests/ui/impl-trait/hidden-type-is-opaque-2.rs | 6 +- tests/ui/impl-trait/hidden-type-is-opaque-2.stderr | 24 +- .../in-trait/assumed-wf-bounds-in-impl.rs | 29 + tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs | 6 +- .../in-trait/bad-item-bound-within-rpitit-2.rs | 11 + .../in-trait/bad-item-bound-within-rpitit-2.stderr | 33 + .../in-trait/bad-item-bound-within-rpitit.rs | 24 + .../in-trait/bad-item-bound-within-rpitit.stderr | 17 + .../in-trait/box-coerce-span-in-default.rs | 2 - .../in-trait/check-wf-on-non-defaulted-rpitit.rs | 10 + .../check-wf-on-non-defaulted-rpitit.stderr | 16 + tests/ui/impl-trait/in-trait/deep-match-works.rs | 2 - .../impl-trait/in-trait/deep-match.current.stderr | 15 - .../ui/impl-trait/in-trait/deep-match.next.stderr | 15 - tests/ui/impl-trait/in-trait/deep-match.rs | 3 - tests/ui/impl-trait/in-trait/deep-match.stderr | 15 + .../default-body-type-err-2.current.stderr | 11 - .../in-trait/default-body-type-err-2.next.stderr | 11 - .../impl-trait/in-trait/default-body-type-err-2.rs | 2 - .../in-trait/default-body-type-err-2.stderr | 11 + .../in-trait/default-body-type-err.current.stderr | 12 - .../in-trait/default-body-type-err.next.stderr | 12 - .../impl-trait/in-trait/default-body-type-err.rs | 3 - .../in-trait/default-body-type-err.stderr | 12 + .../in-trait/default-body-with-rpit.current.stderr | 24 - .../in-trait/default-body-with-rpit.next.stderr | 24 - .../impl-trait/in-trait/default-body-with-rpit.rs | 4 +- tests/ui/impl-trait/in-trait/default-body.rs | 2 - .../in-trait/default-method-binder-shifting.rs | 2 - .../in-trait/default-method-constraint.rs | 2 - .../in-trait/doesnt-satisfy.current.stderr | 17 - .../impl-trait/in-trait/doesnt-satisfy.next.stderr | 17 - tests/ui/impl-trait/in-trait/doesnt-satisfy.rs | 3 - tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr | 17 + ...-project-to-rpitit-with-no-value.current.stderr | 12 - ...ont-project-to-rpitit-with-no-value.next.stderr | 12 - .../dont-project-to-rpitit-with-no-value.rs | 3 - .../dont-project-to-rpitit-with-no-value.stderr | 12 + tests/ui/impl-trait/in-trait/early.rs | 2 - tests/ui/impl-trait/in-trait/encode.rs | 2 - .../impl-trait/in-trait/foreign-dyn-error.stderr | 2 +- tests/ui/impl-trait/in-trait/foreign.rs | 6 +- .../in-trait/generics-mismatch.current.stderr | 12 - .../in-trait/generics-mismatch.next.stderr | 12 - tests/ui/impl-trait/in-trait/generics-mismatch.rs | 3 - .../impl-trait/in-trait/generics-mismatch.stderr | 12 + .../in-trait/issue-102140.current.stderr | 33 - .../impl-trait/in-trait/issue-102140.next.stderr | 29 - tests/ui/impl-trait/in-trait/issue-102140.rs | 3 - tests/ui/impl-trait/in-trait/issue-102140.stderr | 29 + tests/ui/impl-trait/in-trait/issue-102301.rs | 2 - .../in-trait/issue-102571.current.stderr | 14 - .../impl-trait/in-trait/issue-102571.next.stderr | 14 - tests/ui/impl-trait/in-trait/issue-102571.rs | 3 - tests/ui/impl-trait/in-trait/issue-102571.stderr | 14 + .../missing-lt-outlives-in-rpitit-114274.rs | 12 + .../missing-lt-outlives-in-rpitit-114274.stderr | 23 + tests/ui/impl-trait/in-trait/nested-rpitit.rs | 2 - .../in-trait/object-safety.current.stderr | 49 - .../impl-trait/in-trait/object-safety.next.stderr | 49 - tests/ui/impl-trait/in-trait/object-safety.rs | 3 - tests/ui/impl-trait/in-trait/object-safety.stderr | 49 + .../opaque-in-impl-is-opaque.current.stderr | 17 - .../in-trait/opaque-in-impl-is-opaque.next.stderr | 17 - .../in-trait/opaque-in-impl-is-opaque.rs | 3 - .../in-trait/opaque-in-impl-is-opaque.stderr | 17 + tests/ui/impl-trait/in-trait/opaque-in-impl.rs | 2 - .../impl-trait/in-trait/outlives-in-nested-rpit.rs | 11 + .../return-dont-satisfy-bounds.current.stderr | 16 - .../return-dont-satisfy-bounds.next.stderr | 16 - .../in-trait/return-dont-satisfy-bounds.rs | 3 - .../in-trait/return-dont-satisfy-bounds.stderr | 16 + tests/ui/impl-trait/in-trait/reveal.rs | 2 - .../in-trait/rpitit-shadowed-by-missing-adt.rs | 18 + .../in-trait/rpitit-shadowed-by-missing-adt.stderr | 9 + .../in-trait/signature-mismatch.current.stderr | 61 -- .../in-trait/signature-mismatch.next.stderr | 61 -- tests/ui/impl-trait/in-trait/signature-mismatch.rs | 2 - .../impl-trait/in-trait/signature-mismatch.stderr | 61 ++ .../in-trait/specialization-broken.current.stderr | 31 - .../in-trait/specialization-broken.next.stderr | 31 - .../impl-trait/in-trait/specialization-broken.rs | 3 - .../in-trait/specialization-broken.stderr | 31 + .../in-trait/specialization-substs-remap.rs | 2 - tests/ui/impl-trait/in-trait/success.rs | 2 - .../trait-more-generics-than-impl.current.stderr | 12 - .../trait-more-generics-than-impl.next.stderr | 12 - .../in-trait/trait-more-generics-than-impl.rs | 3 - .../in-trait/trait-more-generics-than-impl.stderr | 12 + .../in-trait/unconstrained-lt.current.stderr | 9 - .../in-trait/unconstrained-lt.next.stderr | 9 - tests/ui/impl-trait/in-trait/unconstrained-lt.rs | 7 +- .../ui/impl-trait/in-trait/unconstrained-lt.stderr | 9 + tests/ui/impl-trait/in-trait/variances-of-gat.rs | 2 - .../impl-trait/in-trait/wf-bounds.current.stderr | 57 -- tests/ui/impl-trait/in-trait/wf-bounds.next.stderr | 57 -- tests/ui/impl-trait/in-trait/wf-bounds.rs | 2 - tests/ui/impl-trait/in-trait/wf-bounds.stderr | 53 ++ tests/ui/impl-trait/in-trait/where-clause.rs | 2 - tests/ui/impl-trait/issue-102605.stderr | 16 +- tests/ui/impl-trait/issue-99073-2.rs | 1 + tests/ui/impl-trait/issue-99073-2.stderr | 18 +- tests/ui/impl-trait/issue-99073.rs | 1 + tests/ui/impl-trait/issue-99073.stderr | 21 +- tests/ui/impl-trait/issues/issue-86800.rs | 2 +- .../ui/impl-trait/lifetime-ambiguity-regression.rs | 13 + .../mapping-duplicated-lifetimes-issue-114597.rs | 15 + tests/ui/impl-trait/nested-rpit-hrtb-2.rs | 9 + tests/ui/impl-trait/nested-rpit-hrtb-2.stderr | 12 + tests/ui/impl-trait/normalize-tait-in-const.rs | 5 - tests/ui/impl-trait/normalize-tait-in-const.stderr | 29 +- .../opaque-cast-field-access-in-future.rs | 27 + .../opaque-cast-field-access-in-future.stderr | 9 + tests/ui/impl-trait/recursive-auto-trait.rs | 10 + .../ui/impl-trait/rpit/equal-lifetime-params-ok.rs | 19 + tests/ui/impl-trait/rpit/non-defining-use.rs | 14 + tests/ui/impl-trait/rpit/non-defining-use.stderr | 31 + ...ied-bounds-entailment-wf-vars-issue-114783-1.rs | 26 + ...ied-bounds-entailment-wf-vars-issue-114783-2.rs | 26 + .../implied_bounds_entailment_alias_var.rs | 32 + .../implied_bounds_entailment_skip_non_outlives.rs | 23 + .../implied-bounds/trait-where-clause-implied.rs | 15 + tests/ui/imports/ambiguous-1.rs | 30 + tests/ui/imports/ambiguous-1.stderr | 36 + tests/ui/imports/ambiguous-10.rs | 19 + tests/ui/imports/ambiguous-10.stderr | 25 + tests/ui/imports/ambiguous-11.rs | 14 + tests/ui/imports/ambiguous-11.stderr | 23 + tests/ui/imports/ambiguous-12.rs | 25 + tests/ui/imports/ambiguous-12.stderr | 25 + tests/ui/imports/ambiguous-13.rs | 22 + tests/ui/imports/ambiguous-13.stderr | 25 + tests/ui/imports/ambiguous-14.rs | 26 + tests/ui/imports/ambiguous-14.stderr | 25 + tests/ui/imports/ambiguous-15.rs | 27 + tests/ui/imports/ambiguous-15.stderr | 25 + tests/ui/imports/ambiguous-16.rs | 27 + tests/ui/imports/ambiguous-16.stderr | 25 + tests/ui/imports/ambiguous-17.rs | 29 + tests/ui/imports/ambiguous-17.stderr | 35 + tests/ui/imports/ambiguous-2.rs | 9 + tests/ui/imports/ambiguous-3.rs | 21 + tests/ui/imports/ambiguous-3.stderr | 25 + tests/ui/imports/ambiguous-4-extern.rs | 26 + tests/ui/imports/ambiguous-4-extern.stderr | 35 + tests/ui/imports/ambiguous-4.rs | 9 + tests/ui/imports/ambiguous-5.rs | 24 + tests/ui/imports/ambiguous-5.stderr | 25 + tests/ui/imports/ambiguous-6.rs | 20 + tests/ui/imports/ambiguous-6.stderr | 25 + tests/ui/imports/ambiguous-7.rs | 18 + tests/ui/imports/ambiguous-7.stderr | 23 + tests/ui/imports/ambiguous-8.rs | 14 + tests/ui/imports/ambiguous-8.stderr | 23 + tests/ui/imports/ambiguous-9.rs | 29 + tests/ui/imports/ambiguous-9.stderr | 65 ++ tests/ui/imports/auxiliary/ambiguous-11-extern.rs | 6 + tests/ui/imports/auxiliary/ambiguous-8-extern.rs | 12 + .../auxiliary/extern-with-ambiguous-1-extern.rs | 4 + .../auxiliary/extern-with-ambiguous-2-extern.rs | 9 + .../auxiliary/extern-with-ambiguous-3-extern.rs | 14 + tests/ui/imports/duplicate.rs | 2 + tests/ui/imports/duplicate.stderr | 37 +- tests/ui/imports/extern-with-ambiguous-1.rs | 19 + tests/ui/imports/extern-with-ambiguous-1.stderr | 23 + tests/ui/imports/extern-with-ambiguous-2.rs | 16 + tests/ui/imports/extern-with-ambiguous-3.rs | 17 + tests/ui/imports/import-after-macro-expand-1.rs | 19 + tests/ui/imports/import-after-macro-expand-2.rs | 27 + tests/ui/imports/import-after-macro-expand-3.rs | 24 + tests/ui/imports/import-after-macro-expand-4.rs | 30 + .../ui/imports/import-after-macro-expand-4.stderr | 53 ++ tests/ui/imports/import-after-macro-expand-5.rs | 31 + tests/ui/imports/import-after-macro-expand-6.rs | 24 + tests/ui/imports/import-after-macro-expand-7.rs | 21 + tests/ui/imports/import-after-macro-expand-8.rs | 22 + tests/ui/imports/issue-113953.rs | 6 + tests/ui/imports/issue-113953.stderr | 9 + tests/ui/imports/issue-81413.rs | 23 + tests/ui/imports/issue-81413.stderr | 11 + tests/ui/imports/resolve-other-libc.rs | 14 + tests/ui/imports/resolve-other-libc.stderr | 8 + tests/ui/index-bot.rs | 3 - tests/ui/index-bot.stderr | 9 - tests/ui/index-help.rs | 4 - tests/ui/index-help.stderr | 13 - tests/ui/index_message.rs | 4 - tests/ui/index_message.stderr | 9 - tests/ui/indexing-requires-a-uint.rs | 14 - tests/ui/indexing-requires-a-uint.stderr | 32 - tests/ui/indexing/index-bot.rs | 3 + tests/ui/indexing/index-bot.stderr | 9 + tests/ui/indexing/index-help.rs | 4 + tests/ui/indexing/index-help.stderr | 13 + tests/ui/indexing/index_message.rs | 4 + tests/ui/indexing/index_message.stderr | 9 + tests/ui/indexing/indexing-requires-a-uint.rs | 14 + tests/ui/indexing/indexing-requires-a-uint.stderr | 32 + .../ui/indexing/indexing-spans-caller-location.rs | 27 + tests/ui/inference/issue-113354.fixed | 4 + tests/ui/inference/issue-113354.rs | 4 + tests/ui/inference/issue-113354.stderr | 14 + .../need_type_info/infer-var-for-self-param.rs | 7 + .../need_type_info/infer-var-for-self-param.stderr | 14 + ...3264-incorrect-impl-trait-in-path-suggestion.rs | 12 + ...-incorrect-impl-trait-in-path-suggestion.stderr | 14 + tests/ui/inference/str-as-char.fixed | 1 + tests/ui/inference/str-as-char.rs | 1 + tests/ui/inference/str-as-char.stderr | 13 +- tests/ui/inference/type-infer-generalize-ty-var.rs | 4 +- .../infinite/infinite-trait-alias-recursion.stderr | 1 + .../infinite-type-alias-mutual-recursion.stderr | 1 + .../ui/infinite/infinite-vec-type-recursion.stderr | 1 + .../inline-const/instance-doesnt-depend-on-type.rs | 10 + tests/ui/inline-const/interpolated.rs | 32 + tests/ui/inline-const/pat-match-fndef.rs | 13 + tests/ui/inline-const/pat-match-fndef.stderr | 17 + tests/ui/inline-const/required-const.rs | 13 + tests/ui/inline-const/required-const.stderr | 11 + tests/ui/internal/internal-unstable.rs | 2 - tests/ui/internal/internal-unstable.stderr | 10 +- .../const-eval-select-backtrace-std.run.stderr | 3 +- .../const-eval-select-backtrace.run.stderr | 3 +- tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs | 17 + .../intrinsics/intrinsic-raw_eq-const-bad.stderr | 15 + .../intrinsics/intrinsic-raw_eq-const-padding.rs | 10 - .../intrinsic-raw_eq-const-padding.stderr | 9 - tests/ui/invalid/issue-114435-layout-type-err.rs | 44 + .../ui/invalid/issue-114435-layout-type-err.stderr | 8 + tests/ui/issues/issue-100605.rs | 9 - tests/ui/issues/issue-100605.stderr | 45 - tests/ui/issues/issue-11515.rs | 10 - tests/ui/issues/issue-11515.stderr | 13 - tests/ui/issues/issue-11820.rs | 2 + tests/ui/issues/issue-13497-2.stderr | 12 +- tests/ui/issues/issue-17252.stderr | 1 + tests/ui/issues/issue-20413.stderr | 15 +- tests/ui/issues/issue-20772.stderr | 1 + tests/ui/issues/issue-21177.stderr | 1 + tests/ui/issues/issue-21600.stderr | 2 +- tests/ui/issues/issue-23122-2.stderr | 3 +- tests/ui/issues/issue-23302-1.stderr | 1 + tests/ui/issues/issue-23302-2.stderr | 1 + tests/ui/issues/issue-23302-3.stderr | 1 + tests/ui/issues/issue-27842.stderr | 12 +- tests/ui/issues/issue-34373.stderr | 1 + tests/ui/issues/issue-40861.stderr | 4 +- tests/ui/issues/issue-41726.stderr | 7 +- tests/ui/issues/issue-42106.stderr | 4 +- tests/ui/issues/issue-44405.stderr | 2 +- tests/ui/issues/issue-48364.stderr | 1 - ...sue-51632-try-desugar-incompatible-types.stderr | 2 + .../issues/issue-52126-assign-op-invariance.stderr | 2 +- tests/ui/issues/issue-61108.stderr | 2 +- tests/ui/issues/issue-81584.stderr | 2 +- tests/ui/issues/issue-83190.rs | 49 - tests/ui/issues/issue-87707.run.stderr | 6 +- tests/ui/layout/debug.stderr | 36 + tests/ui/layout/hexagon-enum.stderr | 20 + tests/ui/layout/issue-113941.rs | 13 + ...96158-scalarpair-payload-might-be-uninit.stderr | 34 + .../ui/layout/issue-96185-overaligned-enum.stderr | 24 + tests/ui/layout/malformed-unsized-type-in-union.rs | 8 + .../layout/malformed-unsized-type-in-union.stderr | 9 + tests/ui/layout/thumb-enum.stderr | 20 + tests/ui/layout/valid_range_oob.stderr | 1 + tests/ui/layout/zero-sized-array-enum-niche.stderr | 26 + tests/ui/lazy-type-alias/auxiliary/eager.rs | 6 + tests/ui/lazy-type-alias/auxiliary/lazy.rs | 4 + .../coerce-behind-lazy.current.stderr | 11 + .../lazy-type-alias/coerce-behind-lazy.next.stderr | 11 + tests/ui/lazy-type-alias/coerce-behind-lazy.rs | 16 + tests/ui/lazy-type-alias/enum-variant.rs | 18 + tests/ui/lazy-type-alias/enum-variant.stderr | 11 + .../extern-crate-has-eager-type-aliases.rs | 23 + ...rate-has-lazy-type-aliases.locally_eager.stderr | 15 + ...crate-has-lazy-type-aliases.locally_lazy.stderr | 15 + .../extern-crate-has-lazy-type-aliases.rs | 16 + .../ui/lazy-type-alias/leading-where-clause.fixed | 15 + tests/ui/lazy-type-alias/leading-where-clause.rs | 16 + .../ui/lazy-type-alias/leading-where-clause.stderr | 16 + tests/ui/lazy-type-alias/trailing-where-clause.rs | 13 + .../lazy-type-alias/trailing-where-clause.stderr | 22 + .../type-alias-bounds-are-enforced.rs | 14 + .../unsatisfied-bounds-type-alias-body.rs | 8 + .../unsatisfied-bounds-type-alias-body.stderr | 14 + tests/ui/lazy-type-alias/variance.rs | 38 + tests/ui/lexer/lex-emoji-identifiers.rs | 6 +- tests/ui/lexer/lex-emoji-identifiers.stderr | 34 +- tests/ui/lifetimes/borrowck-let-suggestion.stderr | 8 +- .../ex3-both-anon-regions-using-fn-items.stderr | 22 +- ...x3-both-anon-regions-using-trait-objects.stderr | 22 +- tests/ui/lifetimes/unusual-rib-combinations.stderr | 5 - tests/ui/limits/issue-17913.stderr | 1 + tests/ui/lint/clashing-extern-fn.stderr | 124 ++- .../allow-or-expect-dead_code-114557-2.rs | 19 + .../allow-or-expect-dead_code-114557-2.stderr | 10 + .../allow-or-expect-dead_code-114557-3.rs | 13 + .../allow-or-expect-dead_code-114557-3.stderr | 10 + .../dead-code/allow-or-expect-dead_code-114557.rs | 18 + tests/ui/lint/invalid-nan-comparison.stderr | 5 - tests/ui/lint/issue-111359.stderr | 16 +- tests/ui/lint/issue-1866.stderr | 4 +- tests/ui/lint/lint-attr-everywhere-late.stderr | 104 +- tests/ui/lint/lint-cap-trait-bounds.rs | 8 + tests/ui/lint/lint-missing-doc.stderr | 36 +- tests/ui/lint/lint-qualification.fixed | 21 + tests/ui/lint/lint-qualification.rs | 1 + tests/ui/lint/lint-qualification.stderr | 9 +- tests/ui/lint/lint-struct-necessary.rs | 31 + tests/ui/lint/lint-struct-necessary.stderr | 19 + tests/ui/lint/lint-unconditional-drop-recursion.rs | 38 + .../lint/lint-unconditional-drop-recursion.stderr | 17 + tests/ui/lint/lint-unconditional-recursion.stderr | 2 +- .../missing-copy-implementations-negative-copy.rs | 15 + tests/ui/lint/missing-doc-private-macro.stderr | 12 +- tests/ui/lint/noop-method-call.fixed | 51 + tests/ui/lint/noop-method-call.rs | 30 +- tests/ui/lint/noop-method-call.stderr | 64 +- tests/ui/lint/ptr_null_checks.rs | 76 ++ tests/ui/lint/ptr_null_checks.stderr | 225 +++++ tests/ui/lint/reference_casting.rs | 122 ++- tests/ui/lint/reference_casting.stderr | 162 +++- .../lint-confusable-idents.rs | 4 +- .../lint-confusable-idents.stderr | 12 +- tests/ui/lint/suspicious-double-ref-op.rs | 27 +- tests/ui/lint/suspicious-double-ref-op.stderr | 33 +- tests/ui/lint/unaligned_references.stderr | 2 +- .../ui/lint/unknown-lints/allow-in-other-module.rs | 26 + tests/ui/lint/unknown-lints/other.rs | 10 + tests/ui/lint/unused/const-local-var.rs | 23 + tests/ui/liveness/liveness-move-call-arg-2.rs | 12 + tests/ui/liveness/liveness-move-call-arg-2.stderr | 26 + tests/ui/lto/issue-100772.rs | 4 +- tests/ui/macros/assert-eq-macro-msg.rs | 6 +- tests/ui/macros/assert-eq-macro-panic.rs | 6 +- tests/ui/macros/assert-macro-explicit.rs | 2 +- tests/ui/macros/assert-macro-fmt.rs | 3 +- tests/ui/macros/assert-macro-owned.rs | 3 +- tests/ui/macros/assert-macro-static.rs | 3 +- tests/ui/macros/assert-matches-macro-msg.rs | 6 +- tests/ui/macros/assert-ne-macro-msg.rs | 6 +- tests/ui/macros/assert-ne-macro-panic.rs | 6 +- tests/ui/macros/builtin-env-issue-114010.rs | 10 + tests/ui/macros/builtin-env-issue-114010.stderr | 20 + .../ui/macros/builtin-prelude-no-accidents.stderr | 4 - .../macros/format-args-temporaries-in-write.stderr | 4 +- tests/ui/macros/issue-19163.stderr | 6 +- tests/ui/macros/macro-interpolation.rs | 4 +- tests/ui/macros/macro-interpolation.stderr | 16 + .../macros/rfc-3086-metavar-expr/issue-111904.rs | 14 + .../rfc-3086-metavar-expr/issue-111904.stderr | 19 + tests/ui/match/issue-114691.rs | 39 + tests/ui/match/issue-115681.rs | 32 + tests/ui/match/issue-74050-end-span.stderr | 2 +- ...-first-arm-doesnt-match-expected-return-type.rs | 21 + ...st-arm-doesnt-match-expected-return-type.stderr | 12 + tests/ui/methods/inherent-bound-in-probe.stderr | 3 +- tests/ui/methods/method-self-arg-2.stderr | 4 +- .../suggest-method-on-call-with-macro-rcvr.rs | 6 + .../suggest-method-on-call-with-macro-rcvr.stderr | 15 + tests/ui/mir/debug-ref-undef.rs | 57 ++ tests/ui/mir/validate/storage-live.stderr | 1 + .../closure-arg-type-mismatch-issue-45727.stderr | 4 +- .../closure-arg-type-mismatch.stderr | 2 +- tests/ui/mismatched_types/closure-ref-114180.rs | 8 + .../ui/mismatched_types/closure-ref-114180.stderr | 22 + tests/ui/mismatched_types/issue-36053-2.stderr | 2 +- .../ui/mismatched_types/ref-pat-suggestions.stderr | 44 +- .../suggest-option-asderef-inference-var.stderr | 2 +- .../mismatched_types/suggest-option-asderef.fixed | 2 +- .../ui/mismatched_types/suggest-option-asderef.rs | 2 +- .../mismatched_types/suggest-option-asderef.stderr | 2 +- tests/ui/missing_debug_impls.rs | 2 +- tests/ui/modules/issue-107649.stderr | 2 +- tests/ui/moves/move-fn-self-receiver.stderr | 8 +- .../moves-based-on-type-access-to-field.stderr | 2 +- tests/ui/moves/moves-based-on-type-exprs.stderr | 4 +- .../pin-mut-reborrow-infer-var-issue-107419.stderr | 2 +- tests/ui/moves/pin-mut-reborrow.stderr | 2 +- tests/ui/moves/suggest-clone.stderr | 7 +- .../use_of_moved_value_clone_suggestions.stderr | 2 +- tests/ui/mut/mut-cant-alias.stderr | 2 +- tests/ui/mut/mut-suggestion.stderr | 4 +- tests/ui/nll/closure-access-spans.stderr | 10 +- tests/ui/nll/closure-borrow-spans.stderr | 28 +- .../escape-argument-callee.stderr | 2 +- .../closure-requirements/escape-argument.stderr | 2 +- .../escape-upvar-nested.stderr | 4 +- .../closure-requirements/escape-upvar-ref.stderr | 2 +- .../propagate-approximated-fail-no-postdom.stderr | 2 +- .../propagate-approximated-ref.stderr | 2 +- ...shorter-to-static-comparing-against-free.stderr | 4 +- ...-approximated-shorter-to-static-no-bound.stderr | 2 +- ...proximated-shorter-to-static-wrong-bound.stderr | 2 +- .../propagate-approximated-val.stderr | 2 +- .../propagate-despite-same-free-region.stderr | 2 +- ...ate-fail-to-approximate-longer-no-bounds.stderr | 2 +- ...-fail-to-approximate-longer-wrong-bounds.stderr | 2 +- .../propagate-from-trait-match.stderr | 2 +- .../return-wrong-bound-region.stderr | 2 +- tests/ui/nll/closures-in-loops.stderr | 10 +- tests/ui/nll/get_default.stderr | 6 +- tests/ui/nll/guarantor-issue-46974.rs | 1 - tests/ui/nll/guarantor-issue-46974.stderr | 3 +- tests/ui/nll/issue-46589.stderr | 4 +- tests/ui/nll/issue-51191.stderr | 2 +- tests/ui/nll/issue-51345-2.rs | 3 +- tests/ui/nll/issue-52669.stderr | 2 +- tests/ui/nll/issue-53773.stderr | 4 +- tests/ui/nll/issue-54556-niconii.stderr | 2 +- tests/ui/nll/issue-62007-assign-const-index.stderr | 2 +- .../nll/issue-62007-assign-differing-fields.stderr | 2 +- tests/ui/nll/loan_ends_mid_block_vec.stderr | 6 +- .../polonius/assignment-to-differing-field.stderr | 4 +- tests/ui/nll/return_from_loop.stderr | 4 +- .../projection-no-regions-closure.stderr | 8 +- .../projection-one-region-closure.stderr | 8 +- ...rojection-one-region-trait-bound-closure.stderr | 10 +- ...on-one-region-trait-bound-static-closure.stderr | 10 +- ...rojection-two-region-trait-bound-closure.stderr | 16 +- ...ty-param-closure-approximate-lower-bound.stderr | 4 +- ...-param-closure-outlives-from-return-type.stderr | 2 +- ...param-closure-outlives-from-where-clause.stderr | 8 +- .../nll/user-annotations/dump-adt-brace-struct.rs | 2 +- .../user-annotations/dump-adt-brace-struct.stderr | 2 +- tests/ui/nll/user-annotations/dump-fn-method.rs | 2 +- .../ui/nll/user-annotations/dump-fn-method.stderr | 8 +- .../ui/numbers-arithmetic/apfloat-modulo-wrong.rs | 15 + tests/ui/numbers-arithmetic/overflowing-add.rs | 3 +- tests/ui/numbers-arithmetic/overflowing-mul.rs | 3 +- .../numbers-arithmetic/overflowing-neg-nonzero.rs | 2 +- tests/ui/numbers-arithmetic/overflowing-neg.rs | 2 +- .../numbers-arithmetic/overflowing-pow-signed.rs | 3 +- .../numbers-arithmetic/overflowing-pow-unsigned.rs | 3 +- tests/ui/numbers-arithmetic/overflowing-sub.rs | 3 +- tests/ui/object-safety/assoc_const_bounds.rs | 9 +- tests/ui/object-safety/assoc_const_bounds.stderr | 15 - tests/ui/object-safety/assoc_const_bounds_sized.rs | 9 +- .../object-safety/assoc_const_bounds_sized.stderr | 15 - .../object-safety-by-value-self-use.stderr | 2 +- tests/ui/or-patterns/missing-bindings.stderr | 68 +- tests/ui/panic-handler/weak-lang-item-2.rs | 12 +- tests/ui/panics/abort-on-panic.rs | 2 + tests/ui/panics/default-backtrace-ice.stderr | 1 + tests/ui/panics/fmt-only-once.run.stderr | 3 +- .../issue-47429-short-backtraces.legacy.run.stderr | 3 +- .../issue-47429-short-backtraces.v0.run.stderr | 3 +- .../location-detail-panic-no-column.run.stderr | 3 +- .../location-detail-panic-no-file.run.stderr | 3 +- .../location-detail-panic-no-line.run.stderr | 3 +- ...cation-detail-panic-no-location-info.run.stderr | 3 +- .../location-detail-unwrap-no-file.run.stderr | 3 +- tests/ui/panics/panic-macro-any-wrapped.rs | 3 +- tests/ui/panics/panic-macro-any.rs | 3 +- tests/ui/panics/panic-macro-explicit.rs | 3 +- tests/ui/panics/panic-macro-fmt.rs | 3 +- tests/ui/panics/panic-macro-owned.rs | 3 +- tests/ui/panics/panic-macro-static.rs | 3 +- tests/ui/panics/panic-set-unset-handler.rs | 3 +- tests/ui/panics/panic-take-handler-nop.rs | 3 +- tests/ui/panics/panic-task-name-none.rs | 3 +- tests/ui/panics/panic-task-name-owned.rs | 3 +- tests/ui/panics/runtime-switch.legacy.run.stderr | 3 +- tests/ui/panics/runtime-switch.v0.run.stderr | 3 +- .../short-ice-remove-middle-frames-2.run.stderr | 5 +- .../short-ice-remove-middle-frames.run.stderr | 4 +- tests/ui/parser/async-with-nonterminal-block.rs | 16 + tests/ui/parser/generic-statics.rs | 4 + tests/ui/parser/generic-statics.stderr | 8 + tests/ui/parser/issues/issue-113203.rs | 7 + tests/ui/parser/issues/issue-113203.stderr | 8 + tests/ui/parser/issues/issue-114219.rs | 4 + tests/ui/parser/issues/issue-114219.stderr | 8 + .../issue-115780-pat-lt-bracket-in-macro-call.rs | 21 + tests/ui/parser/issues/issue-22647.rs | 2 +- tests/ui/parser/issues/issue-22647.stderr | 9 +- tests/ui/parser/issues/issue-22712.rs | 2 +- tests/ui/parser/issues/issue-22712.stderr | 9 +- .../parser/issues/issue-70583-block-is-empty-2.rs | 8 +- .../issues/issue-70583-block-is-empty-2.stderr | 3 +- tests/ui/parser/macro/macro-expand-to-field.rs | 70 ++ tests/ui/parser/macro/macro-expand-to-field.stderr | 74 ++ tests/ui/parser/macro/macro-expand-to-match-arm.rs | 18 + .../parser/macro/macro-expand-to-match-arm.stderr | 10 + tests/ui/parser/pat-lt-bracket-3.rs | 3 +- tests/ui/parser/pat-lt-bracket-3.stderr | 9 +- tests/ui/parser/pat-lt-bracket-4.rs | 2 +- tests/ui/parser/pat-lt-bracket-4.stderr | 9 +- tests/ui/parser/ternary_operator.rs | 69 ++ tests/ui/parser/ternary_operator.stderr | 115 +++ tests/ui/parser/trait-object-delimiters.rs | 4 +- tests/ui/parser/trait-object-delimiters.stderr | 12 +- tests/ui/parser/try-with-nonterminal-block.rs | 19 + tests/ui/parser/type-alias-where-fixable.fixed | 28 - tests/ui/parser/type-alias-where-fixable.rs | 28 - tests/ui/parser/type-alias-where-fixable.stderr | 42 - tests/ui/parser/type-alias-where.rs | 11 - tests/ui/parser/type-alias-where.stderr | 18 - tests/ui/pattern/slice-array-infer.rs | 27 + tests/ui/pattern/slice-pattern-refutable.rs | 36 + tests/ui/pattern/slice-pattern-refutable.stderr | 40 + tests/ui/pattern/slice-patterns-ambiguity.rs | 47 + tests/ui/pattern/slice-patterns-ambiguity.stderr | 40 + tests/ui/pattern/slice-patterns-irrefutable.rs | 74 ++ tests/ui/pattern/slice-patterns-irrefutable.stderr | 14 + tests/ui/pattern/slice-patterns-nested.rs | 15 + .../lifetime_errors_on_promotion_misusage.stderr | 6 +- tests/ui/privacy/issue-113860-1.rs | 16 + tests/ui/privacy/issue-113860-1.stderr | 49 + tests/ui/privacy/issue-113860-2.rs | 16 + tests/ui/privacy/issue-113860-2.stderr | 49 + tests/ui/privacy/issue-113860.rs | 16 + tests/ui/privacy/issue-113860.stderr | 49 + tests/ui/privacy/privacy2.rs | 2 + tests/ui/privacy/privacy2.stderr | 8 +- tests/ui/privacy/privacy3.rs | 2 + tests/ui/privacy/privacy3.stderr | 2 +- .../sealed-traits/sealed-trait-local.stderr | 2 +- tests/ui/privacy/unnameable_types.rs | 4 +- tests/ui/privacy/unnameable_types.stderr | 14 +- tests/ui/proc-macro/allowed-attr-stmt-expr.stdout | 12 +- tests/ui/proc-macro/attr-stmt-expr.stdout | 12 +- tests/ui/proc-macro/auxiliary/issue-107113.rs | 13 + .../proc-macro/capture-macro-rules-invoke.stdout | 42 +- tests/ui/proc-macro/capture-unglued-token.stdout | 2 +- tests/ui/proc-macro/derive-helper-shadowed.rs | 2 +- tests/ui/proc-macro/derive-in-mod.rs | 2 +- .../ui/proc-macro/dollar-crate-issue-57089.stdout | 32 +- .../ui/proc-macro/dollar-crate-issue-62325.stdout | 44 +- tests/ui/proc-macro/dollar-crate.stdout | 96 +- tests/ui/proc-macro/edition-imports-2018.rs | 2 +- tests/ui/proc-macro/expand-to-derive.stdout | 20 +- .../proc-macro/expr-stmt-nonterminal-tokens.stdout | 166 ++-- .../extern-prelude-extern-crate-proc-macro.rs | 2 +- .../ui/proc-macro/helper-attr-blocked-by-import.rs | 2 +- tests/ui/proc-macro/input-interpolated.stdout | 16 +- tests/ui/proc-macro/issue-107113-wrap.rs | 8 + tests/ui/proc-macro/issue-107113-wrap.stderr | 16 + tests/ui/proc-macro/issue-53481.rs | 2 +- tests/ui/proc-macro/issue-75734-pp-paren.stdout | 6 +- .../issue-78675-captured-inner-attrs.stdout | 14 +- tests/ui/proc-macro/issue-80760-empty-stmt.stdout | 2 +- tests/ui/proc-macro/load-panic-backtrace.stderr | 3 +- tests/ui/proc-macro/macro-rules-derive-cfg.stdout | 38 +- tests/ui/proc-macro/macro-use-attr.rs | 2 +- tests/ui/proc-macro/macro-use-bang.rs | 2 +- tests/ui/proc-macro/meta-macro-hygiene.rs | 4 +- tests/ui/proc-macro/meta-macro-hygiene.stdout | 33 +- tests/ui/proc-macro/meta-macro.stdout | 2 +- tests/ui/proc-macro/nested-macro-rules.stdout | 16 +- .../ui/proc-macro/nested-nonterminal-tokens.stdout | 18 +- tests/ui/proc-macro/nodelim-groups.stdout | 30 +- tests/ui/proc-macro/nonterminal-expansion.stdout | 10 +- .../proc-macro/nonterminal-recollect-attr.stdout | 24 +- tests/ui/proc-macro/nonterminal-token-hygiene.rs | 3 +- .../ui/proc-macro/nonterminal-token-hygiene.stdout | 36 +- tests/ui/process/multi-panic.rs | 4 +- tests/ui/process/println-with-broken-pipe.rs | 44 + .../ui/process/println-with-broken-pipe.run.stderr | 3 + .../ui/process/println-with-broken-pipe.run.stdout | 1 + .../issue-26548-recursion-via-normalize.rs | 1 + .../issue-26548-recursion-via-normalize.stderr | 1 + tests/ui/recursion/issue-83150.stderr | 3 +- .../recursion/recursive-static-definition.stderr | 1 + tests/ui/regions/higher-ranked-implied.stderr | 8 +- tests/ui/regions/issue-102374.stderr | 3 +- ...gion-lifetime-bounds-on-fns-where-clause.stderr | 4 +- ...iple-lifetime-bounds-on-fns-where-clause.stderr | 4 +- tests/ui/regions/region-object-lifetime-5.rs | 2 +- tests/ui/regions/region-object-lifetime-5.stderr | 7 +- .../regions/regions-lifetime-bounds-on-fns.stderr | 4 +- tests/ui/repr/repr-transparent.stderr | 8 +- tests/ui/resolve/112590-2.fixed | 34 + tests/ui/resolve/112590-2.rs | 26 + tests/ui/resolve/112590-2.stderr | 71 ++ tests/ui/resolve/bad-expr-path.stderr | 12 +- tests/ui/resolve/bad-expr-path2.stderr | 12 +- tests/ui/resolve/derive-macro-1.rs | 18 + tests/ui/resolve/derive-macro-2.rs | 18 + .../ui/resolve/export-fully-qualified-2018.stderr | 5 - tests/ui/resolve/export-fully-qualified.stderr | 5 - tests/ui/resolve/issue-112831.rs | 20 - ...-invalid-unused-qualifications-suggestion.fixed | 31 + ...808-invalid-unused-qualifications-suggestion.rs | 31 + ...invalid-unused-qualifications-suggestion.stderr | 31 + ...433-invalid-unused-qualifications-suggestion.rs | 10 + tests/ui/resolve/issue-2356.stderr | 21 +- tests/ui/resolve/resolve-inconsistent-names.stderr | 18 +- tests/ui/resolve/resolve-self-in-impl.stderr | 1 + tests/ui/resolve/unresolved-segments-visibility.rs | 11 + .../resolve/unresolved-segments-visibility.stderr | 9 + .../resolve/unused-qualifications-suggestion.fixed | 23 + .../ui/resolve/unused-qualifications-suggestion.rs | 23 + .../unused-qualifications-suggestion.stderr | 31 + tests/ui/return/return-struct.rs | 24 + tests/ui/return/return-struct.stderr | 35 + .../rfc-1937-termination-trait/issue-103052-2.rs | 3 - .../issue-103052-2.stderr | 15 + .../borrowck-issue-49631.stderr | 2 +- .../manual-self-impl-for-unsafe-obj.rs | 2 + .../issue-108655-inline-always-closure.rs | 18 + tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs | 4 + .../rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr | 3 +- .../multiple-declarations.stderr | 2 +- .../rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr | 2 +- .../assoc-type-const-bound-usage.rs | 5 +- .../assoc-type-const-bound-usage.stderr | 14 + .../auxiliary/cross-crate.rs | 2 +- .../auxiliary/staged-api.rs | 2 +- .../call-const-trait-method-fail.rs | 2 +- .../call-const-trait-method-fail.stderr | 8 +- .../call-const-trait-method-pass.stderr | 28 +- .../call-generic-method-chain.stderr | 11 +- .../call-generic-method-dup-bound.stderr | 11 +- .../call-generic-method-fail.rs | 5 +- .../call-generic-method-fail.stderr | 28 - .../call-generic-method-nonconst.rs | 5 +- .../call-generic-method-nonconst.stderr | 15 - .../call-generic-method-pass.stderr | 11 +- .../const-and-non-const-impl.stderr | 27 +- .../const-check-fns-in-const-impl.rs | 2 +- .../const-closure-trait-method-fail.stderr | 19 +- .../const-closure-trait-method.rs | 3 +- .../const-closure-trait-method.stderr | 15 + .../rfc-2632-const-trait-impl/const-closures.rs | 3 +- .../const-closures.stderr | 39 + .../const-default-method-bodies.rs | 2 +- .../const-default-method-bodies.stderr | 8 +- .../rfc-2632-const-trait-impl/const-drop-bound.rs | 3 +- .../const-drop-bound.stderr | 9 + .../rfc-2632-const-trait-impl/const-drop-fail-2.rs | 7 +- .../const-drop-fail-2.stderr | 55 +- .../const-drop-fail.precise.stderr | 61 +- .../const-drop-fail.stock.stderr | 63 +- .../const-drop.precise.stderr | 19 + .../rfcs/rfc-2632-const-trait-impl/const-drop.rs | 7 +- .../const-drop.stock.stderr | 19 + .../const-impl-requires-const-trait.rs | 8 +- .../const-impl-requires-const-trait.stderr | 2 +- .../const_derives/derive-const-gate.rs | 1 - .../const_derives/derive-const-gate.stderr | 12 +- .../const_derives/derive-const-non-const-type.rs | 2 +- .../const_derives/derive-const-use.stderr | 40 +- .../const_derives/derive-const-with-params.stderr | 12 +- .../cross-crate.gatednc.stderr | 8 +- .../rfcs/rfc-2632-const-trait-impl/cross-crate.rs | 5 +- .../cross-crate.stocknc.stderr | 22 +- .../default-method-body-is-const-body-checking.rs | 5 +- ...fault-method-body-is-const-body-checking.stderr | 15 - .../default-method-body-is-const-same-trait-ck.rs | 2 +- ...fault-method-body-is-const-same-trait-ck.stderr | 8 +- .../do-not-const-check-override.rs | 2 +- .../effects/helloworld.rs | 6 +- .../rfc-2632-const-trait-impl/generic-bound.stderr | 17 +- .../rfc-2632-const-trait-impl/hir-const-check.rs | 2 +- .../rfcs/rfc-2632-const-trait-impl/issue-102985.rs | 7 +- .../rfc-2632-const-trait-impl/issue-102985.stderr | 36 +- .../rfcs/rfc-2632-const-trait-impl/issue-88155.rs | 6 +- .../rfc-2632-const-trait-impl/issue-88155.stderr | 19 +- .../rfcs/rfc-2632-const-trait-impl/issue-92111.rs | 3 +- .../rfc-2632-const-trait-impl/issue-92111.stderr | 11 + .../match-non-const-eq.gated.stderr | 22 +- .../match-non-const-eq.rs | 5 +- .../match-non-const-eq.stock.stderr | 4 +- ...st-default-bound-non-const-specialized-bound.rs | 6 +- ...efault-bound-non-const-specialized-bound.stderr | 18 - .../const-default-const-specialized.rs | 2 +- ...onst-default-impl-non-const-specialized-impl.rs | 2 +- .../non-const-default-const-specialized.rs | 6 +- .../non-const-default-const-specialized.stderr | 12 + .../specializing-constness-2.rs | 4 +- .../specializing-constness-2.stderr | 18 +- .../specializing-constness.rs | 4 +- .../specializing-constness.stderr | 8 +- .../rfcs/rfc-2632-const-trait-impl/staged-api.rs | 2 +- .../super-traits-fail-2.rs | 8 +- .../super-traits-fail-2.yn.stderr | 16 +- .../super-traits-fail-2.yy.stderr | 16 +- .../super-traits-fail-3.nn.stderr | 6 +- .../super-traits-fail-3.ny.stderr | 4 +- .../super-traits-fail-3.rs | 3 +- .../super-traits-fail-3.yn.stderr | 2 +- .../super-traits-fail-3.yy.stderr | 11 + .../rfc-2632-const-trait-impl/super-traits-fail.rs | 5 +- .../super-traits-fail.stderr | 20 - .../rfcs/rfc-2632-const-trait-impl/super-traits.rs | 2 +- .../tilde-const-and-const-params.rs | 10 +- .../tilde-const-and-const-params.stderr | 25 +- .../tilde_const_on_impl_bound.rs | 5 +- .../tilde_const_on_impl_bound.stderr | 12 + .../trait-default-body-stability.stderr | 33 +- .../trait-where-clause-const.rs | 8 +- .../trait-where-clause-const.stderr | 32 +- .../trait-where-clause-run.rs | 2 +- .../trait-where-clause-self-referential.rs | 2 +- .../rfc-3348-c-string-literals/auxiliary/count.rs | 14 + tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs | 3 +- .../rfcs/rfc-3348-c-string-literals/basic.stderr | 25 - .../rfc-3348-c-string-literals/edition-spans.rs | 16 + .../ui/rfcs/rfc-3348-c-string-literals/gate.stderr | 31 +- .../ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs | Bin 760 -> 623 bytes .../rfcs/rfc-3348-c-string-literals/no-nuls.stderr | Bin 4477 -> 674 bytes .../rfcs/rfc-3348-c-string-literals/non-ascii.rs | 3 +- .../rfc-3348-c-string-literals/non-ascii.stderr | 38 - tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs | 8 - tests/ui/rmeta/auxiliary/rmeta-rmeta.rs | 9 - tests/ui/rmeta/rmeta-rpass.rs | 18 - tests/ui/sanitize/address.rs | 3 +- tests/ui/sanitize/badfree.rs | 1 + .../ui/sanitize/issue-111184-generator-witness.rs | 4 +- .../issue-114275-cfi-const-expr-in-arry-len.rs | 15 + tests/ui/sanitize/issue-72154-lifetime-markers.rs | 1 + .../ui/sanitize/new-llvm-pass-manager-thin-lto.rs | 1 + tests/ui/sanitize/sanitizer-cfi-requires-lto.rs | 2 +- .../ui/sanitize/sanitizer-cfi-requires-lto.stderr | 2 +- ...-with-rustc-lto-requires-single-codegen-unit.rs | 8 + ...h-rustc-lto-requires-single-codegen-unit.stderr | 4 + tests/ui/sanitize/use-after-scope.rs | 1 + .../ui/self/arbitrary_self_type_mut_difference.rs | 13 + .../self/arbitrary_self_type_mut_difference.stderr | 27 + ...ry_self_types_needing_box_or_arc_wrapping.fixed | 17 + ...trary_self_types_needing_box_or_arc_wrapping.rs | 17 + ...y_self_types_needing_box_or_arc_wrapping.stderr | 43 + .../arbitrary_self_types_needing_mut_pin.fixed | 12 + .../self/arbitrary_self_types_needing_mut_pin.rs | 12 + .../arbitrary_self_types_needing_mut_pin.stderr | 20 + .../arbitrary_self_types_pin_needing_borrow.rs | 13 + .../arbitrary_self_types_pin_needing_borrow.stderr | 33 + tests/ui/simd/intrinsic/float-minmax-pass.rs | 2 +- tests/ui/simd/intrinsic/generic-arithmetic-2.rs | 28 + .../ui/simd/intrinsic/generic-arithmetic-2.stderr | 80 +- tests/ui/simd/intrinsic/generic-arithmetic-pass.rs | 35 +- tests/ui/simd/intrinsic/generic-bswap-byte.rs | 22 + tests/ui/simd/intrinsic/generic-elements-pass.rs | 22 +- tests/ui/simd/intrinsic/generic-elements.rs | 22 +- tests/ui/simd/intrinsic/generic-elements.stderr | 74 +- tests/ui/simd/intrinsic/inlining-issue67557-ice.rs | 4 +- tests/ui/simd/intrinsic/inlining-issue67557.rs | 6 +- tests/ui/simd/shuffle-not-out-of-bounds.rs | 31 +- tests/ui/simd/shuffle-not-out-of-bounds.stderr | 50 +- tests/ui/simd/shuffle.rs | 3 +- tests/ui/sized/recursive-type-2.stderr | 1 + ...orrowck-borrow-overloaded-auto-deref-mut.stderr | 8 +- .../borrowck-call-is-borrow-issue-12224.stderr | 2 +- .../borrowck-call-method-from-mut-aliasable.stderr | 2 +- tests/ui/span/borrowck-fn-in-const-b.stderr | 2 +- .../span/borrowck-let-suggestion-suffixes.stderr | 2 +- tests/ui/span/borrowck-object-mutability.stderr | 4 +- tests/ui/span/destructor-restrictions.stderr | 2 +- ...ue-23338-locals-die-before-temps-of-body.stderr | 4 +- tests/ui/span/issue-36537.stderr | 2 +- tests/ui/span/issue-39698.stderr | 20 +- tests/ui/span/issue-40157.stderr | 2 +- tests/ui/span/mut-arg-hint.stderr | 6 +- tests/ui/span/mut-ptr-cant-outlive-ref.stderr | 2 +- .../span/regionck-unboxed-closure-lifetimes.stderr | 2 +- tests/ui/span/regions-escape-loop-via-vec.stderr | 10 +- tests/ui/span/send-is-not-static-std-sync.stderr | 10 +- tests/ui/span/slice-borrow.stderr | 2 +- tests/ui/span/suggestion-non-ascii.stderr | 4 +- tests/ui/span/visibility-ty-params.rs | 2 +- tests/ui/span/visibility-ty-params.stderr | 6 +- .../min_specialization/issue-79224.stderr | 4 +- .../stability-attribute/missing-const-stability.rs | 2 +- tests/ui/std/issue-15149.rs | 57 -- tests/ui/std/switch-stdout.rs | 52 - tests/ui/suggestions/copied-and-cloned.fixed | 34 + tests/ui/suggestions/copied-and-cloned.rs | 34 + tests/ui/suggestions/copied-and-cloned.stderr | 64 +- tests/ui/suggestions/crate-or-module-typo.stderr | 16 +- ...plicit-static-bound-needing-more-suggestions.rs | 2 +- ...it-static-bound-needing-more-suggestions.stderr | 21 +- tests/ui/suggestions/issue-102972.stderr | 9 +- tests/ui/suggestions/issue-114701.rs | 15 + tests/ui/suggestions/issue-114701.stderr | 15 + .../issue-114797-bad-parentheses-dyn-trait.fixed | 17 + .../issue-114797-bad-parentheses-dyn-trait.rs | 17 + .../issue-114797-bad-parentheses-dyn-trait.stderr | 38 + ...missing-semicolon-between-call-and-tuple.stderr | 2 +- .../late-bound-in-borrow-closure-sugg.stderr | 2 +- ...ing-lifetime-in-assoc-const-type.default.stderr | 57 ++ ...-in-assoc-const-type.generic_const_items.stderr | 47 + .../missing-lifetime-in-assoc-const-type.rs | 4 + .../missing-lifetime-in-assoc-const-type.stderr | 57 -- tests/ui/suggestions/missing-semicolon.fixed | 38 + tests/ui/suggestions/missing-semicolon.rs | 38 + tests/ui/suggestions/missing-semicolon.stderr | 75 ++ tests/ui/suggestions/option-content-move.stderr | 4 +- .../remove-question-symbol-with-paren.rs | 9 + .../remove-question-symbol-with-paren.stderr | 25 + .../suggest-mut-method-for-loop-closure.rs | 19 + .../suggest-mut-method-for-loop-closure.stderr | 15 + tests/ui/target-feature/gate.rs | 16 +- tests/ui/target-feature/gate.stderr | 2 +- tests/ui/target-feature/invalid-attribute.rs | 14 +- tests/ui/target-feature/invalid-attribute.stderr | 44 +- .../test-panic-abort-nocapture.run.stderr | 14 +- tests/ui/test-attrs/test-panic-abort.run.stdout | 7 +- tests/ui/test-attrs/test-thread-capture.run.stdout | 3 +- .../ui/test-attrs/test-thread-nocapture.run.stderr | 3 +- tests/ui/thir-print/thir-flat-const-variant.stdout | 8 +- tests/ui/thir-print/thir-tree-match.stdout | 8 +- tests/ui/threads-sendsync/issue-24313.rs | 2 +- .../traits/dont-autoderef-ty-with-escaping-var.rs | 22 + .../dont-autoderef-ty-with-escaping-var.stderr | 27 + tests/ui/traits/issue-105231.rs | 2 +- tests/ui/traits/issue-105231.stderr | 8 +- tests/ui/traits/issue-24010.rs | 2 + .../traits/issue-91949-hangs-on-recursion.stderr | 3 +- .../ui/traits/new-solver/alias-bound-preference.rs | 39 + tests/ui/traits/new-solver/alias-bound-unsound.rs | 9 +- .../traits/new-solver/alias-bound-unsound.stderr | 65 +- .../assemble-normalizing-self-ty-impl-ambiguity.rs | 27 + .../assembly/runaway-impl-candidate-selection.rs | 15 + .../runaway-impl-candidate-selection.stderr | 9 + .../trait_ref_is_knowable-norm-overflow.rs | 20 + .../trait_ref_is_knowable-norm-overflow.stderr | 12 + .../trait_ref_is_knowable-normalization-1.rs | 22 + .../trait_ref_is_knowable-normalization-2.rs | 25 + .../trait_ref_is_knowable-normalization-3.rs | 24 + .../coinduction/fixpoint-exponential-growth.rs | 32 + .../coinduction/fixpoint-exponential-growth.stderr | 23 + .../coinduction/incompleteness-unstable-result.rs | 69 ++ .../incompleteness-unstable-result.stderr | 16 + .../cycles/double-cycle-inductive-coinductive.rs | 37 + .../double-cycle-inductive-coinductive.stderr | 29 + .../new-solver/cycles/inductive-cycle-but-err.rs | 48 + .../cycles/inductive-cycle-but-err.stderr | 16 + .../new-solver/cycles/inductive-cycle-but-ok.rs | 44 + ...tive-cycle-discarded-coinductive-constraints.rs | 36 + .../new-solver/cycles/inductive-not-on-stack.rs | 46 + .../cycles/inductive-not-on-stack.stderr | 16 + .../cycles/leak-check-coinductive-cycle.rs | 33 + .../new-solver/cycles/provisional-result-done.rs | 33 + .../traits/new-solver/dont-coerce-infer-to-dyn.rs | 17 + .../dont-loop-fulfill-on-region-constraints.rs | 32 + .../new-solver/dont-normalize-proj-with-error.rs | 22 + .../dont-normalize-proj-with-error.stderr | 9 + .../traits/new-solver/dyn-any-dont-prefer-impl.rs | 4 + ...caping-bound-vars-in-writeback-normalization.rs | 18 + .../traits/new-solver/exponential-trait-goals.rs | 20 - .../new-solver/exponential-trait-goals.stderr | 23 - .../generalize-proj-new-universe-index-1.rs | 73 ++ .../generalize-proj-new-universe-index-2.rs | 75 ++ .../generalize-proj-new-universe-index-2.stderr | 9 + .../traits/new-solver/lazy-nested-obligations-2.rs | 2 +- .../new-solver/lazy-nested-obligations-2.stderr | 39 - .../new-solver/leak-check-coinductive-cycle.rs | 33 - .../ui/traits/new-solver/more-object-bound.stderr | 4 +- tests/ui/traits/new-solver/normalize-unsize-rhs.rs | 23 + .../object-soundness-requires-generalization.rs | 20 + .../new-solver/overflow/exponential-trait-goals.rs | 20 + .../overflow/exponential-trait-goals.stderr | 23 + .../ui/traits/new-solver/overflow/global-cache.rs | 23 + .../traits/new-solver/overflow/global-cache.stderr | 16 + .../overflow/recursive-self-normalization-2.rs | 20 + .../overflow/recursive-self-normalization-2.stderr | 20 + .../overflow/recursive-self-normalization.rs | 16 + .../overflow/recursive-self-normalization.stderr | 20 + .../traits/new-solver/provisional-result-done.rs | 33 - .../new-solver/recursive-self-normalization-2.rs | 20 - .../recursive-self-normalization-2.stderr | 20 - .../new-solver/recursive-self-normalization.rs | 16 - .../new-solver/recursive-self-normalization.stderr | 20 - .../new-solver/runaway-impl-candidate-selection.rs | 15 - .../runaway-impl-candidate-selection.stderr | 9 - .../trait-upcast-lhs-needs-normalization.rs | 20 + .../traits/new-solver/unsize-although-ambiguous.rs | 13 + .../sized-late-bound-issue-114872.rs | 19 + .../sized-late-bound-issue-114872.stderr | 11 + tests/ui/traits/object/print_vtable_sizes.rs | 5 +- tests/ui/traits/object/print_vtable_sizes.stdout | 2 +- .../cycle-via-builtin-auto-trait-impl.rs | 2 +- .../cycle-via-builtin-auto-trait-impl.stderr | 8 +- .../trait-upcasting/cyclic-trait-resolution.stderr | 1 + .../ui/traits/trait-upcasting/fewer-associated.rs | 25 + .../illegal-upcast-from-impl.current.stderr | 14 + .../illegal-upcast-from-impl.next.stderr | 14 + .../trait-upcasting/illegal-upcast-from-impl.rs | 23 + .../trait-upcasting/issue-11515.current.stderr | 13 + .../traits/trait-upcasting/issue-11515.next.stderr | 13 + tests/ui/traits/trait-upcasting/issue-11515.rs | 11 + tests/ui/traits/trait-upcasting/normalization.rs | 20 + .../type-checking-test-1.current.stderr | 9 + .../type-checking-test-1.next.stderr | 9 + .../traits/trait-upcasting/type-checking-test-1.rs | 4 +- .../trait-upcasting/type-checking-test-1.stderr | 23 - .../traits/trait-upcasting/type-checking-test-2.rs | 2 - .../trait-upcasting/type-checking-test-2.stderr | 37 +- .../upcast-through-struct-tail.current.stderr | 13 + .../upcast-through-struct-tail.next.stderr | 13 + .../trait-upcasting/upcast-through-struct-tail.rs | 14 + tests/ui/traits/vtable/multiple-markers.rs | 47 + tests/ui/traits/vtable/multiple-markers.stderr | 52 + tests/ui/transmutability/issue-110892.rs | 40 + tests/ui/transmutability/issue-110892.stderr | 36 + .../recursive-wrapper-types-bit-compatible.rs | 5 +- .../recursive-wrapper-types-bit-compatible.stderr | 25 - .../references/recursive-wrapper-types.rs | 5 +- .../references/recursive-wrapper-types.stderr | 25 - tests/ui/treat-err-as-bug/delay_span_bug.rs | 2 +- tests/ui/treat-err-as-bug/err.rs | 2 +- .../self-in-enum-definition.stderr | 1 + .../auto-trait-leakage3.stderr | 2 + tests/ui/type-alias-impl-trait/broken_mir.rs | 16 + tests/ui/type-alias-impl-trait/coherence.rs | 2 +- tests/ui/type-alias-impl-trait/coherence.stderr | 8 +- .../coherence_generalization.rs | 5 +- .../type-alias-impl-trait/hidden_type_mismatch.rs | 57 ++ .../hidden_type_mismatch.stderr | 14 + .../type-alias-impl-trait/inference-cycle.stderr | 2 + .../ui/type-alias-impl-trait/issue-53092-2.stderr | 1 + .../issue-96572-unconstrained.rs | 2 + .../nested-rpit-with-lifetimes.rs | 49 + tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs | 15 + .../type-alias-impl-trait/nested-tait-hrtb.stderr | 23 + .../recursive-tait-conflicting-defn-2.rs | 21 + .../recursive-tait-conflicting-defn-2.stderr | 14 + .../recursive-tait-conflicting-defn.rs | 34 + .../recursive-tait-conflicting-defn.stderr | 14 + tests/ui/type-alias-impl-trait/reveal_local.stderr | 3 + .../unconstrained-impl-param.rs | 25 + .../unconstrained-impl-param.stderr | 9 + tests/ui/type-alias-impl-trait/under-binder.rs | 9 + tests/ui/type-alias-impl-trait/under-binder.stderr | 12 + .../wf-check-rpit-lifetimes.rs | 19 + tests/ui/type/option-ref-advice.rs | 11 + tests/ui/type/option-ref-advice.stderr | 45 + tests/ui/typeck/apit-with-error-type-in-sig.rs | 8 + tests/ui/typeck/apit-with-error-type-in-sig.stderr | 9 + tests/ui/typeck/explain_clone_autoref.rs | 116 +++ tests/ui/typeck/explain_clone_autoref.stderr | 215 ++++- ...sue-110017-format-into-help-deletes-macro.fixed | 55 ++ .../issue-110017-format-into-help-deletes-macro.rs | 55 ++ ...ue-110017-format-into-help-deletes-macro.stderr | 59 ++ ...sue-112007-leaked-writeln-macro-internals.fixed | 37 + .../issue-112007-leaked-writeln-macro-internals.rs | 37 + ...ue-112007-leaked-writeln-macro-internals.stderr | 50 + .../issue-112252-ptr-arithmetics-help.stderr | 4 +- .../issue-114423-ice-regression-in-suggestion.rs | 15 + ...ssue-114423-ice-regression-in-suggestion.stderr | 52 + tests/ui/typeck/mismatched-map-under-self.rs | 17 + tests/ui/typeck/mismatched-map-under-self.stderr | 37 + tests/ui/underscore-imports/cycle.rs | 2 + tests/ui/underscore-imports/hygiene.rs | 1 + tests/ui/unop-move-semantics.stderr | 2 +- tests/ui/unpretty/avoid-crash.stderr | 2 +- .../unsafe/unsafe-not-inherited.mirunsafeck.stderr | 24 + tests/ui/unsafe/unsafe-not-inherited.rs | 2 + tests/ui/unsafe/unsafe-not-inherited.stderr | 24 - .../unsafe-not-inherited.thirunsafeck.stderr | 24 + tests/ui/unsized/issue-75899.rs | 2 + .../use-after-move-implicity-coerced-object.stderr | 2 +- tests/ui/use/use-self-type.stderr | 4 +- .../where-clause-bounds-inconsistency.rs | 1 - ...where-clause-placement-assoc-type-in-impl.fixed | 28 + .../where-clause-placement-assoc-type-in-impl.rs | 28 + ...here-clause-placement-assoc-type-in-impl.stderr | 42 + ...here-clause-placement-assoc-type-in-trait.fixed | 15 + .../where-clause-placement-assoc-type-in-trait.rs | 15 + ...ere-clause-placement-assoc-type-in-trait.stderr | 29 + .../where-clause-placement-type-alias.rs | 11 + .../where-clause-placement-type-alias.stderr | 20 + 2095 files changed, 29667 insertions(+), 15513 deletions(-) create mode 100644 tests/assembly/wasm_exceptions.rs create mode 100644 tests/codegen/aarch64-struct-align-128.rs create mode 100644 tests/codegen/align-byval-vector.rs create mode 100644 tests/codegen/align-byval.rs delete mode 100644 tests/codegen/box-maybe-uninit-llvm14.rs delete mode 100644 tests/codegen/c-variadic-copy.rs delete mode 100644 tests/codegen/c-variadic-opt.rs delete mode 100644 tests/codegen/c-variadic.rs create mode 100644 tests/codegen/cffi/c-variadic-copy.rs create mode 100644 tests/codegen/cffi/c-variadic-opt.rs create mode 100644 tests/codegen/cffi/c-variadic.rs create mode 100644 tests/codegen/cffi/ffi-const.rs create mode 100644 tests/codegen/cffi/ffi-out-of-bounds-loads.rs create mode 100644 tests/codegen/cffi/ffi-pure.rs create mode 100644 tests/codegen/cffi/ffi-returns-twice.rs delete mode 100644 tests/codegen/enum-bounds-check-derived-idx.rs delete mode 100644 tests/codegen/enum-bounds-check-issue-13926.rs delete mode 100644 tests/codegen/enum-bounds-check-issue-82871.rs delete mode 100644 tests/codegen/enum-bounds-check.rs delete mode 100644 tests/codegen/enum-debug-clike.rs delete mode 100644 tests/codegen/enum-debug-niche-2.rs delete mode 100644 tests/codegen/enum-debug-niche.rs delete mode 100644 tests/codegen/enum-debug-tagged.rs delete mode 100644 tests/codegen/enum-discriminant-value.rs delete mode 100644 tests/codegen/enum-match.rs delete mode 100644 tests/codegen/enum-u128.rs create mode 100644 tests/codegen/enum/enum-bounds-check-derived-idx.rs create mode 100644 tests/codegen/enum/enum-bounds-check-issue-13926.rs create mode 100644 tests/codegen/enum/enum-bounds-check-issue-82871.rs create mode 100644 tests/codegen/enum/enum-bounds-check.rs create mode 100644 tests/codegen/enum/enum-debug-clike.rs create mode 100644 tests/codegen/enum/enum-debug-niche-2.rs create mode 100644 tests/codegen/enum/enum-debug-niche.rs create mode 100644 tests/codegen/enum/enum-debug-tagged.rs create mode 100644 tests/codegen/enum/enum-discriminant-value.rs create mode 100644 tests/codegen/enum/enum-match.rs create mode 100644 tests/codegen/enum/enum-u128.rs delete mode 100644 tests/codegen/ffi-const.rs delete mode 100644 tests/codegen/ffi-out-of-bounds-loads.rs delete mode 100644 tests/codegen/ffi-pure.rs delete mode 100644 tests/codegen/ffi-returns-twice.rs delete mode 100644 tests/codegen/i686-macosx-deployment-target.rs delete mode 100644 tests/codegen/i686-no-macosx-deployment-target.rs create mode 100644 tests/codegen/intrinsics/compare_bytes.rs create mode 100644 tests/codegen/llvm-ident.rs create mode 100644 tests/codegen/macos/i686-macosx-deployment-target.rs create mode 100644 tests/codegen/macos/i686-no-macosx-deployment-target.rs create mode 100644 tests/codegen/macos/x86_64-macosx-deployment-target.rs create mode 100644 tests/codegen/macos/x86_64-no-macosx-deployment-target.rs create mode 100644 tests/codegen/method-declaration.rs create mode 100644 tests/codegen/naked-fn/naked-functions.rs create mode 100644 tests/codegen/naked-fn/naked-nocoverage.rs create mode 100644 tests/codegen/naked-fn/naked-noinline.rs delete mode 100644 tests/codegen/naked-functions.rs delete mode 100644 tests/codegen/naked-nocoverage.rs delete mode 100644 tests/codegen/naked-noinline.rs create mode 100644 tests/codegen/no_builtins-at-crate.rs create mode 100644 tests/codegen/ptr-arithmetic.rs delete mode 100644 tests/codegen/repr-transparent-aggregates-1.rs delete mode 100644 tests/codegen/repr-transparent-aggregates-2.rs delete mode 100644 tests/codegen/repr-transparent-aggregates-3.rs delete mode 100644 tests/codegen/repr-transparent-sysv64.rs delete mode 100644 tests/codegen/repr-transparent.rs create mode 100644 tests/codegen/repr/transparent-imm-array.rs create mode 100644 tests/codegen/repr/transparent-mips64.rs create mode 100644 tests/codegen/repr/transparent-struct-ptr.rs create mode 100644 tests/codegen/repr/transparent-sysv64.rs create mode 100644 tests/codegen/repr/transparent.rs delete mode 100644 tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs delete mode 100644 tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-checks.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs delete mode 100644 tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs delete mode 100644 tests/codegen/sanitizer-cfi-generalize-pointers.rs delete mode 100644 tests/codegen/sanitizer-cfi-normalize-integers.rs delete mode 100644 tests/codegen/sanitizer-kasan-emits-instrumentation.rs delete mode 100644 tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs delete mode 100644 tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs delete mode 100644 tests/codegen/sanitizer-memory-track-orgins.rs delete mode 100644 tests/codegen/sanitizer-no-sanitize-inlining.rs delete mode 100644 tests/codegen/sanitizer-no-sanitize.rs delete mode 100644 tests/codegen/sanitizer-recover.rs delete mode 100644 tests/codegen/sanitizer-safestack-attr-check.rs create mode 100644 tests/codegen/sanitizer/cfi-add-canonical-jump-tables-flag.rs create mode 100644 tests/codegen/sanitizer/cfi-add-enable-split-lto-unit-flag.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-checks.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs create mode 100644 tests/codegen/sanitizer/cfi-emit-type-metadata-trait-objects.rs create mode 100644 tests/codegen/sanitizer/cfi-generalize-pointers.rs create mode 100644 tests/codegen/sanitizer/cfi-normalize-integers.rs create mode 100644 tests/codegen/sanitizer/kasan-emits-instrumentation.rs create mode 100644 tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle.rs create mode 100644 tests/codegen/sanitizer/kcfi-emit-type-metadata-trait-objects.rs create mode 100644 tests/codegen/sanitizer/memory-track-origins.rs create mode 100644 tests/codegen/sanitizer/memtag-attr-check.rs create mode 100644 tests/codegen/sanitizer/no-sanitize-inlining.rs create mode 100644 tests/codegen/sanitizer/no-sanitize.rs create mode 100644 tests/codegen/sanitizer/safestack-attr-check.rs create mode 100644 tests/codegen/sanitizer/sanitizer-recover.rs create mode 100644 tests/codegen/sanitizer/scs-attr-check.rs delete mode 100644 tests/codegen/sanitizer_memtag_attr_check.rs delete mode 100644 tests/codegen/sanitizer_scs_attr_check.rs delete mode 100644 tests/codegen/simd-wide-sum.rs create mode 100644 tests/codegen/simd/simd-wide-sum.rs create mode 100644 tests/codegen/simd/simd_arith_offset.rs create mode 100644 tests/codegen/simd/swap-simd-types.rs create mode 100644 tests/codegen/simd/unpadded-simd.rs delete mode 100644 tests/codegen/simd_arith_offset.rs create mode 100644 tests/codegen/sroa-fragment-debuginfo.rs delete mode 100644 tests/codegen/swap-simd-types.rs create mode 100644 tests/codegen/target-feature-inline-closure.rs create mode 100644 tests/codegen/trailing_zeros.rs delete mode 100644 tests/codegen/unpadded-simd.rs delete mode 100644 tests/codegen/vec-calloc-llvm14.rs create mode 100644 tests/codegen/wasm_exceptions.rs delete mode 100644 tests/codegen/x86_64-macosx-deployment-target.rs delete mode 100644 tests/codegen/x86_64-no-macosx-deployment-target.rs create mode 100644 tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-abort.diff create mode 100644 tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-unwind.diff create mode 100644 tests/mir-opt/dead-store-elimination/call_arg_copy.rs create mode 100644 tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff create mode 100644 tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff create mode 100644 tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs create mode 100644 tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff create mode 100644 tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff create mode 100644 tests/mir-opt/inline/inline_box_fn.rs create mode 100644 tests/run-make/comment-section/Makefile create mode 100644 tests/run-make/doctests-runtool/Makefile create mode 100644 tests/run-make/doctests-runtool/runtool.rs create mode 100644 tests/run-make/doctests-runtool/t.rs create mode 100644 tests/run-make/dump-ice-to-disk/Makefile create mode 100644 tests/run-make/dump-ice-to-disk/check.sh create mode 100644 tests/run-make/dump-ice-to-disk/src/lib.rs delete mode 100644 tests/run-make/extern-flag-pathless/bar-dynamic.rs delete mode 100644 tests/run-make/extern-flag-pathless/bar-static.rs create mode 100644 tests/run-make/extern-flag-pathless/bar.rs create mode 100644 tests/run-make/extern-fn-explicit-align/Makefile create mode 100644 tests/run-make/extern-fn-explicit-align/test.c create mode 100644 tests/run-make/extern-fn-explicit-align/test.rs create mode 100644 tests/run-make/llvm-ident/Makefile create mode 100644 tests/run-make/no-builtins-attribute/Makefile create mode 100644 tests/run-make/no-builtins-attribute/filecheck.main.txt create mode 100644 tests/run-make/no-builtins-attribute/main.rs create mode 100644 tests/run-make/no-builtins-attribute/no_builtins.rs create mode 100644 tests/run-make/no-cdylib-as-rdylib/Makefile create mode 100644 tests/run-make/no-cdylib-as-rdylib/bar.rs create mode 100644 tests/run-make/no-cdylib-as-rdylib/foo.rs create mode 100644 tests/run-make/optimization-remarks-dir-pgo/Makefile create mode 100644 tests/run-make/optimization-remarks-dir-pgo/foo.rs create mode 100644 tests/run-make/pretty-print-with-dep-file/Makefile create mode 100644 tests/run-make/pretty-print-with-dep-file/with-dep.rs create mode 100644 tests/run-make/rmeta-preferred/Makefile create mode 100644 tests/run-make/rmeta-preferred/lib.rs create mode 100644 tests/run-make/rmeta-preferred/rmeta_aux.rs create mode 100644 tests/run-make/unknown-mod-stdin/Makefile create mode 100644 tests/run-make/unknown-mod-stdin/unknown-mod.stderr create mode 100644 tests/run-make/unknown-mod-stdin/unknown-mod.stdout create mode 100644 tests/run-make/wasm-exceptions-nostd/Makefile create mode 100644 tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs create mode 100644 tests/run-make/wasm-exceptions-nostd/src/lib.rs create mode 100644 tests/run-make/wasm-exceptions-nostd/src/logging.rs create mode 100644 tests/run-make/wasm-exceptions-nostd/src/panicking.rs create mode 100644 tests/run-make/wasm-exceptions-nostd/verify.mjs create mode 100644 tests/rustdoc-json/enums/field_order.rs create mode 100644 tests/rustdoc-json/enums/variant_order.rs create mode 100644 tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs create mode 100644 tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs create mode 100644 tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs create mode 100644 tests/rustdoc-json/structs/field_order.rs create mode 100644 tests/rustdoc-json/traits/private_supertrait.rs create mode 100644 tests/rustdoc-json/unions/field_order.rs create mode 100644 tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.rs create mode 100644 tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.stderr create mode 100644 tests/rustdoc-ui/lints/inline-doc-link.rs create mode 100644 tests/rustdoc-ui/lints/no-redundancy.rs create mode 100644 tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs create mode 100644 tests/rustdoc-ui/lints/redundant_explicit_links.fixed create mode 100644 tests/rustdoc-ui/lints/redundant_explicit_links.rs create mode 100644 tests/rustdoc-ui/lints/redundant_explicit_links.stderr create mode 100644 tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs create mode 100644 tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs create mode 100644 tests/rustdoc/display-hidden-items.rs create mode 100644 tests/rustdoc/generic-const-items.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/impl-sized.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs create mode 100644 tests/rustdoc/inline_cross/generic-const-items.rs create mode 100644 tests/rustdoc/inline_cross/impl-sized.rs create mode 100644 tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs create mode 100644 tests/rustdoc/intra-doc/nested-use.rs create mode 100644 tests/rustdoc/issue-105735-overlapping-reexport-2.rs create mode 100644 tests/rustdoc/issue-105735-overlapping-reexport.rs create mode 100644 tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api.rs create mode 100644 tests/rustdoc/jump-to-def-doc-links.rs create mode 100644 tests/rustdoc/private-use.rs create mode 100644 tests/ui/abi/relocation_model_pic.rs create mode 100644 tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr create mode 100644 tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr create mode 100644 tests/ui/abi/riscv-discoverability-guidance.rs create mode 100644 tests/ui/abi/unsupported.riscv32.stderr create mode 100644 tests/ui/abi/unsupported.riscv64.stderr create mode 100644 tests/ui/annotate-snippet/auxiliary/other_file.rs create mode 100644 tests/ui/annotate-snippet/multiple-files.rs create mode 100644 tests/ui/annotate-snippet/multiple-files.stderr delete mode 100644 tests/ui/array-slice-vec/infer_array_len.stderr create mode 100644 tests/ui/asm/issue-113788.rs create mode 100644 tests/ui/asm/issue-113788.stderr delete mode 100644 tests/ui/associated-inherent-types/not-found-self-type-differs.alias.stderr delete mode 100644 tests/ui/associated-inherent-types/not-found-self-type-differs.local.stderr create mode 100644 tests/ui/associated-inherent-types/not-found-self-type-differs.stderr create mode 100644 tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr create mode 100644 tests/ui/associated-type-bounds/consts.rs create mode 100644 tests/ui/associated-type-bounds/consts.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/equality.stderr create mode 100644 tests/ui/async-await/edition-deny-async-fns-2015.stderr delete mode 100644 tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr delete mode 100644 tests/ui/async-await/in-trait/async-example-desugared-boxed.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr delete mode 100644 tests/ui/async-await/in-trait/async-example-desugared-manual.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-example-desugared-manual.stderr delete mode 100644 tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-generics-and-bounds.stderr delete mode 100644 tests/ui/async-await/in-trait/async-generics.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-generics.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-generics.stderr delete mode 100644 tests/ui/async-await/in-trait/async-recursive-generic.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-recursive-generic.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-recursive-generic.stderr delete mode 100644 tests/ui/async-await/in-trait/async-recursive.current.stderr delete mode 100644 tests/ui/async-await/in-trait/async-recursive.next.stderr create mode 100644 tests/ui/async-await/in-trait/async-recursive.stderr delete mode 100644 tests/ui/async-await/in-trait/bad-signatures.current.stderr delete mode 100644 tests/ui/async-await/in-trait/bad-signatures.next.stderr create mode 100644 tests/ui/async-await/in-trait/bad-signatures.stderr delete mode 100644 tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr delete mode 100644 tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr create mode 100644 tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr delete mode 100644 tests/ui/async-await/in-trait/fn-not-async-err2.current.stderr delete mode 100644 tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr create mode 100644 tests/ui/async-await/in-trait/fn-not-async-err2.stderr delete mode 100644 tests/ui/async-await/in-trait/generics-mismatch.current.stderr delete mode 100644 tests/ui/async-await/in-trait/generics-mismatch.next.stderr delete mode 100644 tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr delete mode 100644 tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr create mode 100644 tests/ui/async-await/in-trait/lifetime-mismatch.stderr delete mode 100644 tests/ui/async-await/in-trait/missing-feature-flag.current.stderr delete mode 100644 tests/ui/async-await/in-trait/missing-feature-flag.next.stderr create mode 100644 tests/ui/async-await/in-trait/missing-feature-flag.stderr delete mode 100644 tests/ui/async-await/in-trait/missing-send-bound.current.stderr delete mode 100644 tests/ui/async-await/in-trait/missing-send-bound.next.stderr create mode 100644 tests/ui/async-await/in-trait/missing-send-bound.stderr delete mode 100644 tests/ui/async-await/in-trait/object-safety.current.stderr delete mode 100644 tests/ui/async-await/in-trait/object-safety.next.stderr create mode 100644 tests/ui/async-await/in-trait/object-safety.stderr delete mode 100644 tests/ui/async-await/in-trait/return-not-existing-pair.current.stderr delete mode 100644 tests/ui/async-await/in-trait/return-not-existing-pair.next.stderr create mode 100644 tests/ui/async-await/in-trait/return-not-existing-pair.stderr delete mode 100644 tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.current.stderr delete mode 100644 tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.next.stderr create mode 100644 tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr delete mode 100644 tests/ui/async-await/in-trait/return-type-suggestion.current.stderr delete mode 100644 tests/ui/async-await/in-trait/return-type-suggestion.next.stderr create mode 100644 tests/ui/async-await/in-trait/return-type-suggestion.stderr create mode 100644 tests/ui/async-await/normalize-output-in-signature-deduction.rs create mode 100644 tests/ui/async-await/return-type-notation/issue-110963-early.stderr create mode 100644 tests/ui/async-await/return-type-notation/issue-110963-late.stderr create mode 100644 tests/ui/async-await/return-type-notation/super-method-bound.stderr create mode 100644 tests/ui/async-await/return-type-notation/supertrait-bound.stderr create mode 100644 tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr create mode 100644 tests/ui/async-await/track-caller/async-block.afn.stderr create mode 100644 tests/ui/async-await/track-caller/async-block.nofeat.stderr delete mode 100644 tests/ui/async-await/track-caller/async-block.stderr create mode 100644 tests/ui/async-await/track-caller/async-closure-gate.afn.stderr create mode 100644 tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr delete mode 100644 tests/ui/async-await/track-caller/async-closure-gate.stderr create mode 100644 tests/ui/async-await/track-caller/panic-track-caller.cls.stderr create mode 100644 tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs delete mode 100644 tests/ui/attributes/invalid-doc-attr.rs delete mode 100644 tests/ui/attributes/invalid-doc-attr.stderr create mode 100644 tests/ui/attributes/macro_export_on_decl_macro.rs create mode 100644 tests/ui/attributes/macro_export_on_decl_macro.stderr create mode 100644 tests/ui/attributes/rustc_confusables.rs create mode 100644 tests/ui/attributes/rustc_confusables.stderr create mode 100644 tests/ui/auto-traits/issue-83857-ub.rs create mode 100644 tests/ui/auto-traits/issue-83857-ub.stderr create mode 100644 tests/ui/binop/borrow-suggestion-109352-2.rs create mode 100644 tests/ui/binop/borrow-suggestion-109352-2.stderr create mode 100644 tests/ui/binop/borrow-suggestion-109352.fixed create mode 100644 tests/ui/binop/borrow-suggestion-109352.rs create mode 100644 tests/ui/binop/borrow-suggestion-109352.stderr create mode 100644 tests/ui/borrowck/clone-span-on-try-operator.fixed create mode 100644 tests/ui/borrowck/clone-span-on-try-operator.rs create mode 100644 tests/ui/borrowck/clone-span-on-try-operator.stderr create mode 100644 tests/ui/borrowck/issue-85765-closure.rs create mode 100644 tests/ui/borrowck/issue-85765-closure.stderr create mode 100644 tests/ui/btreemap/btreemap-index-mut-2.rs create mode 100644 tests/ui/btreemap/btreemap-index-mut-2.stderr create mode 100644 tests/ui/codegen/target-cpus.rs create mode 100644 tests/ui/codegen/target-cpus.stdout create mode 100644 tests/ui/coercion/coerce-block-tail-83783.fixed create mode 100644 tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.rs create mode 100644 tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.stderr create mode 100644 tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs create mode 100644 tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr create mode 100644 tests/ui/command/need-crate-arg-ignore-tidy.x.rs create mode 100644 tests/ui/command/need-crate-arg-ignore-tidy.x.stderr create mode 100644 tests/ui/const-generics/lifetime-in-const-param.rs create mode 100644 tests/ui/const-generics/lifetime-in-const-param.stderr create mode 100644 tests/ui/const_prop/apfloat-f64-roundtrip.rs create mode 100644 tests/ui/const_prop/apfloat-remainder-regression.rs create mode 100644 tests/ui/const_prop/ice-issue-111353.rs create mode 100644 tests/ui/const_prop/ice-issue-96944.rs create mode 100644 tests/ui/consts/const-compare-bytes-ub.rs create mode 100644 tests/ui/consts/const-compare-bytes-ub.stderr create mode 100644 tests/ui/consts/const-compare-bytes.rs create mode 100644 tests/ui/consts/const-eval/const_fn_target_feature.rs create mode 100644 tests/ui/consts/const-eval/const_fn_target_feature.stderr create mode 100644 tests/ui/consts/const-eval/nonnull_as_ref.rs create mode 100644 tests/ui/consts/const-eval/nonnull_as_ref_ub.rs create mode 100644 tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr create mode 100644 tests/ui/consts/const-float-classify.stderr create mode 100644 tests/ui/consts/drop-maybe_uninit.rs delete mode 100644 tests/ui/consts/issue-83182.rs delete mode 100644 tests/ui/consts/issue-83182.stderr create mode 100644 tests/ui/consts/precise-drop-with-promoted.stderr delete mode 100644 tests/ui/consts/ptr_comparisons.stderr create mode 100644 tests/ui/debuginfo/sroa-fragment-debuginfo.rs create mode 100644 tests/ui/diagnostic-flags/colored-session-opt-error.rs create mode 100644 tests/ui/diagnostic-flags/colored-session-opt-error.stderr create mode 100644 tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs create mode 100644 tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs create mode 100644 tests/ui/diagnostic_namespace/existing_proc_macros.rs create mode 100644 tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs create mode 100644 tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr create mode 100644 tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs create mode 100644 tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr create mode 100644 tests/ui/diagnostic_namespace/requires_path.rs create mode 100644 tests/ui/diagnostic_namespace/requires_path.stderr create mode 100644 tests/ui/did_you_mean/issue-114112.rs create mode 100644 tests/ui/did_you_mean/issue-114112.stderr create mode 100644 tests/ui/dst/issue-113447.fixed create mode 100644 tests/ui/dst/issue-113447.rs create mode 100644 tests/ui/dst/issue-113447.stderr create mode 100644 tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.rs create mode 100644 tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.stderr delete mode 100644 tests/ui/dyn-star/llvm-old-style-ptrs.rs delete mode 100644 tests/ui/dyn-star/param-env-region-infer.next.stderr create mode 100644 tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs create mode 100644 tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr create mode 100644 tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs create mode 100644 tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-thiscall.rs delete mode 100644 tests/ui/feature-gates/feature-gate-thiscall.stderr create mode 100644 tests/ui/feature-gates/print-with-path.cfg.stderr create mode 100644 tests/ui/feature-gates/print-with-path.rs create mode 100644 tests/ui/feature-gates/print-with-path.target-cpus.stderr create mode 100644 tests/ui/feature-gates/print-with-path.target-features.stderr create mode 100644 tests/ui/fmt/closing-brace-as-fill.rs create mode 100644 tests/ui/fmt/closing-brace-as-fill.stderr create mode 100644 tests/ui/fmt/suggest-inline-args.rs create mode 100644 tests/ui/fmt/suggest-inline-args.stderr create mode 100644 tests/ui/generator/issue-113279.rs create mode 100644 tests/ui/generator/issue-113279.stderr create mode 100644 tests/ui/generic-associated-types/issue-102114.current.stderr create mode 100644 tests/ui/generic-associated-types/issue-102114.next.stderr delete mode 100644 tests/ui/generic-associated-types/issue-102114.stderr create mode 100644 tests/ui/generic-const-items/associated-const-equality.rs create mode 100644 tests/ui/generic-const-items/basic.rs create mode 100644 tests/ui/generic-const-items/compare-impl-item.rs create mode 100644 tests/ui/generic-const-items/compare-impl-item.stderr create mode 100644 tests/ui/generic-const-items/const-trait-impl.rs create mode 100644 tests/ui/generic-const-items/const-trait-impl.stderr create mode 100644 tests/ui/generic-const-items/duplicate-where-clause.rs create mode 100644 tests/ui/generic-const-items/duplicate-where-clause.stderr create mode 100644 tests/ui/generic-const-items/elided-lifetimes.rs create mode 100644 tests/ui/generic-const-items/elided-lifetimes.stderr create mode 100644 tests/ui/generic-const-items/evaluatable-bounds.rs create mode 100644 tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr create mode 100644 tests/ui/generic-const-items/feature-gate-generic_const_items.rs create mode 100644 tests/ui/generic-const-items/feature-gate-generic_const_items.stderr create mode 100644 tests/ui/generic-const-items/inference-failure.rs create mode 100644 tests/ui/generic-const-items/inference-failure.stderr create mode 100644 tests/ui/generic-const-items/misplaced-where-clause.fixed create mode 100644 tests/ui/generic-const-items/misplaced-where-clause.rs create mode 100644 tests/ui/generic-const-items/misplaced-where-clause.stderr create mode 100644 tests/ui/generic-const-items/parameter-defaults.rs create mode 100644 tests/ui/generic-const-items/parameter-defaults.stderr create mode 100644 tests/ui/generic-const-items/recursive.rs create mode 100644 tests/ui/generic-const-items/reference-outlives-referent.rs create mode 100644 tests/ui/generic-const-items/reference-outlives-referent.stderr create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr create mode 100644 tests/ui/generic-const-items/unsatisfied-bounds.rs create mode 100644 tests/ui/generic-const-items/unsatisfied-bounds.stderr create mode 100644 tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs create mode 100644 tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr create mode 100644 tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs create mode 100644 tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr create mode 100644 tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs create mode 100644 tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr create mode 100644 tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs create mode 100644 tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr create mode 100644 tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr create mode 100644 tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs create mode 100644 tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr delete mode 100644 tests/ui/impl-trait/in-trait/deep-match.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/deep-match.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/deep-match.stderr delete mode 100644 tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr delete mode 100644 tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/default-body-type-err.stderr delete mode 100644 tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr delete mode 100644 tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr delete mode 100644 tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr delete mode 100644 tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/generics-mismatch.stderr delete mode 100644 tests/ui/impl-trait/in-trait/issue-102140.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/issue-102140.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/issue-102140.stderr delete mode 100644 tests/ui/impl-trait/in-trait/issue-102571.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/issue-102571.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/issue-102571.stderr create mode 100644 tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs create mode 100644 tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr delete mode 100644 tests/ui/impl-trait/in-trait/object-safety.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/object-safety.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/object-safety.stderr delete mode 100644 tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr create mode 100644 tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs delete mode 100644 tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr create mode 100644 tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs create mode 100644 tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr delete mode 100644 tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/signature-mismatch.stderr delete mode 100644 tests/ui/impl-trait/in-trait/specialization-broken.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/specialization-broken.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/specialization-broken.stderr delete mode 100644 tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr delete mode 100644 tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/unconstrained-lt.stderr delete mode 100644 tests/ui/impl-trait/in-trait/wf-bounds.current.stderr delete mode 100644 tests/ui/impl-trait/in-trait/wf-bounds.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/wf-bounds.stderr create mode 100644 tests/ui/impl-trait/lifetime-ambiguity-regression.rs create mode 100644 tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs create mode 100644 tests/ui/impl-trait/nested-rpit-hrtb-2.rs create mode 100644 tests/ui/impl-trait/nested-rpit-hrtb-2.stderr create mode 100644 tests/ui/impl-trait/opaque-cast-field-access-in-future.rs create mode 100644 tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr create mode 100644 tests/ui/impl-trait/recursive-auto-trait.rs create mode 100644 tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs create mode 100644 tests/ui/impl-trait/rpit/non-defining-use.rs create mode 100644 tests/ui/impl-trait/rpit/non-defining-use.stderr create mode 100644 tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-1.rs create mode 100644 tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-2.rs create mode 100644 tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs create mode 100644 tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs create mode 100644 tests/ui/implied-bounds/trait-where-clause-implied.rs create mode 100644 tests/ui/imports/ambiguous-1.rs create mode 100644 tests/ui/imports/ambiguous-1.stderr create mode 100644 tests/ui/imports/ambiguous-10.rs create mode 100644 tests/ui/imports/ambiguous-10.stderr create mode 100644 tests/ui/imports/ambiguous-11.rs create mode 100644 tests/ui/imports/ambiguous-11.stderr create mode 100644 tests/ui/imports/ambiguous-12.rs create mode 100644 tests/ui/imports/ambiguous-12.stderr create mode 100644 tests/ui/imports/ambiguous-13.rs create mode 100644 tests/ui/imports/ambiguous-13.stderr create mode 100644 tests/ui/imports/ambiguous-14.rs create mode 100644 tests/ui/imports/ambiguous-14.stderr create mode 100644 tests/ui/imports/ambiguous-15.rs create mode 100644 tests/ui/imports/ambiguous-15.stderr create mode 100644 tests/ui/imports/ambiguous-16.rs create mode 100644 tests/ui/imports/ambiguous-16.stderr create mode 100644 tests/ui/imports/ambiguous-17.rs create mode 100644 tests/ui/imports/ambiguous-17.stderr create mode 100644 tests/ui/imports/ambiguous-2.rs create mode 100644 tests/ui/imports/ambiguous-3.rs create mode 100644 tests/ui/imports/ambiguous-3.stderr create mode 100644 tests/ui/imports/ambiguous-4-extern.rs create mode 100644 tests/ui/imports/ambiguous-4-extern.stderr create mode 100644 tests/ui/imports/ambiguous-4.rs create mode 100644 tests/ui/imports/ambiguous-5.rs create mode 100644 tests/ui/imports/ambiguous-5.stderr create mode 100644 tests/ui/imports/ambiguous-6.rs create mode 100644 tests/ui/imports/ambiguous-6.stderr create mode 100644 tests/ui/imports/ambiguous-7.rs create mode 100644 tests/ui/imports/ambiguous-7.stderr create mode 100644 tests/ui/imports/ambiguous-8.rs create mode 100644 tests/ui/imports/ambiguous-8.stderr create mode 100644 tests/ui/imports/ambiguous-9.rs create mode 100644 tests/ui/imports/ambiguous-9.stderr create mode 100644 tests/ui/imports/auxiliary/ambiguous-11-extern.rs create mode 100644 tests/ui/imports/auxiliary/ambiguous-8-extern.rs create mode 100644 tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs create mode 100644 tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs create mode 100644 tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs create mode 100644 tests/ui/imports/extern-with-ambiguous-1.rs create mode 100644 tests/ui/imports/extern-with-ambiguous-1.stderr create mode 100644 tests/ui/imports/extern-with-ambiguous-2.rs create mode 100644 tests/ui/imports/extern-with-ambiguous-3.rs create mode 100644 tests/ui/imports/import-after-macro-expand-1.rs create mode 100644 tests/ui/imports/import-after-macro-expand-2.rs create mode 100644 tests/ui/imports/import-after-macro-expand-3.rs create mode 100644 tests/ui/imports/import-after-macro-expand-4.rs create mode 100644 tests/ui/imports/import-after-macro-expand-4.stderr create mode 100644 tests/ui/imports/import-after-macro-expand-5.rs create mode 100644 tests/ui/imports/import-after-macro-expand-6.rs create mode 100644 tests/ui/imports/import-after-macro-expand-7.rs create mode 100644 tests/ui/imports/import-after-macro-expand-8.rs create mode 100644 tests/ui/imports/issue-113953.rs create mode 100644 tests/ui/imports/issue-113953.stderr create mode 100644 tests/ui/imports/issue-81413.rs create mode 100644 tests/ui/imports/issue-81413.stderr create mode 100644 tests/ui/imports/resolve-other-libc.rs create mode 100644 tests/ui/imports/resolve-other-libc.stderr delete mode 100644 tests/ui/index-bot.rs delete mode 100644 tests/ui/index-bot.stderr delete mode 100644 tests/ui/index-help.rs delete mode 100644 tests/ui/index-help.stderr delete mode 100644 tests/ui/index_message.rs delete mode 100644 tests/ui/index_message.stderr delete mode 100644 tests/ui/indexing-requires-a-uint.rs delete mode 100644 tests/ui/indexing-requires-a-uint.stderr create mode 100644 tests/ui/indexing/index-bot.rs create mode 100644 tests/ui/indexing/index-bot.stderr create mode 100644 tests/ui/indexing/index-help.rs create mode 100644 tests/ui/indexing/index-help.stderr create mode 100644 tests/ui/indexing/index_message.rs create mode 100644 tests/ui/indexing/index_message.stderr create mode 100644 tests/ui/indexing/indexing-requires-a-uint.rs create mode 100644 tests/ui/indexing/indexing-requires-a-uint.stderr create mode 100644 tests/ui/indexing/indexing-spans-caller-location.rs create mode 100644 tests/ui/inference/issue-113354.fixed create mode 100644 tests/ui/inference/issue-113354.rs create mode 100644 tests/ui/inference/issue-113354.stderr create mode 100644 tests/ui/inference/need_type_info/infer-var-for-self-param.rs create mode 100644 tests/ui/inference/need_type_info/infer-var-for-self-param.stderr create mode 100644 tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs create mode 100644 tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr create mode 100644 tests/ui/inline-const/instance-doesnt-depend-on-type.rs create mode 100644 tests/ui/inline-const/interpolated.rs create mode 100644 tests/ui/inline-const/pat-match-fndef.rs create mode 100644 tests/ui/inline-const/pat-match-fndef.stderr create mode 100644 tests/ui/inline-const/required-const.rs create mode 100644 tests/ui/inline-const/required-const.stderr create mode 100644 tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs create mode 100644 tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr delete mode 100644 tests/ui/intrinsics/intrinsic-raw_eq-const-padding.rs delete mode 100644 tests/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr create mode 100644 tests/ui/invalid/issue-114435-layout-type-err.rs create mode 100644 tests/ui/invalid/issue-114435-layout-type-err.stderr delete mode 100644 tests/ui/issues/issue-100605.rs delete mode 100644 tests/ui/issues/issue-100605.stderr delete mode 100644 tests/ui/issues/issue-11515.rs delete mode 100644 tests/ui/issues/issue-11515.stderr delete mode 100644 tests/ui/issues/issue-83190.rs create mode 100644 tests/ui/layout/issue-113941.rs create mode 100644 tests/ui/layout/malformed-unsized-type-in-union.rs create mode 100644 tests/ui/layout/malformed-unsized-type-in-union.stderr create mode 100644 tests/ui/lazy-type-alias/auxiliary/eager.rs create mode 100644 tests/ui/lazy-type-alias/auxiliary/lazy.rs create mode 100644 tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr create mode 100644 tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr create mode 100644 tests/ui/lazy-type-alias/coerce-behind-lazy.rs create mode 100644 tests/ui/lazy-type-alias/enum-variant.rs create mode 100644 tests/ui/lazy-type-alias/enum-variant.stderr create mode 100644 tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs create mode 100644 tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr create mode 100644 tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr create mode 100644 tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs create mode 100644 tests/ui/lazy-type-alias/leading-where-clause.fixed create mode 100644 tests/ui/lazy-type-alias/leading-where-clause.rs create mode 100644 tests/ui/lazy-type-alias/leading-where-clause.stderr create mode 100644 tests/ui/lazy-type-alias/trailing-where-clause.rs create mode 100644 tests/ui/lazy-type-alias/trailing-where-clause.stderr create mode 100644 tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs create mode 100644 tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.rs create mode 100644 tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.stderr create mode 100644 tests/ui/lazy-type-alias/variance.rs create mode 100644 tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.rs create mode 100644 tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.stderr create mode 100644 tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.rs create mode 100644 tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.stderr create mode 100644 tests/ui/lint/dead-code/allow-or-expect-dead_code-114557.rs create mode 100644 tests/ui/lint/lint-cap-trait-bounds.rs create mode 100644 tests/ui/lint/lint-qualification.fixed create mode 100644 tests/ui/lint/lint-struct-necessary.rs create mode 100644 tests/ui/lint/lint-struct-necessary.stderr create mode 100644 tests/ui/lint/lint-unconditional-drop-recursion.rs create mode 100644 tests/ui/lint/lint-unconditional-drop-recursion.stderr create mode 100644 tests/ui/lint/missing-copy-implementations-negative-copy.rs create mode 100644 tests/ui/lint/noop-method-call.fixed create mode 100644 tests/ui/lint/ptr_null_checks.rs create mode 100644 tests/ui/lint/ptr_null_checks.stderr create mode 100644 tests/ui/lint/unknown-lints/allow-in-other-module.rs create mode 100644 tests/ui/lint/unknown-lints/other.rs create mode 100644 tests/ui/lint/unused/const-local-var.rs create mode 100644 tests/ui/liveness/liveness-move-call-arg-2.rs create mode 100644 tests/ui/liveness/liveness-move-call-arg-2.stderr create mode 100644 tests/ui/macros/builtin-env-issue-114010.rs create mode 100644 tests/ui/macros/builtin-env-issue-114010.stderr create mode 100644 tests/ui/macros/macro-interpolation.stderr create mode 100644 tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs create mode 100644 tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr create mode 100644 tests/ui/match/issue-114691.rs create mode 100644 tests/ui/match/issue-115681.rs create mode 100644 tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs create mode 100644 tests/ui/match/non-first-arm-doesnt-match-expected-return-type.stderr create mode 100644 tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs create mode 100644 tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr create mode 100644 tests/ui/mir/debug-ref-undef.rs create mode 100644 tests/ui/mismatched_types/closure-ref-114180.rs create mode 100644 tests/ui/mismatched_types/closure-ref-114180.stderr create mode 100644 tests/ui/numbers-arithmetic/apfloat-modulo-wrong.rs delete mode 100644 tests/ui/object-safety/assoc_const_bounds.stderr delete mode 100644 tests/ui/object-safety/assoc_const_bounds_sized.stderr create mode 100644 tests/ui/parser/async-with-nonterminal-block.rs create mode 100644 tests/ui/parser/generic-statics.rs create mode 100644 tests/ui/parser/generic-statics.stderr create mode 100644 tests/ui/parser/issues/issue-113203.rs create mode 100644 tests/ui/parser/issues/issue-113203.stderr create mode 100644 tests/ui/parser/issues/issue-114219.rs create mode 100644 tests/ui/parser/issues/issue-114219.stderr create mode 100644 tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs create mode 100644 tests/ui/parser/macro/macro-expand-to-field.rs create mode 100644 tests/ui/parser/macro/macro-expand-to-field.stderr create mode 100644 tests/ui/parser/macro/macro-expand-to-match-arm.rs create mode 100644 tests/ui/parser/macro/macro-expand-to-match-arm.stderr create mode 100644 tests/ui/parser/ternary_operator.rs create mode 100644 tests/ui/parser/ternary_operator.stderr create mode 100644 tests/ui/parser/try-with-nonterminal-block.rs delete mode 100644 tests/ui/parser/type-alias-where-fixable.fixed delete mode 100644 tests/ui/parser/type-alias-where-fixable.rs delete mode 100644 tests/ui/parser/type-alias-where-fixable.stderr delete mode 100644 tests/ui/parser/type-alias-where.rs delete mode 100644 tests/ui/parser/type-alias-where.stderr create mode 100644 tests/ui/pattern/slice-array-infer.rs create mode 100644 tests/ui/pattern/slice-pattern-refutable.rs create mode 100644 tests/ui/pattern/slice-pattern-refutable.stderr create mode 100644 tests/ui/pattern/slice-patterns-ambiguity.rs create mode 100644 tests/ui/pattern/slice-patterns-ambiguity.stderr create mode 100644 tests/ui/pattern/slice-patterns-irrefutable.rs create mode 100644 tests/ui/pattern/slice-patterns-irrefutable.stderr create mode 100644 tests/ui/pattern/slice-patterns-nested.rs create mode 100644 tests/ui/privacy/issue-113860-1.rs create mode 100644 tests/ui/privacy/issue-113860-1.stderr create mode 100644 tests/ui/privacy/issue-113860-2.rs create mode 100644 tests/ui/privacy/issue-113860-2.stderr create mode 100644 tests/ui/privacy/issue-113860.rs create mode 100644 tests/ui/privacy/issue-113860.stderr create mode 100644 tests/ui/proc-macro/auxiliary/issue-107113.rs create mode 100644 tests/ui/proc-macro/issue-107113-wrap.rs create mode 100644 tests/ui/proc-macro/issue-107113-wrap.stderr create mode 100644 tests/ui/process/println-with-broken-pipe.rs create mode 100644 tests/ui/process/println-with-broken-pipe.run.stderr create mode 100644 tests/ui/process/println-with-broken-pipe.run.stdout create mode 100644 tests/ui/resolve/112590-2.fixed create mode 100644 tests/ui/resolve/112590-2.rs create mode 100644 tests/ui/resolve/112590-2.stderr create mode 100644 tests/ui/resolve/derive-macro-1.rs create mode 100644 tests/ui/resolve/derive-macro-2.rs delete mode 100644 tests/ui/resolve/issue-112831.rs create mode 100644 tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed create mode 100644 tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs create mode 100644 tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr create mode 100644 tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs create mode 100644 tests/ui/resolve/unresolved-segments-visibility.rs create mode 100644 tests/ui/resolve/unresolved-segments-visibility.stderr create mode 100644 tests/ui/resolve/unused-qualifications-suggestion.fixed create mode 100644 tests/ui/resolve/unused-qualifications-suggestion.rs create mode 100644 tests/ui/resolve/unused-qualifications-suggestion.stderr create mode 100644 tests/ui/return/return-struct.rs create mode 100644 tests/ui/return/return-struct.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr create mode 100644 tests/ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr create mode 100644 tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs delete mode 100644 tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr create mode 100644 tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs delete mode 100644 tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr delete mode 100644 tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs delete mode 100644 tests/ui/rmeta/auxiliary/rmeta-rmeta.rs delete mode 100644 tests/ui/rmeta/rmeta-rpass.rs create mode 100644 tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs create mode 100644 tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.rs create mode 100644 tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.stderr create mode 100644 tests/ui/self/arbitrary_self_type_mut_difference.rs create mode 100644 tests/ui/self/arbitrary_self_type_mut_difference.stderr create mode 100644 tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.fixed create mode 100644 tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.rs create mode 100644 tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.stderr create mode 100644 tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed create mode 100644 tests/ui/self/arbitrary_self_types_needing_mut_pin.rs create mode 100644 tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr create mode 100644 tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs create mode 100644 tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr create mode 100644 tests/ui/simd/intrinsic/generic-bswap-byte.rs delete mode 100644 tests/ui/std/issue-15149.rs delete mode 100644 tests/ui/std/switch-stdout.rs create mode 100644 tests/ui/suggestions/issue-114701.rs create mode 100644 tests/ui/suggestions/issue-114701.stderr create mode 100644 tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed create mode 100644 tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs create mode 100644 tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr create mode 100644 tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr create mode 100644 tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr delete mode 100644 tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr create mode 100644 tests/ui/suggestions/missing-semicolon.fixed create mode 100644 tests/ui/suggestions/missing-semicolon.rs create mode 100644 tests/ui/suggestions/missing-semicolon.stderr create mode 100644 tests/ui/suggestions/remove-question-symbol-with-paren.rs create mode 100644 tests/ui/suggestions/remove-question-symbol-with-paren.stderr create mode 100644 tests/ui/suggestions/suggest-mut-method-for-loop-closure.rs create mode 100644 tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr create mode 100644 tests/ui/traits/dont-autoderef-ty-with-escaping-var.rs create mode 100644 tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr create mode 100644 tests/ui/traits/new-solver/alias-bound-preference.rs create mode 100644 tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs create mode 100644 tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.rs create mode 100644 tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.stderr create mode 100644 tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.rs create mode 100644 tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr create mode 100644 tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-1.rs create mode 100644 tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-2.rs create mode 100644 tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-3.rs create mode 100644 tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs create mode 100644 tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr create mode 100644 tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs create mode 100644 tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.stderr create mode 100644 tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.rs create mode 100644 tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr create mode 100644 tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.rs create mode 100644 tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.stderr create mode 100644 tests/ui/traits/new-solver/cycles/inductive-cycle-but-ok.rs create mode 100644 tests/ui/traits/new-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs create mode 100644 tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs create mode 100644 tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr create mode 100644 tests/ui/traits/new-solver/cycles/leak-check-coinductive-cycle.rs create mode 100644 tests/ui/traits/new-solver/cycles/provisional-result-done.rs create mode 100644 tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs create mode 100644 tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs create mode 100644 tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs create mode 100644 tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr create mode 100644 tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs delete mode 100644 tests/ui/traits/new-solver/exponential-trait-goals.rs delete mode 100644 tests/ui/traits/new-solver/exponential-trait-goals.stderr create mode 100644 tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs create mode 100644 tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs create mode 100644 tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr delete mode 100644 tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr delete mode 100644 tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs create mode 100644 tests/ui/traits/new-solver/normalize-unsize-rhs.rs create mode 100644 tests/ui/traits/new-solver/object-soundness-requires-generalization.rs create mode 100644 tests/ui/traits/new-solver/overflow/exponential-trait-goals.rs create mode 100644 tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr create mode 100644 tests/ui/traits/new-solver/overflow/global-cache.rs create mode 100644 tests/ui/traits/new-solver/overflow/global-cache.stderr create mode 100644 tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.rs create mode 100644 tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr create mode 100644 tests/ui/traits/new-solver/overflow/recursive-self-normalization.rs create mode 100644 tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr delete mode 100644 tests/ui/traits/new-solver/provisional-result-done.rs delete mode 100644 tests/ui/traits/new-solver/recursive-self-normalization-2.rs delete mode 100644 tests/ui/traits/new-solver/recursive-self-normalization-2.stderr delete mode 100644 tests/ui/traits/new-solver/recursive-self-normalization.rs delete mode 100644 tests/ui/traits/new-solver/recursive-self-normalization.stderr delete mode 100644 tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs delete mode 100644 tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr create mode 100644 tests/ui/traits/new-solver/trait-upcast-lhs-needs-normalization.rs create mode 100644 tests/ui/traits/new-solver/unsize-although-ambiguous.rs create mode 100644 tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.rs create mode 100644 tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.stderr create mode 100644 tests/ui/traits/trait-upcasting/fewer-associated.rs create mode 100644 tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr create mode 100644 tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr create mode 100644 tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs create mode 100644 tests/ui/traits/trait-upcasting/issue-11515.current.stderr create mode 100644 tests/ui/traits/trait-upcasting/issue-11515.next.stderr create mode 100644 tests/ui/traits/trait-upcasting/issue-11515.rs create mode 100644 tests/ui/traits/trait-upcasting/normalization.rs create mode 100644 tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr create mode 100644 tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr delete mode 100644 tests/ui/traits/trait-upcasting/type-checking-test-1.stderr create mode 100644 tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr create mode 100644 tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr create mode 100644 tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs create mode 100644 tests/ui/traits/vtable/multiple-markers.rs create mode 100644 tests/ui/traits/vtable/multiple-markers.stderr create mode 100644 tests/ui/transmutability/issue-110892.rs create mode 100644 tests/ui/transmutability/issue-110892.stderr delete mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr delete mode 100644 tests/ui/transmutability/references/recursive-wrapper-types.stderr create mode 100644 tests/ui/type-alias-impl-trait/broken_mir.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr create mode 100644 tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs create mode 100644 tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs create mode 100644 tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr create mode 100644 tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs create mode 100644 tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr create mode 100644 tests/ui/type-alias-impl-trait/under-binder.rs create mode 100644 tests/ui/type-alias-impl-trait/under-binder.stderr create mode 100644 tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs create mode 100644 tests/ui/type/option-ref-advice.rs create mode 100644 tests/ui/type/option-ref-advice.stderr create mode 100644 tests/ui/typeck/apit-with-error-type-in-sig.rs create mode 100644 tests/ui/typeck/apit-with-error-type-in-sig.stderr create mode 100644 tests/ui/typeck/issue-110017-format-into-help-deletes-macro.fixed create mode 100644 tests/ui/typeck/issue-110017-format-into-help-deletes-macro.rs create mode 100644 tests/ui/typeck/issue-110017-format-into-help-deletes-macro.stderr create mode 100644 tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.fixed create mode 100644 tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.rs create mode 100644 tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.stderr create mode 100644 tests/ui/typeck/issue-114423-ice-regression-in-suggestion.rs create mode 100644 tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr create mode 100644 tests/ui/typeck/mismatched-map-under-self.rs create mode 100644 tests/ui/typeck/mismatched-map-under-self.stderr create mode 100644 tests/ui/unsafe/unsafe-not-inherited.mirunsafeck.stderr delete mode 100644 tests/ui/unsafe/unsafe-not-inherited.stderr create mode 100644 tests/ui/unsafe/unsafe-not-inherited.thirunsafeck.stderr create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr create mode 100644 tests/ui/where-clauses/where-clause-placement-type-alias.rs create mode 100644 tests/ui/where-clauses/where-clause-placement-type-alias.stderr (limited to 'tests') diff --git a/tests/assembly/is_aligned.rs b/tests/assembly/is_aligned.rs index 148d11ee4..d152d200a 100644 --- a/tests/assembly/is_aligned.rs +++ b/tests/assembly/is_aligned.rs @@ -1,5 +1,4 @@ // assembly-output: emit-asm -// min-llvm-version: 15.0 // only-x86_64 // ignore-sgx // revisions: opt-speed opt-size diff --git a/tests/assembly/slice-is_ascii.rs b/tests/assembly/slice-is_ascii.rs index b3e1fee15..124121164 100644 --- a/tests/assembly/slice-is_ascii.rs +++ b/tests/assembly/slice-is_ascii.rs @@ -3,7 +3,6 @@ // [LIN] only-linux // assembly-output: emit-asm // compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel -// min-llvm-version: 14 // only-x86_64 // ignore-sgx // ignore-debug diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs index 011a253c6..a7c9e4845 100644 --- a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs @@ -3,6 +3,7 @@ // ignore-macos slightly different policy on stack protection of arrays // ignore-windows stack check code uses different function names // ignore-nvptx64 stack protector is not supported +// ignore-wasm32-bare // [all] compile-flags: -Z stack-protector=all // [strong] compile-flags: -Z stack-protector=strong // [basic] compile-flags: -Z stack-protector=basic diff --git a/tests/assembly/stack-protector/stack-protector-target-support.rs b/tests/assembly/stack-protector/stack-protector-target-support.rs index d5b48105e..e5cbace80 100644 --- a/tests/assembly/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly/stack-protector/stack-protector-target-support.rs @@ -152,28 +152,30 @@ // [r72] needs-llvm-components: webassembly // [r73] compile-flags:--target wasm32-wasi // [r73] needs-llvm-components: webassembly -// [r74] compile-flags:--target x86_64-apple-ios -// [r74] needs-llvm-components: x86 -// [r75] compile-flags:--target x86_64-fortanix-unknown-sgx +// [r74] compile-flags:--target wasm32-wasi-preview1-threads +// [r74] needs-llvm-components: webassembly +// [r75] compile-flags:--target x86_64-apple-ios // [r75] needs-llvm-components: x86 -// [r76] compile-flags:--target x86_64-unknown-fuchsia +// [r76] compile-flags:--target x86_64-fortanix-unknown-sgx // [r76] needs-llvm-components: x86 -// [r77] compile-flags:--target x86_64-linux-android +// [r77] compile-flags:--target x86_64-unknown-fuchsia // [r77] needs-llvm-components: x86 -// [r78] compile-flags:--target x86_64-sun-solaris +// [r78] compile-flags:--target x86_64-linux-android // [r78] needs-llvm-components: x86 -// [r79] compile-flags:--target x86_64-unknown-freebsd +// [r79] compile-flags:--target x86_64-sun-solaris // [r79] needs-llvm-components: x86 -// [r80] compile-flags:--target x86_64-unknown-illumos +// [r80] compile-flags:--target x86_64-unknown-freebsd // [r80] needs-llvm-components: x86 -// [r81] compile-flags:--target x86_64-unknown-linux-gnux32 +// [r81] compile-flags:--target x86_64-unknown-illumos // [r81] needs-llvm-components: x86 -// [r82] compile-flags:--target x86_64-unknown-linux-musl +// [r82] compile-flags:--target x86_64-unknown-linux-gnux32 // [r82] needs-llvm-components: x86 -// [r83] compile-flags:--target x86_64-unknown-netbsd +// [r83] compile-flags:--target x86_64-unknown-linux-musl // [r83] needs-llvm-components: x86 -// [r84] compile-flags: --target x86_64-unknown-redox +// [r84] compile-flags:--target x86_64-unknown-netbsd // [r84] needs-llvm-components: x86 +// [r85] compile-flags: --target x86_64-unknown-redox +// [r85] needs-llvm-components: x86 // compile-flags: -Z stack-protector=all // compile-flags: -C opt-level=2 diff --git a/tests/assembly/strict_provenance.rs b/tests/assembly/strict_provenance.rs index 24a7c6b5b..ef8566a93 100644 --- a/tests/assembly/strict_provenance.rs +++ b/tests/assembly/strict_provenance.rs @@ -2,7 +2,6 @@ // compile-flags: -Copt-level=1 // only-x86_64 // ignore-sgx -// min-llvm-version: 15.0 #![crate_type = "rlib"] // CHECK-LABEL: old_style diff --git a/tests/assembly/wasm_exceptions.rs b/tests/assembly/wasm_exceptions.rs new file mode 100644 index 000000000..b7d20881b --- /dev/null +++ b/tests/assembly/wasm_exceptions.rs @@ -0,0 +1,60 @@ +// only-wasm32-bare +// assembly-output: emit-asm +// compile-flags: -C target-feature=+exception-handling +// compile-flags: -C panic=unwind +// compile-flags: -C llvm-args=-wasm-enable-eh + +#![crate_type = "lib"] +#![feature(core_intrinsics)] +#![feature(rustc_attrs)] + +extern { + fn may_panic(); + + #[rustc_nounwind] + fn log_number(number: usize); +} + +struct LogOnDrop; + +impl Drop for LogOnDrop { + fn drop(&mut self) { + unsafe { log_number(0); } + } +} + +// CHECK-LABEL: test_cleanup: +#[no_mangle] +pub fn test_cleanup() { + let _log_on_drop = LogOnDrop; + unsafe { may_panic(); } + + // CHECK-NOT: call + // CHECK: try + // CHECK: call may_panic + // CHECK: catch_all + // CHECK: rethrow + // CHECK: end_try +} + +// CHECK-LABEL: test_rtry: +#[no_mangle] +pub fn test_rtry() { + unsafe { + core::intrinsics::r#try(|_| { + may_panic(); + }, core::ptr::null_mut(), |data, exception| { + log_number(data as usize); + log_number(exception as usize); + }); + } + + // CHECK-NOT: call + // CHECK: try + // CHECK: call may_panic + // CHECK: catch + // CHECK: call log_number + // CHECK: call log_number + // CHECK-NOT: rethrow + // CHECK: end_try +} diff --git a/tests/codegen/aarch64-struct-align-128.rs b/tests/codegen/aarch64-struct-align-128.rs new file mode 100644 index 000000000..bf3471778 --- /dev/null +++ b/tests/codegen/aarch64-struct-align-128.rs @@ -0,0 +1,150 @@ +// Test that structs aligned to 128 bits are passed with the correct ABI on aarch64. + +// revisions:linux darwin windows +//[linux] compile-flags: --target aarch64-unknown-linux-gnu +//[darwin] compile-flags: --target aarch64-apple-darwin +//[windows] compile-flags: --target aarch64-pc-windows-msvc +//[linux] needs-llvm-components: aarch64 +//[darwin] needs-llvm-components: aarch64 +//[windows] needs-llvm-components: aarch64 + +#![feature(no_core, lang_items)] +#![crate_type = "lib"] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + + + +// Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits. +#[repr(C)] +pub struct Align8 { + pub a: u64, + pub b: u64, +} + +// repr(transparent), so same as above. +#[repr(transparent)] +pub struct Transparent8 { + a: Align8 +} + +// Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits. +#[repr(C)] +pub struct Wrapped8 { + a: Align8, +} + +extern "C" { + // linux: declare void @test_8([2 x i64], [2 x i64], [2 x i64]) + // darwin: declare void @test_8([2 x i64], [2 x i64], [2 x i64]) + // windows: declare void @test_8([2 x i64], [2 x i64], [2 x i64]) + fn test_8(a: Align8, b: Transparent8, c: Wrapped8); +} + + + +// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits. +// EXCEPT on Linux, where there's a special case to use its unadjusted alignment, +// making it the same as `Align8`, so it's be passed as `[i64 x 2]`. +#[repr(C)] +#[repr(align(16))] +pub struct Align16 { + pub a: u64, + pub b: u64, +} + +// repr(transparent), so same as above. +#[repr(transparent)] +pub struct Transparent16 { + a: Align16 +} + +// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits. +// On Linux, the "unadjustedness" doesn't recurse into fields, so this is passed as `i128`. +#[repr(C)] +pub struct Wrapped16 { + pub a: Align16, +} + +extern "C" { + // linux: declare void @test_16([2 x i64], [2 x i64], i128) + // darwin: declare void @test_16(i128, i128, i128) + // windows: declare void @test_16(i128, i128, i128) + fn test_16(a: Align16, b: Transparent16, c: Wrapped16); +} + + + +// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits. +#[repr(C)] +pub struct I128 { + pub a: i128, +} + +// repr(transparent), so same as above. +#[repr(transparent)] +pub struct TransparentI128 { + a: I128 +} + +// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits. +#[repr(C)] +pub struct WrappedI128 { + pub a: I128 +} + +extern "C" { + // linux: declare void @test_i128(i128, i128, i128) + // darwin: declare void @test_i128(i128, i128, i128) + // windows: declare void @test_i128(i128, i128, i128) + fn test_i128(a: I128, b: TransparentI128, c: WrappedI128); +} + + + +// Passed as `[2 x i64]`, since it's an aggregate with size <= 128 bits, align < 128 bits. +// Note that the Linux special case does not apply, because packing is not considered "adjustment". +#[repr(C)] +#[repr(packed)] +pub struct Packed { + pub a: i128, +} + +// repr(transparent), so same as above. +#[repr(transparent)] +pub struct TransparentPacked { + a: Packed +} + +// Passed as `[2 x i64]`, since it's an aggregate with size <= 128 bits, align < 128 bits. +#[repr(C)] +pub struct WrappedPacked { + pub a: Packed +} + +extern "C" { + // linux: declare void @test_packed([2 x i64], [2 x i64], [2 x i64]) + // darwin: declare void @test_packed([2 x i64], [2 x i64], [2 x i64]) + // windows: declare void @test_packed([2 x i64], [2 x i64], [2 x i64]) + fn test_packed(a: Packed, b: TransparentPacked, c: WrappedPacked); +} + + + +pub unsafe fn main( + a1: Align8, a2: Transparent8, a3: Wrapped8, + b1: Align16, b2: Transparent16, b3: Wrapped16, + c1: I128, c2: TransparentI128, c3: WrappedI128, + d1: Packed, d2: TransparentPacked, d3: WrappedPacked, +) { + test_8(a1, a2, a3); + test_16(b1, b2, b3); + test_i128(c1, c2, c3); + test_packed(d1, d2, d3); +} diff --git a/tests/codegen/abi-main-signature-16bit-c-int.rs b/tests/codegen/abi-main-signature-16bit-c-int.rs index 353e7489b..ce4d35dea 100644 --- a/tests/codegen/abi-main-signature-16bit-c-int.rs +++ b/tests/codegen/abi-main-signature-16bit-c-int.rs @@ -2,22 +2,10 @@ // entry point. It must match C's `int main(int, char **)`. // This test is for targets with 16bit c_int only. -// ignore-aarch64 -// ignore-arm -// ignore-asmjs -// ignore-hexagon -// ignore-mips -// ignore-mips64 -// ignore-powerpc -// ignore-powerpc64 -// ignore-riscv64 -// ignore-s390x -// ignore-sparc -// ignore-sparc64 -// ignore-wasm32 -// ignore-x86 -// ignore-x86_64 -// ignore-loongarch64 +// revisions: avr msp +//[avr] only-avr +//[msp] only-msp430 + fn main() { } diff --git a/tests/codegen/abi-main-signature-32bit-c-int.rs b/tests/codegen/abi-main-signature-32bit-c-int.rs index 7f22ddcfc..34571823f 100644 --- a/tests/codegen/abi-main-signature-32bit-c-int.rs +++ b/tests/codegen/abi-main-signature-32bit-c-int.rs @@ -3,8 +3,9 @@ // This test is for targets with 32bit c_int only. // ignore-msp430 +// ignore-avr fn main() { } -// CHECK: define{{( hidden)?}} i32 @main(i32{{( %0)?}}, {{i8\*\*|ptr}}{{( %1)?}}) +// CHECK: define{{( hidden)?}} i32 @main(i32{{( %0)?}}, ptr{{( %1)?}}) diff --git a/tests/codegen/addr-of-mutate.rs b/tests/codegen/addr-of-mutate.rs index bea1aad23..97af61815 100644 --- a/tests/codegen/addr-of-mutate.rs +++ b/tests/codegen/addr-of-mutate.rs @@ -1,12 +1,11 @@ // compile-flags: -C opt-level=3 -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) #![crate_type = "lib"] // Test for the absence of `readonly` on the argument when it is mutated via `&raw const`. // See . -// CHECK: i8 @foo(ptr noalias nocapture noundef dereferenceable(128) %x) +// CHECK: i8 @foo(ptr noalias nocapture noundef align 1 dereferenceable(128) %x) #[no_mangle] pub fn foo(x: [u8; 128]) -> u8 { let ptr = core::ptr::addr_of!(x).cast_mut(); @@ -16,7 +15,7 @@ pub fn foo(x: [u8; 128]) -> u8 { x[0] } -// CHECK: i1 @second(ptr noalias nocapture noundef dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @second(ptr noalias nocapture noundef align {{[0-9]+}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut(); @@ -25,7 +24,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { } // If going through a deref (and there are no other mutating accesses), then `readonly` is fine. -// CHECK: i1 @third(ptr noalias nocapture noundef readonly dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @third(ptr noalias nocapture noundef readonly align {{[0-9]+}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut(); diff --git a/tests/codegen/adjustments.rs b/tests/codegen/adjustments.rs index b53a68a55..0739c79ba 100644 --- a/tests/codegen/adjustments.rs +++ b/tests/codegen/adjustments.rs @@ -13,9 +13,9 @@ pub fn helper(_: usize) { pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] { // We used to generate an extra alloca and memcpy for the block's trailing expression value, so // check that we copy directly to the return value slot -// CHECK: %0 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } poison, {{\[0 x i8\]\*|ptr}} %x.0, 0 -// CHECK: %1 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %0, [[USIZE]] %x.1, 1 -// CHECK: ret { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %1 +// CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0 +// CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1 +// CHECK: ret { ptr, [[USIZE]] } %1 { x } } diff --git a/tests/codegen/align-byval-vector.rs b/tests/codegen/align-byval-vector.rs new file mode 100644 index 000000000..3c8be6596 --- /dev/null +++ b/tests/codegen/align-byval-vector.rs @@ -0,0 +1,58 @@ +// revisions:x86-linux x86-darwin + +//[x86-linux] compile-flags: --target i686-unknown-linux-gnu +//[x86-linux] needs-llvm-components: x86 +//[x86-darwin] compile-flags: --target i686-apple-darwin +//[x86-darwin] needs-llvm-components: x86 + +// Tests that aggregates containing vector types get their alignment increased to 16 on Darwin. + +#![feature(no_core, lang_items, repr_simd, simd_ffi)] +#![crate_type = "lib"] +#![no_std] +#![no_core] +#![allow(non_camel_case_types)] + +#[lang = "sized"] +trait Sized {} +#[lang = "freeze"] +trait Freeze {} +#[lang = "copy"] +trait Copy {} + +#[repr(simd)] +pub struct i32x4(i32, i32, i32, i32); + +#[repr(C)] +pub struct Foo { + a: i32x4, + b: i8, +} + +// This tests that we recursively check for vector types, not just at the top level. +#[repr(C)] +pub struct DoubleFoo { + one: Foo, + two: Foo, +} + +extern "C" { + // x86-linux: declare void @f({{.*}}byval(%Foo) align 4{{.*}}) + // x86-darwin: declare void @f({{.*}}byval(%Foo) align 16{{.*}}) + fn f(foo: Foo); + + // x86-linux: declare void @g({{.*}}byval(%DoubleFoo) align 4{{.*}}) + // x86-darwin: declare void @g({{.*}}byval(%DoubleFoo) align 16{{.*}}) + fn g(foo: DoubleFoo); +} + +pub fn main() { + unsafe { f(Foo { a: i32x4(1, 2, 3, 4), b: 0 }) } + + unsafe { + g(DoubleFoo { + one: Foo { a: i32x4(1, 2, 3, 4), b: 0 }, + two: Foo { a: i32x4(1, 2, 3, 4), b: 0 }, + }) + } +} diff --git a/tests/codegen/align-byval.rs b/tests/codegen/align-byval.rs new file mode 100644 index 000000000..e2446e02e --- /dev/null +++ b/tests/codegen/align-byval.rs @@ -0,0 +1,342 @@ +// ignore-tidy-linelength +// revisions:m68k wasm x86_64-linux x86_64-windows i686-linux i686-windows + +//[m68k] compile-flags: --target m68k-unknown-linux-gnu +//[m68k] needs-llvm-components: m68k +//[wasm] compile-flags: --target wasm32-unknown-emscripten +//[wasm] needs-llvm-components: webassembly +//[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu +//[x86_64-linux] needs-llvm-components: x86 +//[x86_64-windows] compile-flags: --target x86_64-pc-windows-msvc +//[x86_64-windows] needs-llvm-components: x86 +//[i686-linux] compile-flags: --target i686-unknown-linux-gnu +//[i686-linux] needs-llvm-components: x86 +//[i686-windows] compile-flags: --target i686-pc-windows-msvc +//[i686-windows] needs-llvm-components: x86 + +// Tests that `byval` alignment is properly specified (#80127). +// The only targets that use `byval` are m68k, wasm, x86-64, and x86. +// Note also that Windows mandates a by-ref ABI here, so it does not use byval. + +#![feature(no_core, lang_items)] +#![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } + +impl Copy for i32 {} +impl Copy for i64 {} + +// This struct can be represented as a pair, so it exercises the OperandValue::Pair +// codepath in `codegen_argument`. +#[repr(C)] +pub struct NaturalAlign1 { + a: i8, + b: i8, +} + +// This struct cannot be represented as an immediate, so it exercises the OperandValue::Ref +// codepath in `codegen_argument`. +#[repr(C)] +pub struct NaturalAlign2 { + a: [i16; 16], + b: i16, +} + +#[repr(C)] +#[repr(align(4))] +pub struct ForceAlign4 { + a: [i8; 16], + b: i8, +} + +// On i686-windows, this is passed on stack using `byval` +#[repr(C)] +pub struct NaturalAlign8 { + a: i64, + b: i64, + c: i64 +} + +// On i686-windows, this is passed by reference (because alignment is >4 and requested/forced), +// even though it has the exact same layout as `NaturalAlign8`! +#[repr(C)] +#[repr(align(8))] +pub struct ForceAlign8 { + a: i64, + b: i64, + c: i64 +} + +// On i686-windows, this is passed on stack, because requested alignment is <=4. +#[repr(C)] +#[repr(align(4))] +pub struct LowerFA8 { + a: i64, + b: i64, + c: i64 +} + +// On i686-windows, this is passed by reference, because it contains a field with +// requested/forced alignment. +#[repr(C)] +pub struct WrappedFA8 { + a: ForceAlign8 +} + +// On i686-windows, this has the same ABI as ForceAlign8, i.e. passed by reference. +#[repr(transparent)] +pub struct TransparentFA8 { + _0: (), + a: ForceAlign8 +} + +#[repr(C)] +#[repr(align(16))] +pub struct ForceAlign16 { + a: [i32; 16], + b: i8 +} + +// CHECK-LABEL: @call_na1 +#[no_mangle] +pub unsafe fn call_na1(x: NaturalAlign1) { + // CHECK: start: + + // m68k: [[ALLOCA:%[a-z0-9+]]] = alloca { i8, i8 }, align 1 + // m68k: call void @natural_align_1({{.*}}byval({ i8, i8 }) align 1{{.*}} [[ALLOCA]]) + + // wasm: [[ALLOCA:%[a-z0-9+]]] = alloca { i8, i8 }, align 1 + // wasm: call void @natural_align_1({{.*}}byval({ i8, i8 }) align 1{{.*}} [[ALLOCA]]) + + // x86_64-linux: call void @natural_align_1(i16 + + // x86_64-windows: call void @natural_align_1(i16 + + // i686-linux: [[ALLOCA:%[a-z0-9+]]] = alloca { i8, i8 }, align 4 + // i686-linux: call void @natural_align_1({{.*}}byval({ i8, i8 }) align 4{{.*}} [[ALLOCA]]) + + // i686-windows: [[ALLOCA:%[a-z0-9+]]] = alloca { i8, i8 }, align 4 + // i686-windows: call void @natural_align_1({{.*}}byval({ i8, i8 }) align 4{{.*}} [[ALLOCA]]) + natural_align_1(x); +} + +// CHECK-LABEL: @call_na2 +#[no_mangle] +pub unsafe fn call_na2(x: NaturalAlign2) { + // CHECK: start: + + // m68k-NEXT: call void @natural_align_2 + // wasm-NEXT: call void @natural_align_2 + // x86_64-linux-NEXT: call void @natural_align_2 + // x86_64-windows-NEXT: call void @natural_align_2 + + // i686-linux: [[ALLOCA:%[0-9]+]] = alloca %NaturalAlign2, align 4 + // i686-linux: call void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}} [[ALLOCA]]) + + // i686-windows: [[ALLOCA:%[0-9]+]] = alloca %NaturalAlign2, align 4 + // i686-windows: call void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}} [[ALLOCA]]) + natural_align_2(x); +} + +// CHECK-LABEL: @call_fa4 +#[no_mangle] +pub unsafe fn call_fa4(x: ForceAlign4) { + // CHECK: start: + // CHECK-NEXT: call void @force_align_4 + force_align_4(x); +} + +// CHECK-LABEL: @call_na8 +#[no_mangle] +pub unsafe fn call_na8(x: NaturalAlign8) { + // CHECK: start: + // CHECK-NEXT: call void @natural_align_8 + natural_align_8(x); +} + +// CHECK-LABEL: @call_fa8 +#[no_mangle] +pub unsafe fn call_fa8(x: ForceAlign8) { + // CHECK: start: + // CHECK-NEXT: call void @force_align_8 + force_align_8(x); +} + +// CHECK-LABEL: @call_lfa8 +#[no_mangle] +pub unsafe fn call_lfa8(x: LowerFA8) { + // CHECK: start: + // CHECK-NEXT: call void @lower_fa8 + lower_fa8(x); +} + +// CHECK-LABEL: @call_wfa8 +#[no_mangle] +pub unsafe fn call_wfa8(x: WrappedFA8) { + // CHECK: start: + // CHECK-NEXT: call void @wrapped_fa8 + wrapped_fa8(x); +} + +// CHECK-LABEL: @call_tfa8 +#[no_mangle] +pub unsafe fn call_tfa8(x: TransparentFA8) { + // CHECK: start: + // CHECK-NEXT: call void @transparent_fa8 + transparent_fa8(x); +} + +// CHECK-LABEL: @call_fa16 +#[no_mangle] +pub unsafe fn call_fa16(x: ForceAlign16) { + // CHECK: start: + // CHECK-NEXT: call void @force_align_16 + force_align_16(x); +} + +extern "C" { + // m68k: declare void @natural_align_1({{.*}}byval({ i8, i8 }) align 1{{.*}}) + + // wasm: declare void @natural_align_1({{.*}}byval({ i8, i8 }) align 1{{.*}}) + + // x86_64-linux: declare void @natural_align_1(i16) + + // x86_64-windows: declare void @natural_align_1(i16) + + // i686-linux: declare void @natural_align_1({{.*}}byval({ i8, i8 }) align 4{{.*}}) + + // i686-windows: declare void @natural_align_1({{.*}}byval({ i8, i8 }) align 4{{.*}}) + fn natural_align_1(x: NaturalAlign1); + + // m68k: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}}) + + // wasm: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}}) + + // x86_64-linux: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}}) + + // x86_64-windows: declare void @natural_align_2( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 2{{.*}}) + + // i686-linux: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}}) + + // i686-windows: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}}) + fn natural_align_2(x: NaturalAlign2); + + // m68k: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + + // wasm: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + + // x86_64-linux: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + + // x86_64-windows: declare void @force_align_4( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 4{{.*}}) + + // i686-linux: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + + // i686-windows: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + fn force_align_4(x: ForceAlign4); + + // m68k: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}}) + + // wasm: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}}) + + // x86_64-linux: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}}) + + // x86_64-windows: declare void @natural_align_8( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 8{{.*}}) + + // i686-linux: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}}) + + // i686-windows: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}}) + fn natural_align_8(x: NaturalAlign8); + + // m68k: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}}) + + // wasm: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}}) + + // x86_64-linux: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}}) + + // x86_64-windows: declare void @force_align_8( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 8{{.*}}) + + // i686-linux: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 4{{.*}}) + + // i686-windows: declare void @force_align_8( + // i686-windows-NOT: byval + // i686-windows-SAME: align 8{{.*}}) + fn force_align_8(x: ForceAlign8); + + // m68k: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 4{{.*}}) + + // wasm: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 8{{.*}}) + + // x86_64-linux: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 8{{.*}}) + + // x86_64-windows: declare void @lower_fa8( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 8{{.*}}) + + // i686-linux: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 4{{.*}}) + + // i686-windows: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 4{{.*}}) + fn lower_fa8(x: LowerFA8); + + // m68k: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 8{{.*}}) + + // wasm: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 8{{.*}}) + + // x86_64-linux: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 8{{.*}}) + + // x86_64-windows: declare void @wrapped_fa8( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 8{{.*}}) + + // i686-linux: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 4{{.*}}) + + // i686-windows: declare void @wrapped_fa8( + // i686-windows-NOT: byval + // i686-windows-SAME: align 8{{.*}}) + fn wrapped_fa8(x: WrappedFA8); + + // m68k: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 8{{.*}}) + + // wasm: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 8{{.*}}) + + // x86_64-linux: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 8{{.*}}) + + // x86_64-windows: declare void @transparent_fa8( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 8{{.*}}) + + // i686-linux: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 4{{.*}}) + + // i686-windows: declare void @transparent_fa8( + // i686-windows-NOT: byval + // i686-windows-SAME: align 8{{.*}}) + fn transparent_fa8(x: TransparentFA8); + + // m68k: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}}) + + // wasm: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}}) + + // x86_64-linux: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}}) + + // x86_64-windows: declare void @force_align_16( + // x86_64-windows-NOT: byval + // x86_64-windows-SAME: align 16{{.*}}) + + // i686-linux: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 4{{.*}}) + + // i686-windows: declare void @force_align_16( + // i686-windows-NOT: byval + // i686-windows-SAME: align 16{{.*}}) + fn force_align_16(x: ForceAlign16); +} diff --git a/tests/codegen/align-enum.rs b/tests/codegen/align-enum.rs index 70f09ace0..5901f0113 100644 --- a/tests/codegen/align-enum.rs +++ b/tests/codegen/align-enum.rs @@ -20,7 +20,7 @@ pub struct Nested64 { #[no_mangle] pub fn align64(a: u32) -> Align64 { // CHECK: %a64 = alloca %Align64, align 64 -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 64 %{{.*}}, {{i8\*|ptr}} align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) let a64 = Align64::A(a); a64 } diff --git a/tests/codegen/align-offset.rs b/tests/codegen/align-offset.rs index 7c7660c5a..d4d8b18d3 100644 --- a/tests/codegen/align-offset.rs +++ b/tests/codegen/align-offset.rs @@ -1,5 +1,4 @@ // compile-flags: -O -// min-llvm-version: 15.0 (because we're using opaque pointers) // ignore-debug (debug assertions in `slice::from_raw_parts` block optimizations) #![crate_type = "lib"] diff --git a/tests/codegen/align-struct.rs b/tests/codegen/align-struct.rs index a2f47354b..40bba6d52 100644 --- a/tests/codegen/align-struct.rs +++ b/tests/codegen/align-struct.rs @@ -32,7 +32,7 @@ pub enum Enum64 { #[no_mangle] pub fn align64(i : i32) -> Align64 { // CHECK: %a64 = alloca %Align64, align 64 -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 64 %{{.*}}, {{i8\*|ptr}} align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) let a64 = Align64(i); a64 } @@ -42,7 +42,7 @@ pub fn align64(i : i32) -> Align64 { // CHECK-LABEL: @align64_load #[no_mangle] pub fn align64_load(a: Align64) -> i32 { -// CHECK: {{%.*}} = load i32, {{i32\*|ptr}} {{%.*}}, align 64 +// CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64 a.0 } diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs index 98488eb92..ba0d444f9 100644 --- a/tests/codegen/array-codegen.rs +++ b/tests/codegen/array-codegen.rs @@ -1,15 +1,14 @@ // compile-flags: -O -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) #![crate_type = "lib"] // CHECK-LABEL: @array_load #[no_mangle] pub fn array_load(a: &[u8; 4]) -> [u8; 4] { - // CHECK: %0 = alloca [4 x i8], align 1 + // CHECK: %_0 = alloca [4 x i8], align 1 // CHECK: %[[TEMP1:.+]] = load <4 x i8>, ptr %a, align 1 - // CHECK: store <4 x i8> %[[TEMP1]], ptr %0, align 1 - // CHECK: %[[TEMP2:.+]] = load i32, ptr %0, align 1 + // CHECK: store <4 x i8> %[[TEMP1]], ptr %_0, align 1 + // CHECK: %[[TEMP2:.+]] = load i32, ptr %_0, align 1 // CHECK: ret i32 %[[TEMP2]] *a } diff --git a/tests/codegen/array-equality.rs b/tests/codegen/array-equality.rs index abfe295f8..1941452ea 100644 --- a/tests/codegen/array-equality.rs +++ b/tests/codegen/array-equality.rs @@ -16,8 +16,8 @@ pub fn array_eq_value(a: [u16; 3], b: [u16; 3]) -> bool { #[no_mangle] pub fn array_eq_ref(a: &[u16; 3], b: &[u16; 3]) -> bool { // CHECK: start: - // CHECK: load i48, {{i48\*|ptr}} %{{.+}}, align 2 - // CHECK: load i48, {{i48\*|ptr}} %{{.+}}, align 2 + // CHECK: load i48, ptr %{{.+}}, align 2 + // CHECK: load i48, ptr %{{.+}}, align 2 // CHECK: icmp eq i48 // CHECK-NEXT: ret a == b @@ -27,7 +27,7 @@ pub fn array_eq_ref(a: &[u16; 3], b: &[u16; 3]) -> bool { #[no_mangle] pub fn array_eq_value_still_passed_by_pointer(a: [u16; 9], b: [u16; 9]) -> bool { // CHECK-NEXT: start: - // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{i8\*|ptr}} {{.*}} dereferenceable(18) %{{.+}}, {{i8\*|ptr}} {{.*}} dereferenceable(18) %{{.+}}, i64 18) + // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}(ptr {{.*}} dereferenceable(18) %{{.+}}, ptr {{.*}} dereferenceable(18) %{{.+}}, i64 18) // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[CMP]], 0 // CHECK-NEXT: ret i1 %[[EQ]] a == b @@ -37,7 +37,7 @@ pub fn array_eq_value_still_passed_by_pointer(a: [u16; 9], b: [u16; 9]) -> bool #[no_mangle] pub fn array_eq_long(a: &[u16; 1234], b: &[u16; 1234]) -> bool { // CHECK-NEXT: start: - // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{i8\*|ptr}} {{.*}} dereferenceable(2468) %{{.+}}, {{i8\*|ptr}} {{.*}} dereferenceable(2468) %{{.+}}, i64 2468) + // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}(ptr {{.*}} dereferenceable(2468) %{{.+}}, ptr {{.*}} dereferenceable(2468) %{{.+}}, i64 2468) // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[CMP]], 0 // CHECK-NEXT: ret i1 %[[EQ]] a == b diff --git a/tests/codegen/array-map.rs b/tests/codegen/array-map.rs index 24f3f43d0..4d218e6a9 100644 --- a/tests/codegen/array-map.rs +++ b/tests/codegen/array-map.rs @@ -30,7 +30,6 @@ pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] { pub fn long_integer_map(x: [u32; 512]) -> [u32; 512] { // CHECK: start: // CHECK-NEXT: alloca [512 x i32] - // CHECK-NEXT: alloca %"core::mem::manually_drop::ManuallyDrop<[u32; 512]>" // CHECK-NOT: alloca // CHECK: mul <{{[0-9]+}} x i32> // CHECK: add <{{[0-9]+}} x i32> diff --git a/tests/codegen/atomic-operations.rs b/tests/codegen/atomic-operations.rs index d2bc618df..20980c489 100644 --- a/tests/codegen/atomic-operations.rs +++ b/tests/codegen/atomic-operations.rs @@ -7,37 +7,37 @@ use std::sync::atomic::{AtomicI32, Ordering::*}; // CHECK-LABEL: @compare_exchange #[no_mangle] pub fn compare_exchange(a: &AtomicI32) { - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 10 monotonic monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 11 monotonic acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 12 monotonic seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 10 monotonic monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 11 monotonic acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 12 monotonic seq_cst let _ = a.compare_exchange(0, 10, Relaxed, Relaxed); let _ = a.compare_exchange(0, 11, Relaxed, Acquire); let _ = a.compare_exchange(0, 12, Relaxed, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 20 release monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 21 release acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 22 release seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 20 release monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 21 release acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 22 release seq_cst let _ = a.compare_exchange(0, 20, Release, Relaxed); let _ = a.compare_exchange(0, 21, Release, Acquire); let _ = a.compare_exchange(0, 22, Release, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 30 acquire monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 31 acquire acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 32 acquire seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 30 acquire monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 31 acquire acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 32 acquire seq_cst let _ = a.compare_exchange(0, 30, Acquire, Relaxed); let _ = a.compare_exchange(0, 31, Acquire, Acquire); let _ = a.compare_exchange(0, 32, Acquire, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 40 acq_rel monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 41 acq_rel acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 42 acq_rel seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 40 acq_rel monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 41 acq_rel acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 42 acq_rel seq_cst let _ = a.compare_exchange(0, 40, AcqRel, Relaxed); let _ = a.compare_exchange(0, 41, AcqRel, Acquire); let _ = a.compare_exchange(0, 42, AcqRel, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 50 seq_cst monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 51 seq_cst acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 52 seq_cst seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 50 seq_cst monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 51 seq_cst acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 52 seq_cst seq_cst let _ = a.compare_exchange(0, 50, SeqCst, Relaxed); let _ = a.compare_exchange(0, 51, SeqCst, Acquire); let _ = a.compare_exchange(0, 52, SeqCst, SeqCst); @@ -46,37 +46,37 @@ pub fn compare_exchange(a: &AtomicI32) { // CHECK-LABEL: @compare_exchange_weak #[no_mangle] pub fn compare_exchange_weak(w: &AtomicI32) { - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 10 monotonic monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 11 monotonic acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 12 monotonic seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 10 monotonic monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 11 monotonic acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 12 monotonic seq_cst let _ = w.compare_exchange_weak(1, 10, Relaxed, Relaxed); let _ = w.compare_exchange_weak(1, 11, Relaxed, Acquire); let _ = w.compare_exchange_weak(1, 12, Relaxed, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 20 release monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 21 release acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 22 release seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 20 release monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 21 release acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 22 release seq_cst let _ = w.compare_exchange_weak(1, 20, Release, Relaxed); let _ = w.compare_exchange_weak(1, 21, Release, Acquire); let _ = w.compare_exchange_weak(1, 22, Release, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 30 acquire monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 31 acquire acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 32 acquire seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 30 acquire monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 31 acquire acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 32 acquire seq_cst let _ = w.compare_exchange_weak(1, 30, Acquire, Relaxed); let _ = w.compare_exchange_weak(1, 31, Acquire, Acquire); let _ = w.compare_exchange_weak(1, 32, Acquire, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 40 acq_rel monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 41 acq_rel acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 42 acq_rel seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 40 acq_rel monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 41 acq_rel acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 42 acq_rel seq_cst let _ = w.compare_exchange_weak(1, 40, AcqRel, Relaxed); let _ = w.compare_exchange_weak(1, 41, AcqRel, Acquire); let _ = w.compare_exchange_weak(1, 42, AcqRel, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 50 seq_cst monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 51 seq_cst acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 52 seq_cst seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 50 seq_cst monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 51 seq_cst acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 52 seq_cst seq_cst let _ = w.compare_exchange_weak(1, 50, SeqCst, Relaxed); let _ = w.compare_exchange_weak(1, 51, SeqCst, Acquire); let _ = w.compare_exchange_weak(1, 52, SeqCst, SeqCst); diff --git a/tests/codegen/avr/avr-func-addrspace.rs b/tests/codegen/avr/avr-func-addrspace.rs index bc11e1081..dc36a9fac 100644 --- a/tests/codegen/avr/avr-func-addrspace.rs +++ b/tests/codegen/avr/avr-func-addrspace.rs @@ -94,7 +94,7 @@ pub extern "C" fn test() { // Validate that we can codegen transmutes between data ptrs and fn ptrs. -// CHECK: define{{.+}}{{void \(\) addrspace\(1\)\*|ptr addrspace\(1\)}} @transmute_data_ptr_to_fn({{\{\}\*|ptr}}{{.*}} %x) +// CHECK: define{{.+}}ptr addrspace(1) @transmute_data_ptr_to_fn(ptr{{.*}} %x) #[no_mangle] pub unsafe fn transmute_data_ptr_to_fn(x: *const ()) -> fn() { // It doesn't matter precisely how this is codegenned (through memory or an addrspacecast), @@ -102,7 +102,7 @@ pub unsafe fn transmute_data_ptr_to_fn(x: *const ()) -> fn() { transmute(x) } -// CHECK: define{{.+}}{{\{\}\*|ptr}} @transmute_fn_ptr_to_data({{void \(\) addrspace\(1\)\*|ptr addrspace\(1\)}}{{.*}} %x) +// CHECK: define{{.+}}ptr @transmute_fn_ptr_to_data(ptr addrspace(1){{.*}} %x) #[no_mangle] pub unsafe fn transmute_fn_ptr_to_data(x: fn()) -> *const () { // It doesn't matter precisely how this is codegenned (through memory or an addrspacecast), @@ -116,7 +116,7 @@ pub enum Either { A(T), B(U) } // with the `ptr` field representing both `&i32` and `fn()` depending on the variant. // This is incorrect, because `fn()` should be `ptr addrspace(1)`, not `ptr`. -// CHECK: define{{.+}}void @should_not_combine_addrspace({{.+\*|ptr}}{{.+}}sret{{.+}}%0, {{.+\*|ptr}}{{.+}}%x) +// CHECK: define{{.+}}void @should_not_combine_addrspace(ptr{{.+}}sret{{.+}}%_0, ptr{{.+}}%x) #[no_mangle] #[inline(never)] pub fn should_not_combine_addrspace(x: Either<&i32, fn()>) -> Either<&i32, fn()> { diff --git a/tests/codegen/box-maybe-uninit-llvm14.rs b/tests/codegen/box-maybe-uninit-llvm14.rs deleted file mode 100644 index c9f88fb3f..000000000 --- a/tests/codegen/box-maybe-uninit-llvm14.rs +++ /dev/null @@ -1,34 +0,0 @@ -// compile-flags: -O - -// Once we're done with llvm 14 and earlier, this test can be deleted. - -#![crate_type = "lib"] - -use std::mem::MaybeUninit; - -// Boxing a `MaybeUninit` value should not copy junk from the stack -#[no_mangle] -pub fn box_uninitialized() -> Box> { - // CHECK-LABEL: @box_uninitialized - // CHECK-NOT: store - // CHECK-NOT: alloca - // CHECK-NOT: memcpy - // CHECK-NOT: memset - Box::new(MaybeUninit::uninit()) -} - -// https://github.com/rust-lang/rust/issues/58201 -#[no_mangle] -pub fn box_uninitialized2() -> Box> { - // CHECK-LABEL: @box_uninitialized2 - // CHECK-NOT: store - // CHECK-NOT: alloca - // CHECK-NOT: memcpy - // CHECK-NOT: memset - Box::new(MaybeUninit::uninit()) -} - -// Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc -// from the CHECK-NOT above. We don't check the attributes here because we can't rely -// on all of them being set until LLVM 15. -// CHECK: declare {{(dso_local )?}}noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef) diff --git a/tests/codegen/box-maybe-uninit.rs b/tests/codegen/box-maybe-uninit.rs index 5c08b5832..282af99b0 100644 --- a/tests/codegen/box-maybe-uninit.rs +++ b/tests/codegen/box-maybe-uninit.rs @@ -1,5 +1,4 @@ // compile-flags: -O -// min-llvm-version: 15.0 #![crate_type = "lib"] use std::mem::MaybeUninit; diff --git a/tests/codegen/c-variadic-copy.rs b/tests/codegen/c-variadic-copy.rs deleted file mode 100644 index 4c61c4fcf..000000000 --- a/tests/codegen/c-variadic-copy.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Tests that `VaListImpl::clone` gets inlined into a call to `llvm.va_copy` - -#![crate_type = "lib"] -#![feature(c_variadic)] -#![no_std] -use core::ffi::VaList; - -extern "C" { - fn foreign_c_variadic_1(_: VaList, ...); -} - -pub unsafe extern "C" fn clone_variadic(ap: VaList) { - let mut ap2 = ap.clone(); - // CHECK: call void @llvm.va_copy - foreign_c_variadic_1(ap2.as_va_list(), 42i32); -} diff --git a/tests/codegen/c-variadic-opt.rs b/tests/codegen/c-variadic-opt.rs deleted file mode 100644 index 969dce80f..000000000 --- a/tests/codegen/c-variadic-opt.rs +++ /dev/null @@ -1,30 +0,0 @@ -// compile-flags: -C opt-level=3 - -#![crate_type = "lib"] -#![feature(c_variadic)] -#![no_std] -use core::ffi::VaList; - -extern "C" { - fn vprintf(fmt: *const i8, ap: VaList) -> i32; -} - -// Ensure that `va_start` and `va_end` are properly injected even -// when the "spoofed" `VaListImpl` is not used. -#[no_mangle] -pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 { - // CHECK: call void @llvm.va_start - vprintf(fmt, ap.as_va_list()) - // CHECK: call void @llvm.va_end -} - -// Check that `VaListImpl::clone` gets inlined into a direct call to `llvm.va_copy` -#[no_mangle] -pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 { - // CHECK: call void @llvm.va_start - let mut ap2 = ap.clone(); - // CHECK: call void @llvm.va_copy - let res = vprintf(fmt, ap2.as_va_list()); - res - // CHECK: call void @llvm.va_end -} diff --git a/tests/codegen/c-variadic.rs b/tests/codegen/c-variadic.rs deleted file mode 100644 index cab326522..000000000 --- a/tests/codegen/c-variadic.rs +++ /dev/null @@ -1,72 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default -// compile-flags: -C no-prepopulate-passes -Copt-level=0 -// - -#![crate_type = "lib"] -#![feature(c_variadic)] -#![feature(c_unwind)] -#![no_std] -use core::ffi::VaList; - -extern "C" { - fn foreign_c_variadic_0(_: i32, ...); - fn foreign_c_variadic_1(_: VaList, ...); -} - -pub unsafe extern "C" fn use_foreign_c_variadic_0() { - // Ensure that we correctly call foreign C-variadic functions. - // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0) - foreign_c_variadic_0(0); - // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42) - foreign_c_variadic_0(0, 42i32); - // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024) - foreign_c_variadic_0(0, 42i32, 1024i32); - // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0) - foreign_c_variadic_0(0, 42i32, 1024i32, 0i32); -} - -// Ensure that we do not remove the `va_list` passed to the foreign function when -// removing the "spoofed" `VaListImpl` that is used by Rust defined C-variadics. -pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap) - foreign_c_variadic_1(ap); -} - -pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42) - foreign_c_variadic_1(ap, 42i32); -} -pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42) - foreign_c_variadic_1(ap, 2i32, 42i32); -} - -pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42, [[PARAM]] 0) - foreign_c_variadic_1(ap, 2i32, 42i32, 0i32); -} - -// Ensure that `va_start` and `va_end` are properly injected. -#[no_mangle] -pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 { - // CHECK: call void @llvm.va_start - let mut sum = 0; - for _ in 0..n { - sum += ap.arg::(); - } - sum - // CHECK: call void @llvm.va_end -} - -// Ensure that we generate the correct `call` signature when calling a Rust -// defined C-variadic. -pub unsafe fn test_c_variadic_call() { - // CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0) - c_variadic(0); - // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42) - c_variadic(0, 42i32); - // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024) - c_variadic(0, 42i32, 1024i32); - // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0) - c_variadic(0, 42i32, 1024i32, 0i32); -} diff --git a/tests/codegen/cffi/c-variadic-copy.rs b/tests/codegen/cffi/c-variadic-copy.rs new file mode 100644 index 000000000..4c61c4fcf --- /dev/null +++ b/tests/codegen/cffi/c-variadic-copy.rs @@ -0,0 +1,16 @@ +// Tests that `VaListImpl::clone` gets inlined into a call to `llvm.va_copy` + +#![crate_type = "lib"] +#![feature(c_variadic)] +#![no_std] +use core::ffi::VaList; + +extern "C" { + fn foreign_c_variadic_1(_: VaList, ...); +} + +pub unsafe extern "C" fn clone_variadic(ap: VaList) { + let mut ap2 = ap.clone(); + // CHECK: call void @llvm.va_copy + foreign_c_variadic_1(ap2.as_va_list(), 42i32); +} diff --git a/tests/codegen/cffi/c-variadic-opt.rs b/tests/codegen/cffi/c-variadic-opt.rs new file mode 100644 index 000000000..969dce80f --- /dev/null +++ b/tests/codegen/cffi/c-variadic-opt.rs @@ -0,0 +1,30 @@ +// compile-flags: -C opt-level=3 + +#![crate_type = "lib"] +#![feature(c_variadic)] +#![no_std] +use core::ffi::VaList; + +extern "C" { + fn vprintf(fmt: *const i8, ap: VaList) -> i32; +} + +// Ensure that `va_start` and `va_end` are properly injected even +// when the "spoofed" `VaListImpl` is not used. +#[no_mangle] +pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 { + // CHECK: call void @llvm.va_start + vprintf(fmt, ap.as_va_list()) + // CHECK: call void @llvm.va_end +} + +// Check that `VaListImpl::clone` gets inlined into a direct call to `llvm.va_copy` +#[no_mangle] +pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 { + // CHECK: call void @llvm.va_start + let mut ap2 = ap.clone(); + // CHECK: call void @llvm.va_copy + let res = vprintf(fmt, ap2.as_va_list()); + res + // CHECK: call void @llvm.va_end +} diff --git a/tests/codegen/cffi/c-variadic.rs b/tests/codegen/cffi/c-variadic.rs new file mode 100644 index 000000000..cab326522 --- /dev/null +++ b/tests/codegen/cffi/c-variadic.rs @@ -0,0 +1,72 @@ +// ignore-wasm32-bare compiled with panic=abort by default +// compile-flags: -C no-prepopulate-passes -Copt-level=0 +// + +#![crate_type = "lib"] +#![feature(c_variadic)] +#![feature(c_unwind)] +#![no_std] +use core::ffi::VaList; + +extern "C" { + fn foreign_c_variadic_0(_: i32, ...); + fn foreign_c_variadic_1(_: VaList, ...); +} + +pub unsafe extern "C" fn use_foreign_c_variadic_0() { + // Ensure that we correctly call foreign C-variadic functions. + // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0) + foreign_c_variadic_0(0); + // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42) + foreign_c_variadic_0(0, 42i32); + // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024) + foreign_c_variadic_0(0, 42i32, 1024i32); + // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0) + foreign_c_variadic_0(0, 42i32, 1024i32, 0i32); +} + +// Ensure that we do not remove the `va_list` passed to the foreign function when +// removing the "spoofed" `VaListImpl` that is used by Rust defined C-variadics. +pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) { + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap) + foreign_c_variadic_1(ap); +} + +pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) { + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42) + foreign_c_variadic_1(ap, 42i32); +} +pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) { + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42) + foreign_c_variadic_1(ap, 2i32, 42i32); +} + +pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) { + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42, [[PARAM]] 0) + foreign_c_variadic_1(ap, 2i32, 42i32, 0i32); +} + +// Ensure that `va_start` and `va_end` are properly injected. +#[no_mangle] +pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 { + // CHECK: call void @llvm.va_start + let mut sum = 0; + for _ in 0..n { + sum += ap.arg::(); + } + sum + // CHECK: call void @llvm.va_end +} + +// Ensure that we generate the correct `call` signature when calling a Rust +// defined C-variadic. +pub unsafe fn test_c_variadic_call() { + // CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0) + c_variadic(0); + // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42) + c_variadic(0, 42i32); + // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024) + c_variadic(0, 42i32, 1024i32); + // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0) + c_variadic(0, 42i32, 1024i32, 0i32); +} diff --git a/tests/codegen/cffi/ffi-const.rs b/tests/codegen/cffi/ffi-const.rs new file mode 100644 index 000000000..937205034 --- /dev/null +++ b/tests/codegen/cffi/ffi-const.rs @@ -0,0 +1,13 @@ +// compile-flags: -C no-prepopulate-passes +#![crate_type = "lib"] +#![feature(ffi_const)] + +pub fn bar() { unsafe { foo() } } + +extern "C" { + // CHECK-LABEL: declare{{.*}}void @foo() + // CHECK-SAME: [[ATTRS:#[0-9]+]] + // The attribute changed from `readnone` to `memory(none)` with LLVM 16.0. + // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readnone|memory\(none\)}}{{.*}} } + #[ffi_const] pub fn foo(); +} diff --git a/tests/codegen/cffi/ffi-out-of-bounds-loads.rs b/tests/codegen/cffi/ffi-out-of-bounds-loads.rs new file mode 100644 index 000000000..099726b2f --- /dev/null +++ b/tests/codegen/cffi/ffi-out-of-bounds-loads.rs @@ -0,0 +1,25 @@ +// Regression test for #29988 + +// compile-flags: -C no-prepopulate-passes +// only-x86_64 +// ignore-windows + +#[repr(C)] +struct S { + f1: i32, + f2: i32, + f3: i32, +} + +extern "C" { + fn foo(s: S); +} + +fn main() { + let s = S { f1: 1, f2: 2, f3: 3 }; + unsafe { + // CHECK: load { i64, i32 }, {{.*}}, align 4 + // CHECK: call void @foo({ i64, i32 } {{.*}}) + foo(s); + } +} diff --git a/tests/codegen/cffi/ffi-pure.rs b/tests/codegen/cffi/ffi-pure.rs new file mode 100644 index 000000000..2ed735813 --- /dev/null +++ b/tests/codegen/cffi/ffi-pure.rs @@ -0,0 +1,13 @@ +// compile-flags: -C no-prepopulate-passes +#![crate_type = "lib"] +#![feature(ffi_pure)] + +pub fn bar() { unsafe { foo() } } + +extern "C" { + // CHECK-LABEL: declare{{.*}}void @foo() + // CHECK-SAME: [[ATTRS:#[0-9]+]] + // The attribute changed from `readonly` to `memory(read)` with LLVM 16.0. + // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readonly|memory\(read\)}}{{.*}} } + #[ffi_pure] pub fn foo(); +} diff --git a/tests/codegen/cffi/ffi-returns-twice.rs b/tests/codegen/cffi/ffi-returns-twice.rs new file mode 100644 index 000000000..0fbe03f0b --- /dev/null +++ b/tests/codegen/cffi/ffi-returns-twice.rs @@ -0,0 +1,11 @@ +// compile-flags: -C no-prepopulate-passes +#![crate_type = "lib"] +#![feature(ffi_returns_twice)] + +pub fn bar() { unsafe { foo() } } + +extern "C" { + // CHECK: declare{{( dso_local)?}} void @foo(){{.*}}[[ATTRS:#[0-9]+]] + // CHECK: attributes [[ATTRS]] = { {{.*}}returns_twice{{.*}} } + #[ffi_returns_twice] pub fn foo(); +} diff --git a/tests/codegen/comparison-operators-2-tuple.rs b/tests/codegen/comparison-operators-2-tuple.rs index a9d25e3b5..7a2a3fc93 100644 --- a/tests/codegen/comparison-operators-2-tuple.rs +++ b/tests/codegen/comparison-operators-2-tuple.rs @@ -1,5 +1,4 @@ // compile-flags: -C opt-level=1 -Z merge-functions=disabled -// min-llvm-version: 15.0 // only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/comparison-operators-newtype.rs b/tests/codegen/comparison-operators-newtype.rs index 683a2bd4f..8fd8a81df 100644 --- a/tests/codegen/comparison-operators-newtype.rs +++ b/tests/codegen/comparison-operators-newtype.rs @@ -3,7 +3,6 @@ // in the operators for such a type all optimize away. // compile-flags: -C opt-level=1 -// min-llvm-version: 15.0 #![crate_type = "lib"] diff --git a/tests/codegen/consts.rs b/tests/codegen/consts.rs index fc2badc41..3797e1a99 100644 --- a/tests/codegen/consts.rs +++ b/tests/codegen/consts.rs @@ -42,7 +42,7 @@ pub fn inline_enum_const() -> E { #[no_mangle] pub fn low_align_const() -> E { // Check that low_align_const and high_align_const use the same constant - // CHECK: memcpy.{{.+}}({{i8\*|ptr}} align 2 %{{[0-9]+}}, {{i8\*|ptr}} align 2 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) + // CHECK: memcpy.{{.+}}(ptr align 2 %_0, ptr align 2 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) *&E::A(0) } @@ -50,6 +50,6 @@ pub fn low_align_const() -> E { #[no_mangle] pub fn high_align_const() -> E { // Check that low_align_const and high_align_const use the same constant - // CHECK: memcpy.{{.+}}({{i8\*|ptr}} align 4 %{{[0-9]+}}, {{i8\*|ptr}} align 4 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) + // CHECK: memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) *&E::A(0) } diff --git a/tests/codegen/drop-in-place-noalias.rs b/tests/codegen/drop-in-place-noalias.rs index 725e6fc04..ece1e426c 100644 --- a/tests/codegen/drop-in-place-noalias.rs +++ b/tests/codegen/drop-in-place-noalias.rs @@ -7,9 +7,9 @@ use std::marker::PhantomPinned; -// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}({{.*\*|ptr}} noalias noundef align 4 dereferenceable(12) %{{.+}}) +// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}(ptr noalias noundef align 4 dereferenceable(12) %{{.+}}) -// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}({{.*\*|ptr}} noundef nonnull align 4 %{{.+}}) +// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}}) pub struct StructUnpin { a: i32, diff --git a/tests/codegen/enum-bounds-check-derived-idx.rs b/tests/codegen/enum-bounds-check-derived-idx.rs deleted file mode 100644 index aa66c2ed0..000000000 --- a/tests/codegen/enum-bounds-check-derived-idx.rs +++ /dev/null @@ -1,24 +0,0 @@ -// This test checks an optimization that is not guaranteed to work. This test case should not block -// a future LLVM update. -// compile-flags: -O - -#![crate_type = "lib"] - -pub enum Bar { - A = 1, - B = 3, -} - -// CHECK-LABEL: @lookup_inc -#[no_mangle] -pub fn lookup_inc(buf: &[u8; 5], f: Bar) -> u8 { - // CHECK-NOT: panic_bounds_check - buf[f as usize + 1] -} - -// CHECK-LABEL: @lookup_dec -#[no_mangle] -pub fn lookup_dec(buf: &[u8; 5], f: Bar) -> u8 { - // CHECK-NOT: panic_bounds_check - buf[f as usize - 1] -} diff --git a/tests/codegen/enum-bounds-check-issue-13926.rs b/tests/codegen/enum-bounds-check-issue-13926.rs deleted file mode 100644 index b26945bc5..000000000 --- a/tests/codegen/enum-bounds-check-issue-13926.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This test checks an optimization that is not guaranteed to work. This test case should not block -// a future LLVM update. -// compile-flags: -O - -#![crate_type = "lib"] - -#[repr(u8)] -pub enum Exception { - Low = 5, - High = 10, -} - -// CHECK-LABEL: @access -#[no_mangle] -pub fn access(array: &[usize; 12], exc: Exception) -> usize { - // CHECK-NOT: panic_bounds_check - array[(exc as u8 - 4) as usize] -} diff --git a/tests/codegen/enum-bounds-check-issue-82871.rs b/tests/codegen/enum-bounds-check-issue-82871.rs deleted file mode 100644 index 32fdc4a5f..000000000 --- a/tests/codegen/enum-bounds-check-issue-82871.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -C opt-level=0 - -#![crate_type = "lib"] - -#[repr(C)] -pub enum E { - A, -} - -// CHECK-LABEL: @index -#[no_mangle] -pub fn index(x: &[u32; 3], ind: E) -> u32 { - // Canary: we should be able to optimize out the bounds check, but we need - // to track the range of the discriminant result in order to be able to do that. - // oli-obk tried to add that, but that caused miscompilations all over the place. - // CHECK: panic_bounds_check - x[ind as usize] -} diff --git a/tests/codegen/enum-bounds-check.rs b/tests/codegen/enum-bounds-check.rs deleted file mode 100644 index 17322d591..000000000 --- a/tests/codegen/enum-bounds-check.rs +++ /dev/null @@ -1,26 +0,0 @@ -// compile-flags: -O - -#![crate_type = "lib"] - -pub enum Foo { - A, B -} - -// CHECK-LABEL: @lookup -#[no_mangle] -pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 { - // CHECK-NOT: panic_bounds_check - buf[f as usize] -} - -pub enum Bar { - A = 2, - B = 3 -} - -// CHECK-LABEL: @lookup_unmodified -#[no_mangle] -pub fn lookup_unmodified(buf: &[u8; 5], f: Bar) -> u8 { - // CHECK-NOT: panic_bounds_check - buf[f as usize] -} diff --git a/tests/codegen/enum-debug-clike.rs b/tests/codegen/enum-debug-clike.rs deleted file mode 100644 index 1e369a2c4..000000000 --- a/tests/codegen/enum-debug-clike.rs +++ /dev/null @@ -1,23 +0,0 @@ -// This tests that debug info for "c-like" enums is properly emitted. -// This is ignored for the fallback mode on MSVC due to problems with PDB. - -// -// ignore-msvc - -// compile-flags: -g -C no-prepopulate-passes - -// CHECK-LABEL: @main -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: DIFlagEnumClass,{{.*}} -// CHECK: {{.*}}DIEnumerator{{.*}}name: "A",{{.*}}value: {{[0-9].*}} -// CHECK: {{.*}}DIEnumerator{{.*}}name: "B",{{.*}}value: {{[0-9].*}} -// CHECK: {{.*}}DIEnumerator{{.*}}name: "C",{{.*}}value: {{[0-9].*}} - -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(unused_assignments)] - -enum E { A, B, C } - -pub fn main() { - let e = E::C; -} diff --git a/tests/codegen/enum-debug-niche-2.rs b/tests/codegen/enum-debug-niche-2.rs deleted file mode 100644 index 4b607d505..000000000 --- a/tests/codegen/enum-debug-niche-2.rs +++ /dev/null @@ -1,50 +0,0 @@ -// This tests that optimized enum debug info accurately reflects the enum layout. -// This is ignored for the fallback mode on MSVC due to problems with PDB. - -// -// ignore-msvc - -// compile-flags: -g -C no-prepopulate-passes - -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}} - -#![feature(never_type)] - -#[derive(Copy, Clone)] -pub struct Entity { - private: std::num::NonZeroU32, -} - -#[derive(Copy, Clone, PartialEq, Eq)] -pub struct Declaration; - -impl TypeFamily for Declaration { - type Base = Base; - type Placeholder = !; - - fn intern_base_data(_: BaseKind) {} -} - -#[derive(Copy, Clone)] -pub struct Base; - -pub trait TypeFamily: Copy + 'static { - type Base: Copy; - type Placeholder: Copy; - - fn intern_base_data(_: BaseKind); -} - -#[derive(Copy, Clone)] -pub enum BaseKind { - Named(Entity), - Placeholder(F::Placeholder), - Error, -} - -pub fn main() { - let x = BaseKind::Error::; - let y = 7; -} diff --git a/tests/codegen/enum-debug-niche.rs b/tests/codegen/enum-debug-niche.rs deleted file mode 100644 index b718a6854..000000000 --- a/tests/codegen/enum-debug-niche.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This tests that optimized enum debug info accurately reflects the enum layout. -// This is ignored for the fallback mode on MSVC due to problems with PDB. - -// ignore-msvc - -// compile-flags: -g -C no-prepopulate-passes - -// CHECK-LABEL: @main -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "C",{{.*}}extraData:{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "C",{{.*}} -// CHECK-NOT: {{.*}}DIDerivedType{{.*}}name: "D",{{.*}}extraData:{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "D",{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "D",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}} - -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(unused_assignments)] - -enum E { A, B, C, D(bool) } - -pub fn main() { - let e = E::D(true); -} diff --git a/tests/codegen/enum-debug-tagged.rs b/tests/codegen/enum-debug-tagged.rs deleted file mode 100644 index 095c49ac3..000000000 --- a/tests/codegen/enum-debug-tagged.rs +++ /dev/null @@ -1,27 +0,0 @@ -// This tests that debug info for tagged (ordinary) enums is properly emitted. -// This is ignored for the fallback mode on MSVC due to problems with PDB. - -// ignore-msvc - -// compile-flags: -g -C no-prepopulate-passes - -// CHECK-LABEL: @main -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "E",{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}} -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}} - -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(unused_assignments)] - -enum E { A(u32), B(u32) } - -pub fn main() { - let e = E::A(23); -} diff --git a/tests/codegen/enum-discriminant-value.rs b/tests/codegen/enum-discriminant-value.rs deleted file mode 100644 index cc14c2120..000000000 --- a/tests/codegen/enum-discriminant-value.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Verify that DIEnumerator uses isUnsigned flag when appropriate. -// -// compile-flags: -g -C no-prepopulate-passes - -#[repr(i64)] -pub enum I64 { - I64Min = i64::MIN, - I64Max = i64::MAX, -} - -#[repr(u64)] -pub enum U64 { - U64Min = u64::MIN, - U64Max = u64::MAX, -} - -fn main() { - let _a = I64::I64Min; - let _b = I64::I64Max; - let _c = U64::U64Min; - let _d = U64::U64Max; -} - -// CHECK: !DIEnumerator(name: "I64Min", value: -9223372036854775808) -// CHECK: !DIEnumerator(name: "I64Max", value: 9223372036854775807) -// CHECK: !DIEnumerator(name: "U64Min", value: 0, isUnsigned: true) -// CHECK: !DIEnumerator(name: "U64Max", value: 18446744073709551615, isUnsigned: true) diff --git a/tests/codegen/enum-match.rs b/tests/codegen/enum-match.rs deleted file mode 100644 index 36c6be190..000000000 --- a/tests/codegen/enum-match.rs +++ /dev/null @@ -1,112 +0,0 @@ -// compile-flags: -Copt-level=1 -// only-x86_64 - -#![crate_type = "lib"] - -// Check each of the 3 cases for `codegen_get_discr`. - -// Case 0: One tagged variant. -pub enum Enum0 { - A(bool), - B, -} - -// CHECK: define noundef i8 @match0{{.*}} -// CHECK-NEXT: start: -// CHECK-NEXT: %1 = icmp eq i8 %0, 2 -// CHECK-NEXT: %2 = and i8 %0, 1 -// CHECK-NEXT: %.0 = select i1 %1, i8 13, i8 %2 -#[no_mangle] -pub fn match0(e: Enum0) -> u8 { - use Enum0::*; - match e { - A(b) => b as u8, - B => 13, - } -} - -// Case 1: Niche values are on a boundary for `range`. -pub enum Enum1 { - A(bool), - B, - C, -} - -// CHECK: define noundef i8 @match1{{.*}} -// CHECK-NEXT: start: -// CHECK-NEXT: %1 = add i8 %0, -2 -// CHECK-NEXT: %2 = zext i8 %1 to i64 -// CHECK-NEXT: %3 = icmp ult i8 %1, 2 -// CHECK-NEXT: %4 = add nuw nsw i64 %2, 1 -// CHECK-NEXT: %_2 = select i1 %3, i64 %4, i64 0 -#[no_mangle] -pub fn match1(e: Enum1) -> u8 { - use Enum1::*; - match e { - A(b) => b as u8, - B => 13, - C => 100, - } -} - -// Case 2: Special cases don't apply. -pub enum X { - _2=2, _3, _4, _5, _6, _7, _8, _9, _10, _11, - _12, _13, _14, _15, _16, _17, _18, _19, _20, - _21, _22, _23, _24, _25, _26, _27, _28, _29, - _30, _31, _32, _33, _34, _35, _36, _37, _38, - _39, _40, _41, _42, _43, _44, _45, _46, _47, - _48, _49, _50, _51, _52, _53, _54, _55, _56, - _57, _58, _59, _60, _61, _62, _63, _64, _65, - _66, _67, _68, _69, _70, _71, _72, _73, _74, - _75, _76, _77, _78, _79, _80, _81, _82, _83, - _84, _85, _86, _87, _88, _89, _90, _91, _92, - _93, _94, _95, _96, _97, _98, _99, _100, _101, - _102, _103, _104, _105, _106, _107, _108, _109, - _110, _111, _112, _113, _114, _115, _116, _117, - _118, _119, _120, _121, _122, _123, _124, _125, - _126, _127, _128, _129, _130, _131, _132, _133, - _134, _135, _136, _137, _138, _139, _140, _141, - _142, _143, _144, _145, _146, _147, _148, _149, - _150, _151, _152, _153, _154, _155, _156, _157, - _158, _159, _160, _161, _162, _163, _164, _165, - _166, _167, _168, _169, _170, _171, _172, _173, - _174, _175, _176, _177, _178, _179, _180, _181, - _182, _183, _184, _185, _186, _187, _188, _189, - _190, _191, _192, _193, _194, _195, _196, _197, - _198, _199, _200, _201, _202, _203, _204, _205, - _206, _207, _208, _209, _210, _211, _212, _213, - _214, _215, _216, _217, _218, _219, _220, _221, - _222, _223, _224, _225, _226, _227, _228, _229, - _230, _231, _232, _233, _234, _235, _236, _237, - _238, _239, _240, _241, _242, _243, _244, _245, - _246, _247, _248, _249, _250, _251, _252, _253, -} - -pub enum Enum2 { - A(X), - B, - C, - D, - E, -} - -// CHECK: define noundef i8 @match2{{.*}} -// CHECK-NEXT: start: -// CHECK-NEXT: %1 = add i8 %0, 2 -// CHECK-NEXT: %2 = zext i8 %1 to i64 -// CHECK-NEXT: %3 = icmp ult i8 %1, 4 -// CHECK-NEXT: %4 = add nuw nsw i64 %2, 1 -// CHECK-NEXT: %_2 = select i1 %3, i64 %4, i64 0 -// CHECK-NEXT: switch i64 %_2, label {{.*}} [ -#[no_mangle] -pub fn match2(e: Enum2) -> u8 { - use Enum2::*; - match e { - A(b) => b as u8, - B => 13, - C => 100, - D => 200, - E => 250, - } -} diff --git a/tests/codegen/enum-u128.rs b/tests/codegen/enum-u128.rs deleted file mode 100644 index f50d360ac..000000000 --- a/tests/codegen/enum-u128.rs +++ /dev/null @@ -1,27 +0,0 @@ -// This tests that debug info for "c-like" 128bit enums is properly emitted. -// This is ignored for the fallback mode on MSVC due to problems with PDB. - -// -// ignore-msvc - -// compile-flags: -g -C no-prepopulate-passes - -// CHECK-LABEL: @main -// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "Foo",{{.*}}flags: DIFlagEnumClass,{{.*}} -// CHECK: {{.*}}DIEnumerator{{.*}}name: "Lo",{{.*}}value: 0,{{.*}} -// CHECK: {{.*}}DIEnumerator{{.*}}name: "Hi",{{.*}}value: 18446744073709551616,{{.*}} -// CHECK: {{.*}}DIEnumerator{{.*}}name: "Bar",{{.*}}value: 18446745000000000123,{{.*}} - -#![allow(incomplete_features)] -#![feature(repr128)] - -#[repr(u128)] -pub enum Foo { - Lo, - Hi = 1 << 64, - Bar = 18_446_745_000_000_000_123, -} - -pub fn main() { - let foo = Foo::Bar; -} diff --git a/tests/codegen/enum/enum-bounds-check-derived-idx.rs b/tests/codegen/enum/enum-bounds-check-derived-idx.rs new file mode 100644 index 000000000..aa66c2ed0 --- /dev/null +++ b/tests/codegen/enum/enum-bounds-check-derived-idx.rs @@ -0,0 +1,24 @@ +// This test checks an optimization that is not guaranteed to work. This test case should not block +// a future LLVM update. +// compile-flags: -O + +#![crate_type = "lib"] + +pub enum Bar { + A = 1, + B = 3, +} + +// CHECK-LABEL: @lookup_inc +#[no_mangle] +pub fn lookup_inc(buf: &[u8; 5], f: Bar) -> u8 { + // CHECK-NOT: panic_bounds_check + buf[f as usize + 1] +} + +// CHECK-LABEL: @lookup_dec +#[no_mangle] +pub fn lookup_dec(buf: &[u8; 5], f: Bar) -> u8 { + // CHECK-NOT: panic_bounds_check + buf[f as usize - 1] +} diff --git a/tests/codegen/enum/enum-bounds-check-issue-13926.rs b/tests/codegen/enum/enum-bounds-check-issue-13926.rs new file mode 100644 index 000000000..b26945bc5 --- /dev/null +++ b/tests/codegen/enum/enum-bounds-check-issue-13926.rs @@ -0,0 +1,18 @@ +// This test checks an optimization that is not guaranteed to work. This test case should not block +// a future LLVM update. +// compile-flags: -O + +#![crate_type = "lib"] + +#[repr(u8)] +pub enum Exception { + Low = 5, + High = 10, +} + +// CHECK-LABEL: @access +#[no_mangle] +pub fn access(array: &[usize; 12], exc: Exception) -> usize { + // CHECK-NOT: panic_bounds_check + array[(exc as u8 - 4) as usize] +} diff --git a/tests/codegen/enum/enum-bounds-check-issue-82871.rs b/tests/codegen/enum/enum-bounds-check-issue-82871.rs new file mode 100644 index 000000000..32fdc4a5f --- /dev/null +++ b/tests/codegen/enum/enum-bounds-check-issue-82871.rs @@ -0,0 +1,18 @@ +// compile-flags: -C opt-level=0 + +#![crate_type = "lib"] + +#[repr(C)] +pub enum E { + A, +} + +// CHECK-LABEL: @index +#[no_mangle] +pub fn index(x: &[u32; 3], ind: E) -> u32 { + // Canary: we should be able to optimize out the bounds check, but we need + // to track the range of the discriminant result in order to be able to do that. + // oli-obk tried to add that, but that caused miscompilations all over the place. + // CHECK: panic_bounds_check + x[ind as usize] +} diff --git a/tests/codegen/enum/enum-bounds-check.rs b/tests/codegen/enum/enum-bounds-check.rs new file mode 100644 index 000000000..17322d591 --- /dev/null +++ b/tests/codegen/enum/enum-bounds-check.rs @@ -0,0 +1,26 @@ +// compile-flags: -O + +#![crate_type = "lib"] + +pub enum Foo { + A, B +} + +// CHECK-LABEL: @lookup +#[no_mangle] +pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 { + // CHECK-NOT: panic_bounds_check + buf[f as usize] +} + +pub enum Bar { + A = 2, + B = 3 +} + +// CHECK-LABEL: @lookup_unmodified +#[no_mangle] +pub fn lookup_unmodified(buf: &[u8; 5], f: Bar) -> u8 { + // CHECK-NOT: panic_bounds_check + buf[f as usize] +} diff --git a/tests/codegen/enum/enum-debug-clike.rs b/tests/codegen/enum/enum-debug-clike.rs new file mode 100644 index 000000000..1e369a2c4 --- /dev/null +++ b/tests/codegen/enum/enum-debug-clike.rs @@ -0,0 +1,23 @@ +// This tests that debug info for "c-like" enums is properly emitted. +// This is ignored for the fallback mode on MSVC due to problems with PDB. + +// +// ignore-msvc + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK-LABEL: @main +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: DIFlagEnumClass,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "A",{{.*}}value: {{[0-9].*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "B",{{.*}}value: {{[0-9].*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "C",{{.*}}value: {{[0-9].*}} + +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_assignments)] + +enum E { A, B, C } + +pub fn main() { + let e = E::C; +} diff --git a/tests/codegen/enum/enum-debug-niche-2.rs b/tests/codegen/enum/enum-debug-niche-2.rs new file mode 100644 index 000000000..4b607d505 --- /dev/null +++ b/tests/codegen/enum/enum-debug-niche-2.rs @@ -0,0 +1,50 @@ +// This tests that optimized enum debug info accurately reflects the enum layout. +// This is ignored for the fallback mode on MSVC due to problems with PDB. + +// +// ignore-msvc + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}} + +#![feature(never_type)] + +#[derive(Copy, Clone)] +pub struct Entity { + private: std::num::NonZeroU32, +} + +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct Declaration; + +impl TypeFamily for Declaration { + type Base = Base; + type Placeholder = !; + + fn intern_base_data(_: BaseKind) {} +} + +#[derive(Copy, Clone)] +pub struct Base; + +pub trait TypeFamily: Copy + 'static { + type Base: Copy; + type Placeholder: Copy; + + fn intern_base_data(_: BaseKind); +} + +#[derive(Copy, Clone)] +pub enum BaseKind { + Named(Entity), + Placeholder(F::Placeholder), + Error, +} + +pub fn main() { + let x = BaseKind::Error::; + let y = 7; +} diff --git a/tests/codegen/enum/enum-debug-niche.rs b/tests/codegen/enum/enum-debug-niche.rs new file mode 100644 index 000000000..b718a6854 --- /dev/null +++ b/tests/codegen/enum/enum-debug-niche.rs @@ -0,0 +1,29 @@ +// This tests that optimized enum debug info accurately reflects the enum layout. +// This is ignored for the fallback mode on MSVC due to problems with PDB. + +// ignore-msvc + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK-LABEL: @main +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "C",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "C",{{.*}} +// CHECK-NOT: {{.*}}DIDerivedType{{.*}}name: "D",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "D",{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "D",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}} + +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_assignments)] + +enum E { A, B, C, D(bool) } + +pub fn main() { + let e = E::D(true); +} diff --git a/tests/codegen/enum/enum-debug-tagged.rs b/tests/codegen/enum/enum-debug-tagged.rs new file mode 100644 index 000000000..095c49ac3 --- /dev/null +++ b/tests/codegen/enum/enum-debug-tagged.rs @@ -0,0 +1,27 @@ +// This tests that debug info for tagged (ordinary) enums is properly emitted. +// This is ignored for the fallback mode on MSVC due to problems with PDB. + +// ignore-msvc + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK-LABEL: @main +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "E",{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}} + +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_assignments)] + +enum E { A(u32), B(u32) } + +pub fn main() { + let e = E::A(23); +} diff --git a/tests/codegen/enum/enum-discriminant-value.rs b/tests/codegen/enum/enum-discriminant-value.rs new file mode 100644 index 000000000..cc14c2120 --- /dev/null +++ b/tests/codegen/enum/enum-discriminant-value.rs @@ -0,0 +1,27 @@ +// Verify that DIEnumerator uses isUnsigned flag when appropriate. +// +// compile-flags: -g -C no-prepopulate-passes + +#[repr(i64)] +pub enum I64 { + I64Min = i64::MIN, + I64Max = i64::MAX, +} + +#[repr(u64)] +pub enum U64 { + U64Min = u64::MIN, + U64Max = u64::MAX, +} + +fn main() { + let _a = I64::I64Min; + let _b = I64::I64Max; + let _c = U64::U64Min; + let _d = U64::U64Max; +} + +// CHECK: !DIEnumerator(name: "I64Min", value: -9223372036854775808) +// CHECK: !DIEnumerator(name: "I64Max", value: 9223372036854775807) +// CHECK: !DIEnumerator(name: "U64Min", value: 0, isUnsigned: true) +// CHECK: !DIEnumerator(name: "U64Max", value: 18446744073709551615, isUnsigned: true) diff --git a/tests/codegen/enum/enum-match.rs b/tests/codegen/enum/enum-match.rs new file mode 100644 index 000000000..5548cd251 --- /dev/null +++ b/tests/codegen/enum/enum-match.rs @@ -0,0 +1,112 @@ +// compile-flags: -Copt-level=1 +// only-x86_64 + +#![crate_type = "lib"] + +// Check each of the 3 cases for `codegen_get_discr`. + +// Case 0: One tagged variant. +pub enum Enum0 { + A(bool), + B, +} + +// CHECK: define noundef i8 @match0{{.*}} +// CHECK-NEXT: start: +// CHECK-NEXT: %1 = icmp eq i8 %0, 2 +// CHECK-NEXT: %2 = and i8 %0, 1 +// CHECK-NEXT: %_0.0 = select i1 %1, i8 13, i8 %2 +#[no_mangle] +pub fn match0(e: Enum0) -> u8 { + use Enum0::*; + match e { + A(b) => b as u8, + B => 13, + } +} + +// Case 1: Niche values are on a boundary for `range`. +pub enum Enum1 { + A(bool), + B, + C, +} + +// CHECK: define noundef i8 @match1{{.*}} +// CHECK-NEXT: start: +// CHECK-NEXT: %1 = add i8 %0, -2 +// CHECK-NEXT: %2 = zext i8 %1 to i64 +// CHECK-NEXT: %3 = icmp ult i8 %1, 2 +// CHECK-NEXT: %4 = add nuw nsw i64 %2, 1 +// CHECK-NEXT: %_2 = select i1 %3, i64 %4, i64 0 +#[no_mangle] +pub fn match1(e: Enum1) -> u8 { + use Enum1::*; + match e { + A(b) => b as u8, + B => 13, + C => 100, + } +} + +// Case 2: Special cases don't apply. +pub enum X { + _2=2, _3, _4, _5, _6, _7, _8, _9, _10, _11, + _12, _13, _14, _15, _16, _17, _18, _19, _20, + _21, _22, _23, _24, _25, _26, _27, _28, _29, + _30, _31, _32, _33, _34, _35, _36, _37, _38, + _39, _40, _41, _42, _43, _44, _45, _46, _47, + _48, _49, _50, _51, _52, _53, _54, _55, _56, + _57, _58, _59, _60, _61, _62, _63, _64, _65, + _66, _67, _68, _69, _70, _71, _72, _73, _74, + _75, _76, _77, _78, _79, _80, _81, _82, _83, + _84, _85, _86, _87, _88, _89, _90, _91, _92, + _93, _94, _95, _96, _97, _98, _99, _100, _101, + _102, _103, _104, _105, _106, _107, _108, _109, + _110, _111, _112, _113, _114, _115, _116, _117, + _118, _119, _120, _121, _122, _123, _124, _125, + _126, _127, _128, _129, _130, _131, _132, _133, + _134, _135, _136, _137, _138, _139, _140, _141, + _142, _143, _144, _145, _146, _147, _148, _149, + _150, _151, _152, _153, _154, _155, _156, _157, + _158, _159, _160, _161, _162, _163, _164, _165, + _166, _167, _168, _169, _170, _171, _172, _173, + _174, _175, _176, _177, _178, _179, _180, _181, + _182, _183, _184, _185, _186, _187, _188, _189, + _190, _191, _192, _193, _194, _195, _196, _197, + _198, _199, _200, _201, _202, _203, _204, _205, + _206, _207, _208, _209, _210, _211, _212, _213, + _214, _215, _216, _217, _218, _219, _220, _221, + _222, _223, _224, _225, _226, _227, _228, _229, + _230, _231, _232, _233, _234, _235, _236, _237, + _238, _239, _240, _241, _242, _243, _244, _245, + _246, _247, _248, _249, _250, _251, _252, _253, +} + +pub enum Enum2 { + A(X), + B, + C, + D, + E, +} + +// CHECK: define noundef i8 @match2{{.*}} +// CHECK-NEXT: start: +// CHECK-NEXT: %1 = add i8 %0, 2 +// CHECK-NEXT: %2 = zext i8 %1 to i64 +// CHECK-NEXT: %3 = icmp ult i8 %1, 4 +// CHECK-NEXT: %4 = add nuw nsw i64 %2, 1 +// CHECK-NEXT: %_2 = select i1 %3, i64 %4, i64 0 +// CHECK-NEXT: switch i64 %_2, label {{.*}} [ +#[no_mangle] +pub fn match2(e: Enum2) -> u8 { + use Enum2::*; + match e { + A(b) => b as u8, + B => 13, + C => 100, + D => 200, + E => 250, + } +} diff --git a/tests/codegen/enum/enum-u128.rs b/tests/codegen/enum/enum-u128.rs new file mode 100644 index 000000000..f50d360ac --- /dev/null +++ b/tests/codegen/enum/enum-u128.rs @@ -0,0 +1,27 @@ +// This tests that debug info for "c-like" 128bit enums is properly emitted. +// This is ignored for the fallback mode on MSVC due to problems with PDB. + +// +// ignore-msvc + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK-LABEL: @main +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "Foo",{{.*}}flags: DIFlagEnumClass,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "Lo",{{.*}}value: 0,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "Hi",{{.*}}value: 18446744073709551616,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "Bar",{{.*}}value: 18446745000000000123,{{.*}} + +#![allow(incomplete_features)] +#![feature(repr128)] + +#[repr(u128)] +pub enum Foo { + Lo, + Hi = 1 << 64, + Bar = 18_446_745_000_000_000_123, +} + +pub fn main() { + let foo = Foo::Bar; +} diff --git a/tests/codegen/fastcall-inreg.rs b/tests/codegen/fastcall-inreg.rs index 02f5d5459..ab19efa45 100644 --- a/tests/codegen/fastcall-inreg.rs +++ b/tests/codegen/fastcall-inreg.rs @@ -19,7 +19,7 @@ pub mod tests { #[no_mangle] pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {} - // CHECK: @f2({{i32\*|ptr}} inreg noundef %_1, {{i32\*|ptr}} inreg noundef %_2, {{i32\*|ptr}} noundef %_3) + // CHECK: @f2(ptr inreg noundef %_1, ptr inreg noundef %_2, ptr noundef %_3) #[no_mangle] pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {} diff --git a/tests/codegen/fewer-names.rs b/tests/codegen/fewer-names.rs index a09c79592..df1080bff 100644 --- a/tests/codegen/fewer-names.rs +++ b/tests/codegen/fewer-names.rs @@ -13,8 +13,8 @@ pub fn sum(x: u32, y: u32) -> u32 { // NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y) // NO-NEXT: start: - // NO-NEXT: %0 = add i32 %y, %x - // NO-NEXT: ret i32 %0 + // NO-NEXT: %z = add i32 %y, %x + // NO-NEXT: ret i32 %z let z = x + y; z } diff --git a/tests/codegen/ffi-const.rs b/tests/codegen/ffi-const.rs deleted file mode 100644 index 937205034..000000000 --- a/tests/codegen/ffi-const.rs +++ /dev/null @@ -1,13 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -#![crate_type = "lib"] -#![feature(ffi_const)] - -pub fn bar() { unsafe { foo() } } - -extern "C" { - // CHECK-LABEL: declare{{.*}}void @foo() - // CHECK-SAME: [[ATTRS:#[0-9]+]] - // The attribute changed from `readnone` to `memory(none)` with LLVM 16.0. - // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readnone|memory\(none\)}}{{.*}} } - #[ffi_const] pub fn foo(); -} diff --git a/tests/codegen/ffi-out-of-bounds-loads.rs b/tests/codegen/ffi-out-of-bounds-loads.rs deleted file mode 100644 index 099726b2f..000000000 --- a/tests/codegen/ffi-out-of-bounds-loads.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Regression test for #29988 - -// compile-flags: -C no-prepopulate-passes -// only-x86_64 -// ignore-windows - -#[repr(C)] -struct S { - f1: i32, - f2: i32, - f3: i32, -} - -extern "C" { - fn foo(s: S); -} - -fn main() { - let s = S { f1: 1, f2: 2, f3: 3 }; - unsafe { - // CHECK: load { i64, i32 }, {{.*}}, align 4 - // CHECK: call void @foo({ i64, i32 } {{.*}}) - foo(s); - } -} diff --git a/tests/codegen/ffi-pure.rs b/tests/codegen/ffi-pure.rs deleted file mode 100644 index 2ed735813..000000000 --- a/tests/codegen/ffi-pure.rs +++ /dev/null @@ -1,13 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -#![crate_type = "lib"] -#![feature(ffi_pure)] - -pub fn bar() { unsafe { foo() } } - -extern "C" { - // CHECK-LABEL: declare{{.*}}void @foo() - // CHECK-SAME: [[ATTRS:#[0-9]+]] - // The attribute changed from `readonly` to `memory(read)` with LLVM 16.0. - // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readonly|memory\(read\)}}{{.*}} } - #[ffi_pure] pub fn foo(); -} diff --git a/tests/codegen/ffi-returns-twice.rs b/tests/codegen/ffi-returns-twice.rs deleted file mode 100644 index 0fbe03f0b..000000000 --- a/tests/codegen/ffi-returns-twice.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -#![crate_type = "lib"] -#![feature(ffi_returns_twice)] - -pub fn bar() { unsafe { foo() } } - -extern "C" { - // CHECK: declare{{( dso_local)?}} void @foo(){{.*}}[[ATTRS:#[0-9]+]] - // CHECK: attributes [[ATTRS]] = { {{.*}}returns_twice{{.*}} } - #[ffi_returns_twice] pub fn foo(); -} diff --git a/tests/codegen/function-arguments-noopt.rs b/tests/codegen/function-arguments-noopt.rs index 0c62e0d35..8fe6c790d 100644 --- a/tests/codegen/function-arguments-noopt.rs +++ b/tests/codegen/function-arguments-noopt.rs @@ -23,13 +23,13 @@ pub fn boolean_call(x: bool, f: fn(bool) -> bool) -> bool { f(x) } -// CHECK: align 4 {{i32\*|ptr}} @borrow({{i32\*|ptr}} align 4 %x) +// CHECK: align 4 ptr @borrow(ptr align 4 %x) #[no_mangle] pub fn borrow(x: &i32) -> &i32 { x } -// CHECK: align 4 {{i32\*|ptr}} @borrow_mut({{i32\*|ptr}} align 4 %x) +// CHECK: align 4 ptr @borrow_mut(ptr align 4 %x) #[no_mangle] pub fn borrow_mut(x: &mut i32) -> &mut i32 { x @@ -38,11 +38,11 @@ pub fn borrow_mut(x: &mut i32) -> &mut i32 { // CHECK-LABEL: @borrow_call #[no_mangle] pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 { - // CHECK: call align 4 {{i32\*|ptr}} %f({{i32\*|ptr}} align 4 %x) + // CHECK: call align 4 ptr %f(ptr align 4 %x) f(x) } -// CHECK: void @struct_({{%S\*|ptr}} sret(%S){{( %0)?}}, {{%S\*|ptr}} %x) +// CHECK: void @struct_(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %x) #[no_mangle] pub fn struct_(x: S) -> S { x @@ -51,7 +51,7 @@ pub fn struct_(x: S) -> S { // CHECK-LABEL: @struct_call #[no_mangle] pub fn struct_call(x: S, f: fn(S) -> S) -> S { - // CHECK: call void %f({{%S\*|ptr}} sret(%S){{( %0)?}}, {{%S\*|ptr}} %{{.+}}) + // CHECK: call void %f(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %{{.+}}) f(x) } diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index d6f019016..a218596da 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -80,95 +80,95 @@ pub fn option_nonzero_int(x: Option) -> Option { x } -// CHECK: @readonly_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @readonly_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn readonly_borrow(_: &i32) { } -// CHECK: noundef align 4 dereferenceable(4) {{i32\*|ptr}} @readonly_borrow_ret() +// CHECK: noundef align 4 dereferenceable(4) ptr @readonly_borrow_ret() #[no_mangle] pub fn readonly_borrow_ret() -> &'static i32 { loop {} } -// CHECK: @static_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @static_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // static borrow may be captured #[no_mangle] pub fn static_borrow(_: &'static i32) { } -// CHECK: @named_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @named_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // borrow with named lifetime may be captured #[no_mangle] pub fn named_borrow<'r>(_: &'r i32) { } -// CHECK: @unsafe_borrow({{i16\*|ptr}} noundef nonnull align 2 %_1) +// CHECK: @unsafe_borrow(ptr noundef nonnull align 2 %_1) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_borrow(_: &UnsafeInner) { } -// CHECK: @mutable_unsafe_borrow({{i16\*|ptr}} noalias noundef align 2 dereferenceable(2) %_1) +// CHECK: @mutable_unsafe_borrow(ptr noalias noundef align 2 dereferenceable(2) %_1) // ... unless this is a mutable borrow, those never alias #[no_mangle] pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { } -// CHECK: @mutable_borrow({{i32\*|ptr}} noalias noundef align 4 dereferenceable(4) %_1) +// CHECK: @mutable_borrow(ptr noalias noundef align 4 dereferenceable(4) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_borrow(_: &mut i32) { } -// CHECK: noundef align 4 dereferenceable(4) {{i32\*|ptr}} @mutable_borrow_ret() +// CHECK: noundef align 4 dereferenceable(4) ptr @mutable_borrow_ret() #[no_mangle] pub fn mutable_borrow_ret() -> &'static mut i32 { loop {} } #[no_mangle] -// CHECK: @mutable_notunpin_borrow({{i32\*|ptr}} noundef nonnull align 4 %_1) +// CHECK: @mutable_notunpin_borrow(ptr noundef nonnull align 4 %_1) // This one is *not* `noalias` because it might be self-referential. // It is also not `dereferenceable` due to // . pub fn mutable_notunpin_borrow(_: &mut NotUnpin) { } -// CHECK: @notunpin_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @notunpin_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // But `&NotUnpin` behaves perfectly normal. #[no_mangle] pub fn notunpin_borrow(_: &NotUnpin) { } -// CHECK: @indirect_struct({{%S\*|ptr}} noalias nocapture noundef readonly dereferenceable(32) %_1) +// CHECK: @indirect_struct(ptr noalias nocapture noundef readonly align 4 dereferenceable(32) %_1) #[no_mangle] pub fn indirect_struct(_: S) { } -// CHECK: @borrowed_struct({{%S\*|ptr}} noalias noundef readonly align 4 dereferenceable(32) %_1) +// CHECK: @borrowed_struct(ptr noalias noundef readonly align 4 dereferenceable(32) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn borrowed_struct(_: &S) { } -// CHECK: @option_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable_or_null(4) %x) +// CHECK: @option_borrow(ptr noalias noundef readonly align 4 dereferenceable_or_null(4) %x) #[no_mangle] pub fn option_borrow(x: Option<&i32>) { } -// CHECK: @option_borrow_mut({{i32\*|ptr}} noalias noundef align 4 dereferenceable_or_null(4) %x) +// CHECK: @option_borrow_mut(ptr noalias noundef align 4 dereferenceable_or_null(4) %x) #[no_mangle] pub fn option_borrow_mut(x: Option<&mut i32>) { } -// CHECK: @raw_struct({{%S\*|ptr}} noundef %_1) +// CHECK: @raw_struct(ptr noundef %_1) #[no_mangle] pub fn raw_struct(_: *const S) { } -// CHECK: @raw_option_nonnull_struct({{i32\*|ptr}} noundef %_1) +// CHECK: @raw_option_nonnull_struct(ptr noundef %_1) #[no_mangle] pub fn raw_option_nonnull_struct(_: Option>) { } @@ -176,19 +176,19 @@ pub fn raw_option_nonnull_struct(_: Option>) { // `Box` can get deallocated during execution of the function, so it should // not get `dereferenceable`. -// CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x) +// CHECK: noundef nonnull align 4 ptr @_box(ptr noalias noundef nonnull align 4 %x) #[no_mangle] pub fn _box(x: Box) -> Box { x } -// CHECK: noundef nonnull align 4 {{i32\*|ptr}} @notunpin_box({{i32\*|ptr}} noundef nonnull align 4 %x) +// CHECK: noundef nonnull align 4 ptr @notunpin_box(ptr noundef nonnull align 4 %x) #[no_mangle] pub fn notunpin_box(x: Box) -> Box { x } -// CHECK: @struct_return({{%S\*|ptr}} noalias nocapture noundef sret(%S) dereferenceable(32){{( %0)?}}) +// CHECK: @struct_return(ptr noalias nocapture noundef sret(%S) align 4 dereferenceable(32){{( %_0)?}}) #[no_mangle] pub fn struct_return() -> S { S { @@ -202,68 +202,68 @@ pub fn struct_return() -> S { pub fn helper(_: usize) { } -// CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @slice(ptr noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn slice(_: &[u8]) { } -// CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @mutable_slice(ptr noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_slice(_: &mut [u8]) { } -// CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @unsafe_slice(ptr noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_slice(_: &[UnsafeInner]) { } -// CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} noundef %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @raw_slice(ptr noundef %_1.0, [[USIZE]] noundef %_1.1) #[no_mangle] pub fn raw_slice(_: *const [u8]) { } -// CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @str(ptr noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn str(_: &[u8]) { } -// CHECK: @trait_borrow({{\{\}\*|ptr}} noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) +// CHECK: @trait_borrow(ptr noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn trait_borrow(_: &dyn Drop) { } -// CHECK: @option_trait_borrow({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +// CHECK: @option_trait_borrow(ptr noundef align 1 %x.0, ptr %x.1) #[no_mangle] pub fn option_trait_borrow(x: Option<&dyn Drop>) { } -// CHECK: @option_trait_borrow_mut({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +// CHECK: @option_trait_borrow_mut(ptr noundef align 1 %x.0, ptr %x.1) #[no_mangle] pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) { } -// CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) +// CHECK: @trait_raw(ptr noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) #[no_mangle] pub fn trait_raw(_: *const dyn Drop) { } -// CHECK: @trait_box({{\{\}\*|ptr}} noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) +// CHECK: @trait_box(ptr noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) #[no_mangle] pub fn trait_box(_: Box) { } -// CHECK: { {{i8\*|ptr}}, {{i8\*|ptr}} } @trait_option({{i8\*|ptr}} noalias noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +// CHECK: { ptr, ptr } @trait_option(ptr noalias noundef align 1 %x.0, ptr %x.1) #[no_mangle] pub fn trait_option(x: Option>) -> Option> { x } -// CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1) +// CHECK: { ptr, [[USIZE]] } @return_slice(ptr noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1) #[no_mangle] pub fn return_slice(x: &[u16]) -> &[u16] { x @@ -281,7 +281,7 @@ pub fn enum_id_2(x: Option) -> Option { x } -// CHECK: { {{\{\}\*|ptr}}, {{.+}} } @dyn_star({{\{\}\*|ptr}} noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1) +// CHECK: { ptr, {{.+}} } @dyn_star(ptr noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1) // Expect an ABI something like `{ {}*, [3 x i64]* }`, but that's hard to match on generically, // so do like the `trait_box` test and just match on `{{.+}}` for the vtable. #[no_mangle] diff --git a/tests/codegen/global_asm.rs b/tests/codegen/global_asm.rs index 41a99530a..4c2ccf4e0 100644 --- a/tests/codegen/global_asm.rs +++ b/tests/codegen/global_asm.rs @@ -1,24 +1,6 @@ -// ignore-aarch64 -// ignore-arm -// ignore-avr -// ignore-bpf -// ignore-bpf -// ignore-hexagon -// ignore-mips -// ignore-mips64 -// ignore-msp430 -// ignore-powerpc64 -// ignore-powerpc -// ignore-sparc -// ignore-sparc64 -// ignore-s390x -// ignore-thumb -// ignore-nvptx64 -// ignore-spirv -// ignore-wasm32 -// ignore-wasm64 -// ignore-emscripten -// ignore-loongarch64 +// revisions: x32 x64 +//[x32] only-x86 +//[x64] only-x86_64 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/global_asm_include.rs b/tests/codegen/global_asm_include.rs index e25c164f4..0fede8c71 100644 --- a/tests/codegen/global_asm_include.rs +++ b/tests/codegen/global_asm_include.rs @@ -1,24 +1,6 @@ -// ignore-aarch64 -// ignore-arm -// ignore-avr -// ignore-bpf -// ignore-bpf -// ignore-hexagon -// ignore-mips -// ignore-mips64 -// ignore-msp430 -// ignore-powerpc64 -// ignore-powerpc -// ignore-sparc -// ignore-sparc64 -// ignore-s390x -// ignore-thumb -// ignore-nvptx64 -// ignore-spirv -// ignore-wasm32 -// ignore-wasm64 -// ignore-emscripten -// ignore-loongarch64 +// revisions: x32 x64 +//[x32] only-x86 +//[x64] only-x86_64 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/global_asm_x2.rs b/tests/codegen/global_asm_x2.rs index 71ecef124..1fc2825b2 100644 --- a/tests/codegen/global_asm_x2.rs +++ b/tests/codegen/global_asm_x2.rs @@ -1,24 +1,6 @@ -// ignore-aarch64 -// ignore-arm -// ignore-avr -// ignore-bpf -// ignore-bpf -// ignore-hexagon -// ignore-mips -// ignore-mips64 -// ignore-msp430 -// ignore-powerpc64 -// ignore-powerpc -// ignore-sparc -// ignore-sparc64 -// ignore-s390x -// ignore-thumb -// ignore-nvptx64 -// ignore-spirv -// ignore-wasm32 -// ignore-wasm64 -// ignore-emscripten -// ignore-loongarch64 +// revisions: x32 x64 +//[x32] only-x86 +//[x64] only-x86_64 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/i686-macosx-deployment-target.rs b/tests/codegen/i686-macosx-deployment-target.rs deleted file mode 100644 index 17258a264..000000000 --- a/tests/codegen/i686-macosx-deployment-target.rs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. -// See issue #60235. - -// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib -// needs-llvm-components: x86 -// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="freeze"] -trait Freeze { } -#[lang="copy"] -trait Copy { } - -#[repr(C)] -pub struct Bool { - b: bool, -} - -// CHECK: target triple = "i686-apple-macosx10.9.0" -#[no_mangle] -pub extern "C" fn structbool() -> Bool { - Bool { b: true } -} diff --git a/tests/codegen/i686-no-macosx-deployment-target.rs b/tests/codegen/i686-no-macosx-deployment-target.rs deleted file mode 100644 index 043040a95..000000000 --- a/tests/codegen/i686-no-macosx-deployment-target.rs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset. -// See issue #60235. - -// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib -// needs-llvm-components: x86 -// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="freeze"] -trait Freeze { } -#[lang="copy"] -trait Copy { } - -#[repr(C)] -pub struct Bool { - b: bool, -} - -// CHECK: target triple = "i686-apple-macosx10.7.0" -#[no_mangle] -pub extern "C" fn structbool() -> Bool { - Bool { b: true } -} diff --git a/tests/codegen/intrinsics/compare_bytes.rs b/tests/codegen/intrinsics/compare_bytes.rs new file mode 100644 index 000000000..e69224d81 --- /dev/null +++ b/tests/codegen/intrinsics/compare_bytes.rs @@ -0,0 +1,34 @@ +// revisions: INT32 INT16 +// compile-flags: -O +// [INT32] ignore-16bit +// [INT16] only-16bit + +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +use std::intrinsics::compare_bytes; + +#[no_mangle] +// CHECK-LABEL: @bytes_cmp( +pub unsafe fn bytes_cmp(a: *const u8, b: *const u8, n: usize) -> i32 { + // INT32: %[[TEMP:.+]] = tail call i32 @memcmp(ptr %a, ptr %b, {{i32|i64}} %n) + // INT32-NOT: sext + // INT32: ret i32 %[[TEMP]] + + // INT16: %[[TEMP1:.+]] = tail call i16 @memcmp(ptr %a, ptr %b, i16 %n) + // INT16: %[[TEMP2:.+]] = sext i16 %[[TEMP1]] to i32 + // INT16: ret i32 %[[TEMP2]] + compare_bytes(a, b, n) +} + +// Ensure that, even though there's an `sext` emitted by the intrinsic, +// that doesn't end up pessiming checks against zero. +#[no_mangle] +// CHECK-LABEL: @bytes_eq( +pub unsafe fn bytes_eq(a: *const u8, b: *const u8, n: usize) -> bool { + // CHECK: call {{.+}} @{{bcmp|memcmp}}(ptr %a, ptr %b, {{i16|i32|i64}} %n) + // CHECK-NOT: sext + // INT32: icmp eq i32 + // INT16: icmp eq i16 + compare_bytes(a, b, n) == 0_i32 +} diff --git a/tests/codegen/intrinsics/mask.rs b/tests/codegen/intrinsics/mask.rs index 8f93da2e5..82131c558 100644 --- a/tests/codegen/intrinsics/mask.rs +++ b/tests/codegen/intrinsics/mask.rs @@ -7,6 +7,6 @@ #[no_mangle] pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 { // CHECK: call - // CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]]({{ptr|i8\*}} {{%ptr|%1}}, [[WORD]] %mask) + // CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]](ptr {{%ptr|%1}}, [[WORD]] %mask) core::intrinsics::ptr_mask(ptr, mask) } diff --git a/tests/codegen/intrinsics/nontemporal.rs b/tests/codegen/intrinsics/nontemporal.rs index d8ee29452..dc020c121 100644 --- a/tests/codegen/intrinsics/nontemporal.rs +++ b/tests/codegen/intrinsics/nontemporal.rs @@ -6,7 +6,7 @@ #[no_mangle] pub fn a(a: &mut u32, b: u32) { // CHECK-LABEL: define{{.*}}void @a - // CHECK: store i32 %b, {{i32\*|ptr}} %a, align 4, !nontemporal + // CHECK: store i32 %b, ptr %a, align 4, !nontemporal unsafe { std::intrinsics::nontemporal_store(a, b); } diff --git a/tests/codegen/intrinsics/offset.rs b/tests/codegen/intrinsics/offset.rs index 7fc4f4498..542bacf99 100644 --- a/tests/codegen/intrinsics/offset.rs +++ b/tests/codegen/intrinsics/offset.rs @@ -1,5 +1,4 @@ // compile-flags: -O -C no-prepopulate-passes -// min-llvm-version: 15.0 (because we're using opaque pointers) #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/transmute-niched.rs b/tests/codegen/intrinsics/transmute-niched.rs index 69e9b1d12..e9c8d803c 100644 --- a/tests/codegen/intrinsics/transmute-niched.rs +++ b/tests/codegen/intrinsics/transmute-niched.rs @@ -2,7 +2,6 @@ // [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes // [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes // only-64bit (so I don't need to worry about usize) -// min-llvm-version: 15.0 # this test assumes `ptr`s #![crate_type = "lib"] @@ -169,16 +168,16 @@ pub unsafe fn check_bool_from_ordering(x: std::cmp::Ordering) -> bool { // CHECK-LABEL: @check_bool_to_ordering( #[no_mangle] pub unsafe fn check_bool_to_ordering(x: bool) -> std::cmp::Ordering { - // CHECK: %0 = zext i1 %x to i8 - // OPT: %1 = icmp ule i8 %0, 1 - // OPT: call void @llvm.assume(i1 %1) - // OPT: %2 = icmp uge i8 %0, -1 - // OPT: %3 = icmp ule i8 %0, 1 - // OPT: %4 = or i1 %2, %3 - // OPT: call void @llvm.assume(i1 %4) + // CHECK: %_0 = zext i1 %x to i8 + // OPT: %0 = icmp ule i8 %_0, 1 + // OPT: call void @llvm.assume(i1 %0) + // OPT: %1 = icmp uge i8 %_0, -1 + // OPT: %2 = icmp ule i8 %_0, 1 + // OPT: %3 = or i1 %1, %2 + // OPT: call void @llvm.assume(i1 %3) // DBG-NOT: icmp // DBG-NOT: assume - // CHECK: ret i8 %0 + // CHECK: ret i8 %_0 transmute(x) } diff --git a/tests/codegen/intrinsics/transmute-x64.rs b/tests/codegen/intrinsics/transmute-x64.rs index 99d258c62..19020f628 100644 --- a/tests/codegen/intrinsics/transmute-x64.rs +++ b/tests/codegen/intrinsics/transmute-x64.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C no-prepopulate-passes // only-x86_64 (it's using arch-specific types) -// min-llvm-version: 15.0 # this test assumes `ptr`s #![crate_type = "lib"] @@ -11,8 +10,8 @@ use std::mem::transmute; #[no_mangle] pub unsafe fn check_sse_float_to_int(x: __m128) -> __m128i { // CHECK-NOT: alloca - // CHECK: %1 = load <4 x float>, ptr %x, align 16 - // CHECK: store <4 x float> %1, ptr %0, align 16 + // CHECK: %0 = load <4 x float>, ptr %x, align 16 + // CHECK: store <4 x float> %0, ptr %_0, align 16 transmute(x) } @@ -20,8 +19,8 @@ pub unsafe fn check_sse_float_to_int(x: __m128) -> __m128i { #[no_mangle] pub unsafe fn check_sse_pair_to_avx(x: (__m128i, __m128i)) -> __m256i { // CHECK-NOT: alloca - // CHECK: %1 = load <4 x i64>, ptr %x, align 16 - // CHECK: store <4 x i64> %1, ptr %0, align 32 + // CHECK: %0 = load <4 x i64>, ptr %x, align 16 + // CHECK: store <4 x i64> %0, ptr %_0, align 32 transmute(x) } @@ -29,7 +28,7 @@ pub unsafe fn check_sse_pair_to_avx(x: (__m128i, __m128i)) -> __m256i { #[no_mangle] pub unsafe fn check_sse_pair_from_avx(x: __m256i) -> (__m128i, __m128i) { // CHECK-NOT: alloca - // CHECK: %1 = load <4 x i64>, ptr %x, align 32 - // CHECK: store <4 x i64> %1, ptr %0, align 16 + // CHECK: %0 = load <4 x i64>, ptr %x, align 32 + // CHECK: store <4 x i64> %0, ptr %_0, align 16 transmute(x) } diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index fe4249400..e64af33ab 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C no-prepopulate-passes // only-64bit (so I don't need to worry about usize) -// min-llvm-version: 15.0 # this test assumes `ptr`s #![crate_type = "lib"] #![feature(core_intrinsics)] @@ -8,8 +7,8 @@ #![feature(inline_const)] #![allow(unreachable_code)] -use std::mem::MaybeUninit; use std::intrinsics::{transmute, transmute_unchecked}; +use std::mem::MaybeUninit; // Some of these need custom MIR to not get removed by MIR optimizations. use std::intrinsics::mir::*; @@ -63,7 +62,7 @@ pub unsafe fn check_to_empty_array(x: [u32; 5]) -> [u32; 0] { // CHECK-NOT: trap // CHECK: call void @llvm.trap // CHECK-NOT: trap - mir!{ + mir! { { RET = CastTransmute(x); Return() @@ -78,7 +77,7 @@ pub unsafe fn check_from_empty_array(x: [u32; 0]) -> [u32; 5] { // CHECK-NOT: trap // CHECK: call void @llvm.trap // CHECK-NOT: trap - mir!{ + mir! { { RET = CastTransmute(x); Return() @@ -93,7 +92,7 @@ pub unsafe fn check_to_uninhabited(x: u16) { // CHECK-NOT: trap // CHECK: call void @llvm.trap // CHECK-NOT: trap - mir!{ + mir! { let temp: BigNever; { temp = CastTransmute(x); @@ -107,7 +106,7 @@ pub unsafe fn check_to_uninhabited(x: u16) { #[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_from_uninhabited(x: BigNever) -> u16 { // CHECK: ret i16 poison - mir!{ + mir! { { RET = CastTransmute(x); Return() @@ -122,9 +121,7 @@ pub unsafe fn check_intermediate_passthrough(x: u32) -> i32 { // CHECK: %[[TMP:.+]] = add i32 1, %x // CHECK: %[[RET:.+]] = add i32 %[[TMP]], 1 // CHECK: ret i32 %[[RET]] - unsafe { - transmute::(1 + x) + 1 - } + unsafe { transmute::(1 + x) + 1 } } // CHECK-LABEL: @check_nop_pair( @@ -134,9 +131,7 @@ pub unsafe fn check_nop_pair(x: (u8, i8)) -> (i8, u8) { // CHECK: %0 = insertvalue { i8, i8 } poison, i8 %x.0, 0 // CHECK: %1 = insertvalue { i8, i8 } %0, i8 %x.1, 1 // CHECK: ret { i8, i8 } %1 - unsafe { - transmute(x) - } + unsafe { transmute(x) } } // CHECK-LABEL: @check_to_newtype( @@ -168,9 +163,9 @@ pub unsafe fn check_aggregate_to_bool(x: Aggregate8) -> bool { // CHECK-LABEL: @check_aggregate_from_bool( #[no_mangle] pub unsafe fn check_aggregate_from_bool(x: bool) -> Aggregate8 { - // CHECK: %0 = alloca %Aggregate8, align 1 + // CHECK: %_0 = alloca %Aggregate8, align 1 // CHECK: %[[BYTE:.+]] = zext i1 %x to i8 - // CHECK: store i8 %[[BYTE]], ptr %0, align 1 + // CHECK: store i8 %[[BYTE]], ptr %_0, align 1 transmute(x) } @@ -195,8 +190,8 @@ pub unsafe fn check_byte_from_bool(x: bool) -> u8 { // CHECK-LABEL: @check_to_pair( #[no_mangle] pub unsafe fn check_to_pair(x: u64) -> Option { - // CHECK: %0 = alloca { i32, i32 }, align 4 - // CHECK: store i64 %x, ptr %0, align 4 + // CHECK: %_0 = alloca { i32, i32 }, align 4 + // CHECK: store i64 %x, ptr %_0, align 4 transmute(x) } @@ -207,11 +202,11 @@ pub unsafe fn check_from_pair(x: Option) -> u64 { // immediates so we can write using the destination alloca's alignment. const { assert!(std::mem::align_of::>() == 4) }; - // CHECK: %0 = alloca i64, align 8 - // CHECK: store i32 %x.0, ptr %1, align 8 - // CHECK: store i32 %x.1, ptr %2, align 4 - // CHECK: %3 = load i64, ptr %0, align 8 - // CHECK: ret i64 %3 + // CHECK: %_0 = alloca i64, align 8 + // CHECK: store i32 %x.0, ptr %0, align 8 + // CHECK: store i32 %x.1, ptr %1, align 4 + // CHECK: %2 = load i64, ptr %_0, align 8 + // CHECK: ret i64 %2 transmute(x) } @@ -219,8 +214,8 @@ pub unsafe fn check_from_pair(x: Option) -> u64 { #[no_mangle] pub unsafe fn check_to_float(x: u32) -> f32 { // CHECK-NOT: alloca - // CHECK: %0 = bitcast i32 %x to float - // CHECK: ret float %0 + // CHECK: %_0 = bitcast i32 %x to float + // CHECK: ret float %_0 transmute(x) } @@ -228,16 +223,16 @@ pub unsafe fn check_to_float(x: u32) -> f32 { #[no_mangle] pub unsafe fn check_from_float(x: f32) -> u32 { // CHECK-NOT: alloca - // CHECK: %0 = bitcast float %x to i32 - // CHECK: ret i32 %0 + // CHECK: %_0 = bitcast float %x to i32 + // CHECK: ret i32 %_0 transmute(x) } // CHECK-LABEL: @check_to_bytes( #[no_mangle] pub unsafe fn check_to_bytes(x: u32) -> [u8; 4] { - // CHECK: %0 = alloca [4 x i8], align 1 - // CHECK: store i32 %x, ptr %0, align 1 + // CHECK: %_0 = alloca [4 x i8], align 1 + // CHECK: store i32 %x, ptr %_0, align 1 transmute(x) } @@ -253,10 +248,10 @@ pub unsafe fn check_from_bytes(x: [u8; 4]) -> u32 { // CHECK-LABEL: @check_to_aggregate( #[no_mangle] pub unsafe fn check_to_aggregate(x: u64) -> Aggregate64 { - // CHECK: %0 = alloca %Aggregate64, align 4 - // CHECK: store i64 %x, ptr %0, align 4 - // CHECK: %1 = load i64, ptr %0, align 4 - // CHECK: ret i64 %1 + // CHECK: %_0 = alloca %Aggregate64, align 4 + // CHECK: store i64 %x, ptr %_0, align 4 + // CHECK: %0 = load i64, ptr %_0, align 4 + // CHECK: ret i64 %0 transmute(x) } @@ -273,7 +268,7 @@ pub unsafe fn check_from_aggregate(x: Aggregate64) -> u64 { #[no_mangle] pub unsafe fn check_long_array_less_aligned(x: [u64; 100]) -> [u16; 400] { // CHECK-NEXT: start - // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 2 %0, ptr align 8 %x, i64 800, i1 false) + // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 2 %_0, ptr align 8 %x, i64 800, i1 false) // CHECK-NEXT: ret void transmute(x) } @@ -282,7 +277,7 @@ pub unsafe fn check_long_array_less_aligned(x: [u64; 100]) -> [u16; 400] { #[no_mangle] pub unsafe fn check_long_array_more_aligned(x: [u8; 100]) -> [u32; 25] { // CHECK-NEXT: start - // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 1 %x, i64 100, i1 false) + // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %_0, ptr align 1 %x, i64 100, i1 false) // CHECK-NEXT: ret void transmute(x) } @@ -301,8 +296,8 @@ pub unsafe fn check_pair_with_bool(x: (u8, bool)) -> (bool, i8) { pub unsafe fn check_float_to_pointer(x: f64) -> *const () { // CHECK-NOT: alloca // CHECK: %0 = bitcast double %x to i64 - // CHECK: %1 = inttoptr i64 %0 to ptr - // CHECK: ret ptr %1 + // CHECK: %_0 = inttoptr i64 %0 to ptr + // CHECK: ret ptr %_0 transmute(x) } @@ -311,8 +306,8 @@ pub unsafe fn check_float_to_pointer(x: f64) -> *const () { pub unsafe fn check_float_from_pointer(x: *const ()) -> f64 { // CHECK-NOT: alloca // CHECK: %0 = ptrtoint ptr %x to i64 - // CHECK: %1 = bitcast i64 %0 to double - // CHECK: ret double %1 + // CHECK: %_0 = bitcast i64 %0 to double + // CHECK: ret double %_0 transmute(x) } @@ -376,10 +371,10 @@ pub unsafe fn check_issue_110005(x: (usize, bool)) -> Option> { // CHECK-LABEL: @check_pair_to_dst_ref( #[no_mangle] pub unsafe fn check_pair_to_dst_ref<'a>(x: (usize, usize)) -> &'a [u8] { - // CHECK: %0 = inttoptr i64 %x.0 to ptr - // CHECK: %1 = insertvalue { ptr, i64 } poison, ptr %0, 0 - // CHECK: %2 = insertvalue { ptr, i64 } %1, i64 %x.1, 1 - // CHECK: ret { ptr, i64 } %2 + // CHECK: %_0.0 = inttoptr i64 %x.0 to ptr + // CHECK: %0 = insertvalue { ptr, i64 } poison, ptr %_0.0, 0 + // CHECK: %1 = insertvalue { ptr, i64 } %0, i64 %x.1, 1 + // CHECK: ret { ptr, i64 } %1 transmute(x) } @@ -391,7 +386,7 @@ pub unsafe fn check_issue_109992(x: ()) -> [(); 1] { // CHECK: start // CHECK-NEXT: ret void - mir!{ + mir! { { RET = CastTransmute(x); Return() @@ -408,7 +403,7 @@ pub unsafe fn check_unit_to_never(x: ()) { // CHECK-NOT: trap // CHECK: call void @llvm.trap // CHECK-NOT: trap - mir!{ + mir! { let temp: ZstNever; { temp = CastTransmute(x); @@ -425,7 +420,7 @@ pub unsafe fn check_unit_from_never(x: ZstNever) -> () { // CHECK: start // CHECK-NEXT: ret void - mir!{ + mir! { { RET = CastTransmute(x); Return() @@ -457,10 +452,10 @@ pub struct HighAlignScalar(u8); // CHECK-LABEL: @check_to_overalign( #[no_mangle] pub unsafe fn check_to_overalign(x: u64) -> HighAlignScalar { - // CHECK: %0 = alloca %HighAlignScalar, align 8 - // CHECK: store i64 %x, ptr %0, align 8 - // CHECK: %1 = load i64, ptr %0, align 8 - // CHECK: ret i64 %1 + // CHECK: %_0 = alloca %HighAlignScalar, align 8 + // CHECK: store i64 %x, ptr %_0, align 8 + // CHECK: %0 = load i64, ptr %_0, align 8 + // CHECK: ret i64 %0 transmute(x) } diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index 6e0eacfe4..f345c96e6 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -1,6 +1,5 @@ // compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates // MIR SROA will decompose the closure -// min-llvm-version: 15.0 # this test uses opaque pointer notation #![feature(stmt_expr_attributes)] pub struct S([usize; 8]); @@ -16,8 +15,8 @@ pub fn outer_function(x: S, y: S) -> usize { // Check that we do not attempt to load from the spilled arg before it is assigned to // when generating debuginfo. // CHECK-LABEL: @outer_function -// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:10:23: 10:25]" -// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:10:23: 10:25]", ptr [[spill]] +// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]" +// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] // CHECK-NOT: [[load:%.*]] = load ptr, ptr // CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) // CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]] diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs index 28b029a8b..e2fbcef72 100644 --- a/tests/codegen/issues/issue-114312.rs +++ b/tests/codegen/issues/issue-114312.rs @@ -1,5 +1,5 @@ // compile-flags: -O -// min-system-llvm-version: 17 +// min-llvm-version: 17 // only-x86_64-unknown-linux-gnu // We want to check that this function does not mis-optimize to loop jumping. diff --git a/tests/codegen/issues/issue-37945.rs b/tests/codegen/issues/issue-37945.rs index 4f386d335..329769940 100644 --- a/tests/codegen/issues/issue-37945.rs +++ b/tests/codegen/issues/issue-37945.rs @@ -12,11 +12,11 @@ use std::slice::Iter; pub fn is_empty_1(xs: Iter) -> bool { // CHECK-LABEL: @is_empty_1( // CHECK-NEXT: start: -// CHECK-NEXT: [[A:%.*]] = icmp ne {{i32\*|ptr}} {{%xs.0|%xs.1}}, null +// CHECK-NEXT: [[A:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null // CHECK-NEXT: tail call void @llvm.assume(i1 [[A]]) // The order between %xs.0 and %xs.1 on the next line doesn't matter // and different LLVM versions produce different order. -// CHECK-NEXT: [[B:%.*]] = icmp eq {{i32\*|ptr}} {{%xs.0, %xs.1|%xs.1, %xs.0}} +// CHECK-NEXT: [[B:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}} // CHECK-NEXT: ret i1 [[B:%.*]] {xs}.next().is_none() } @@ -25,11 +25,11 @@ pub fn is_empty_1(xs: Iter) -> bool { pub fn is_empty_2(xs: Iter) -> bool { // CHECK-LABEL: @is_empty_2 // CHECK-NEXT: start: -// CHECK-NEXT: [[C:%.*]] = icmp ne {{i32\*|ptr}} {{%xs.0|%xs.1}}, null +// CHECK-NEXT: [[C:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null // CHECK-NEXT: tail call void @llvm.assume(i1 [[C]]) // The order between %xs.0 and %xs.1 on the next line doesn't matter // and different LLVM versions produce different order. -// CHECK-NEXT: [[D:%.*]] = icmp eq {{i32\*|ptr}} {{%xs.0, %xs.1|%xs.1, %xs.0}} +// CHECK-NEXT: [[D:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}} // CHECK-NEXT: ret i1 [[D:%.*]] xs.map(|&x| x).next().is_none() } diff --git a/tests/codegen/issues/issue-56267-2.rs b/tests/codegen/issues/issue-56267-2.rs index 4dc9ebfeb..1715e9f05 100644 --- a/tests/codegen/issues/issue-56267-2.rs +++ b/tests/codegen/issues/issue-56267-2.rs @@ -11,7 +11,7 @@ pub struct Foo { // The load from bar.1 should have alignment 4. Not checking // other loads here, as the alignment will be platform-dependent. -// CHECK: %{{.+}} = load i32, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: %{{.+}} = load i32, ptr %{{.+}}, align 4 #[no_mangle] pub fn test(x: Foo<(i32, i32)>) -> (i32, i32) { x.bar diff --git a/tests/codegen/issues/issue-56267.rs b/tests/codegen/issues/issue-56267.rs index 7bdd25779..90aa9f7ae 100644 --- a/tests/codegen/issues/issue-56267.rs +++ b/tests/codegen/issues/issue-56267.rs @@ -11,7 +11,7 @@ pub struct Foo { // The store writing to bar.1 should have alignment 4. Not checking // other stores here, as the alignment will be platform-dependent. -// CHECK: store i32 [[TMP1:%.+]], {{i32\*|ptr}} [[TMP2:%.+]], align 4 +// CHECK: store i32 [[TMP1:%.+]], ptr [[TMP2:%.+]], align 4 #[no_mangle] pub fn test(x: (i32, i32)) -> Foo<(i32, i32)> { Foo { foo: 0, bar: x } diff --git a/tests/codegen/issues/issue-56927.rs b/tests/codegen/issues/issue-56927.rs index 044d72181..1b09ce565 100644 --- a/tests/codegen/issues/issue-56927.rs +++ b/tests/codegen/issues/issue-56927.rs @@ -8,10 +8,10 @@ pub struct S { } // CHECK-LABEL: @test1 -// CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 16 -// CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 4 -// CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 8 -// CHECK: store i32 3, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 0, ptr %{{.+}}, align 16 +// CHECK: store i32 1, ptr %{{.+}}, align 4 +// CHECK: store i32 2, ptr %{{.+}}, align 8 +// CHECK: store i32 3, ptr %{{.+}}, align 4 #[no_mangle] pub fn test1(s: &mut S) { s.arr[0] = 0; @@ -21,7 +21,7 @@ pub fn test1(s: &mut S) { } // CHECK-LABEL: @test2 -// CHECK: store i32 4, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 4, ptr %{{.+}}, align 4 #[allow(unconditional_panic)] #[no_mangle] pub fn test2(s: &mut S) { @@ -29,14 +29,14 @@ pub fn test2(s: &mut S) { } // CHECK-LABEL: @test3 -// CHECK: store i32 5, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 5, ptr %{{.+}}, align 4 #[no_mangle] pub fn test3(s: &mut S, i: usize) { s.arr[i] = 5; } // CHECK-LABEL: @test4 -// CHECK: store i32 6, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 6, ptr %{{.+}}, align 4 #[no_mangle] pub fn test4(s: &mut S) { s.arr = [6; 4]; diff --git a/tests/codegen/issues/issue-58881.rs b/tests/codegen/issues/issue-58881.rs index 00f8953d9..a1d0e8eb7 100644 --- a/tests/codegen/issues/issue-58881.rs +++ b/tests/codegen/issues/issue-58881.rs @@ -16,6 +16,6 @@ struct Bar(u64, u64, u64); // Ensure that emit arguments of the correct type. pub unsafe fn test_call_variadic() { - // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}}) + // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, ptr {{.*}}) variadic_fn(0, Foo(0), Bar(0, 0, 0)) } diff --git a/tests/codegen/issues/issue-85872-multiple-reverse.rs b/tests/codegen/issues/issue-85872-multiple-reverse.rs index 591a1aca7..a4723a0e9 100644 --- a/tests/codegen/issues/issue-85872-multiple-reverse.rs +++ b/tests/codegen/issues/issue-85872-multiple-reverse.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0.0 // compile-flags: -O #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs index be5034dcf..15aef344a 100644 --- a/tests/codegen/issues/issue-86106.rs +++ b/tests/codegen/issues/issue-86106.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0 // only-64bit llvm appears to use stores instead of memset on 32bit // compile-flags: -C opt-level=3 -Z merge-functions=disabled diff --git a/tests/codegen/issues/issue-96274.rs b/tests/codegen/issues/issue-96274.rs index 28bfcce0d..a44789ce3 100644 --- a/tests/codegen/issues/issue-96274.rs +++ b/tests/codegen/issues/issue-96274.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0 // compile-flags: -O #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs index 0413ed6b2..3ea6a5405 100644 --- a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs +++ b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs @@ -3,7 +3,6 @@ // in some situations, see https://github.com/rust-lang/rust/issues/96497#issuecomment-1112865218 // compile-flags: -O -// min-llvm-version: 15.0 #![crate_type="lib"] diff --git a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs index 7da29cd79..b87e43c13 100644 --- a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs +++ b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0.0 // ignore-debug: The debug assertions get in the way // compile-flags: -O diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 24059f190..0b08e5781 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -33,7 +33,8 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN) -> Option(x: &&'a i32) -> &'a i32 { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_ref_higher_alignment #[no_mangle] pub fn load_ref_higher_alignment<'a>(x: &&'a Align16) -> &'a Align16 { - // CHECK: load {{%Align16\*|i128\*|ptr}}, {{%Align16\*\*|i128\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_scalar_pair #[no_mangle] pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16) { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} - // CHECK: load {{i64\*|ptr}}, {{i64\*\*|ptr}} %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META]], !noundef !{{[0-9]+}} *x } @@ -51,70 +51,70 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16 #[no_mangle] pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 { // loaded raw pointer should not have !nonnull or !align metadata - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef ![[NOUNDEF:[0-9]+]]{{$}} + // CHECK: load ptr, ptr %x, align [[PTR_ALIGNMENT]], !noundef ![[NOUNDEF:[0-9]+]]{{$}} *x } // CHECK-LABEL: @load_box #[no_mangle] pub fn load_box<'a>(x: Box>) -> Box { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_bool #[no_mangle] pub fn load_bool(x: &bool) -> bool { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1, !range ![[BOOL_RANGE:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load i8, ptr %x, align 1, !range ![[BOOL_RANGE:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_maybeuninit_bool #[no_mangle] pub fn load_maybeuninit_bool(x: &MaybeUninit) -> MaybeUninit { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1{{$}} + // CHECK: load i8, ptr %x, align 1{{$}} *x } // CHECK-LABEL: @load_enum_bool #[no_mangle] pub fn load_enum_bool(x: &MyBool) -> MyBool { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1, !range ![[BOOL_RANGE]], !noundef !{{[0-9]+}} + // CHECK: load i8, ptr %x, align 1, !range ![[BOOL_RANGE]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_maybeuninit_enum_bool #[no_mangle] pub fn load_maybeuninit_enum_bool(x: &MaybeUninit) -> MaybeUninit { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1{{$}} + // CHECK: load i8, ptr %x, align 1{{$}} *x } // CHECK-LABEL: @load_int #[no_mangle] pub fn load_int(x: &u16) -> u16 { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef ![[NOUNDEF]]{{$}} + // CHECK: load i16, ptr %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } // CHECK-LABEL: @load_nonzero_int #[no_mangle] pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !range ![[NONZEROU16_RANGE:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load i16, ptr %x, align 2, !range ![[NONZEROU16_RANGE:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_option_nonzero_int #[no_mangle] pub fn load_option_nonzero_int(x: &Option) -> Option { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef ![[NOUNDEF]]{{$}} + // CHECK: load i16, ptr %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } // CHECK-LABEL: @borrow #[no_mangle] pub fn borrow(x: &i32) -> &i32 { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x{{.*}}, !nonnull + // CHECK: load ptr, ptr %x{{.*}}, !nonnull &x; // keep variable in an alloca x } @@ -122,7 +122,7 @@ pub fn borrow(x: &i32) -> &i32 { // CHECK-LABEL: @_box #[no_mangle] pub fn _box(x: Box) -> i32 { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x{{.*}}, align [[PTR_ALIGNMENT]] + // CHECK: load ptr, ptr %x{{.*}}, align [[PTR_ALIGNMENT]] *x } @@ -131,7 +131,7 @@ pub fn _box(x: Box) -> i32 { // dependent alignment #[no_mangle] pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] { - // CHECK: [[VAR:%[0-9]+]] = load i32, {{i32\*|ptr}} %{{.*}}, align 1 + // CHECK: [[VAR:%[0-9]+]] = load i32, ptr %{{.*}}, align 1 // CHECK: ret i32 [[VAR]] x } @@ -141,7 +141,7 @@ pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] { // dependent alignment #[no_mangle] pub fn small_struct_alignment(x: Bytes) -> Bytes { - // CHECK: [[VAR:%[0-9]+]] = load i32, {{i32\*|ptr}} %{{.*}}, align 1 + // CHECK: [[VAR:%[0-9]+]] = load i32, ptr %{{.*}}, align 1 // CHECK: ret i32 [[VAR]] x } diff --git a/tests/codegen/macos/i686-macosx-deployment-target.rs b/tests/codegen/macos/i686-macosx-deployment-target.rs new file mode 100644 index 000000000..17258a264 --- /dev/null +++ b/tests/codegen/macos/i686-macosx-deployment-target.rs @@ -0,0 +1,27 @@ +// +// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. +// See issue #60235. + +// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +// needs-llvm-components: x86 +// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "i686-apple-macosx10.9.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/tests/codegen/macos/i686-no-macosx-deployment-target.rs b/tests/codegen/macos/i686-no-macosx-deployment-target.rs new file mode 100644 index 000000000..043040a95 --- /dev/null +++ b/tests/codegen/macos/i686-no-macosx-deployment-target.rs @@ -0,0 +1,27 @@ +// +// Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset. +// See issue #60235. + +// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +// needs-llvm-components: x86 +// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "i686-apple-macosx10.7.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/tests/codegen/macos/x86_64-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-macosx-deployment-target.rs new file mode 100644 index 000000000..8e673d11d --- /dev/null +++ b/tests/codegen/macos/x86_64-macosx-deployment-target.rs @@ -0,0 +1,27 @@ +// +// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. +// See issue #60235. + +// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +// needs-llvm-components: x86 +// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "x86_64-apple-macosx10.9.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs new file mode 100644 index 000000000..25ae6924d --- /dev/null +++ b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs @@ -0,0 +1,27 @@ +// +// Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset. +// See issue #60235. + +// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +// needs-llvm-components: x86 +// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "x86_64-apple-macosx10.7.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/tests/codegen/match-optimized.rs b/tests/codegen/match-optimized.rs index 520c46a0d..e32a5e545 100644 --- a/tests/codegen/match-optimized.rs +++ b/tests/codegen/match-optimized.rs @@ -20,13 +20,13 @@ pub fn exhaustive_match(e: E) -> u8 { // CHECK-NEXT: unreachable // // CHECK: [[A]]: -// CHECK-NEXT: store i8 0, {{i8\*|ptr}} %1, align 1 +// CHECK-NEXT: store i8 0, ptr %_0, align 1 // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] // CHECK: [[B]]: -// CHECK-NEXT: store i8 1, {{i8\*|ptr}} %1, align 1 +// CHECK-NEXT: store i8 1, ptr %_0, align 1 // CHECK-NEXT: br label %[[EXIT]] // CHECK: [[C]]: -// CHECK-NEXT: store i8 2, {{i8\*|ptr}} %1, align 1 +// CHECK-NEXT: store i8 2, ptr %_0, align 1 // CHECK-NEXT: br label %[[EXIT]] match e { E::A => 0, diff --git a/tests/codegen/mem-replace-big-type.rs b/tests/codegen/mem-replace-big-type.rs index c6b920cf5..fc3e9d22b 100644 --- a/tests/codegen/mem-replace-big-type.rs +++ b/tests/codegen/mem-replace-big-type.rs @@ -25,9 +25,9 @@ pub fn replace_big(dst: &mut Big, src: Big) -> Big { // For a large type, we expect exactly three `memcpy`s // CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret(%Big) // CHECK-NOT: call void @llvm.memcpy -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %0, {{i8\*|ptr}} align 8 %dest, i{{.*}} 56, i1 false) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr align 8 %result, ptr align 8 %dest, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %dest, {{i8\*|ptr}} align 8 %src, i{{.*}} 56, i1 false) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr align 8 %dest, ptr align 8 %src, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy // CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs index 751aeaa2b..be3af989e 100644 --- a/tests/codegen/mem-replace-simple-type.rs +++ b/tests/codegen/mem-replace-simple-type.rs @@ -1,5 +1,4 @@ // compile-flags: -O -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) // only-x86_64 (to not worry about usize differing) // ignore-debug (the debug assertions get in the way) @@ -37,7 +36,7 @@ pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str { // CHECK-LABEL: @replace_short_array_3( pub fn replace_short_array_3(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] { // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %r, i64 12, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %result, ptr align 4 %r, i64 12, i1 false) // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 12, i1 false) std::mem::replace(r, v) } @@ -47,7 +46,7 @@ pub fn replace_short_array_3(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] { pub fn replace_short_array_4(r: &mut [u32; 4], v: [u32; 4]) -> [u32; 4] { // CHECK-NOT: alloca // CHECK: %[[R:.+]] = load <4 x i32>, ptr %r, align 4 - // CHECK: store <4 x i32> %[[R]], ptr %0 + // CHECK: store <4 x i32> %[[R]], ptr %result // CHECK: %[[V:.+]] = load <4 x i32>, ptr %v, align 4 // CHECK: store <4 x i32> %[[V]], ptr %r std::mem::replace(r, v) diff --git a/tests/codegen/method-declaration.rs b/tests/codegen/method-declaration.rs new file mode 100644 index 000000000..4ae332b01 --- /dev/null +++ b/tests/codegen/method-declaration.rs @@ -0,0 +1,26 @@ +// compile-flags: -g -Cno-prepopulate-passes + +// Verify that we added a declaration for a method. + +// CHECK: define{{.*}}@method{{.*}} !dbg ![[METHOD_DEF_DBG:[0-9]+]] +// CHECK: define{{.*}}@function{{.*}} !dbg ![[FUNC_DEF_DBG:[0-9]+]] + +#![crate_type = "lib"] + +// CHECK-DAG: ![[FOO_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Foo", {{.*}} identifier: +pub struct Foo; + +impl Foo { + // CHECK-DAG: ![[METHOD_DEF_DBG]] = distinct !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[METHOD_DECL_DBG:[0-9]+]] + // CHECK-DAG: ![[METHOD_DECL_DBG]] = !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]] + #[no_mangle] + pub fn method() {} +} + +// CHECK: ![[FUNC_DEF_DBG]] = distinct !DISubprogram(name: "function" +// CHECK-NOT: declaration +// CHECK-SAME: DISPFlagDefinition +// CHECK-NOT: declaration +// CHECK-SAME: ) +#[no_mangle] +pub fn function() {} diff --git a/tests/codegen/move-operands.rs b/tests/codegen/move-operands.rs index 1d8209e8e..cd87e6d81 100644 --- a/tests/codegen/move-operands.rs +++ b/tests/codegen/move-operands.rs @@ -1,4 +1,5 @@ -// compile-flags: -C no-prepopulate-passes -Zmir-enable-passes=+DestinationPropagation,-CopyProp +// Verify that optimized MIR only copies `a` once. +// compile-flags: -O -C no-prepopulate-passes #![crate_type = "lib"] @@ -6,7 +7,7 @@ type T = [u8; 256]; #[no_mangle] pub fn f(a: T, b: fn(_: T, _: T)) { - // CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, {{.*}} 256, i1 false) - // CHECK-NOT: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, {{.*}} 256, i1 false) + // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, {{.*}} 256, i1 false) + // CHECK-NOT: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, {{.*}} 256, i1 false) b(a, a) } diff --git a/tests/codegen/naked-fn/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs new file mode 100644 index 000000000..e05bbc26e --- /dev/null +++ b/tests/codegen/naked-fn/naked-functions.rs @@ -0,0 +1,32 @@ +// compile-flags: -C no-prepopulate-passes -Copt-level=0 +// needs-asm-support +// only-x86_64 + +#![crate_type = "lib"] +#![feature(naked_functions)] +use std::arch::asm; + +// CHECK: Function Attrs: naked +// CHECK-NEXT: define{{.*}}void @naked_empty() +#[no_mangle] +#[naked] +pub unsafe extern "C" fn naked_empty() { + // CHECK-NEXT: {{.+}}: + // CHECK-NEXT: call void asm + // CHECK-NEXT: unreachable + asm!("ret", + options(noreturn)); +} + +// CHECK: Function Attrs: naked +// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b) +#[no_mangle] +#[naked] +pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize { + // CHECK-NEXT: {{.+}}: + // CHECK-NEXT: call void asm + // CHECK-NEXT: unreachable + asm!("lea rax, [rdi + rsi]", + "ret", + options(noreturn)); +} diff --git a/tests/codegen/naked-fn/naked-nocoverage.rs b/tests/codegen/naked-fn/naked-nocoverage.rs new file mode 100644 index 000000000..3c755e49c --- /dev/null +++ b/tests/codegen/naked-fn/naked-nocoverage.rs @@ -0,0 +1,19 @@ +// Checks that naked functions are not instrumented by -Cinstrument-coverage. +// Regression test for issue #105170. +// +// needs-asm-support +// needs-profiler-support +// compile-flags: -Cinstrument-coverage +#![crate_type = "lib"] +#![feature(naked_functions)] +use std::arch::asm; + +#[naked] +#[no_mangle] +pub unsafe extern "C" fn f() { + // CHECK: define {{(dso_local )?}}void @f() + // CHECK-NEXT: start: + // CHECK-NEXT: call void asm + // CHECK-NEXT: unreachable + asm!("", options(noreturn)); +} diff --git a/tests/codegen/naked-fn/naked-noinline.rs b/tests/codegen/naked-fn/naked-noinline.rs new file mode 100644 index 000000000..5cfb500c0 --- /dev/null +++ b/tests/codegen/naked-fn/naked-noinline.rs @@ -0,0 +1,31 @@ +// Checks that naked functions are never inlined. +// compile-flags: -O -Zmir-opt-level=3 +// needs-asm-support +// ignore-wasm32 +#![crate_type = "lib"] +#![feature(naked_functions)] + +use std::arch::asm; + +#[naked] +#[no_mangle] +pub unsafe extern "C" fn f() { + // Check that f has naked and noinline attributes. + // + // CHECK: define {{(dso_local )?}}void @f() unnamed_addr [[ATTR:#[0-9]+]] + // CHECK-NEXT: start: + // CHECK-NEXT: call void asm + asm!("", options(noreturn)); +} + +#[no_mangle] +pub unsafe fn g() { + // Check that call to f is not inlined. + // + // CHECK-LABEL: define {{(dso_local )?}}void @g() + // CHECK-NEXT: start: + // CHECK-NEXT: call void @f() + f(); +} + +// CHECK: attributes [[ATTR]] = { naked{{.*}}noinline{{.*}} } diff --git a/tests/codegen/naked-functions.rs b/tests/codegen/naked-functions.rs deleted file mode 100644 index e05bbc26e..000000000 --- a/tests/codegen/naked-functions.rs +++ /dev/null @@ -1,32 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -Copt-level=0 -// needs-asm-support -// only-x86_64 - -#![crate_type = "lib"] -#![feature(naked_functions)] -use std::arch::asm; - -// CHECK: Function Attrs: naked -// CHECK-NEXT: define{{.*}}void @naked_empty() -#[no_mangle] -#[naked] -pub unsafe extern "C" fn naked_empty() { - // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: call void asm - // CHECK-NEXT: unreachable - asm!("ret", - options(noreturn)); -} - -// CHECK: Function Attrs: naked -// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b) -#[no_mangle] -#[naked] -pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize { - // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: call void asm - // CHECK-NEXT: unreachable - asm!("lea rax, [rdi + rsi]", - "ret", - options(noreturn)); -} diff --git a/tests/codegen/naked-nocoverage.rs b/tests/codegen/naked-nocoverage.rs deleted file mode 100644 index 3c755e49c..000000000 --- a/tests/codegen/naked-nocoverage.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Checks that naked functions are not instrumented by -Cinstrument-coverage. -// Regression test for issue #105170. -// -// needs-asm-support -// needs-profiler-support -// compile-flags: -Cinstrument-coverage -#![crate_type = "lib"] -#![feature(naked_functions)] -use std::arch::asm; - -#[naked] -#[no_mangle] -pub unsafe extern "C" fn f() { - // CHECK: define {{(dso_local )?}}void @f() - // CHECK-NEXT: start: - // CHECK-NEXT: call void asm - // CHECK-NEXT: unreachable - asm!("", options(noreturn)); -} diff --git a/tests/codegen/naked-noinline.rs b/tests/codegen/naked-noinline.rs deleted file mode 100644 index 5cfb500c0..000000000 --- a/tests/codegen/naked-noinline.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Checks that naked functions are never inlined. -// compile-flags: -O -Zmir-opt-level=3 -// needs-asm-support -// ignore-wasm32 -#![crate_type = "lib"] -#![feature(naked_functions)] - -use std::arch::asm; - -#[naked] -#[no_mangle] -pub unsafe extern "C" fn f() { - // Check that f has naked and noinline attributes. - // - // CHECK: define {{(dso_local )?}}void @f() unnamed_addr [[ATTR:#[0-9]+]] - // CHECK-NEXT: start: - // CHECK-NEXT: call void asm - asm!("", options(noreturn)); -} - -#[no_mangle] -pub unsafe fn g() { - // Check that call to f is not inlined. - // - // CHECK-LABEL: define {{(dso_local )?}}void @g() - // CHECK-NEXT: start: - // CHECK-NEXT: call void @f() - f(); -} - -// CHECK: attributes [[ATTR]] = { naked{{.*}}noinline{{.*}} } diff --git a/tests/codegen/no_builtins-at-crate.rs b/tests/codegen/no_builtins-at-crate.rs new file mode 100644 index 000000000..02ed67090 --- /dev/null +++ b/tests/codegen/no_builtins-at-crate.rs @@ -0,0 +1,24 @@ +// compile-flags: -C opt-level=1 + +#![no_builtins] +#![crate_type = "lib"] + +// CHECK: define +// CHECK-SAME: @__aeabi_memcpy +// CHECK-SAME: #0 +#[no_mangle] +pub unsafe extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, size: usize) { + // CHECK: call + // CHECK-SAME: @memcpy( + memcpy(dest, src, size); +} + +// CHECK: declare +// CHECK-SAME: @memcpy +// CHECK-SAME: #0 +extern "C" { + pub fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8; +} + +// CHECK: attributes #0 +// CHECK-SAME: "no-builtins" diff --git a/tests/codegen/option-nonzero-eq.rs b/tests/codegen/option-nonzero-eq.rs index a394695f3..ce5b6328a 100644 --- a/tests/codegen/option-nonzero-eq.rs +++ b/tests/codegen/option-nonzero-eq.rs @@ -32,7 +32,7 @@ pub fn non_zero_signed_eq(l: Option, r: Option) -> bool #[no_mangle] pub fn non_null_eq(l: Option>, r: Option>) -> bool { // CHECK: start: - // CHECK-NEXT: icmp eq {{(i8\*|ptr)}} + // CHECK-NEXT: icmp eq ptr // CHECK-NEXT: ret i1 l == r } diff --git a/tests/codegen/packed.rs b/tests/codegen/packed.rs index fd63b4f0a..96cd9a42e 100644 --- a/tests/codegen/packed.rs +++ b/tests/codegen/packed.rs @@ -18,8 +18,8 @@ pub struct Packed2 { // CHECK-LABEL: @write_pkd1 #[no_mangle] pub fn write_pkd1(pkd: &mut Packed1) -> u32 { -// CHECK: %{{.*}} = load i32, {{i32\*|ptr}} %{{.*}}, align 1 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.*}}, align 1 +// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 1 +// CHECK: store i32 42, ptr %{{.*}}, align 1 let result = pkd.data; pkd.data = 42; result @@ -28,8 +28,8 @@ pub fn write_pkd1(pkd: &mut Packed1) -> u32 { // CHECK-LABEL: @write_pkd2 #[no_mangle] pub fn write_pkd2(pkd: &mut Packed2) -> u32 { -// CHECK: %{{.*}} = load i32, {{i32\*|ptr}} %{{.*}}, align 2 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.*}}, align 2 +// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 2 +// CHECK: store i32 42, ptr %{{.*}}, align 2 let result = pkd.data; pkd.data = 42; result @@ -52,8 +52,8 @@ pub struct BigPacked2 { #[no_mangle] pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 { // CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca %Array -// CHECK: call void %{{.*}}({{%Array\*|ptr}} noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) +// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) // check that calls whose destination is a field of a packed struct // go through an alloca rather than calling the function with an // unaligned destination. @@ -64,8 +64,8 @@ pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 { #[no_mangle] pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 { // CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca %Array -// CHECK: call void %{{.*}}({{%Array\*|ptr}} noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 2 %{{.*}}, {{i8\*|ptr}} align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) +// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) // check that calls whose destination is a field of a packed struct // go through an alloca rather than calling the function with an // unaligned destination. @@ -73,9 +73,9 @@ pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 { } // CHECK-LABEL: @write_packed_array1 -// CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 1 -// CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 1 -// CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 1 +// CHECK: store i32 0, ptr %{{.+}}, align 1 +// CHECK: store i32 1, ptr %{{.+}}, align 1 +// CHECK: store i32 2, ptr %{{.+}}, align 1 #[no_mangle] pub fn write_packed_array1(p: &mut BigPacked1) { p.data.0[0] = 0; @@ -84,9 +84,9 @@ pub fn write_packed_array1(p: &mut BigPacked1) { } // CHECK-LABEL: @write_packed_array2 -// CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 2 -// CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 2 -// CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 2 +// CHECK: store i32 0, ptr %{{.+}}, align 2 +// CHECK: store i32 1, ptr %{{.+}}, align 2 +// CHECK: store i32 2, ptr %{{.+}}, align 2 #[no_mangle] pub fn write_packed_array2(p: &mut BigPacked2) { p.data.0[0] = 0; @@ -95,14 +95,14 @@ pub fn write_packed_array2(p: &mut BigPacked2) { } // CHECK-LABEL: @repeat_packed_array1 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.+}}, align 1 +// CHECK: store i32 42, ptr %{{.+}}, align 1 #[no_mangle] pub fn repeat_packed_array1(p: &mut BigPacked1) { p.data.0 = [42; 8]; } // CHECK-LABEL: @repeat_packed_array2 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.+}}, align 2 +// CHECK: store i32 42, ptr %{{.+}}, align 2 #[no_mangle] pub fn repeat_packed_array2(p: &mut BigPacked2) { p.data.0 = [42; 8]; @@ -119,14 +119,14 @@ pub struct Packed2Pair(u8, u32); // CHECK-LABEL: @pkd1_pair #[no_mangle] pub fn pkd1_pair(pair1: &mut Packed1Pair, pair2: &mut Packed1Pair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{[0-9]+}} 5, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 5, i1 false) *pair2 = *pair1; } // CHECK-LABEL: @pkd2_pair #[no_mangle] pub fn pkd2_pair(pair1: &mut Packed2Pair, pair2: &mut Packed2Pair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 2 %{{.*}}, {{i8\*|ptr}} align 2 %{{.*}}, i{{[0-9]+}} 6, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 6, i1 false) *pair2 = *pair1; } @@ -141,13 +141,13 @@ pub struct Packed2NestedPair((u32, u32)); // CHECK-LABEL: @pkd1_nested_pair #[no_mangle] pub fn pkd1_nested_pair(pair1: &mut Packed1NestedPair, pair2: &mut Packed1NestedPair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{[0-9]+}} 8, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 8, i1 false) *pair2 = *pair1; } // CHECK-LABEL: @pkd2_nested_pair #[no_mangle] pub fn pkd2_nested_pair(pair1: &mut Packed2NestedPair, pair2: &mut Packed2NestedPair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 2 %{{.*}}, {{i8\*|ptr}} align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false) *pair2 = *pair1; } diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs index 9ff7a9b3e..47243bece 100644 --- a/tests/codegen/personality_lifetimes.rs +++ b/tests/codegen/personality_lifetimes.rs @@ -22,7 +22,7 @@ pub fn test() { let _s = S; // Check that the personality slot alloca gets a lifetime start in each cleanup block, not just // in the first one. - // CHECK: [[SLOT:%[0-9]+]] = alloca { {{i8\*|ptr}}, i32 } + // CHECK: [[SLOT:%[0-9]+]] = alloca { ptr, i32 } // CHECK-LABEL: cleanup: // CHECK: call void @llvm.lifetime.start.{{.*}}({{.*}}) // CHECK-LABEL: cleanup1: diff --git a/tests/codegen/ptr-arithmetic.rs b/tests/codegen/ptr-arithmetic.rs new file mode 100644 index 000000000..292bfdaf3 --- /dev/null +++ b/tests/codegen/ptr-arithmetic.rs @@ -0,0 +1,34 @@ +// compile-flags: -O -Z merge-functions=disabled +// ignore-debug (the extra assertions get in the way) + +#![crate_type = "lib"] + +// CHECK-LABEL: ptr @i32_add( +// CHECK-SAME: [[WORD:i[0-9]+]] noundef %n) +#[no_mangle] +pub unsafe fn i32_add(p: *const i32, n: usize) -> *const i32 { + // CHECK: %[[TEMP:.+]] = getelementptr inbounds i32, ptr %p, [[WORD]] %n + // CHECK: ret ptr %[[TEMP]] + p.add(n) +} + +// Ensure we tell LLVM that the negation in `sub` can't overflow. + +// CHECK-LABEL: ptr @i32_sub( +// CHECK-SAME: [[WORD:i[0-9]+]] noundef %n) +#[no_mangle] +pub unsafe fn i32_sub(p: *const i32, n: usize) -> *const i32 { + // CHECK: %[[DELTA:.+]] = sub nsw [[WORD]] 0, %n + // CHECK: %[[TEMP:.+]] = getelementptr inbounds i32, ptr %p, [[WORD]] %[[DELTA]] + // CHECK: ret ptr %[[TEMP]] + p.sub(n) +} + +// CHECK-LABEL: ptr @i32_offset( +// CHECK-SAME: [[WORD:i[0-9]+]] noundef %d) +#[no_mangle] +pub unsafe fn i32_offset(p: *const i32, d: isize) -> *const i32 { + // CHECK: %[[TEMP:.+]] = getelementptr inbounds i32, ptr %p, [[WORD]] %d + // CHECK: ret ptr %[[TEMP]] + p.offset(d) +} diff --git a/tests/codegen/refs.rs b/tests/codegen/refs.rs index a52897667..1c7746a30 100644 --- a/tests/codegen/refs.rs +++ b/tests/codegen/refs.rs @@ -13,9 +13,9 @@ pub fn helper(_: usize) { pub fn ref_dst(s: &[u8]) { // We used to generate an extra alloca and memcpy to ref the dst, so check that we copy // directly to the alloca for "x" -// CHECK: [[X0:%[0-9]+]] = getelementptr inbounds { {{\[0 x i8\]\*|ptr}}, [[USIZE]] }, {{.*}} %x, i32 0, i32 0 -// CHECK: store {{\[0 x i8\]\*|ptr}} %s.0, {{.*}} [[X0]] -// CHECK: [[X1:%[0-9]+]] = getelementptr inbounds { {{\[0 x i8\]\*|ptr}}, [[USIZE]] }, {{.*}} %x, i32 0, i32 1 +// CHECK: [[X0:%[0-9]+]] = getelementptr inbounds { ptr, [[USIZE]] }, {{.*}} %x, i32 0, i32 0 +// CHECK: store ptr %s.0, {{.*}} [[X0]] +// CHECK: [[X1:%[0-9]+]] = getelementptr inbounds { ptr, [[USIZE]] }, {{.*}} %x, i32 0, i32 1 // CHECK: store [[USIZE]] %s.1, {{.*}} [[X1]] let x = &*s; diff --git a/tests/codegen/repeat-trusted-len.rs b/tests/codegen/repeat-trusted-len.rs index 87c8fe135..bd6ff977e 100644 --- a/tests/codegen/repeat-trusted-len.rs +++ b/tests/codegen/repeat-trusted-len.rs @@ -8,13 +8,13 @@ use std::iter; // CHECK-LABEL: @repeat_take_collect #[no_mangle] pub fn repeat_take_collect() -> Vec { -// CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}align 1{{.*}} %{{[0-9]+}}, i8 42, i{{[0-9]+}} 100000, i1 false) + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}align 1{{.*}} %{{.*}}, i8 42, i{{[0-9]+}} 100000, i1 false) iter::repeat(42).take(100000).collect() } // CHECK-LABEL: @repeat_with_take_collect #[no_mangle] pub fn repeat_with_take_collect() -> Vec { -// CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}align 1{{.*}} %{{[0-9]+}}, i8 13, i{{[0-9]+}} 12345, i1 false) + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}align 1{{.*}} %{{.*}}, i8 13, i{{[0-9]+}} 12345, i1 false) iter::repeat_with(|| 13).take(12345).collect() } diff --git a/tests/codegen/repr-transparent-aggregates-1.rs b/tests/codegen/repr-transparent-aggregates-1.rs deleted file mode 100644 index 9c4b0e58e..000000000 --- a/tests/codegen/repr-transparent-aggregates-1.rs +++ /dev/null @@ -1,88 +0,0 @@ -// compile-flags: -O -C no-prepopulate-passes -// - -// ignore-arm -// ignore-aarch64 -// ignore-mips -// ignore-mips64 -// ignore-powerpc -// ignore-powerpc64 -// ignore-riscv64 see codegen/riscv-abi -// ignore-s390x -// ignore-windows -// ignore-loongarch64 -// See repr-transparent.rs - -#![feature(transparent_unions)] - -#![crate_type="lib"] - - -#[derive(Clone, Copy)] -#[repr(C)] -pub struct BigS([u32; 16]); - -#[repr(transparent)] -pub struct TsBigS(BigS); - -#[repr(transparent)] -pub union TuBigS { - field: BigS, -} - -#[repr(transparent)] -pub enum TeBigS { - Variant(BigS), -} - -// CHECK: define{{.*}}void @test_BigS({{%BigS\*|ptr}} [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], {{%BigS\*|ptr}} [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]]) -#[no_mangle] -pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} } - -// CHECK: define{{.*}}void @test_TsBigS({{%TsBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], {{%TsBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]]) -#[no_mangle] -pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } - -// CHECK: define{{.*}}void @test_TuBigS({{%TuBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], {{%TuBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]]) -#[no_mangle] -pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } - -// CHECK: define{{.*}}void @test_TeBigS({{%"TeBigS::Variant"\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], {{%"TeBigS::Variant"\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]]) -#[no_mangle] -pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } - - -#[derive(Clone, Copy)] -#[repr(C)] -pub union BigU { - foo: [u32; 16], -} - -#[repr(transparent)] -pub struct TsBigU(BigU); - -#[repr(transparent)] -pub union TuBigU { - field: BigU, -} - -#[repr(transparent)] -pub enum TeBigU { - Variant(BigU), -} - -// CHECK: define{{.*}}void @test_BigU({{%BigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], {{%BigU\*|ptr}} [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]]) -#[no_mangle] -pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} } - -// CHECK: define{{.*}}void @test_TsBigU({{%TsBigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], {{%TsBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]]) -#[no_mangle] -pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } - -// CHECK: define{{.*}}void @test_TuBigU({{%TuBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], {{%TuBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]]) -#[no_mangle] -pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } - -// CHECK: define{{.*}}void @test_TeBigU({{%"TeBigU::Variant"\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], {{%"TeBigU::Variant"\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]]) -#[no_mangle] -pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr-transparent-aggregates-2.rs b/tests/codegen/repr-transparent-aggregates-2.rs deleted file mode 100644 index a7bde2d05..000000000 --- a/tests/codegen/repr-transparent-aggregates-2.rs +++ /dev/null @@ -1,90 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -// - -// ignore-aarch64 -// ignore-emscripten -// ignore-mips64 -// ignore-powerpc -// ignore-powerpc64 -// ignore-riscv64 see codegen/riscv-abi -// ignore-s390x -// ignore-sparc -// ignore-sparc64 -// ignore-x86 -// ignore-x86_64 -// ignore-loongarch64 -// See repr-transparent.rs - -#![feature(transparent_unions)] - -#![crate_type="lib"] - - -#[derive(Clone, Copy)] -#[repr(C)] -pub struct BigS([u32; 16]); - -#[repr(transparent)] -pub struct TsBigS(BigS); - -#[repr(transparent)] -pub union TuBigS { - field: BigS, -} - -#[repr(transparent)] -pub enum TeBigS { - Variant(BigS), -} - -// CHECK: define void @test_BigS({{%BigS\*|ptr}} [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [16 x i32] -#[no_mangle] -pub extern fn test_BigS(_: BigS) -> BigS { loop {} } - -// CHECK: define void @test_TsBigS({{%TsBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [16 x i32] -#[no_mangle] -pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } - -// CHECK: define void @test_TuBigS({{%TuBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [16 x i32] -#[no_mangle] -pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } - -// CHECK: define void @test_TeBigS({{%"TeBigS::Variant"\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [16 x i32] -#[no_mangle] -pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } - - -#[derive(Clone, Copy)] -#[repr(C)] -pub union BigU { - foo: [u32; 16], -} - -#[repr(transparent)] -pub struct TsBigU(BigU); - -#[repr(transparent)] -pub union TuBigU { - field: BigU, -} - -#[repr(transparent)] -pub enum TeBigU { - Variant(BigU), -} - -// CHECK: define void @test_BigU({{%BigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [16 x i32] -#[no_mangle] -pub extern fn test_BigU(_: BigU) -> BigU { loop {} } - -// CHECK: define void @test_TsBigU({{%TsBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [16 x i32] -#[no_mangle] -pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } - -// CHECK: define void @test_TuBigU({{%TuBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [16 x i32] -#[no_mangle] -pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } - -// CHECK: define void @test_TeBigU({{%"TeBigU::Variant"\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [16 x i32] -#[no_mangle] -pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr-transparent-aggregates-3.rs b/tests/codegen/repr-transparent-aggregates-3.rs deleted file mode 100644 index 0db17e6b1..000000000 --- a/tests/codegen/repr-transparent-aggregates-3.rs +++ /dev/null @@ -1,79 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -// - -// only-mips64 -// See repr-transparent.rs - -#![feature(transparent_unions)] - -#![crate_type="lib"] - - -#[derive(Clone, Copy)] -#[repr(C)] -pub struct BigS([u32; 16]); - -#[repr(transparent)] -pub struct TsBigS(BigS); - -#[repr(transparent)] -pub union TuBigS { - field: BigS, -} - -#[repr(transparent)] -pub enum TeBigS { - Variant(BigS), -} - -// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [8 x i64] -#[no_mangle] -pub extern fn test_BigS(_: BigS) -> BigS { loop {} } - -// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [8 x i64] -#[no_mangle] -pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } - -// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [8 x i64] -#[no_mangle] -pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } - -// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [8 x i64] -#[no_mangle] -pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } - - -#[derive(Clone, Copy)] -#[repr(C)] -pub union BigU { - foo: [u32; 16], -} - -#[repr(transparent)] -pub struct TsBigU(BigU); - -#[repr(transparent)] -pub union TuBigU { - field: BigU, -} - -#[repr(transparent)] -pub enum TeBigU { - Variant(BigU), -} - -// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [8 x i64] -#[no_mangle] -pub extern fn test_BigU(_: BigU) -> BigU { loop {} } - -// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [8 x i64] -#[no_mangle] -pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } - -// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [8 x i64] -#[no_mangle] -pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } - -// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [8 x i64] -#[no_mangle] -pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr-transparent-sysv64.rs b/tests/codegen/repr-transparent-sysv64.rs deleted file mode 100644 index 886b0dd9e..000000000 --- a/tests/codegen/repr-transparent-sysv64.rs +++ /dev/null @@ -1,28 +0,0 @@ -// only-x86_64 - -// compile-flags: -C no-prepopulate-passes - -#![crate_type="lib"] - -#[repr(C)] -pub struct Rgb8 { r: u8, g: u8, b: u8 } - -#[repr(transparent)] -pub struct Rgb8Wrap(Rgb8); - -// CHECK: i24 @test_Rgb8Wrap(i24{{( %0)?}}) -#[no_mangle] -pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} } - -#[repr(C)] -pub union FloatBits { - float: f32, - bits: u32, -} - -#[repr(transparent)] -pub struct SmallUnion(FloatBits); - -// CHECK: i32 @test_SmallUnion(i32{{( %0)?}}) -#[no_mangle] -pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} } diff --git a/tests/codegen/repr-transparent.rs b/tests/codegen/repr-transparent.rs deleted file mode 100644 index 759ddea67..000000000 --- a/tests/codegen/repr-transparent.rs +++ /dev/null @@ -1,171 +0,0 @@ -// compile-flags: -O -C no-prepopulate-passes - -// ignore-riscv64 riscv64 has an i128 type used with test_Vector -// see codegen/riscv-abi for riscv functiona call tests -// ignore-s390x s390x with default march passes vector types per reference -// ignore-loongarch64 see codegen/loongarch-abi for loongarch function call tests - -#![crate_type="lib"] -#![feature(repr_simd, transparent_unions)] - -use std::marker::PhantomData; - -#[derive(Copy, Clone)] -pub struct Zst1; -#[derive(Copy, Clone)] -pub struct Zst2(()); - -#[derive(Copy, Clone)] -#[repr(transparent)] -pub struct F32(f32); - -// CHECK: define{{.*}}float @test_F32(float noundef %_1) -#[no_mangle] -pub extern "C" fn test_F32(_: F32) -> F32 { loop {} } - -#[repr(transparent)] -pub struct Ptr(*mut u8); - -// CHECK: define{{.*}}{{i8\*|ptr}} @test_Ptr({{i8\*|ptr}} noundef %_1) -#[no_mangle] -pub extern "C" fn test_Ptr(_: Ptr) -> Ptr { loop {} } - -#[repr(transparent)] -pub struct WithZst(u64, Zst1); - -// CHECK: define{{.*}}i64 @test_WithZst(i64 noundef %_1) -#[no_mangle] -pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} } - -#[repr(transparent)] -pub struct WithZeroSizedArray(*const f32, [i8; 0]); - -// Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever. -// CHECK: define{{.*}}{{i32\*|ptr}} @test_WithZeroSizedArray({{i32\*|ptr}} noundef %_1) -#[no_mangle] -pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} } - -#[repr(transparent)] -pub struct Generic(T); - -// CHECK: define{{.*}}double @test_Generic(double noundef %_1) -#[no_mangle] -pub extern "C" fn test_Generic(_: Generic) -> Generic { loop {} } - -#[repr(transparent)] -pub struct GenericPlusZst(T, Zst2); - -#[repr(u8)] -pub enum Bool { True, False, FileNotFound } - -// CHECK: define{{( dso_local)?}} noundef{{( zeroext)?}} i8 @test_Gpz(i8 noundef{{( zeroext)?}} %_1) -#[no_mangle] -pub extern "C" fn test_Gpz(_: GenericPlusZst) -> GenericPlusZst { loop {} } - -#[repr(transparent)] -pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>); - -// CHECK: define{{.*}}{{i16\*|ptr}} @test_LifetimePhantom({{i16\*|ptr}} noundef %_1) -#[no_mangle] -pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom) -> LifetimePhantom { loop {} } - -// This works despite current alignment resrictions because PhantomData is always align(1) -#[repr(transparent)] -pub struct UnitPhantom { val: T, unit: PhantomData } - -pub struct Px; - -// CHECK: define{{.*}}float @test_UnitPhantom(float noundef %_1) -#[no_mangle] -pub extern "C" fn test_UnitPhantom(_: UnitPhantom) -> UnitPhantom { loop {} } - -#[repr(transparent)] -pub struct TwoZsts(Zst1, i8, Zst2); - -// CHECK: define{{( dso_local)?}} noundef{{( signext)?}} i8 @test_TwoZsts(i8 noundef{{( signext)?}} %_1) -#[no_mangle] -pub extern "C" fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} } - -#[repr(transparent)] -pub struct Nested1(Zst2, Generic); - -// CHECK: define{{.*}}double @test_Nested1(double noundef %_1) -#[no_mangle] -pub extern "C" fn test_Nested1(_: Nested1) -> Nested1 { loop {} } - -#[repr(transparent)] -pub struct Nested2(Nested1, Zst1); - -// CHECK: define{{.*}}double @test_Nested2(double noundef %_1) -#[no_mangle] -pub extern "C" fn test_Nested2(_: Nested2) -> Nested2 { loop {} } - -#[repr(simd)] -struct f32x4(f32, f32, f32, f32); - -#[repr(transparent)] -pub struct Vector(f32x4); - -// CHECK: define{{.*}}<4 x float> @test_Vector(<4 x float> %_1) -#[no_mangle] -pub extern "C" fn test_Vector(_: Vector) -> Vector { loop {} } - -trait Mirror { type It: ?Sized; } -impl Mirror for T { type It = Self; } - -#[repr(transparent)] -pub struct StructWithProjection(::It); - -// CHECK: define{{.*}}float @test_Projection(float noundef %_1) -#[no_mangle] -pub extern "C" fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } - -#[repr(transparent)] -pub enum EnumF32 { - Variant(F32) -} - -// CHECK: define{{.*}}float @test_EnumF32(float noundef %_1) -#[no_mangle] -pub extern "C" fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} } - -#[repr(transparent)] -pub enum EnumF32WithZsts { - Variant(Zst1, F32, Zst2) -} - -// CHECK: define{{.*}}float @test_EnumF32WithZsts(float noundef %_1) -#[no_mangle] -pub extern "C" fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} } - -#[repr(transparent)] -pub union UnionF32 { - field: F32, -} - -// CHECK: define{{.*}} float @test_UnionF32(float %_1) -#[no_mangle] -pub extern "C" fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } - -#[repr(transparent)] -pub union UnionF32WithZsts { - zst1: Zst1, - field: F32, - zst2: Zst2, -} - -// CHECK: define{{.*}}float @test_UnionF32WithZsts(float %_1) -#[no_mangle] -pub extern "C" fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} } - - -// All that remains to be tested are aggregates. They are tested in separate files called repr- -// transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR -// function signatures vary so much that it's not reasonably possible to cover all of them with a -// single CHECK line. -// -// You may be wondering why we don't just compare the return types and argument types for equality -// with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on newtypes -// containing aggregates. This is OK on all ABIs we support, but because LLVM has not gotten rid of -// pointee types yet, the IR function signature will be syntactically different (%Foo* vs -// %FooWrapper*). diff --git a/tests/codegen/repr/transparent-imm-array.rs b/tests/codegen/repr/transparent-imm-array.rs new file mode 100644 index 000000000..6d7127785 --- /dev/null +++ b/tests/codegen/repr/transparent-imm-array.rs @@ -0,0 +1,86 @@ +// revisions: arm mips thumb wasm32 +// compile-flags: -C no-prepopulate-passes +// +//[arm] only-arm +//[mips] only-mips +//[thumb] only-thumb +//[wasm32] only-wasm32 +// ignore-emscripten +// See ./transparent.rs +// Some platforms pass large aggregates using immediate arrays in LLVMIR +// Other platforms pass large aggregates using struct pointer in LLVMIR +// This covers the "immediate array" case. + +#![feature(transparent_unions)] + +#![crate_type="lib"] + + +#[derive(Clone, Copy)] +#[repr(C)] +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} + +#[repr(transparent)] +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [16 x i32] +#[no_mangle] +pub extern fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [16 x i32] +#[no_mangle] +pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } + +// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [16 x i32] +#[no_mangle] +pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } + +// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [16 x i32] +#[no_mangle] +pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } + + +#[derive(Clone, Copy)] +#[repr(C)] +pub union BigU { + foo: [u32; 16], +} + +#[repr(transparent)] +pub struct TsBigU(BigU); + +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} + +// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [16 x i32] +#[no_mangle] +pub extern fn test_BigU(_: BigU) -> BigU { loop {} } + +// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [16 x i32] +#[no_mangle] +pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [16 x i32] +#[no_mangle] +pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [16 x i32] +#[no_mangle] +pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-mips64.rs b/tests/codegen/repr/transparent-mips64.rs new file mode 100644 index 000000000..245daf13e --- /dev/null +++ b/tests/codegen/repr/transparent-mips64.rs @@ -0,0 +1,79 @@ +// compile-flags: -C no-prepopulate-passes +// + +// only-mips64 +// See ./transparent.rs + +#![feature(transparent_unions)] + +#![crate_type="lib"] + + +#[derive(Clone, Copy)] +#[repr(C)] +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} + +#[repr(transparent)] +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [8 x i64] +#[no_mangle] +pub extern fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [8 x i64] +#[no_mangle] +pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } + +// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [8 x i64] +#[no_mangle] +pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } + +// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [8 x i64] +#[no_mangle] +pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } + + +#[derive(Clone, Copy)] +#[repr(C)] +pub union BigU { + foo: [u32; 16], +} + +#[repr(transparent)] +pub struct TsBigU(BigU); + +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} + +// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [8 x i64] +#[no_mangle] +pub extern fn test_BigU(_: BigU) -> BigU { loop {} } + +// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [8 x i64] +#[no_mangle] +pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [8 x i64] +#[no_mangle] +pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [8 x i64] +#[no_mangle] +pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-struct-ptr.rs b/tests/codegen/repr/transparent-struct-ptr.rs new file mode 100644 index 000000000..d2120f7ec --- /dev/null +++ b/tests/codegen/repr/transparent-struct-ptr.rs @@ -0,0 +1,87 @@ +// revisions: x32 x64 sparc sparc64 +// compile-flags: -O -C no-prepopulate-passes +// +//[x32] only-x86 +//[x64] only-x86_64 +//[sparc] only-sparc +//[sparc64] only-sparc64 +// ignore-windows +// See ./transparent.rs +// Some platforms pass large aggregates using immediate arrays in LLVMIR +// Other platforms pass large aggregates using struct pointer in LLVMIR +// This covers the "struct pointer" case. + + +#![feature(transparent_unions)] + +#![crate_type="lib"] + + +#[derive(Clone, Copy)] +#[repr(C)] +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} + +#[repr(transparent)] +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], ptr [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]]) +#[no_mangle] +pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]]) +#[no_mangle] +pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } + +// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]]) +#[no_mangle] +pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } + +// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]]) +#[no_mangle] +pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } + + +#[derive(Clone, Copy)] +#[repr(C)] +pub union BigU { + foo: [u32; 16], +} + +#[repr(transparent)] +pub struct TsBigU(BigU); + +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} + +// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]]) +#[no_mangle] +pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} } + +// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]]) +#[no_mangle] +pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]]) +#[no_mangle] +pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]]) +#[no_mangle] +pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-sysv64.rs b/tests/codegen/repr/transparent-sysv64.rs new file mode 100644 index 000000000..886b0dd9e --- /dev/null +++ b/tests/codegen/repr/transparent-sysv64.rs @@ -0,0 +1,28 @@ +// only-x86_64 + +// compile-flags: -C no-prepopulate-passes + +#![crate_type="lib"] + +#[repr(C)] +pub struct Rgb8 { r: u8, g: u8, b: u8 } + +#[repr(transparent)] +pub struct Rgb8Wrap(Rgb8); + +// CHECK: i24 @test_Rgb8Wrap(i24{{( %0)?}}) +#[no_mangle] +pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} } + +#[repr(C)] +pub union FloatBits { + float: f32, + bits: u32, +} + +#[repr(transparent)] +pub struct SmallUnion(FloatBits); + +// CHECK: i32 @test_SmallUnion(i32{{( %0)?}}) +#[no_mangle] +pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} } diff --git a/tests/codegen/repr/transparent.rs b/tests/codegen/repr/transparent.rs new file mode 100644 index 000000000..b140fc719 --- /dev/null +++ b/tests/codegen/repr/transparent.rs @@ -0,0 +1,174 @@ +// compile-flags: -O -C no-prepopulate-passes +// ignore-riscv64 riscv64 has an i128 type used with test_Vector +// ignore-s390x s390x with default march passes vector types per reference +// ignore-loongarch64 see codegen/loongarch-abi for loongarch function call tests + +// This codegen test embeds assumptions about how certain "C" psABIs are handled +// so it doesn't apply to all architectures or even all OS +// For RISCV: see codegen/riscv-abi +// For LoongArch: see codegen/loongarch-abi + +#![crate_type="lib"] +#![feature(repr_simd, transparent_unions)] + +use std::marker::PhantomData; + +#[derive(Copy, Clone)] +pub struct Zst1; +#[derive(Copy, Clone)] +pub struct Zst2(()); + +#[derive(Copy, Clone)] +#[repr(transparent)] +pub struct F32(f32); + +// CHECK: define{{.*}}float @test_F32(float noundef %_1) +#[no_mangle] +pub extern "C" fn test_F32(_: F32) -> F32 { loop {} } + +#[repr(transparent)] +pub struct Ptr(*mut u8); + +// CHECK: define{{.*}}ptr @test_Ptr(ptr noundef %_1) +#[no_mangle] +pub extern "C" fn test_Ptr(_: Ptr) -> Ptr { loop {} } + +#[repr(transparent)] +pub struct WithZst(u64, Zst1); + +// CHECK: define{{.*}}i64 @test_WithZst(i64 noundef %_1) +#[no_mangle] +pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} } + +#[repr(transparent)] +pub struct WithZeroSizedArray(*const f32, [i8; 0]); + +// Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever. +// CHECK: define{{.*}}ptr @test_WithZeroSizedArray(ptr noundef %_1) +#[no_mangle] +pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} } + +#[repr(transparent)] +pub struct Generic(T); + +// CHECK: define{{.*}}double @test_Generic(double noundef %_1) +#[no_mangle] +pub extern "C" fn test_Generic(_: Generic) -> Generic { loop {} } + +#[repr(transparent)] +pub struct GenericPlusZst(T, Zst2); + +#[repr(u8)] +pub enum Bool { True, False, FileNotFound } + +// CHECK: define{{( dso_local)?}} noundef{{( zeroext)?}} i8 @test_Gpz(i8 noundef{{( zeroext)?}} %_1) +#[no_mangle] +pub extern "C" fn test_Gpz(_: GenericPlusZst) -> GenericPlusZst { loop {} } + +#[repr(transparent)] +pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>); + +// CHECK: define{{.*}}ptr @test_LifetimePhantom(ptr noundef %_1) +#[no_mangle] +pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom) -> LifetimePhantom { loop {} } + +// This works despite current alignment resrictions because PhantomData is always align(1) +#[repr(transparent)] +pub struct UnitPhantom { val: T, unit: PhantomData } + +pub struct Px; + +// CHECK: define{{.*}}float @test_UnitPhantom(float noundef %_1) +#[no_mangle] +pub extern "C" fn test_UnitPhantom(_: UnitPhantom) -> UnitPhantom { loop {} } + +#[repr(transparent)] +pub struct TwoZsts(Zst1, i8, Zst2); + +// CHECK: define{{( dso_local)?}} noundef{{( signext)?}} i8 @test_TwoZsts(i8 noundef{{( signext)?}} %_1) +#[no_mangle] +pub extern "C" fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} } + +#[repr(transparent)] +pub struct Nested1(Zst2, Generic); + +// CHECK: define{{.*}}double @test_Nested1(double noundef %_1) +#[no_mangle] +pub extern "C" fn test_Nested1(_: Nested1) -> Nested1 { loop {} } + +#[repr(transparent)] +pub struct Nested2(Nested1, Zst1); + +// CHECK: define{{.*}}double @test_Nested2(double noundef %_1) +#[no_mangle] +pub extern "C" fn test_Nested2(_: Nested2) -> Nested2 { loop {} } + +#[repr(simd)] +struct f32x4(f32, f32, f32, f32); + +#[repr(transparent)] +pub struct Vector(f32x4); + +// CHECK: define{{.*}}<4 x float> @test_Vector(<4 x float> %_1) +#[no_mangle] +pub extern "C" fn test_Vector(_: Vector) -> Vector { loop {} } + +trait Mirror { type It: ?Sized; } +impl Mirror for T { type It = Self; } + +#[repr(transparent)] +pub struct StructWithProjection(::It); + +// CHECK: define{{.*}}float @test_Projection(float noundef %_1) +#[no_mangle] +pub extern "C" fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } + +#[repr(transparent)] +pub enum EnumF32 { + Variant(F32) +} + +// CHECK: define{{.*}}float @test_EnumF32(float noundef %_1) +#[no_mangle] +pub extern "C" fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} } + +#[repr(transparent)] +pub enum EnumF32WithZsts { + Variant(Zst1, F32, Zst2) +} + +// CHECK: define{{.*}}float @test_EnumF32WithZsts(float noundef %_1) +#[no_mangle] +pub extern "C" fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} } + +#[repr(transparent)] +pub union UnionF32 { + field: F32, +} + +// CHECK: define{{.*}} float @test_UnionF32(float %_1) +#[no_mangle] +pub extern "C" fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } + +#[repr(transparent)] +pub union UnionF32WithZsts { + zst1: Zst1, + field: F32, + zst2: Zst2, +} + +// CHECK: define{{.*}}float @test_UnionF32WithZsts(float %_1) +#[no_mangle] +pub extern "C" fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} } + + +// All that remains to be tested are aggregates. They are tested in separate files called +// transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR +// function signatures vary so much that it's not reasonably possible to cover all of them with a +// single CHECK line. +// +// You may be wondering why we don't just compare the return types and argument types for equality +// with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on newtypes +// containing aggregates. This is OK on all ABIs we support, but because LLVM has not gotten rid of +// pointee types yet, the IR function signature will be syntactically different (%Foo* vs +// %FooWrapper*). diff --git a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs index 045f01985..fdb9c6217 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs @@ -127,18 +127,18 @@ pub struct Large { d: i64, } -// CHECK: define void @f_agg_large({{%Large\*|ptr}} {{.*}}%x) +// CHECK: define void @f_agg_large(ptr {{.*}}%x) #[no_mangle] pub extern "C" fn f_agg_large(mut x: Large) { } -// CHECK: define void @f_agg_large_ret({{%Large\*|ptr}} {{.*}}sret{{.*}}, i32 noundef signext %i, i8 noundef signext %j) +// CHECK: define void @f_agg_large_ret(ptr {{.*}}sret{{.*}}, i32 noundef signext %i, i8 noundef signext %j) #[no_mangle] pub extern "C" fn f_agg_large_ret(i: i32, j: i8) -> Large { Large { a: 1, b: 2, c: 3, d: 4 } } -// CHECK: define void @f_scalar_stack_1(i64 %0, [2 x i64] %1, i128 %2, {{%Large\*|ptr}} {{.*}}%d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef %g, i8 noundef %h) +// CHECK: define void @f_scalar_stack_1(i64 %0, [2 x i64] %1, i128 %2, ptr {{.*}}%d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef %g, i8 noundef %h) #[no_mangle] pub extern "C" fn f_scalar_stack_1( a: Tiny, @@ -152,7 +152,7 @@ pub extern "C" fn f_scalar_stack_1( ) { } -// CHECK: define void @f_scalar_stack_2({{%Large\*|ptr}} {{.*}}sret{{.*}} %0, i64 noundef %a, i128 %1, i128 %2, i64 noundef %d, i8 noundef zeroext %e, i8 noundef %f, i8 noundef %g) +// CHECK: define void @f_scalar_stack_2(ptr {{.*}}sret{{.*}} %_0, i64 noundef %a, i128 %0, i128 %1, i64 noundef %d, i8 noundef zeroext %e, i8 noundef %f, i8 noundef %g) #[no_mangle] pub extern "C" fn f_scalar_stack_2( a: u64, @@ -172,7 +172,7 @@ extern "C" { #[no_mangle] pub unsafe extern "C" fn f_va_caller() { - // CHECK: call noundef signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i64 noundef 3, double {{.*}}, double {{.*}}, i64 {{.*}}, [2 x i64] {{.*}}, i128 {{.*}}, {{%Large\*|ptr}} {{.*}}) + // CHECK: call noundef signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i64 noundef 3, double {{.*}}, double {{.*}}, i64 {{.*}}, [2 x i64] {{.*}}, i128 {{.*}}, ptr {{.*}}) f_va_callee( 1, 2i32, diff --git a/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs b/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs deleted file mode 100644 index 1ee8bdfc3..000000000 --- a/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Verifies that "CFI Canonical Jump Tables" module flag is added. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi - -#![crate_type="lib"] - -pub fn foo() { -} - -// CHECK: !{{[0-9]+}} = !{i32 4, !"CFI Canonical Jump Tables", i32 1} diff --git a/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs b/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs deleted file mode 100644 index 68c91384b..000000000 --- a/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Verifies that "EnableSplitLTOUnit" module flag is added. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi - -#![crate_type="lib"] - -pub fn foo() { -} - -// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1} diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs deleted file mode 100644 index 2b61c9078..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Verifies that pointer type membership tests for indirect calls are omitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 - -#![crate_type="lib"] -#![feature(no_sanitize)] - -#[no_sanitize(cfi)] -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: sanitizer_cfi_emit_type_checks_attr_no_sanitize::foo - // CHECK: Function Attrs: {{.*}} - // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: start: - // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) - // CHECK-NEXT: ret i32 {{%.+}} - f(arg) -} diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks.rs b/tests/codegen/sanitizer-cfi-emit-type-checks.rs deleted file mode 100644 index cea6aac8b..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-checks.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Verifies that pointer type membership tests for indirect calls are emitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 - -#![crate_type="lib"] - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: start: - // CHECK: [[TT:%.+]] = call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"{{[[:print:]]+}}") - // CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail - // CHECK: type_test.pass: - // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) - // CHECK: type_test.fail: - // CHECK-NEXT: call void @llvm.trap() - // CHECK-NEXT: unreachable - f(arg) -} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs deleted file mode 100644 index 084d8bf80..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Verifies that user-defined CFI encoding for types are emitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi - -#![crate_type="lib"] -#![feature(cfi_encoding, extern_types)] - -#[cfi_encoding = "3Foo"] -pub struct Type1(i32); - -extern { - #[cfi_encoding = "3Bar"] - type Type2; -} - -#[cfi_encoding = "3Baz"] -#[repr(transparent)] -pub struct Type3(i32); - -pub fn foo0(_: Type1) { } -// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo1(_: Type1, _: Type1) { } -// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo2(_: Type1, _: Type1, _: Type1) { } -// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo3(_: *mut Type2) { } -// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo4(_: *mut Type2, _: *mut Type2) { } -// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo5(_: *mut Type2, _: *mut Type2, _: *mut Type2) { } -// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo6(_: *mut Type3) { } -// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo7(_: *mut Type3, _: *mut Type3) { } -// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo8(_: *mut Type3, _: *mut Type3, _: *mut Type3) { } -// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - -// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFv3FooE"} -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFv3FooS_E"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFv3FooS_S_E"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvP3BarE"} -// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvP3BarS0_E"} -// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvP3BarS0_S0_E"} -// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvP3BazE"} -// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvP3BazS0_E"} -// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvP3BazS0_S0_E"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs deleted file mode 100644 index 63e63c5d4..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ /dev/null @@ -1,604 +0,0 @@ -// Verifies that type metadata identifiers for functions are emitted correctly. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi - -#![crate_type="lib"] -#![allow(dead_code)] -#![allow(incomplete_features)] -#![allow(unused_must_use)] -#![feature(adt_const_params, extern_types, inline_const, type_alias_impl_trait)] - -extern crate core; -use core::ffi::*; -use std::marker::PhantomData; - -// User-defined type (structure) -pub struct Struct1 { - member1: T, -} - -// User-defined type (enum) -pub enum Enum1 { - Variant1(T), -} - -// User-defined type (union) -pub union Union1 { - member1: std::mem::ManuallyDrop, -} - -// Extern type -extern { - pub type type1; -} - -// Trait -pub trait Trait1 { - fn foo(&self) { } -} - -// Trait implementation -impl Trait1 for i32 { - fn foo(&self) { } -} - -// Trait implementation -impl Trait1 for Struct1 { - fn foo(&self) { } -} - -// impl Trait type aliases for helping with defining other types (see below) -pub type Type1 = impl Send; -pub type Type2 = impl Send; -pub type Type3 = impl Send; -pub type Type4 = impl Send; -pub type Type5 = impl Send; -pub type Type6 = impl Send; -pub type Type7 = impl Send; -pub type Type8 = impl Send; -pub type Type9 = impl Send; -pub type Type10 = impl Send; -pub type Type11 = impl Send; - -pub fn fn1<'a>() where - Type1: 'static, - Type2: 'static, - Type3: 'static, - Type4: 'static, - Type5: 'static, - Type6: 'static, - Type7: 'static, - Type8: 'static, - Type9: 'static, - Type10: 'static, - Type11: 'static, -{ - // Closure - let closure1 = || { }; - let _: Type1 = closure1; - - // Constructor - pub struct Foo(i32); - let _: Type2 = Foo; - - // Type in extern path - extern { - fn foo(); - } - let _: Type3 = foo; - - // Type in closure path - || { - pub struct Foo; - let _: Type4 = Foo; - }; - - // Type in const path - const { - pub struct Foo; - fn foo() -> Type5 { Foo } - }; - - // Type in impl path - impl Struct1 { - fn foo(&self) { } - } - let _: Type6 = >::foo; - - // Trait method - let _: Type7 = >::foo; - - // Trait method - let _: Type8 = >::foo; - - // Trait method - let _: Type9 = as Trait1>::foo; - - // Const generics - pub struct Qux([T; N]); - let _: Type10 = Qux([0; 32]); - - // Lifetimes/regions - pub struct Quux<'a>(&'a i32); - pub struct Quuux<'a, 'b>(&'a i32, &'b Quux<'b>); - let _: Type11 = Quuux; -} - -// Helper type to make Type12 have an unique id -struct Foo(i32); - -// repr(transparent) user-defined type -#[repr(transparent)] -pub struct Type12 { - member1: (), - member2: PhantomData, - member3: Foo, -} - -// Self-referencing repr(transparent) user-defined type -#[repr(transparent)] -pub struct Type13<'a> { - member1: (), - member2: PhantomData, - member3: &'a Type13<'a>, -} - -// Helper type to make Type14 have an unique id -pub struct Bar; - -// repr(transparent) user-defined generic type -#[repr(transparent)] -pub struct Type14(T); - -pub fn foo0(_: ()) { } -// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo1(_: (), _: c_void) { } -// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo2(_: (), _: c_void, _: c_void) { } -// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo3(_: *mut ()) { } -// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo4(_: *mut (), _: *mut c_void) { } -// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo5(_: *mut (), _: *mut c_void, _: *mut c_void) { } -// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo6(_: *const ()) { } -// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo7(_: *const (), _: *const c_void) { } -// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo8(_: *const (), _: *const c_void, _: *const c_void) { } -// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo9(_: bool) { } -// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo10(_: bool, _: bool) { } -// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo11(_: bool, _: bool, _: bool) { } -// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo12(_: i8) { } -// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo13(_: i8, _: i8) { } -// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo14(_: i8, _: i8, _: i8) { } -// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo15(_: i16) { } -// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo16(_: i16, _: i16) { } -// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo17(_: i16, _: i16, _: i16) { } -// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo18(_: i32) { } -// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo19(_: i32, _: i32) { } -// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo20(_: i32, _: i32, _: i32) { } -// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo21(_: i64) { } -// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo22(_: i64, _: i64) { } -// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo23(_: i64, _: i64, _: i64) { } -// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo24(_: i128) { } -// CHECK: define{{.*}}foo24{{.*}}!type ![[TYPE24:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo25(_: i128, _: i128) { } -// CHECK: define{{.*}}foo25{{.*}}!type ![[TYPE25:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo26(_: i128, _: i128, _: i128) { } -// CHECK: define{{.*}}foo26{{.*}}!type ![[TYPE26:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo27(_: isize) { } -// CHECK: define{{.*}}foo27{{.*}}!type ![[TYPE27:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo28(_: isize, _: isize) { } -// CHECK: define{{.*}}foo28{{.*}}!type ![[TYPE28:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo29(_: isize, _: isize, _: isize) { } -// CHECK: define{{.*}}foo29{{.*}}!type ![[TYPE29:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo30(_: u8) { } -// CHECK: define{{.*}}foo30{{.*}}!type ![[TYPE30:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo31(_: u8, _: u8) { } -// CHECK: define{{.*}}foo31{{.*}}!type ![[TYPE31:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo32(_: u8, _: u8, _: u8) { } -// CHECK: define{{.*}}foo32{{.*}}!type ![[TYPE32:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo33(_: u16) { } -// CHECK: define{{.*}}foo33{{.*}}!type ![[TYPE33:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo34(_: u16, _: u16) { } -// CHECK: define{{.*}}foo34{{.*}}!type ![[TYPE34:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo35(_: u16, _: u16, _: u16) { } -// CHECK: define{{.*}}foo35{{.*}}!type ![[TYPE35:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo36(_: u32) { } -// CHECK: define{{.*}}foo36{{.*}}!type ![[TYPE36:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo37(_: u32, _: u32) { } -// CHECK: define{{.*}}foo37{{.*}}!type ![[TYPE37:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo38(_: u32, _: u32, _: u32) { } -// CHECK: define{{.*}}foo38{{.*}}!type ![[TYPE38:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo39(_: u64) { } -// CHECK: define{{.*}}foo39{{.*}}!type ![[TYPE39:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo40(_: u64, _: u64) { } -// CHECK: define{{.*}}foo40{{.*}}!type ![[TYPE40:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo41(_: u64, _: u64, _: u64) { } -// CHECK: define{{.*}}foo41{{.*}}!type ![[TYPE41:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo42(_: u128) { } -// CHECK: define{{.*}}foo42{{.*}}!type ![[TYPE42:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo43(_: u128, _: u128) { } -// CHECK: define{{.*}}foo43{{.*}}!type ![[TYPE43:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo44(_: u128, _: u128, _: u128) { } -// CHECK: define{{.*}}foo44{{.*}}!type ![[TYPE44:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo45(_: usize) { } -// CHECK: define{{.*}}foo45{{.*}}!type ![[TYPE45:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo46(_: usize, _: usize) { } -// CHECK: define{{.*}}foo46{{.*}}!type ![[TYPE46:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo47(_: usize, _: usize, _: usize) { } -// CHECK: define{{.*}}foo47{{.*}}!type ![[TYPE47:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo48(_: f32) { } -// CHECK: define{{.*}}foo48{{.*}}!type ![[TYPE48:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo49(_: f32, _: f32) { } -// CHECK: define{{.*}}foo49{{.*}}!type ![[TYPE49:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo50(_: f32, _: f32, _: f32) { } -// CHECK: define{{.*}}foo50{{.*}}!type ![[TYPE50:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo51(_: f64) { } -// CHECK: define{{.*}}foo51{{.*}}!type ![[TYPE51:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo52(_: f64, _: f64) { } -// CHECK: define{{.*}}foo52{{.*}}!type ![[TYPE52:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo53(_: f64, _: f64, _: f64) { } -// CHECK: define{{.*}}foo53{{.*}}!type ![[TYPE53:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo54(_: char) { } -// CHECK: define{{.*}}foo54{{.*}}!type ![[TYPE54:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo55(_: char, _: char) { } -// CHECK: define{{.*}}foo55{{.*}}!type ![[TYPE55:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo56(_: char, _: char, _: char) { } -// CHECK: define{{.*}}foo56{{.*}}!type ![[TYPE56:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo57(_: &str) { } -// CHECK: define{{.*}}foo57{{.*}}!type ![[TYPE57:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo58(_: &str, _: &str) { } -// CHECK: define{{.*}}foo58{{.*}}!type ![[TYPE58:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo59(_: &str, _: &str, _: &str) { } -// CHECK: define{{.*}}foo59{{.*}}!type ![[TYPE59:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo60(_: (i32, i32)) { } -// CHECK: define{{.*}}foo60{{.*}}!type ![[TYPE60:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo61(_: (i32, i32), _: (i32, i32)) { } -// CHECK: define{{.*}}foo61{{.*}}!type ![[TYPE61:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo62(_: (i32, i32), _: (i32, i32), _: (i32, i32)) { } -// CHECK: define{{.*}}foo62{{.*}}!type ![[TYPE62:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo63(_: [i32; 32]) { } -// CHECK: define{{.*}}foo63{{.*}}!type ![[TYPE63:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo64(_: [i32; 32], _: [i32; 32]) { } -// CHECK: define{{.*}}foo64{{.*}}!type ![[TYPE64:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo65(_: [i32; 32], _: [i32; 32], _: [i32; 32]) { } -// CHECK: define{{.*}}foo65{{.*}}!type ![[TYPE65:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo66(_: &[i32]) { } -// CHECK: define{{.*}}foo66{{.*}}!type ![[TYPE66:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo67(_: &[i32], _: &[i32]) { } -// CHECK: define{{.*}}foo67{{.*}}!type ![[TYPE67:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo68(_: &[i32], _: &[i32], _: &[i32]) { } -// CHECK: define{{.*}}foo68{{.*}}!type ![[TYPE68:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo69(_: &Struct1::) { } -// CHECK: define{{.*}}foo69{{.*}}!type ![[TYPE69:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo70(_: &Struct1::, _: &Struct1::) { } -// CHECK: define{{.*}}foo70{{.*}}!type ![[TYPE70:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo71(_: &Struct1::, _: &Struct1::, _: &Struct1::) { } -// CHECK: define{{.*}}foo71{{.*}}!type ![[TYPE71:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo72(_: &Enum1::) { } -// CHECK: define{{.*}}foo72{{.*}}!type ![[TYPE72:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo73(_: &Enum1::, _: &Enum1::) { } -// CHECK: define{{.*}}foo73{{.*}}!type ![[TYPE73:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo74(_: &Enum1::, _: &Enum1::, _: &Enum1::) { } -// CHECK: define{{.*}}foo74{{.*}}!type ![[TYPE74:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo75(_: &Union1::) { } -// CHECK: define{{.*}}foo75{{.*}}!type ![[TYPE75:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo76(_: &Union1::, _: &Union1::) { } -// CHECK: define{{.*}}foo76{{.*}}!type ![[TYPE76:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo77(_: &Union1::, _: &Union1::, _: &Union1::) { } -// CHECK: define{{.*}}foo77{{.*}}!type ![[TYPE77:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo78(_: *mut type1) { } -// CHECK: define{{.*}}foo78{{.*}}!type ![[TYPE78:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo79(_: *mut type1, _: *mut type1) { } -// CHECK: define{{.*}}foo79{{.*}}!type ![[TYPE79:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo80(_: *mut type1, _: *mut type1, _: *mut type1) { } -// CHECK: define{{.*}}foo80{{.*}}!type ![[TYPE80:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo81(_: &mut i32) { } -// CHECK: define{{.*}}foo81{{.*}}!type ![[TYPE81:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo82(_: &mut i32, _: &i32) { } -// CHECK: define{{.*}}foo82{{.*}}!type ![[TYPE82:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo83(_: &mut i32, _: &i32, _: &i32) { } -// CHECK: define{{.*}}foo83{{.*}}!type ![[TYPE83:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo84(_: &i32) { } -// CHECK: define{{.*}}foo84{{.*}}!type ![[TYPE84:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo85(_: &i32, _: &mut i32) { } -// CHECK: define{{.*}}foo85{{.*}}!type ![[TYPE85:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo86(_: &i32, _: &mut i32, _: &mut i32) { } -// CHECK: define{{.*}}foo86{{.*}}!type ![[TYPE86:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo87(_: *mut i32) { } -// CHECK: define{{.*}}foo87{{.*}}!type ![[TYPE87:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo88(_: *mut i32, _: *const i32) { } -// CHECK: define{{.*}}foo88{{.*}}!type ![[TYPE88:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo89(_: *mut i32, _: *const i32, _: *const i32) { } -// CHECK: define{{.*}}foo89{{.*}}!type ![[TYPE89:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo90(_: *const i32) { } -// CHECK: define{{.*}}foo90{{.*}}!type ![[TYPE90:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo91(_: *const i32, _: *mut i32) { } -// CHECK: define{{.*}}foo91{{.*}}!type ![[TYPE91:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo92(_: *const i32, _: *mut i32, _: *mut i32) { } -// CHECK: define{{.*}}foo92{{.*}}!type ![[TYPE92:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo93(_: fn(i32) -> i32) { } -// CHECK: define{{.*}}foo93{{.*}}!type ![[TYPE93:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo94(_: fn(i32) -> i32, _: fn(i32) -> i32) { } -// CHECK: define{{.*}}foo94{{.*}}!type ![[TYPE94:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo95(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) { } -// CHECK: define{{.*}}foo95{{.*}}!type ![[TYPE95:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo96(_: &dyn Fn(i32) -> i32) { } -// CHECK: define{{.*}}foo96{{.*}}!type ![[TYPE96:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo97(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { } -// CHECK: define{{.*}}foo97{{.*}}!type ![[TYPE97:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo98(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { } -// CHECK: define{{.*}}foo98{{.*}}!type ![[TYPE98:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo99(_: &dyn FnMut(i32) -> i32) { } -// CHECK: define{{.*}}foo99{{.*}}!type ![[TYPE99:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo100(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { } -// CHECK: define{{.*}}foo100{{.*}}!type ![[TYPE100:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo101(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { } -// CHECK: define{{.*}}foo101{{.*}}!type ![[TYPE101:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo102(_: &dyn FnOnce(i32) -> i32) { } -// CHECK: define{{.*}}foo102{{.*}}!type ![[TYPE102:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo103(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) { } -// CHECK: define{{.*}}foo103{{.*}}!type ![[TYPE103:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo104(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) {} -// CHECK: define{{.*}}foo104{{.*}}!type ![[TYPE104:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo105(_: &dyn Send) { } -// CHECK: define{{.*}}foo105{{.*}}!type ![[TYPE105:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo106(_: &dyn Send, _: &dyn Send) { } -// CHECK: define{{.*}}foo106{{.*}}!type ![[TYPE106:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo107(_: &dyn Send, _: &dyn Send, _: &dyn Send) { } -// CHECK: define{{.*}}foo107{{.*}}!type ![[TYPE107:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo108(_: Type1) { } -// CHECK: define{{.*}}foo108{{.*}}!type ![[TYPE108:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo109(_: Type1, _: Type1) { } -// CHECK: define{{.*}}foo109{{.*}}!type ![[TYPE109:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo110(_: Type1, _: Type1, _: Type1) { } -// CHECK: define{{.*}}foo110{{.*}}!type ![[TYPE110:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo111(_: Type2) { } -// CHECK: define{{.*}}foo111{{.*}}!type ![[TYPE111:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo112(_: Type2, _: Type2) { } -// CHECK: define{{.*}}foo112{{.*}}!type ![[TYPE112:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo113(_: Type2, _: Type2, _: Type2) { } -// CHECK: define{{.*}}foo113{{.*}}!type ![[TYPE113:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo114(_: Type3) { } -// CHECK: define{{.*}}foo114{{.*}}!type ![[TYPE114:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo115(_: Type3, _: Type3) { } -// CHECK: define{{.*}}foo115{{.*}}!type ![[TYPE115:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo116(_: Type3, _: Type3, _: Type3) { } -// CHECK: define{{.*}}foo116{{.*}}!type ![[TYPE116:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo117(_: Type4) { } -// CHECK: define{{.*}}foo117{{.*}}!type ![[TYPE117:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo118(_: Type4, _: Type4) { } -// CHECK: define{{.*}}foo118{{.*}}!type ![[TYPE118:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo119(_: Type4, _: Type4, _: Type4) { } -// CHECK: define{{.*}}foo119{{.*}}!type ![[TYPE119:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo120(_: Type5) { } -// CHECK: define{{.*}}foo120{{.*}}!type ![[TYPE120:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo121(_: Type5, _: Type5) { } -// CHECK: define{{.*}}foo121{{.*}}!type ![[TYPE121:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo122(_: Type5, _: Type5, _: Type5) { } -// CHECK: define{{.*}}foo122{{.*}}!type ![[TYPE122:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo123(_: Type6) { } -// CHECK: define{{.*}}foo123{{.*}}!type ![[TYPE123:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo124(_: Type6, _: Type6) { } -// CHECK: define{{.*}}foo124{{.*}}!type ![[TYPE124:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo125(_: Type6, _: Type6, _: Type6) { } -// CHECK: define{{.*}}foo125{{.*}}!type ![[TYPE125:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo126(_: Type7) { } -// CHECK: define{{.*}}foo126{{.*}}!type ![[TYPE126:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo127(_: Type7, _: Type7) { } -// CHECK: define{{.*}}foo127{{.*}}!type ![[TYPE127:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo128(_: Type7, _: Type7, _: Type7) { } -// CHECK: define{{.*}}foo128{{.*}}!type ![[TYPE128:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo129(_: Type8) { } -// CHECK: define{{.*}}foo129{{.*}}!type ![[TYPE129:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo130(_: Type8, _: Type8) { } -// CHECK: define{{.*}}foo130{{.*}}!type ![[TYPE130:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo131(_: Type8, _: Type8, _: Type8) { } -// CHECK: define{{.*}}foo131{{.*}}!type ![[TYPE131:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo132(_: Type9) { } -// CHECK: define{{.*}}foo132{{.*}}!type ![[TYPE132:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo133(_: Type9, _: Type9) { } -// CHECK: define{{.*}}foo133{{.*}}!type ![[TYPE133:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo134(_: Type9, _: Type9, _: Type9) { } -// CHECK: define{{.*}}foo134{{.*}}!type ![[TYPE134:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo135(_: Type10) { } -// CHECK: define{{.*}}foo135{{.*}}!type ![[TYPE135:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo136(_: Type10, _: Type10) { } -// CHECK: define{{.*}}foo136{{.*}}!type ![[TYPE136:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo137(_: Type10, _: Type10, _: Type10) { } -// CHECK: define{{.*}}foo137{{.*}}!type ![[TYPE137:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo138(_: Type11) { } -// CHECK: define{{.*}}foo138{{.*}}!type ![[TYPE138:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo139(_: Type11, _: Type11) { } -// CHECK: define{{.*}}foo139{{.*}}!type ![[TYPE139:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo140(_: Type11, _: Type11, _: Type11) { } -// CHECK: define{{.*}}foo140{{.*}}!type ![[TYPE140:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo141(_: Type12) { } -// CHECK: define{{.*}}foo141{{.*}}!type ![[TYPE141:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo142(_: Type12, _: Type12) { } -// CHECK: define{{.*}}foo142{{.*}}!type ![[TYPE142:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo143(_: Type12, _: Type12, _: Type12) { } -// CHECK: define{{.*}}foo143{{.*}}!type ![[TYPE143:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo144(_: Type13) { } -// CHECK: define{{.*}}foo144{{.*}}!type ![[TYPE144:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo145(_: Type13, _: Type13) { } -// CHECK: define{{.*}}foo145{{.*}}!type ![[TYPE145:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo146(_: Type13, _: Type13, _: Type13) { } -// CHECK: define{{.*}}foo146{{.*}}!type ![[TYPE146:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo147(_: Type14) { } -// CHECK: define{{.*}}foo147{{.*}}!type ![[TYPE147:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo148(_: Type14, _: Type14) { } -// CHECK: define{{.*}}foo148{{.*}}!type ![[TYPE148:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo149(_: Type14, _: Type14, _: Type14) { } -// CHECK: define{{.*}}foo149{{.*}}!type ![[TYPE149:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - -// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvvE"} -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvvvE"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvvvvE"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPvE"} -// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvPvS_E"} -// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvPvS_S_E"} -// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPKvE"} -// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvPKvS0_E"} -// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvPKvS0_S0_E"} -// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvbE"} -// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvbbE"} -// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvbbbE"} -// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFvu2i8E"} -// CHECK: ![[TYPE13]] = !{i64 0, !"_ZTSFvu2i8S_E"} -// CHECK: ![[TYPE14]] = !{i64 0, !"_ZTSFvu2i8S_S_E"} -// CHECK: ![[TYPE15]] = !{i64 0, !"_ZTSFvu3i16E"} -// CHECK: ![[TYPE16]] = !{i64 0, !"_ZTSFvu3i16S_E"} -// CHECK: ![[TYPE17]] = !{i64 0, !"_ZTSFvu3i16S_S_E"} -// CHECK: ![[TYPE18]] = !{i64 0, !"_ZTSFvu3i32E"} -// CHECK: ![[TYPE19]] = !{i64 0, !"_ZTSFvu3i32S_E"} -// CHECK: ![[TYPE20]] = !{i64 0, !"_ZTSFvu3i32S_S_E"} -// CHECK: ![[TYPE21]] = !{i64 0, !"_ZTSFvu3i64E"} -// CHECK: ![[TYPE22]] = !{i64 0, !"_ZTSFvu3i64S_E"} -// CHECK: ![[TYPE23]] = !{i64 0, !"_ZTSFvu3i64S_S_E"} -// CHECK: ![[TYPE24]] = !{i64 0, !"_ZTSFvu4i128E"} -// CHECK: ![[TYPE25]] = !{i64 0, !"_ZTSFvu4i128S_E"} -// CHECK: ![[TYPE26]] = !{i64 0, !"_ZTSFvu4i128S_S_E"} -// CHECK: ![[TYPE27]] = !{i64 0, !"_ZTSFvu5isizeE"} -// CHECK: ![[TYPE28]] = !{i64 0, !"_ZTSFvu5isizeS_E"} -// CHECK: ![[TYPE29]] = !{i64 0, !"_ZTSFvu5isizeS_S_E"} -// CHECK: ![[TYPE30]] = !{i64 0, !"_ZTSFvu2u8E"} -// CHECK: ![[TYPE31]] = !{i64 0, !"_ZTSFvu2u8S_E"} -// CHECK: ![[TYPE32]] = !{i64 0, !"_ZTSFvu2u8S_S_E"} -// CHECK: ![[TYPE33]] = !{i64 0, !"_ZTSFvu3u16E"} -// CHECK: ![[TYPE34]] = !{i64 0, !"_ZTSFvu3u16S_E"} -// CHECK: ![[TYPE35]] = !{i64 0, !"_ZTSFvu3u16S_S_E"} -// CHECK: ![[TYPE36]] = !{i64 0, !"_ZTSFvu3u32E"} -// CHECK: ![[TYPE37]] = !{i64 0, !"_ZTSFvu3u32S_E"} -// CHECK: ![[TYPE38]] = !{i64 0, !"_ZTSFvu3u32S_S_E"} -// CHECK: ![[TYPE39]] = !{i64 0, !"_ZTSFvu3u64E"} -// CHECK: ![[TYPE40]] = !{i64 0, !"_ZTSFvu3u64S_E"} -// CHECK: ![[TYPE41]] = !{i64 0, !"_ZTSFvu3u64S_S_E"} -// CHECK: ![[TYPE42]] = !{i64 0, !"_ZTSFvu4u128E"} -// CHECK: ![[TYPE43]] = !{i64 0, !"_ZTSFvu4u128S_E"} -// CHECK: ![[TYPE44]] = !{i64 0, !"_ZTSFvu4u128S_S_E"} -// CHECK: ![[TYPE45]] = !{i64 0, !"_ZTSFvu5usizeE"} -// CHECK: ![[TYPE46]] = !{i64 0, !"_ZTSFvu5usizeS_E"} -// CHECK: ![[TYPE47]] = !{i64 0, !"_ZTSFvu5usizeS_S_E"} -// CHECK: ![[TYPE48]] = !{i64 0, !"_ZTSFvu3f32E"} -// CHECK: ![[TYPE49]] = !{i64 0, !"_ZTSFvu3f32S_E"} -// CHECK: ![[TYPE50]] = !{i64 0, !"_ZTSFvu3f32S_S_E"} -// CHECK: ![[TYPE51]] = !{i64 0, !"_ZTSFvu3f64E"} -// CHECK: ![[TYPE52]] = !{i64 0, !"_ZTSFvu3f64S_E"} -// CHECK: ![[TYPE53]] = !{i64 0, !"_ZTSFvu3f64S_S_E"} -// CHECK: ![[TYPE54]] = !{i64 0, !"_ZTSFvu4charE"} -// CHECK: ![[TYPE55]] = !{i64 0, !"_ZTSFvu4charS_E"} -// CHECK: ![[TYPE56]] = !{i64 0, !"_ZTSFvu4charS_S_E"} -// CHECK: ![[TYPE57]] = !{i64 0, !"_ZTSFvu3refIu3strEE"} -// CHECK: ![[TYPE58]] = !{i64 0, !"_ZTSFvu3refIu3strES0_E"} -// CHECK: ![[TYPE59]] = !{i64 0, !"_ZTSFvu3refIu3strES0_S0_E"} -// CHECK: ![[TYPE60]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_EE"} -// CHECK: ![[TYPE61]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_ES0_E"} -// CHECK: ![[TYPE62]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_ES0_S0_E"} -// CHECK: ![[TYPE63]] = !{i64 0, !"_ZTSFvA32u3i32E"} -// CHECK: ![[TYPE64]] = !{i64 0, !"_ZTSFvA32u3i32S0_E"} -// CHECK: ![[TYPE65]] = !{i64 0, !"_ZTSFvA32u3i32S0_S0_E"} -// CHECK: ![[TYPE66]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EEE"} -// CHECK: ![[TYPE67]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EES1_E"} -// CHECK: ![[TYPE68]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EES1_S1_E"} -// CHECK: ![[TYPE69]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32EEE"} -// CHECK: ![[TYPE70]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32EES1_E"} -// CHECK: ![[TYPE71]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32EES1_S1_E"} -// CHECK: ![[TYPE72]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi5Enum1Iu3i32EEE"} -// CHECK: ![[TYPE73]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi5Enum1Iu3i32EES1_E"} -// CHECK: ![[TYPE74]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi5Enum1Iu3i32EES1_S1_E"} -// CHECK: ![[TYPE75]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Union1Iu3i32EEE"} -// CHECK: ![[TYPE76]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Union1Iu3i32EES1_E"} -// CHECK: ![[TYPE77]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Union1Iu3i32EES1_S1_E"} -// CHECK: ![[TYPE78]] = !{i64 0, !"_ZTSFvP5type1E"} -// CHECK: ![[TYPE79]] = !{i64 0, !"_ZTSFvP5type1S0_E"} -// CHECK: ![[TYPE80]] = !{i64 0, !"_ZTSFvP5type1S0_S0_E"} -// CHECK: ![[TYPE81]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32EE"} -// CHECK: ![[TYPE82]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32ES0_E"} -// CHECK: ![[TYPE83]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32ES0_S0_E"} -// CHECK: ![[TYPE84]] = !{i64 0, !"_ZTSFvu3refIu3i32EE"} -// CHECK: ![[TYPE85]] = !{i64 0, !"_ZTSFvu3refIu3i32EU3mutS0_E"} -// CHECK: ![[TYPE86]] = !{i64 0, !"_ZTSFvu3refIu3i32EU3mutS0_S1_E"} -// CHECK: ![[TYPE87]] = !{i64 0, !"_ZTSFvPu3i32E"} -// CHECK: ![[TYPE88]] = !{i64 0, !"_ZTSFvPu3i32PKS_E"} -// CHECK: ![[TYPE89]] = !{i64 0, !"_ZTSFvPu3i32PKS_S2_E"} -// CHECK: ![[TYPE90]] = !{i64 0, !"_ZTSFvPKu3i32E"} -// CHECK: ![[TYPE91]] = !{i64 0, !"_ZTSFvPKu3i32PS_E"} -// CHECK: ![[TYPE92]] = !{i64 0, !"_ZTSFvPKu3i32PS_S2_E"} -// CHECK: ![[TYPE93]] = !{i64 0, !"_ZTSFvPFu3i32S_EE"} -// CHECK: ![[TYPE94]] = !{i64 0, !"_ZTSFvPFu3i32S_ES0_E"} -// CHECK: ![[TYPE95]] = !{i64 0, !"_ZTSFvPFu3i32S_ES0_S0_E"} -// CHECK: ![[TYPE96]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEEE"} -// CHECK: ![[TYPE97]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEES3_E"} -// CHECK: ![[TYPE98]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEES3_S3_E"} -// CHECK: ![[TYPE99]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEEE"} -// CHECK: ![[TYPE100]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEES3_E"} -// CHECK: ![[TYPE101]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEES3_S3_E"} -// CHECK: ![[TYPE102]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEEE"} -// CHECK: ![[TYPE103]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEES3_E"} -// CHECK: ![[TYPE104]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEES3_S3_E"} -// CHECK: ![[TYPE105]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEEE"} -// CHECK: ![[TYPE106]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_E"} -// CHECK: ![[TYPE107]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_S2_E"} -// CHECK: ![[TYPE108]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvEE"} -// CHECK: ![[TYPE109]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_E"} -// CHECK: ![[TYPE110]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_S1_E"} -// CHECK: ![[TYPE111]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}E"} -// CHECK: ![[TYPE112]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_E"} -// CHECK: ![[TYPE113]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_S_E"} -// CHECK: ![[TYPE114]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn110{{[{}][{}]}}extern{{[}][}]}}3fooE"} -// CHECK: ![[TYPE115]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_E"} -// CHECK: ![[TYPE116]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_S_E"} -// CHECK: ![[TYPE117]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooE"} -// CHECK: ![[TYPE118]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_E"} -// CHECK: ![[TYPE119]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_S_E"} -// CHECK: ![[TYPE120]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooE"} -// CHECK: ![[TYPE121]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_E"} -// CHECK: ![[TYPE122]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"} -// CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32EE"} -// CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_E"} -// CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_S0_E"} -// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32EE"} -// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32ES4_E"} -// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32ES4_S4_E"} -// CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_EE"} -// CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_E"} -// CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_S0_E"} -// CHECK: ![[TYPE132]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_EE"} -// CHECK: ![[TYPE133]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_ES1_E"} -// CHECK: ![[TYPE134]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_ES1_S1_E"} -// CHECK: ![[TYPE135]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EEE"} -// CHECK: ![[TYPE136]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EES2_E"} -// CHECK: ![[TYPE137]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EES2_S2_E"} -// CHECK: ![[TYPE138]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_EE"} -// CHECK: ![[TYPE139]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_E"} -// CHECK: ![[TYPE140]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_S0_E"} -// CHECK: ![[TYPE141]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3FooE"} -// CHECK: ![[TYPE142]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3FooS_E"} -// CHECK: ![[TYPE143]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3FooS_S_E"} -// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"} -// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"} -// CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"} -// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE"} -// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E"} -// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs deleted file mode 100644 index 78ef0c2c7..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Verifies that generalized type metadata for functions are emitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers - -#![crate_type="lib"] - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.generalized") - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.generalized") - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.generalized") - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PKvS_E.generalized"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PKvS_S_E.generalized"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PKvS_S_S_E.generalized"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs deleted file mode 100644 index 3b72459c4..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Verifies that normalized and generalized type metadata for functions are emitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers - -#![crate_type="lib"] - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}![[TYPE1:[0-9]+]] - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized.generalized") - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}![[TYPE2:[0-9]+]] - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized.generalized") - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}![[TYPE3:[0-9]+]] - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized.generalized") - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PKvS_E.normalized.generalized"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PKvS_S_E.normalized.generalized"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PKvS_S_S_E.normalized.generalized"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs deleted file mode 100644 index 9218e9947..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Verifies that normalized type metadata for functions are emitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers - -#![crate_type="lib"] - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized") - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized") - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized") - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PFS_S_ES_E.normalized"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_ES_S_E.normalized"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_S_ES_S_S_E.normalized"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs deleted file mode 100644 index f9fd816de..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Verifies that type metadata for functions are emitted. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi - -#![crate_type="lib"] - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E") - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E") - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E") - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PFS_S_ES_E"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_ES_S_E"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_S_ES_S_S_E"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs deleted file mode 100644 index 0f79adab7..000000000 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs +++ /dev/null @@ -1,120 +0,0 @@ -// Verifies that type metadata identifiers for trait objects are emitted correctly. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi - -#![crate_type="lib"] - -pub trait Trait1 { - fn foo(&self); -} - -#[derive(Clone, Copy)] -pub struct Type1; - -impl Trait1 for Type1 { - fn foo(&self) { - } -} - -pub trait Trait2 { - fn bar(&self); -} - -pub struct Type2; - -impl Trait2 for Type2 { - fn bar(&self) { - } -} - -pub trait Trait3 { - fn baz(&self, _: &T); -} - -pub struct Type3; - -impl Trait3 for T { - fn baz(&self, _: &U) { - } -} - -pub trait Trait4<'a, T> { - type Output: 'a; - fn qux(&self, _: &T) -> Self::Output; -} - -pub struct Type4; - -impl<'a, T, U> Trait4<'a, U> for T { - type Output = &'a i32; - fn qux(&self, _: &U) -> Self::Output { - &0 - } -} - -pub fn foo1(a: &dyn Trait1) { - a.foo(); - // CHECK-LABEL: define{{.*}}4foo1{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE1:[[:print:]]+]]") -} - -pub fn bar1() { - let a = Type1; - let b = &a as &dyn Trait1; - b.foo(); - // CHECK-LABEL: define{{.*}}4bar1{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") -} - -pub fn foo2(a: &dyn Trait2) { - a.bar(); - // CHECK-LABEL: define{{.*}}4foo2{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") -} - -pub fn bar2() { - let a = Type2; - foo2(&a); - let b = &a as &dyn Trait2; - b.bar(); - // CHECK-LABEL: define{{.*}}4bar2{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") -} - -pub fn foo3(a: &dyn Trait3) { - let b = Type3; - a.baz(&b); - // CHECK-LABEL: define{{.*}}4foo3{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") -} - -pub fn bar3() { - let a = Type3; - foo3(&a); - let b = &a as &dyn Trait3; - b.baz(&a); - // CHECK-LABEL: define{{.*}}4bar3{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") -} - -pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { - let b = Type4; - a.qux(&b); - // CHECK-LABEL: define{{.*}}4foo4{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") -} - -pub fn bar4<'a>() { - let a = Type4; - foo4(&a); - let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; - b.qux(&a); - // CHECK-LABEL: define{{.*}}4bar4{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") -} - -// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE1]]"} -// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE2]]"} -// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE3]]"} -// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE4]]"} diff --git a/tests/codegen/sanitizer-cfi-generalize-pointers.rs b/tests/codegen/sanitizer-cfi-generalize-pointers.rs deleted file mode 100644 index 677ebdb27..000000000 --- a/tests/codegen/sanitizer-cfi-generalize-pointers.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Verifies that pointer types are generalized. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers - -#![crate_type="lib"] - -extern crate core; - -pub fn foo0(_: &mut i32) { } -// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo1(_: &mut i32, _: &mut i32) { } -// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo2(_: &mut i32, _: &mut i32, _: &mut i32) { } -// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo3(_: &i32) { } -// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo4(_: &i32, _: &i32) { } -// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo5(_: &i32, _: &i32, _: &i32) { } -// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo6(_: *mut i32) { } -// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo7(_: *mut i32, _: *mut i32) { } -// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo8(_: *mut i32, _: *mut i32, _: *mut i32) { } -// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo9(_: *const i32) { } -// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo10(_: *const i32, _: *const i32) { } -// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} -pub fn foo11(_: *const i32, _: *const i32, _: *const i32) { } -// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - -// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvU3mutu3refIvEE.generalized"} -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_E.generalized"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_S0_E.generalized"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvu3refIvEE.generalized"} -// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu3refIvES_E.generalized"} -// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu3refIvES_S_E.generalized"} -// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPvE.generalized"} -// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvPvS_E.generalized"} -// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvPvS_S_E.generalized"} -// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvPKvE.generalized"} -// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvPKvS0_E.generalized"} -// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvPKvS0_S0_E.generalized"} diff --git a/tests/codegen/sanitizer-cfi-normalize-integers.rs b/tests/codegen/sanitizer-cfi-normalize-integers.rs deleted file mode 100644 index aa3913cb8..000000000 --- a/tests/codegen/sanitizer-cfi-normalize-integers.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Verifies that integer types are normalized. -// -// needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers - -#![crate_type="lib"] - -extern crate core; -use core::ffi::*; - -pub fn foo0(_: bool) { } -// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} -pub fn foo1(_: bool, _: c_uchar) { } -// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} -pub fn foo2(_: bool, _: c_uchar, _: c_uchar) { } -// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} -pub fn foo3(_: isize) { } -// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} -pub fn foo4(_: isize, _: c_long) { } -// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} -pub fn foo5(_: isize, _: c_long, _: c_longlong) { } -// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} -pub fn foo6(_: usize) { } -// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} -pub fn foo7(_: usize, _: c_ulong) { } -// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} -pub fn foo8(_: usize, _: c_ulong, _: c_ulonglong) { } -// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} -pub fn foo9(_: c_schar) { } -// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} -pub fn foo10(_: c_char, _: c_schar) { } -// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} -pub fn foo11(_: c_char, _: c_schar, _: c_schar) { } -// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} -pub fn foo12(_: c_int) { } -// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} -pub fn foo13(_: c_int, _: c_int) { } -// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} -pub fn foo14(_: c_int, _: c_int, _: c_int) { } -// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} -pub fn foo15(_: c_short) { } -// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} -pub fn foo16(_: c_short, _: c_short) { } -// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} -pub fn foo17(_: c_short, _: c_short, _: c_short) { } -// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} -pub fn foo18(_: c_uint) { } -// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} -pub fn foo19(_: c_uint, _: c_uint) { } -// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} -pub fn foo20(_: c_uint, _: c_uint, _: c_uint) { } -// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} -pub fn foo21(_: c_ushort) { } -// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} -pub fn foo22(_: c_ushort, _: c_ushort) { } -// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} -pub fn foo23(_: c_ushort, _: c_ushort, _: c_ushort) { } -// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} - -// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvu2u8E.normalized"} -// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu2u8S_E.normalized"} -// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu2u8S_S_E.normalized"} -// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"} -// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}{{u3i32|u3i64|S_}}E.normalized"} -// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}{{u3i32|u3i64|S_}}{{u3i64|S_|S0_}}E.normalized"} -// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}E.normalized"} -// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}{{u3u32|u3u64|S_}}E.normalized"} -// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}{{u3u32|u3u64|S_}}{{u3u64|S_|S0_}}E.normalized"} -// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu2i8E.normalized"} -// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFv{{u2i8S_|u2u8u2i8}}E.normalized"} -// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFv{{u2i8S_S_|u2u8u2i8S0_}}E.normalized"} -// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"} -// CHECK: ![[TYPE13]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_E.normalized"} -// CHECK: ![[TYPE14]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_S_E.normalized"} -// CHECK: ![[TYPE15]] = !{i64 0, !"_ZTSFvu3i16E.normalized"} -// CHECK: ![[TYPE16]] = !{i64 0, !"_ZTSFvu3i16S_E.normalized"} -// CHECK: ![[TYPE17]] = !{i64 0, !"_ZTSFvu3i16S_S_E.normalized"} -// CHECK: ![[TYPE18]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}E.normalized"} -// CHECK: ![[TYPE19]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}S_E.normalized"} -// CHECK: ![[TYPE20]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}S_S_E.normalized"} -// CHECK: ![[TYPE21]] = !{i64 0, !"_ZTSFvu3u16E.normalized"} -// CHECK: ![[TYPE22]] = !{i64 0, !"_ZTSFvu3u16S_E.normalized"} -// CHECK: ![[TYPE23]] = !{i64 0, !"_ZTSFvu3u16S_S_E.normalized"} diff --git a/tests/codegen/sanitizer-kasan-emits-instrumentation.rs b/tests/codegen/sanitizer-kasan-emits-instrumentation.rs deleted file mode 100644 index d6e3f2719..000000000 --- a/tests/codegen/sanitizer-kasan-emits-instrumentation.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. - -// compile-flags: -Zsanitizer=kernel-address -// revisions: aarch64 riscv64imac riscv64gc x86_64 -//[aarch64] compile-flags: --target aarch64-unknown-none -//[aarch64] needs-llvm-components: aarch64 -//[riscv64imac] compile-flags: --target riscv64imac-unknown-none-elf -//[riscv64imac] needs-llvm-components: riscv -//[riscv64imac] min-llvm-version: 16 -//[riscv64gc] compile-flags: --target riscv64gc-unknown-none-elf -//[riscv64gc] needs-llvm-components: riscv -//[riscv64gc] min-llvm-version: 16 -//[x86_64] compile-flags: --target x86_64-unknown-none -//[x86_64] needs-llvm-components: x86 - -#![crate_type = "rlib"] -#![feature(no_core, no_sanitize, lang_items)] -#![no_core] - -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -impl Copy for u8 {} - -// CHECK-LABEL: ; sanitizer_kasan_emits_instrumentation::unsanitized -// CHECK-NEXT: ; Function Attrs: -// CHECK-NOT: sanitize_address -// CHECK: start: -// CHECK-NOT: call void @__asan_report_load -// CHECK: } -#[no_sanitize(address)] -pub fn unsanitized(b: &mut u8) -> u8 { - *b -} - -// CHECK-LABEL: ; sanitizer_kasan_emits_instrumentation::sanitized -// CHECK-NEXT: ; Function Attrs: -// CHECK: sanitize_address -// CHECK: start: -// CHECK: call void @__asan_report_load -// CHECK: } -pub fn sanitized(b: &mut u8) -> u8 { - *b -} diff --git a/tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs b/tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs deleted file mode 100644 index c2eb852ae..000000000 --- a/tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Verifies that "kcfi" module flag is added. -// -// needs-sanitizer-kcfi -// compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi - -#![crate_type="lib"] - -pub fn foo() { -} - -// CHECK: !{{[0-9]+}} = !{i32 4, !"kcfi", i32 1} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs deleted file mode 100644 index bb317e4a2..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Verifies that KCFI operand bundles are omitted. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 - -#![crate_type="lib"] -#![feature(no_core, no_sanitize, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } - -impl Copy for i32 {} - -#[no_sanitize(kcfi)] -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: sanitizer_kcfi_emit_kcfi_operand_bundle_attr_no_sanitize::foo - // CHECK: Function Attrs: {{.*}} - // CHECK-LABEL: define{{.*}}foo{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: start: - // CHECK-NOT: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 {{[-0-9]+}}) ] - // CHECK: ret i32 {{%.+}} - f(arg) -} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs deleted file mode 100644 index 29e4df351..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Verifies that generalized KCFI type metadata for functions are emitted. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers - -#![crate_type="lib"] -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } - -impl Copy for i32 {} - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 233085384) ] - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 435418021) ] - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 -1003721339) ] - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i32 -1741689296} -// CHECK: ![[TYPE2]] = !{i32 489439372} -// CHECK: ![[TYPE3]] = !{i32 2026563871} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs deleted file mode 100644 index 84d678a33..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Verifies that normalized and generalized KCFI type metadata for functions are emitted. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers - -#![crate_type="lib"] -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } - -impl Copy for i32 {} - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -686570305) ] - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 1281038450) ] - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 -1751512973) ] - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i32 975484707} -// CHECK: ![[TYPE2]] = !{i32 1658833102} -// CHECK: ![[TYPE3]] = !{i32 230429758} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs deleted file mode 100644 index 761c37a9e..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Verifies that normalized KCFI type metadata for functions are emitted. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers - -#![crate_type="lib"] -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } - -impl Copy for i32 {} - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -841055669) ] - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 1390819368) ] - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 586925835) ] - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i32 -458317079} -// CHECK: ![[TYPE2]] = !{i32 1737138182} -// CHECK: ![[TYPE3]] = !{i32 197182412} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs deleted file mode 100644 index 83cda0ef1..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Verifies that KCFI type metadata for functions are emitted. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 - -#![crate_type="lib"] -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } - -impl Copy for i32 {} - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -1666898348) ] - f(arg) -} - -pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { - // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 -1789026986) ] - f(arg1, arg2) -} - -pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { - // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 1248878270) ] - f(arg1, arg2, arg3) -} - -// CHECK: ![[TYPE1]] = !{i32 653723426} -// CHECK: ![[TYPE2]] = !{i32 412174924} -// CHECK: ![[TYPE3]] = !{i32 -636668840} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs deleted file mode 100644 index e1d617b5e..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Verifies that KCFI operand bundles are emitted. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 - -#![crate_type="lib"] -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } - -impl Copy for i32 {} - -pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: start: - // CHECK-NEXT: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 {{[-0-9]+}}) ] - // CHECK-NEXT: ret i32 {{%.+}} - f(arg) -} diff --git a/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs deleted file mode 100644 index 004a67e7d..000000000 --- a/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs +++ /dev/null @@ -1,144 +0,0 @@ -// Verifies that type metadata identifiers for trait objects are emitted correctly. -// -// revisions: aarch64 x86_64 -// [aarch64] compile-flags: --target aarch64-unknown-none -// [aarch64] needs-llvm-components: aarch64 -// [x86_64] compile-flags: --target x86_64-unknown-none -// [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 - -#![crate_type="lib"] -#![feature(arbitrary_self_types, no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } -#[lang="receiver"] -trait Receiver { } -#[lang="dispatch_from_dyn"] -trait DispatchFromDyn { } -impl<'a, T: ?Sized + Unsize, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} -#[lang = "unsize"] -trait Unsize { } -#[lang = "coerce_unsized"] -pub trait CoerceUnsized { } -impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} -#[lang="freeze"] -trait Freeze { } -#[lang="drop_in_place"] -fn drop_in_place_fn() { } - -pub trait Trait1 { - fn foo(&self); -} - -pub struct Type1; - -impl Trait1 for Type1 { - fn foo(&self) { - } -} - -pub trait Trait2 { - fn bar(&self); -} - -pub struct Type2; - -impl Trait2 for Type2 { - fn bar(&self) { - } -} - -pub trait Trait3 { - fn baz(&self, _: &T); -} - -pub struct Type3; - -impl Trait3 for T { - fn baz(&self, _: &U) { - } -} - -pub trait Trait4<'a, T> { - type Output: 'a; - fn qux(&self, _: &T) -> Self::Output; -} - -pub struct Type4; - -impl<'a, T, U> Trait4<'a, U> for T { - type Output = &'a i32; - fn qux(&self, _: &U) -> Self::Output { - &0 - } -} - -pub fn foo1(a: &dyn Trait1) { - a.foo(); - // CHECK-LABEL: define{{.*}}4foo1{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] -} - -pub fn bar1() { - let a = Type1; - let b = &a as &dyn Trait1; - b.foo(); - // CHECK-LABEL: define{{.*}}4bar1{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] -} - -pub fn foo2(a: &dyn Trait2) { - a.bar(); - // CHECK-LABEL: define{{.*}}4foo2{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] -} - -pub fn bar2() { - let a = Type2; - foo2(&a); - let b = &a as &dyn Trait2; - b.bar(); - // CHECK-LABEL: define{{.*}}4bar2{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] -} - -pub fn foo3(a: &dyn Trait3) { - let b = Type3; - a.baz(&b); - // CHECK-LABEL: define{{.*}}4foo3{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type3\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] -} - -pub fn bar3() { - let a = Type3; - foo3(&a); - let b = &a as &dyn Trait3; - b.baz(&a); - // CHECK-LABEL: define{{.*}}4bar3{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type3\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] -} - -pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { - let b = Type4; - a.qux(&b); - // CHECK-LABEL: define{{.*}}4foo4{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call align 4 {{ptr|i32\*}} %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type4\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] -} - -pub fn bar4<'a>() { - let a = Type4; - foo4(&a); - let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; - b.qux(&a); - // CHECK-LABEL: define{{.*}}4bar4{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call align 4 {{ptr|i32\*}} %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type4\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] -} - -// CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]} -// CHECK: !{{[0-9]+}} = !{i32 [[TYPE2]]} -// CHECK: !{{[0-9]+}} = !{i32 [[TYPE3]]} -// CHECK: !{{[0-9]+}} = !{i32 [[TYPE4]]} diff --git a/tests/codegen/sanitizer-memory-track-orgins.rs b/tests/codegen/sanitizer-memory-track-orgins.rs deleted file mode 100644 index 4bd50508d..000000000 --- a/tests/codegen/sanitizer-memory-track-orgins.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Verifies that MemorySanitizer track-origins level can be controlled -// with -Zsanitizer-memory-track-origins option. -// -// needs-sanitizer-memory -// revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO -// -//[MSAN-0] compile-flags: -Zsanitizer=memory -//[MSAN-1] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 -//[MSAN-2] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins -//[MSAN-1-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 -C lto=fat -//[MSAN-2-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins -C lto=fat - -#![crate_type="lib"] - -// MSAN-0-NOT: @__msan_track_origins -// MSAN-1: @__msan_track_origins = weak_odr {{.*}}constant i32 1 -// MSAN-2: @__msan_track_origins = weak_odr {{.*}}constant i32 2 -// MSAN-1-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 1 -// MSAN-2-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 2 -// -// MSAN-0-LABEL: define void @copy( -// MSAN-1-LABEL: define void @copy( -// MSAN-2-LABEL: define void @copy( -#[no_mangle] -pub fn copy(dst: &mut i32, src: &i32) { - // MSAN-0-NOT: call i32 @__msan_chain_origin( - // MSAN-1-NOT: call i32 @__msan_chain_origin( - // MSAN-2: call i32 @__msan_chain_origin( - *dst = *src; -} diff --git a/tests/codegen/sanitizer-no-sanitize-inlining.rs b/tests/codegen/sanitizer-no-sanitize-inlining.rs deleted file mode 100644 index f4af60bae..000000000 --- a/tests/codegen/sanitizer-no-sanitize-inlining.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Verifies that no_sanitize attribute prevents inlining when -// given sanitizer is enabled, but has no effect on inlining otherwise. -// -// needs-sanitizer-address -// needs-sanitizer-leak -// revisions: ASAN LSAN -//[ASAN] compile-flags: -Zsanitizer=address -C opt-level=3 -Z mir-opt-level=4 -//[LSAN] compile-flags: -Zsanitizer=leak -C opt-level=3 -Z mir-opt-level=4 - -#![crate_type="lib"] -#![feature(no_sanitize)] - -// ASAN-LABEL: define void @test -// ASAN: call {{.*}} @random_inline -// ASAN: } -// -// LSAN-LABEL: define void @test -// LSAN-NO: call -// LSAN: } -#[no_mangle] -pub fn test(n: &mut u32) { - random_inline(n); -} - -#[no_sanitize(address)] -#[inline] -#[no_mangle] -pub fn random_inline(n: &mut u32) { - *n = 42; -} diff --git a/tests/codegen/sanitizer-no-sanitize.rs b/tests/codegen/sanitizer-no-sanitize.rs deleted file mode 100644 index fb9d249da..000000000 --- a/tests/codegen/sanitizer-no-sanitize.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Verifies that no_sanitize attribute can be used to -// selectively disable sanitizer instrumentation. -// -// needs-sanitizer-address -// compile-flags: -Zsanitizer=address - -#![crate_type="lib"] -#![feature(no_sanitize)] - -// CHECK-LABEL: ; sanitizer_no_sanitize::unsanitized -// CHECK-NEXT: ; Function Attrs: -// CHECK-NOT: sanitize_address -// CHECK: start: -// CHECK-NOT: call void @__asan_report_load -// CHECK: } -#[no_sanitize(address)] -pub fn unsanitized(b: &mut u8) -> u8 { - *b -} - -// CHECK-LABEL: ; sanitizer_no_sanitize::sanitized -// CHECK-NEXT: ; Function Attrs: -// CHECK: sanitize_address -// CHECK: start: -// CHECK: call void @__asan_report_load -// CHECK: } -pub fn sanitized(b: &mut u8) -> u8 { - *b -} diff --git a/tests/codegen/sanitizer-recover.rs b/tests/codegen/sanitizer-recover.rs deleted file mode 100644 index 7b00fcf8e..000000000 --- a/tests/codegen/sanitizer-recover.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Verifies that AddressSanitizer and MemorySanitizer -// recovery mode can be enabled with -Zsanitizer-recover. -// -// needs-sanitizer-address -// needs-sanitizer-memory -// revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO -// no-prefer-dynamic -// -//[ASAN] compile-flags: -Zsanitizer=address -Copt-level=0 -//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0 -//[MSAN] compile-flags: -Zsanitizer=memory -//[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -//[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -C lto=fat -// -// MSAN-NOT: @__msan_keep_going -// MSAN-RECOVER: @__msan_keep_going = weak_odr {{.*}}constant i32 1 -// MSAN-RECOVER-LTO: @__msan_keep_going = weak_odr {{.*}}constant i32 1 - -// ASAN-LABEL: define dso_local i32 @penguin( -// ASAN: call void @__asan_report_load4(i64 %0) -// ASAN: unreachable -// ASAN: } -// -// ASAN-RECOVER-LABEL: define dso_local i32 @penguin( -// ASAN-RECOVER: call void @__asan_report_load4_noabort( -// ASAN-RECOVER-NOT: unreachable -// ASAN: } -// -// MSAN-LABEL: define dso_local noundef i32 @penguin( -// MSAN: call void @__msan_warning{{(_with_origin_noreturn\(i32 0\)|_noreturn\(\))}} -// MSAN: unreachable -// MSAN: } -// -// MSAN-RECOVER-LABEL: define dso_local noundef i32 @penguin( -// MSAN-RECOVER: call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}} -// MSAN-RECOVER-NOT: unreachable -// MSAN-RECOVER: } -// -// MSAN-RECOVER-LTO-LABEL: define dso_local noundef i32 @penguin( -// MSAN-RECOVER-LTO: call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}} -// MSAN-RECOVER-LTO-NOT: unreachable -// MSAN-RECOVER-LTO: } -// -#[no_mangle] -pub fn penguin(p: &mut i32) -> i32 { - *p -} - -fn main() {} diff --git a/tests/codegen/sanitizer-safestack-attr-check.rs b/tests/codegen/sanitizer-safestack-attr-check.rs deleted file mode 100644 index b73ed00e7..000000000 --- a/tests/codegen/sanitizer-safestack-attr-check.rs +++ /dev/null @@ -1,11 +0,0 @@ -// This tests that the safestack attribute is applied when enabling the safe-stack sanitizer. -// -// needs-sanitizer-safestack -// compile-flags: -Zsanitizer=safestack - -#![crate_type = "lib"] - -// CHECK: ; Function Attrs:{{.*}}safestack -pub fn tagged() {} - -// CHECK: attributes #0 = {{.*}}safestack diff --git a/tests/codegen/sanitizer/cfi-add-canonical-jump-tables-flag.rs b/tests/codegen/sanitizer/cfi-add-canonical-jump-tables-flag.rs new file mode 100644 index 000000000..1ee8bdfc3 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-add-canonical-jump-tables-flag.rs @@ -0,0 +1,11 @@ +// Verifies that "CFI Canonical Jump Tables" module flag is added. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] + +pub fn foo() { +} + +// CHECK: !{{[0-9]+}} = !{i32 4, !"CFI Canonical Jump Tables", i32 1} diff --git a/tests/codegen/sanitizer/cfi-add-enable-split-lto-unit-flag.rs b/tests/codegen/sanitizer/cfi-add-enable-split-lto-unit-flag.rs new file mode 100644 index 000000000..68c91384b --- /dev/null +++ b/tests/codegen/sanitizer/cfi-add-enable-split-lto-unit-flag.rs @@ -0,0 +1,11 @@ +// Verifies that "EnableSplitLTOUnit" module flag is added. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] + +pub fn foo() { +} + +// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1} diff --git a/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs new file mode 100644 index 000000000..a3cd16e3d --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs @@ -0,0 +1,18 @@ +// Verifies that pointer type membership tests for indirect calls are omitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_sanitize)] + +#[no_sanitize(cfi)] +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: cfi_emit_type_checks_attr_no_sanitize::foo + // CHECK: Function Attrs: {{.*}} + // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: start: + // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) + // CHECK-NEXT: ret i32 {{%.+}} + f(arg) +} diff --git a/tests/codegen/sanitizer/cfi-emit-type-checks.rs b/tests/codegen/sanitizer/cfi-emit-type-checks.rs new file mode 100644 index 000000000..f0fe5de9f --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-checks.rs @@ -0,0 +1,19 @@ +// Verifies that pointer type membership tests for indirect calls are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: start: + // CHECK: [[TT:%.+]] = call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"{{[[:print:]]+}}") + // CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail + // CHECK: type_test.pass: + // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) + // CHECK: type_test.fail: + // CHECK-NEXT: call void @llvm.trap() + // CHECK-NEXT: unreachable + f(arg) +} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs new file mode 100644 index 000000000..084d8bf80 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs @@ -0,0 +1,48 @@ +// Verifies that user-defined CFI encoding for types are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] +#![feature(cfi_encoding, extern_types)] + +#[cfi_encoding = "3Foo"] +pub struct Type1(i32); + +extern { + #[cfi_encoding = "3Bar"] + type Type2; +} + +#[cfi_encoding = "3Baz"] +#[repr(transparent)] +pub struct Type3(i32); + +pub fn foo0(_: Type1) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo1(_: Type1, _: Type1) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo2(_: Type1, _: Type1, _: Type1) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo3(_: *mut Type2) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo4(_: *mut Type2, _: *mut Type2) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo5(_: *mut Type2, _: *mut Type2, _: *mut Type2) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo6(_: *mut Type3) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo7(_: *mut Type3, _: *mut Type3) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo8(_: *mut Type3, _: *mut Type3, _: *mut Type3) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFv3FooE"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFv3FooS_E"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFv3FooS_S_E"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvP3BarE"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvP3BarS0_E"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvP3BarS0_S0_E"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvP3BazE"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvP3BazS0_E"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvP3BazS0_S0_E"} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs new file mode 100644 index 000000000..da608e180 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -0,0 +1,604 @@ +// Verifies that type metadata identifiers for functions are emitted correctly. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] +#![allow(dead_code)] +#![allow(incomplete_features)] +#![allow(unused_must_use)] +#![feature(adt_const_params, extern_types, inline_const, type_alias_impl_trait)] + +extern crate core; +use core::ffi::*; +use std::marker::PhantomData; + +// User-defined type (structure) +pub struct Struct1 { + member1: T, +} + +// User-defined type (enum) +pub enum Enum1 { + Variant1(T), +} + +// User-defined type (union) +pub union Union1 { + member1: std::mem::ManuallyDrop, +} + +// Extern type +extern { + pub type type1; +} + +// Trait +pub trait Trait1 { + fn foo(&self) { } +} + +// Trait implementation +impl Trait1 for i32 { + fn foo(&self) { } +} + +// Trait implementation +impl Trait1 for Struct1 { + fn foo(&self) { } +} + +// impl Trait type aliases for helping with defining other types (see below) +pub type Type1 = impl Send; +pub type Type2 = impl Send; +pub type Type3 = impl Send; +pub type Type4 = impl Send; +pub type Type5 = impl Send; +pub type Type6 = impl Send; +pub type Type7 = impl Send; +pub type Type8 = impl Send; +pub type Type9 = impl Send; +pub type Type10 = impl Send; +pub type Type11 = impl Send; + +pub fn fn1<'a>() where + Type1: 'static, + Type2: 'static, + Type3: 'static, + Type4: 'static, + Type5: 'static, + Type6: 'static, + Type7: 'static, + Type8: 'static, + Type9: 'static, + Type10: 'static, + Type11: 'static, +{ + // Closure + let closure1 = || { }; + let _: Type1 = closure1; + + // Constructor + pub struct Foo(i32); + let _: Type2 = Foo; + + // Type in extern path + extern { + fn foo(); + } + let _: Type3 = foo; + + // Type in closure path + || { + pub struct Foo; + let _: Type4 = Foo; + }; + + // Type in const path + const { + pub struct Foo; + fn foo() -> Type5 { Foo } + }; + + // Type in impl path + impl Struct1 { + fn foo(&self) { } + } + let _: Type6 = >::foo; + + // Trait method + let _: Type7 = >::foo; + + // Trait method + let _: Type8 = >::foo; + + // Trait method + let _: Type9 = as Trait1>::foo; + + // Const generics + pub struct Qux([T; N]); + let _: Type10 = Qux([0; 32]); + + // Lifetimes/regions + pub struct Quux<'a>(&'a i32); + pub struct Quuux<'a, 'b>(&'a i32, &'b Quux<'b>); + let _: Type11 = Quuux; +} + +// Helper type to make Type12 have an unique id +struct Foo(i32); + +// repr(transparent) user-defined type +#[repr(transparent)] +pub struct Type12 { + member1: (), + member2: PhantomData, + member3: Foo, +} + +// Self-referencing repr(transparent) user-defined type +#[repr(transparent)] +pub struct Type13<'a> { + member1: (), + member2: PhantomData, + member3: &'a Type13<'a>, +} + +// Helper type to make Type14 have an unique id +pub struct Bar; + +// repr(transparent) user-defined generic type +#[repr(transparent)] +pub struct Type14(T); + +pub fn foo0(_: ()) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo1(_: (), _: c_void) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo2(_: (), _: c_void, _: c_void) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo3(_: *mut ()) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo4(_: *mut (), _: *mut c_void) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo5(_: *mut (), _: *mut c_void, _: *mut c_void) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo6(_: *const ()) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo7(_: *const (), _: *const c_void) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo8(_: *const (), _: *const c_void, _: *const c_void) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo9(_: bool) { } +// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo10(_: bool, _: bool) { } +// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo11(_: bool, _: bool, _: bool) { } +// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo12(_: i8) { } +// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo13(_: i8, _: i8) { } +// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo14(_: i8, _: i8, _: i8) { } +// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo15(_: i16) { } +// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo16(_: i16, _: i16) { } +// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo17(_: i16, _: i16, _: i16) { } +// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo18(_: i32) { } +// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo19(_: i32, _: i32) { } +// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo20(_: i32, _: i32, _: i32) { } +// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo21(_: i64) { } +// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo22(_: i64, _: i64) { } +// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo23(_: i64, _: i64, _: i64) { } +// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo24(_: i128) { } +// CHECK: define{{.*}}foo24{{.*}}!type ![[TYPE24:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo25(_: i128, _: i128) { } +// CHECK: define{{.*}}foo25{{.*}}!type ![[TYPE25:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo26(_: i128, _: i128, _: i128) { } +// CHECK: define{{.*}}foo26{{.*}}!type ![[TYPE26:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo27(_: isize) { } +// CHECK: define{{.*}}foo27{{.*}}!type ![[TYPE27:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo28(_: isize, _: isize) { } +// CHECK: define{{.*}}foo28{{.*}}!type ![[TYPE28:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo29(_: isize, _: isize, _: isize) { } +// CHECK: define{{.*}}foo29{{.*}}!type ![[TYPE29:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo30(_: u8) { } +// CHECK: define{{.*}}foo30{{.*}}!type ![[TYPE30:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo31(_: u8, _: u8) { } +// CHECK: define{{.*}}foo31{{.*}}!type ![[TYPE31:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo32(_: u8, _: u8, _: u8) { } +// CHECK: define{{.*}}foo32{{.*}}!type ![[TYPE32:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo33(_: u16) { } +// CHECK: define{{.*}}foo33{{.*}}!type ![[TYPE33:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo34(_: u16, _: u16) { } +// CHECK: define{{.*}}foo34{{.*}}!type ![[TYPE34:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo35(_: u16, _: u16, _: u16) { } +// CHECK: define{{.*}}foo35{{.*}}!type ![[TYPE35:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo36(_: u32) { } +// CHECK: define{{.*}}foo36{{.*}}!type ![[TYPE36:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo37(_: u32, _: u32) { } +// CHECK: define{{.*}}foo37{{.*}}!type ![[TYPE37:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo38(_: u32, _: u32, _: u32) { } +// CHECK: define{{.*}}foo38{{.*}}!type ![[TYPE38:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo39(_: u64) { } +// CHECK: define{{.*}}foo39{{.*}}!type ![[TYPE39:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo40(_: u64, _: u64) { } +// CHECK: define{{.*}}foo40{{.*}}!type ![[TYPE40:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo41(_: u64, _: u64, _: u64) { } +// CHECK: define{{.*}}foo41{{.*}}!type ![[TYPE41:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo42(_: u128) { } +// CHECK: define{{.*}}foo42{{.*}}!type ![[TYPE42:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo43(_: u128, _: u128) { } +// CHECK: define{{.*}}foo43{{.*}}!type ![[TYPE43:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo44(_: u128, _: u128, _: u128) { } +// CHECK: define{{.*}}foo44{{.*}}!type ![[TYPE44:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo45(_: usize) { } +// CHECK: define{{.*}}foo45{{.*}}!type ![[TYPE45:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo46(_: usize, _: usize) { } +// CHECK: define{{.*}}foo46{{.*}}!type ![[TYPE46:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo47(_: usize, _: usize, _: usize) { } +// CHECK: define{{.*}}foo47{{.*}}!type ![[TYPE47:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo48(_: f32) { } +// CHECK: define{{.*}}foo48{{.*}}!type ![[TYPE48:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo49(_: f32, _: f32) { } +// CHECK: define{{.*}}foo49{{.*}}!type ![[TYPE49:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo50(_: f32, _: f32, _: f32) { } +// CHECK: define{{.*}}foo50{{.*}}!type ![[TYPE50:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo51(_: f64) { } +// CHECK: define{{.*}}foo51{{.*}}!type ![[TYPE51:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo52(_: f64, _: f64) { } +// CHECK: define{{.*}}foo52{{.*}}!type ![[TYPE52:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo53(_: f64, _: f64, _: f64) { } +// CHECK: define{{.*}}foo53{{.*}}!type ![[TYPE53:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo54(_: char) { } +// CHECK: define{{.*}}foo54{{.*}}!type ![[TYPE54:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo55(_: char, _: char) { } +// CHECK: define{{.*}}foo55{{.*}}!type ![[TYPE55:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo56(_: char, _: char, _: char) { } +// CHECK: define{{.*}}foo56{{.*}}!type ![[TYPE56:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo57(_: &str) { } +// CHECK: define{{.*}}foo57{{.*}}!type ![[TYPE57:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo58(_: &str, _: &str) { } +// CHECK: define{{.*}}foo58{{.*}}!type ![[TYPE58:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo59(_: &str, _: &str, _: &str) { } +// CHECK: define{{.*}}foo59{{.*}}!type ![[TYPE59:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo60(_: (i32, i32)) { } +// CHECK: define{{.*}}foo60{{.*}}!type ![[TYPE60:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo61(_: (i32, i32), _: (i32, i32)) { } +// CHECK: define{{.*}}foo61{{.*}}!type ![[TYPE61:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo62(_: (i32, i32), _: (i32, i32), _: (i32, i32)) { } +// CHECK: define{{.*}}foo62{{.*}}!type ![[TYPE62:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo63(_: [i32; 32]) { } +// CHECK: define{{.*}}foo63{{.*}}!type ![[TYPE63:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo64(_: [i32; 32], _: [i32; 32]) { } +// CHECK: define{{.*}}foo64{{.*}}!type ![[TYPE64:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo65(_: [i32; 32], _: [i32; 32], _: [i32; 32]) { } +// CHECK: define{{.*}}foo65{{.*}}!type ![[TYPE65:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo66(_: &[i32]) { } +// CHECK: define{{.*}}foo66{{.*}}!type ![[TYPE66:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo67(_: &[i32], _: &[i32]) { } +// CHECK: define{{.*}}foo67{{.*}}!type ![[TYPE67:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo68(_: &[i32], _: &[i32], _: &[i32]) { } +// CHECK: define{{.*}}foo68{{.*}}!type ![[TYPE68:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo69(_: &Struct1::) { } +// CHECK: define{{.*}}foo69{{.*}}!type ![[TYPE69:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo70(_: &Struct1::, _: &Struct1::) { } +// CHECK: define{{.*}}foo70{{.*}}!type ![[TYPE70:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo71(_: &Struct1::, _: &Struct1::, _: &Struct1::) { } +// CHECK: define{{.*}}foo71{{.*}}!type ![[TYPE71:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo72(_: &Enum1::) { } +// CHECK: define{{.*}}foo72{{.*}}!type ![[TYPE72:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo73(_: &Enum1::, _: &Enum1::) { } +// CHECK: define{{.*}}foo73{{.*}}!type ![[TYPE73:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo74(_: &Enum1::, _: &Enum1::, _: &Enum1::) { } +// CHECK: define{{.*}}foo74{{.*}}!type ![[TYPE74:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo75(_: &Union1::) { } +// CHECK: define{{.*}}foo75{{.*}}!type ![[TYPE75:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo76(_: &Union1::, _: &Union1::) { } +// CHECK: define{{.*}}foo76{{.*}}!type ![[TYPE76:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo77(_: &Union1::, _: &Union1::, _: &Union1::) { } +// CHECK: define{{.*}}foo77{{.*}}!type ![[TYPE77:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo78(_: *mut type1) { } +// CHECK: define{{.*}}foo78{{.*}}!type ![[TYPE78:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo79(_: *mut type1, _: *mut type1) { } +// CHECK: define{{.*}}foo79{{.*}}!type ![[TYPE79:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo80(_: *mut type1, _: *mut type1, _: *mut type1) { } +// CHECK: define{{.*}}foo80{{.*}}!type ![[TYPE80:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo81(_: &mut i32) { } +// CHECK: define{{.*}}foo81{{.*}}!type ![[TYPE81:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo82(_: &mut i32, _: &i32) { } +// CHECK: define{{.*}}foo82{{.*}}!type ![[TYPE82:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo83(_: &mut i32, _: &i32, _: &i32) { } +// CHECK: define{{.*}}foo83{{.*}}!type ![[TYPE83:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo84(_: &i32) { } +// CHECK: define{{.*}}foo84{{.*}}!type ![[TYPE84:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo85(_: &i32, _: &mut i32) { } +// CHECK: define{{.*}}foo85{{.*}}!type ![[TYPE85:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo86(_: &i32, _: &mut i32, _: &mut i32) { } +// CHECK: define{{.*}}foo86{{.*}}!type ![[TYPE86:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo87(_: *mut i32) { } +// CHECK: define{{.*}}foo87{{.*}}!type ![[TYPE87:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo88(_: *mut i32, _: *const i32) { } +// CHECK: define{{.*}}foo88{{.*}}!type ![[TYPE88:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo89(_: *mut i32, _: *const i32, _: *const i32) { } +// CHECK: define{{.*}}foo89{{.*}}!type ![[TYPE89:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo90(_: *const i32) { } +// CHECK: define{{.*}}foo90{{.*}}!type ![[TYPE90:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo91(_: *const i32, _: *mut i32) { } +// CHECK: define{{.*}}foo91{{.*}}!type ![[TYPE91:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo92(_: *const i32, _: *mut i32, _: *mut i32) { } +// CHECK: define{{.*}}foo92{{.*}}!type ![[TYPE92:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo93(_: fn(i32) -> i32) { } +// CHECK: define{{.*}}foo93{{.*}}!type ![[TYPE93:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo94(_: fn(i32) -> i32, _: fn(i32) -> i32) { } +// CHECK: define{{.*}}foo94{{.*}}!type ![[TYPE94:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo95(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) { } +// CHECK: define{{.*}}foo95{{.*}}!type ![[TYPE95:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo96(_: &dyn Fn(i32) -> i32) { } +// CHECK: define{{.*}}foo96{{.*}}!type ![[TYPE96:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo97(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { } +// CHECK: define{{.*}}foo97{{.*}}!type ![[TYPE97:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo98(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { } +// CHECK: define{{.*}}foo98{{.*}}!type ![[TYPE98:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo99(_: &dyn FnMut(i32) -> i32) { } +// CHECK: define{{.*}}foo99{{.*}}!type ![[TYPE99:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo100(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { } +// CHECK: define{{.*}}foo100{{.*}}!type ![[TYPE100:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo101(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { } +// CHECK: define{{.*}}foo101{{.*}}!type ![[TYPE101:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo102(_: &dyn FnOnce(i32) -> i32) { } +// CHECK: define{{.*}}foo102{{.*}}!type ![[TYPE102:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo103(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) { } +// CHECK: define{{.*}}foo103{{.*}}!type ![[TYPE103:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo104(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) {} +// CHECK: define{{.*}}foo104{{.*}}!type ![[TYPE104:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo105(_: &dyn Send) { } +// CHECK: define{{.*}}foo105{{.*}}!type ![[TYPE105:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo106(_: &dyn Send, _: &dyn Send) { } +// CHECK: define{{.*}}foo106{{.*}}!type ![[TYPE106:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo107(_: &dyn Send, _: &dyn Send, _: &dyn Send) { } +// CHECK: define{{.*}}foo107{{.*}}!type ![[TYPE107:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo108(_: Type1) { } +// CHECK: define{{.*}}foo108{{.*}}!type ![[TYPE108:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo109(_: Type1, _: Type1) { } +// CHECK: define{{.*}}foo109{{.*}}!type ![[TYPE109:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo110(_: Type1, _: Type1, _: Type1) { } +// CHECK: define{{.*}}foo110{{.*}}!type ![[TYPE110:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo111(_: Type2) { } +// CHECK: define{{.*}}foo111{{.*}}!type ![[TYPE111:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo112(_: Type2, _: Type2) { } +// CHECK: define{{.*}}foo112{{.*}}!type ![[TYPE112:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo113(_: Type2, _: Type2, _: Type2) { } +// CHECK: define{{.*}}foo113{{.*}}!type ![[TYPE113:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo114(_: Type3) { } +// CHECK: define{{.*}}foo114{{.*}}!type ![[TYPE114:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo115(_: Type3, _: Type3) { } +// CHECK: define{{.*}}foo115{{.*}}!type ![[TYPE115:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo116(_: Type3, _: Type3, _: Type3) { } +// CHECK: define{{.*}}foo116{{.*}}!type ![[TYPE116:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo117(_: Type4) { } +// CHECK: define{{.*}}foo117{{.*}}!type ![[TYPE117:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo118(_: Type4, _: Type4) { } +// CHECK: define{{.*}}foo118{{.*}}!type ![[TYPE118:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo119(_: Type4, _: Type4, _: Type4) { } +// CHECK: define{{.*}}foo119{{.*}}!type ![[TYPE119:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo120(_: Type5) { } +// CHECK: define{{.*}}foo120{{.*}}!type ![[TYPE120:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo121(_: Type5, _: Type5) { } +// CHECK: define{{.*}}foo121{{.*}}!type ![[TYPE121:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo122(_: Type5, _: Type5, _: Type5) { } +// CHECK: define{{.*}}foo122{{.*}}!type ![[TYPE122:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo123(_: Type6) { } +// CHECK: define{{.*}}foo123{{.*}}!type ![[TYPE123:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo124(_: Type6, _: Type6) { } +// CHECK: define{{.*}}foo124{{.*}}!type ![[TYPE124:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo125(_: Type6, _: Type6, _: Type6) { } +// CHECK: define{{.*}}foo125{{.*}}!type ![[TYPE125:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo126(_: Type7) { } +// CHECK: define{{.*}}foo126{{.*}}!type ![[TYPE126:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo127(_: Type7, _: Type7) { } +// CHECK: define{{.*}}foo127{{.*}}!type ![[TYPE127:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo128(_: Type7, _: Type7, _: Type7) { } +// CHECK: define{{.*}}foo128{{.*}}!type ![[TYPE128:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo129(_: Type8) { } +// CHECK: define{{.*}}foo129{{.*}}!type ![[TYPE129:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo130(_: Type8, _: Type8) { } +// CHECK: define{{.*}}foo130{{.*}}!type ![[TYPE130:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo131(_: Type8, _: Type8, _: Type8) { } +// CHECK: define{{.*}}foo131{{.*}}!type ![[TYPE131:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo132(_: Type9) { } +// CHECK: define{{.*}}foo132{{.*}}!type ![[TYPE132:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo133(_: Type9, _: Type9) { } +// CHECK: define{{.*}}foo133{{.*}}!type ![[TYPE133:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo134(_: Type9, _: Type9, _: Type9) { } +// CHECK: define{{.*}}foo134{{.*}}!type ![[TYPE134:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo135(_: Type10) { } +// CHECK: define{{.*}}foo135{{.*}}!type ![[TYPE135:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo136(_: Type10, _: Type10) { } +// CHECK: define{{.*}}foo136{{.*}}!type ![[TYPE136:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo137(_: Type10, _: Type10, _: Type10) { } +// CHECK: define{{.*}}foo137{{.*}}!type ![[TYPE137:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo138(_: Type11) { } +// CHECK: define{{.*}}foo138{{.*}}!type ![[TYPE138:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo139(_: Type11, _: Type11) { } +// CHECK: define{{.*}}foo139{{.*}}!type ![[TYPE139:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo140(_: Type11, _: Type11, _: Type11) { } +// CHECK: define{{.*}}foo140{{.*}}!type ![[TYPE140:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo141(_: Type12) { } +// CHECK: define{{.*}}foo141{{.*}}!type ![[TYPE141:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo142(_: Type12, _: Type12) { } +// CHECK: define{{.*}}foo142{{.*}}!type ![[TYPE142:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo143(_: Type12, _: Type12, _: Type12) { } +// CHECK: define{{.*}}foo143{{.*}}!type ![[TYPE143:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo144(_: Type13) { } +// CHECK: define{{.*}}foo144{{.*}}!type ![[TYPE144:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo145(_: Type13, _: Type13) { } +// CHECK: define{{.*}}foo145{{.*}}!type ![[TYPE145:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo146(_: Type13, _: Type13, _: Type13) { } +// CHECK: define{{.*}}foo146{{.*}}!type ![[TYPE146:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo147(_: Type14) { } +// CHECK: define{{.*}}foo147{{.*}}!type ![[TYPE147:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo148(_: Type14, _: Type14) { } +// CHECK: define{{.*}}foo148{{.*}}!type ![[TYPE148:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo149(_: Type14, _: Type14, _: Type14) { } +// CHECK: define{{.*}}foo149{{.*}}!type ![[TYPE149:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvvE"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvvvE"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvvvvE"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPvE"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvPvS_E"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvPvS_S_E"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPKvE"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvPKvS0_E"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvPKvS0_S0_E"} +// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvbE"} +// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvbbE"} +// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvbbbE"} +// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFvu2i8E"} +// CHECK: ![[TYPE13]] = !{i64 0, !"_ZTSFvu2i8S_E"} +// CHECK: ![[TYPE14]] = !{i64 0, !"_ZTSFvu2i8S_S_E"} +// CHECK: ![[TYPE15]] = !{i64 0, !"_ZTSFvu3i16E"} +// CHECK: ![[TYPE16]] = !{i64 0, !"_ZTSFvu3i16S_E"} +// CHECK: ![[TYPE17]] = !{i64 0, !"_ZTSFvu3i16S_S_E"} +// CHECK: ![[TYPE18]] = !{i64 0, !"_ZTSFvu3i32E"} +// CHECK: ![[TYPE19]] = !{i64 0, !"_ZTSFvu3i32S_E"} +// CHECK: ![[TYPE20]] = !{i64 0, !"_ZTSFvu3i32S_S_E"} +// CHECK: ![[TYPE21]] = !{i64 0, !"_ZTSFvu3i64E"} +// CHECK: ![[TYPE22]] = !{i64 0, !"_ZTSFvu3i64S_E"} +// CHECK: ![[TYPE23]] = !{i64 0, !"_ZTSFvu3i64S_S_E"} +// CHECK: ![[TYPE24]] = !{i64 0, !"_ZTSFvu4i128E"} +// CHECK: ![[TYPE25]] = !{i64 0, !"_ZTSFvu4i128S_E"} +// CHECK: ![[TYPE26]] = !{i64 0, !"_ZTSFvu4i128S_S_E"} +// CHECK: ![[TYPE27]] = !{i64 0, !"_ZTSFvu5isizeE"} +// CHECK: ![[TYPE28]] = !{i64 0, !"_ZTSFvu5isizeS_E"} +// CHECK: ![[TYPE29]] = !{i64 0, !"_ZTSFvu5isizeS_S_E"} +// CHECK: ![[TYPE30]] = !{i64 0, !"_ZTSFvu2u8E"} +// CHECK: ![[TYPE31]] = !{i64 0, !"_ZTSFvu2u8S_E"} +// CHECK: ![[TYPE32]] = !{i64 0, !"_ZTSFvu2u8S_S_E"} +// CHECK: ![[TYPE33]] = !{i64 0, !"_ZTSFvu3u16E"} +// CHECK: ![[TYPE34]] = !{i64 0, !"_ZTSFvu3u16S_E"} +// CHECK: ![[TYPE35]] = !{i64 0, !"_ZTSFvu3u16S_S_E"} +// CHECK: ![[TYPE36]] = !{i64 0, !"_ZTSFvu3u32E"} +// CHECK: ![[TYPE37]] = !{i64 0, !"_ZTSFvu3u32S_E"} +// CHECK: ![[TYPE38]] = !{i64 0, !"_ZTSFvu3u32S_S_E"} +// CHECK: ![[TYPE39]] = !{i64 0, !"_ZTSFvu3u64E"} +// CHECK: ![[TYPE40]] = !{i64 0, !"_ZTSFvu3u64S_E"} +// CHECK: ![[TYPE41]] = !{i64 0, !"_ZTSFvu3u64S_S_E"} +// CHECK: ![[TYPE42]] = !{i64 0, !"_ZTSFvu4u128E"} +// CHECK: ![[TYPE43]] = !{i64 0, !"_ZTSFvu4u128S_E"} +// CHECK: ![[TYPE44]] = !{i64 0, !"_ZTSFvu4u128S_S_E"} +// CHECK: ![[TYPE45]] = !{i64 0, !"_ZTSFvu5usizeE"} +// CHECK: ![[TYPE46]] = !{i64 0, !"_ZTSFvu5usizeS_E"} +// CHECK: ![[TYPE47]] = !{i64 0, !"_ZTSFvu5usizeS_S_E"} +// CHECK: ![[TYPE48]] = !{i64 0, !"_ZTSFvu3f32E"} +// CHECK: ![[TYPE49]] = !{i64 0, !"_ZTSFvu3f32S_E"} +// CHECK: ![[TYPE50]] = !{i64 0, !"_ZTSFvu3f32S_S_E"} +// CHECK: ![[TYPE51]] = !{i64 0, !"_ZTSFvu3f64E"} +// CHECK: ![[TYPE52]] = !{i64 0, !"_ZTSFvu3f64S_E"} +// CHECK: ![[TYPE53]] = !{i64 0, !"_ZTSFvu3f64S_S_E"} +// CHECK: ![[TYPE54]] = !{i64 0, !"_ZTSFvu4charE"} +// CHECK: ![[TYPE55]] = !{i64 0, !"_ZTSFvu4charS_E"} +// CHECK: ![[TYPE56]] = !{i64 0, !"_ZTSFvu4charS_S_E"} +// CHECK: ![[TYPE57]] = !{i64 0, !"_ZTSFvu3refIu3strEE"} +// CHECK: ![[TYPE58]] = !{i64 0, !"_ZTSFvu3refIu3strES0_E"} +// CHECK: ![[TYPE59]] = !{i64 0, !"_ZTSFvu3refIu3strES0_S0_E"} +// CHECK: ![[TYPE60]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_EE"} +// CHECK: ![[TYPE61]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_ES0_E"} +// CHECK: ![[TYPE62]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_ES0_S0_E"} +// CHECK: ![[TYPE63]] = !{i64 0, !"_ZTSFvA32u3i32E"} +// CHECK: ![[TYPE64]] = !{i64 0, !"_ZTSFvA32u3i32S0_E"} +// CHECK: ![[TYPE65]] = !{i64 0, !"_ZTSFvA32u3i32S0_S0_E"} +// CHECK: ![[TYPE66]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EEE"} +// CHECK: ![[TYPE67]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EES1_E"} +// CHECK: ![[TYPE68]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EES1_S1_E"} +// CHECK: ![[TYPE69]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME:[0-9]{1,2}[a-z_]{1,99}]]7Struct1Iu3i32EEE"} +// CHECK: ![[TYPE70]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32EES1_E"} +// CHECK: ![[TYPE71]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32EES1_S1_E"} +// CHECK: ![[TYPE72]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]5Enum1Iu3i32EEE"} +// CHECK: ![[TYPE73]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]5Enum1Iu3i32EES1_E"} +// CHECK: ![[TYPE74]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]5Enum1Iu3i32EES1_S1_E"} +// CHECK: ![[TYPE75]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Union1Iu3i32EEE"} +// CHECK: ![[TYPE76]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Union1Iu3i32EES1_E"} +// CHECK: ![[TYPE77]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Union1Iu3i32EES1_S1_E"} +// CHECK: ![[TYPE78]] = !{i64 0, !"_ZTSFvP5type1E"} +// CHECK: ![[TYPE79]] = !{i64 0, !"_ZTSFvP5type1S0_E"} +// CHECK: ![[TYPE80]] = !{i64 0, !"_ZTSFvP5type1S0_S0_E"} +// CHECK: ![[TYPE81]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32EE"} +// CHECK: ![[TYPE82]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32ES0_E"} +// CHECK: ![[TYPE83]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32ES0_S0_E"} +// CHECK: ![[TYPE84]] = !{i64 0, !"_ZTSFvu3refIu3i32EE"} +// CHECK: ![[TYPE85]] = !{i64 0, !"_ZTSFvu3refIu3i32EU3mutS0_E"} +// CHECK: ![[TYPE86]] = !{i64 0, !"_ZTSFvu3refIu3i32EU3mutS0_S1_E"} +// CHECK: ![[TYPE87]] = !{i64 0, !"_ZTSFvPu3i32E"} +// CHECK: ![[TYPE88]] = !{i64 0, !"_ZTSFvPu3i32PKS_E"} +// CHECK: ![[TYPE89]] = !{i64 0, !"_ZTSFvPu3i32PKS_S2_E"} +// CHECK: ![[TYPE90]] = !{i64 0, !"_ZTSFvPKu3i32E"} +// CHECK: ![[TYPE91]] = !{i64 0, !"_ZTSFvPKu3i32PS_E"} +// CHECK: ![[TYPE92]] = !{i64 0, !"_ZTSFvPKu3i32PS_S2_E"} +// CHECK: ![[TYPE93]] = !{i64 0, !"_ZTSFvPFu3i32S_EE"} +// CHECK: ![[TYPE94]] = !{i64 0, !"_ZTSFvPFu3i32S_ES0_E"} +// CHECK: ![[TYPE95]] = !{i64 0, !"_ZTSFvPFu3i32S_ES0_S0_E"} +// CHECK: ![[TYPE96]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEEE"} +// CHECK: ![[TYPE97]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEES3_E"} +// CHECK: ![[TYPE98]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEES3_S3_E"} +// CHECK: ![[TYPE99]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEEE"} +// CHECK: ![[TYPE100]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEES3_E"} +// CHECK: ![[TYPE101]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEES3_S3_E"} +// CHECK: ![[TYPE102]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEEE"} +// CHECK: ![[TYPE103]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEES3_E"} +// CHECK: ![[TYPE104]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEES3_S3_E"} +// CHECK: ![[TYPE105]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEEE"} +// CHECK: ![[TYPE106]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_E"} +// CHECK: ![[TYPE107]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_S2_E"} +// CHECK: ![[TYPE108]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvEE"} +// CHECK: ![[TYPE109]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_E"} +// CHECK: ![[TYPE110]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_S1_E"} +// CHECK: ![[TYPE111]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}E"} +// CHECK: ![[TYPE112]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_E"} +// CHECK: ![[TYPE113]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_S_E"} +// CHECK: ![[TYPE114]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn110{{[{}][{}]}}extern{{[}][}]}}3fooE"} +// CHECK: ![[TYPE115]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_E"} +// CHECK: ![[TYPE116]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_S_E"} +// CHECK: ![[TYPE117]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooE"} +// CHECK: ![[TYPE118]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_E"} +// CHECK: ![[TYPE119]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_S_E"} +// CHECK: ![[TYPE120]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn112{{[{}][{}]}}constant{{[}][}]}}3FooE"} +// CHECK: ![[TYPE121]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_E"} +// CHECK: ![[TYPE122]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"} +// CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32EE"} +// CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_E"} +// CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_S0_E"} +// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait1Iu5paramEu6regionEu3i32EE"} +// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait1Iu5paramEu6regionEu3i32ES4_E"} +// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait1Iu5paramEu6regionEu3i32ES4_S4_E"} +// CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3i32S_EE"} +// CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3i32S_ES0_E"} +// CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3i32S_ES0_S0_E"} +// CHECK: ![[TYPE132]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32ES_EE"} +// CHECK: ![[TYPE133]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32ES_ES1_E"} +// CHECK: ![[TYPE134]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32ES_ES1_S1_E"} +// CHECK: ![[TYPE135]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13QuxIu3i32Lu5usize32EEE"} +// CHECK: ![[TYPE136]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13QuxIu3i32Lu5usize32EES2_E"} +// CHECK: ![[TYPE137]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13QuxIu3i32Lu5usize32EES2_S2_E"} +// CHECK: ![[TYPE138]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_EE"} +// CHECK: ![[TYPE139]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_E"} +// CHECK: ![[TYPE140]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_S0_E"} +// CHECK: ![[TYPE141]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3FooE"} +// CHECK: ![[TYPE142]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3FooS_E"} +// CHECK: ![[TYPE143]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3FooS_S_E"} +// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"} +// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"} +// CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"} +// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3BarE"} +// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3BarS_E"} +// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3BarS_S_E"} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs new file mode 100644 index 000000000..d200ed979 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs @@ -0,0 +1,31 @@ +// Verifies that generalized type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E.generalized") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.generalized") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.generalized") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PKvS_E.generalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PKvS_S_E.generalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PKvS_S_S_E.generalized"} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs new file mode 100644 index 000000000..cdefec17a --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs @@ -0,0 +1,31 @@ +// Verifies that normalized and generalized type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}![[TYPE1:[0-9]+]] + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized.generalized") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}![[TYPE2:[0-9]+]] + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized.generalized") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}![[TYPE3:[0-9]+]] + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized.generalized") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PKvS_E.normalized.generalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PKvS_S_E.normalized.generalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PKvS_S_S_E.normalized.generalized"} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs new file mode 100644 index 000000000..f360b33dd --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs @@ -0,0 +1,31 @@ +// Verifies that normalized type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PFS_S_ES_E.normalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_ES_S_E.normalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_S_ES_S_S_E.normalized"} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs new file mode 100644 index 000000000..3cb817b21 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs @@ -0,0 +1,31 @@ +// Verifies that type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PFS_S_ES_E"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_ES_S_E"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_S_ES_S_S_E"} diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-trait-objects.rs new file mode 100644 index 000000000..b69e57261 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-trait-objects.rs @@ -0,0 +1,149 @@ +// Verifies that type metadata identifiers for trait objects are emitted correctly. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] + +pub trait Trait1 { + fn foo(&self); +} + +#[derive(Clone, Copy)] +pub struct Type1; + +impl Trait1 for Type1 { + fn foo(&self) { + } +} + +pub trait Trait2 { + fn bar(&self); +} + +pub struct Type2; + +impl Trait2 for Type2 { + fn bar(&self) { + } +} + +pub trait Trait3 { + fn baz(&self, _: &T); +} + +pub struct Type3; + +impl Trait3 for T { + fn baz(&self, _: &U) { + } +} + +pub trait Trait4<'a, T> { + type Output: 'a; + fn qux(&self, _: &T) -> Self::Output; +} + +pub struct Type4; + +impl<'a, T, U> Trait4<'a, U> for T { + type Output = &'a i32; + fn qux(&self, _: &U) -> Self::Output { + &0 + } +} + +pub trait Trait5 { + fn quux(&self, _: &[T; N]); +} + +#[derive(Copy, Clone)] +pub struct Type5; + +impl Trait5 for T { + fn quux(&self, _: &[U; N]) { + } +} + +pub fn foo1(a: &dyn Trait1) { + a.foo(); + // CHECK-LABEL: define{{.*}}4foo1{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE1:[[:print:]]+]]") +} + +pub fn bar1() { + let a = Type1; + let b = &a as &dyn Trait1; + b.foo(); + // CHECK-LABEL: define{{.*}}4bar1{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") +} + +pub fn foo2(a: &dyn Trait2) { + a.bar(); + // CHECK-LABEL: define{{.*}}4foo2{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") +} + +pub fn bar2() { + let a = Type2; + foo2(&a); + let b = &a as &dyn Trait2; + b.bar(); + // CHECK-LABEL: define{{.*}}4bar2{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") +} + +pub fn foo3(a: &dyn Trait3) { + let b = Type3; + a.baz(&b); + // CHECK-LABEL: define{{.*}}4foo3{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") +} + +pub fn bar3() { + let a = Type3; + foo3(&a); + let b = &a as &dyn Trait3; + b.baz(&a); + // CHECK-LABEL: define{{.*}}4bar3{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") +} + +pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { + let b = Type4; + a.qux(&b); + // CHECK-LABEL: define{{.*}}4foo4{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") +} + +pub fn bar4<'a>() { + let a = Type4; + foo4(&a); + let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; + b.qux(&a); + // CHECK-LABEL: define{{.*}}4bar4{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") +} + +pub fn foo5(a: &dyn Trait5) { + let b = &[Type5; 32]; + a.quux(&b); + // CHECK-LABEL: define{{.*}}4foo5{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE5:[[:print:]]+]]") +} + +pub fn bar5() { + let a = &[Type5; 32]; + foo5(&a); + let b = &a as &dyn Trait5; + b.quux(&a); + // CHECK-LABEL: define{{.*}}4bar5{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE5:[[:print:]]+]]") +} + +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE1]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE2]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE3]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE4]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE5]]"} diff --git a/tests/codegen/sanitizer/cfi-generalize-pointers.rs b/tests/codegen/sanitizer/cfi-generalize-pointers.rs new file mode 100644 index 000000000..677ebdb27 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-generalize-pointers.rs @@ -0,0 +1,46 @@ +// Verifies that pointer types are generalized. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] + +extern crate core; + +pub fn foo0(_: &mut i32) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo1(_: &mut i32, _: &mut i32) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo2(_: &mut i32, _: &mut i32, _: &mut i32) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo3(_: &i32) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo4(_: &i32, _: &i32) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo5(_: &i32, _: &i32, _: &i32) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo6(_: *mut i32) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo7(_: *mut i32, _: *mut i32) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo8(_: *mut i32, _: *mut i32, _: *mut i32) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo9(_: *const i32) { } +// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo10(_: *const i32, _: *const i32) { } +// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo11(_: *const i32, _: *const i32, _: *const i32) { } +// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvU3mutu3refIvEE.generalized"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_E.generalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_S0_E.generalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvu3refIvEE.generalized"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu3refIvES_E.generalized"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu3refIvES_S_E.generalized"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPvE.generalized"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvPvS_E.generalized"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvPvS_S_E.generalized"} +// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvPKvE.generalized"} +// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvPKvS0_E.generalized"} +// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvPKvS0_S0_E.generalized"} diff --git a/tests/codegen/sanitizer/cfi-normalize-integers.rs b/tests/codegen/sanitizer/cfi-normalize-integers.rs new file mode 100644 index 000000000..aa3913cb8 --- /dev/null +++ b/tests/codegen/sanitizer/cfi-normalize-integers.rs @@ -0,0 +1,83 @@ +// Verifies that integer types are normalized. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers + +#![crate_type="lib"] + +extern crate core; +use core::ffi::*; + +pub fn foo0(_: bool) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} +pub fn foo1(_: bool, _: c_uchar) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} +pub fn foo2(_: bool, _: c_uchar, _: c_uchar) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} +pub fn foo3(_: isize) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} +pub fn foo4(_: isize, _: c_long) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} +pub fn foo5(_: isize, _: c_long, _: c_longlong) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} +pub fn foo6(_: usize) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} +pub fn foo7(_: usize, _: c_ulong) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} +pub fn foo8(_: usize, _: c_ulong, _: c_ulonglong) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} +pub fn foo9(_: c_schar) { } +// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} +pub fn foo10(_: c_char, _: c_schar) { } +// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} +pub fn foo11(_: c_char, _: c_schar, _: c_schar) { } +// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} +pub fn foo12(_: c_int) { } +// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} +pub fn foo13(_: c_int, _: c_int) { } +// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} +pub fn foo14(_: c_int, _: c_int, _: c_int) { } +// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} +pub fn foo15(_: c_short) { } +// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} +pub fn foo16(_: c_short, _: c_short) { } +// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} +pub fn foo17(_: c_short, _: c_short, _: c_short) { } +// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} +pub fn foo18(_: c_uint) { } +// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} +pub fn foo19(_: c_uint, _: c_uint) { } +// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} +pub fn foo20(_: c_uint, _: c_uint, _: c_uint) { } +// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} +pub fn foo21(_: c_ushort) { } +// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} +pub fn foo22(_: c_ushort, _: c_ushort) { } +// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} +pub fn foo23(_: c_ushort, _: c_ushort, _: c_ushort) { } +// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvu2u8E.normalized"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu2u8S_E.normalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu2u8S_S_E.normalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}{{u3i32|u3i64|S_}}E.normalized"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}{{u3i32|u3i64|S_}}{{u3i64|S_|S0_}}E.normalized"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}E.normalized"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}{{u3u32|u3u64|S_}}E.normalized"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}{{u3u32|u3u64|S_}}{{u3u64|S_|S0_}}E.normalized"} +// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu2i8E.normalized"} +// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFv{{u2i8S_|u2u8u2i8}}E.normalized"} +// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFv{{u2i8S_S_|u2u8u2i8S0_}}E.normalized"} +// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"} +// CHECK: ![[TYPE13]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_E.normalized"} +// CHECK: ![[TYPE14]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_S_E.normalized"} +// CHECK: ![[TYPE15]] = !{i64 0, !"_ZTSFvu3i16E.normalized"} +// CHECK: ![[TYPE16]] = !{i64 0, !"_ZTSFvu3i16S_E.normalized"} +// CHECK: ![[TYPE17]] = !{i64 0, !"_ZTSFvu3i16S_S_E.normalized"} +// CHECK: ![[TYPE18]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}E.normalized"} +// CHECK: ![[TYPE19]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}S_E.normalized"} +// CHECK: ![[TYPE20]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}S_S_E.normalized"} +// CHECK: ![[TYPE21]] = !{i64 0, !"_ZTSFvu3u16E.normalized"} +// CHECK: ![[TYPE22]] = !{i64 0, !"_ZTSFvu3u16S_E.normalized"} +// CHECK: ![[TYPE23]] = !{i64 0, !"_ZTSFvu3u16S_S_E.normalized"} diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs new file mode 100644 index 000000000..783bc47b9 --- /dev/null +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -0,0 +1,47 @@ +// Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. + +// compile-flags: -Zsanitizer=kernel-address +// revisions: aarch64 riscv64imac riscv64gc x86_64 +//[aarch64] compile-flags: --target aarch64-unknown-none +//[aarch64] needs-llvm-components: aarch64 +//[riscv64imac] compile-flags: --target riscv64imac-unknown-none-elf +//[riscv64imac] needs-llvm-components: riscv +//[riscv64imac] min-llvm-version: 16 +//[riscv64gc] compile-flags: --target riscv64gc-unknown-none-elf +//[riscv64gc] needs-llvm-components: riscv +//[riscv64gc] min-llvm-version: 16 +//[x86_64] compile-flags: --target x86_64-unknown-none +//[x86_64] needs-llvm-components: x86 + +#![crate_type = "rlib"] +#![feature(no_core, no_sanitize, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +impl Copy for u8 {} + +// CHECK-LABEL: ; kasan_emits_instrumentation::unsanitized +// CHECK-NEXT: ; Function Attrs: +// CHECK-NOT: sanitize_address +// CHECK: start: +// CHECK-NOT: call void @__asan_report_load +// CHECK: } +#[no_sanitize(address)] +pub fn unsanitized(b: &mut u8) -> u8 { + *b +} + +// CHECK-LABEL: ; kasan_emits_instrumentation::sanitized +// CHECK-NEXT: ; Function Attrs: +// CHECK: sanitize_address +// CHECK: start: +// CHECK: call void @__asan_report_load +// CHECK: } +pub fn sanitized(b: &mut u8) -> u8 { + *b +} diff --git a/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs b/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs new file mode 100644 index 000000000..c2eb852ae --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs @@ -0,0 +1,11 @@ +// Verifies that "kcfi" module flag is added. +// +// needs-sanitizer-kcfi +// compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi + +#![crate_type="lib"] + +pub fn foo() { +} + +// CHECK: !{{[0-9]+}} = !{i32 4, !"kcfi", i32 1} diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs new file mode 100644 index 000000000..001fc956a --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs @@ -0,0 +1,30 @@ +// Verifies that KCFI operand bundles are omitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_core, no_sanitize, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +#[no_sanitize(kcfi)] +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: kcfi_emit_kcfi_operand_bundle_attr_no_sanitize::foo + // CHECK: Function Attrs: {{.*}} + // CHECK-LABEL: define{{.*}}foo{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: start: + // CHECK-NOT: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 {{[-0-9]+}}) ] + // CHECK: ret i32 {{%.+}} + f(arg) +} diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs new file mode 100644 index 000000000..29e4df351 --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs @@ -0,0 +1,44 @@ +// Verifies that generalized KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 233085384) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 435418021) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 -1003721339) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 -1741689296} +// CHECK: ![[TYPE2]] = !{i32 489439372} +// CHECK: ![[TYPE3]] = !{i32 2026563871} diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs new file mode 100644 index 000000000..84d678a33 --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs @@ -0,0 +1,44 @@ +// Verifies that normalized and generalized KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -686570305) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 1281038450) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 -1751512973) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 975484707} +// CHECK: ![[TYPE2]] = !{i32 1658833102} +// CHECK: ![[TYPE3]] = !{i32 230429758} diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs new file mode 100644 index 000000000..761c37a9e --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs @@ -0,0 +1,44 @@ +// Verifies that normalized KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -841055669) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 1390819368) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 586925835) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 -458317079} +// CHECK: ![[TYPE2]] = !{i32 1737138182} +// CHECK: ![[TYPE3]] = !{i32 197182412} diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs new file mode 100644 index 000000000..83cda0ef1 --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -0,0 +1,44 @@ +// Verifies that KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -1666898348) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 -1789026986) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 1248878270) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 653723426} +// CHECK: ![[TYPE2]] = !{i32 412174924} +// CHECK: ![[TYPE3]] = !{i32 -636668840} diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle.rs new file mode 100644 index 000000000..e1d617b5e --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle.rs @@ -0,0 +1,27 @@ +// Verifies that KCFI operand bundles are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: start: + // CHECK-NEXT: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 {{[-0-9]+}}) ] + // CHECK-NEXT: ret i32 {{%.+}} + f(arg) +} diff --git a/tests/codegen/sanitizer/kcfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi-emit-type-metadata-trait-objects.rs new file mode 100644 index 000000000..7aed137f2 --- /dev/null +++ b/tests/codegen/sanitizer/kcfi-emit-type-metadata-trait-objects.rs @@ -0,0 +1,174 @@ +// Verifies that type metadata identifiers for trait objects are emitted correctly. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(arbitrary_self_types, no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } +#[lang="receiver"] +trait Receiver { } +#[lang="dispatch_from_dyn"] +trait DispatchFromDyn { } +impl<'a, T: ?Sized + Unsize, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} +#[lang = "unsize"] +trait Unsize { } +#[lang = "coerce_unsized"] +pub trait CoerceUnsized { } +impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +#[lang="freeze"] +trait Freeze { } +#[lang="drop_in_place"] +fn drop_in_place_fn() { } + +pub trait Trait1 { + fn foo(&self); +} + +pub struct Type1; + +impl Trait1 for Type1 { + fn foo(&self) { + } +} + +pub trait Trait2 { + fn bar(&self); +} + +pub struct Type2; + +impl Trait2 for Type2 { + fn bar(&self) { + } +} + +pub trait Trait3 { + fn baz(&self, _: &T); +} + +pub struct Type3; + +impl Trait3 for T { + fn baz(&self, _: &U) { + } +} + +pub trait Trait4<'a, T> { + type Output: 'a; + fn qux(&self, _: &T) -> Self::Output; +} + +pub struct Type4; + +impl<'a, T, U> Trait4<'a, U> for T { + type Output = &'a i32; + fn qux(&self, _: &U) -> Self::Output { + &0 + } +} + +pub trait Trait5 { + fn quux(&self, _: &[T; N]); +} + +pub struct Type5; + +impl Copy for Type5 {} + +impl Trait5 for T { + fn quux(&self, _: &[U; N]) { + } +} + +pub fn foo1(a: &dyn Trait1) { + a.foo(); + // CHECK-LABEL: define{{.*}}4foo1{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] +} + +pub fn bar1() { + let a = Type1; + let b = &a as &dyn Trait1; + b.foo(); + // CHECK-LABEL: define{{.*}}4bar1{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] +} + +pub fn foo2(a: &dyn Trait2) { + a.bar(); + // CHECK-LABEL: define{{.*}}4foo2{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] +} + +pub fn bar2() { + let a = Type2; + foo2(&a); + let b = &a as &dyn Trait2; + b.bar(); + // CHECK-LABEL: define{{.*}}4bar2{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] +} + +pub fn foo3(a: &dyn Trait3) { + let b = Type3; + a.baz(&b); + // CHECK-LABEL: define{{.*}}4foo3{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] +} + +pub fn bar3() { + let a = Type3; + foo3(&a); + let b = &a as &dyn Trait3; + b.baz(&a); + // CHECK-LABEL: define{{.*}}4bar3{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] +} + +pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { + let b = Type4; + a.qux(&b); + // CHECK-LABEL: define{{.*}}4foo4{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call align 4 ptr %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] +} + +pub fn bar4<'a>() { + let a = Type4; + foo4(&a); + let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; + b.qux(&a); + // CHECK-LABEL: define{{.*}}4bar4{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call align 4 ptr %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] +} + +pub fn foo5(a: &dyn Trait5) { + let b = &[Type5; 32]; + a.quux(&b); + // CHECK-LABEL: define{{.*}}4foo5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] +} + +pub fn bar5() { + let a = &[Type5; 32]; + foo5(&a); + let b = &a as &dyn Trait5; + b.quux(&a); + // CHECK-LABEL: define{{.*}}4bar5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] +} + +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE2]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE3]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE4]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE5]]} diff --git a/tests/codegen/sanitizer/memory-track-origins.rs b/tests/codegen/sanitizer/memory-track-origins.rs new file mode 100644 index 000000000..4bd50508d --- /dev/null +++ b/tests/codegen/sanitizer/memory-track-origins.rs @@ -0,0 +1,30 @@ +// Verifies that MemorySanitizer track-origins level can be controlled +// with -Zsanitizer-memory-track-origins option. +// +// needs-sanitizer-memory +// revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO +// +//[MSAN-0] compile-flags: -Zsanitizer=memory +//[MSAN-1] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 +//[MSAN-2] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins +//[MSAN-1-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 -C lto=fat +//[MSAN-2-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins -C lto=fat + +#![crate_type="lib"] + +// MSAN-0-NOT: @__msan_track_origins +// MSAN-1: @__msan_track_origins = weak_odr {{.*}}constant i32 1 +// MSAN-2: @__msan_track_origins = weak_odr {{.*}}constant i32 2 +// MSAN-1-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 1 +// MSAN-2-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 2 +// +// MSAN-0-LABEL: define void @copy( +// MSAN-1-LABEL: define void @copy( +// MSAN-2-LABEL: define void @copy( +#[no_mangle] +pub fn copy(dst: &mut i32, src: &i32) { + // MSAN-0-NOT: call i32 @__msan_chain_origin( + // MSAN-1-NOT: call i32 @__msan_chain_origin( + // MSAN-2: call i32 @__msan_chain_origin( + *dst = *src; +} diff --git a/tests/codegen/sanitizer/memtag-attr-check.rs b/tests/codegen/sanitizer/memtag-attr-check.rs new file mode 100644 index 000000000..2fd362656 --- /dev/null +++ b/tests/codegen/sanitizer/memtag-attr-check.rs @@ -0,0 +1,12 @@ +// This tests that the sanitize_memtag attribute is +// applied when enabling the memtag sanitizer. +// +// needs-sanitizer-memtag +// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte + +#![crate_type = "lib"] + +// CHECK: ; Function Attrs:{{.*}}sanitize_memtag +pub fn tagged() {} + +// CHECK: attributes #0 = {{.*}}sanitize_memtag diff --git a/tests/codegen/sanitizer/no-sanitize-inlining.rs b/tests/codegen/sanitizer/no-sanitize-inlining.rs new file mode 100644 index 000000000..f4af60bae --- /dev/null +++ b/tests/codegen/sanitizer/no-sanitize-inlining.rs @@ -0,0 +1,30 @@ +// Verifies that no_sanitize attribute prevents inlining when +// given sanitizer is enabled, but has no effect on inlining otherwise. +// +// needs-sanitizer-address +// needs-sanitizer-leak +// revisions: ASAN LSAN +//[ASAN] compile-flags: -Zsanitizer=address -C opt-level=3 -Z mir-opt-level=4 +//[LSAN] compile-flags: -Zsanitizer=leak -C opt-level=3 -Z mir-opt-level=4 + +#![crate_type="lib"] +#![feature(no_sanitize)] + +// ASAN-LABEL: define void @test +// ASAN: call {{.*}} @random_inline +// ASAN: } +// +// LSAN-LABEL: define void @test +// LSAN-NO: call +// LSAN: } +#[no_mangle] +pub fn test(n: &mut u32) { + random_inline(n); +} + +#[no_sanitize(address)] +#[inline] +#[no_mangle] +pub fn random_inline(n: &mut u32) { + *n = 42; +} diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs new file mode 100644 index 000000000..783b568e2 --- /dev/null +++ b/tests/codegen/sanitizer/no-sanitize.rs @@ -0,0 +1,29 @@ +// Verifies that no_sanitize attribute can be used to +// selectively disable sanitizer instrumentation. +// +// needs-sanitizer-address +// compile-flags: -Zsanitizer=address + +#![crate_type="lib"] +#![feature(no_sanitize)] + +// CHECK-LABEL: ; no_sanitize::unsanitized +// CHECK-NEXT: ; Function Attrs: +// CHECK-NOT: sanitize_address +// CHECK: start: +// CHECK-NOT: call void @__asan_report_load +// CHECK: } +#[no_sanitize(address)] +pub fn unsanitized(b: &mut u8) -> u8 { + *b +} + +// CHECK-LABEL: ; no_sanitize::sanitized +// CHECK-NEXT: ; Function Attrs: +// CHECK: sanitize_address +// CHECK: start: +// CHECK: call void @__asan_report_load +// CHECK: } +pub fn sanitized(b: &mut u8) -> u8 { + *b +} diff --git a/tests/codegen/sanitizer/safestack-attr-check.rs b/tests/codegen/sanitizer/safestack-attr-check.rs new file mode 100644 index 000000000..b73ed00e7 --- /dev/null +++ b/tests/codegen/sanitizer/safestack-attr-check.rs @@ -0,0 +1,11 @@ +// This tests that the safestack attribute is applied when enabling the safe-stack sanitizer. +// +// needs-sanitizer-safestack +// compile-flags: -Zsanitizer=safestack + +#![crate_type = "lib"] + +// CHECK: ; Function Attrs:{{.*}}safestack +pub fn tagged() {} + +// CHECK: attributes #0 = {{.*}}safestack diff --git a/tests/codegen/sanitizer/sanitizer-recover.rs b/tests/codegen/sanitizer/sanitizer-recover.rs new file mode 100644 index 000000000..7b00fcf8e --- /dev/null +++ b/tests/codegen/sanitizer/sanitizer-recover.rs @@ -0,0 +1,49 @@ +// Verifies that AddressSanitizer and MemorySanitizer +// recovery mode can be enabled with -Zsanitizer-recover. +// +// needs-sanitizer-address +// needs-sanitizer-memory +// revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO +// no-prefer-dynamic +// +//[ASAN] compile-flags: -Zsanitizer=address -Copt-level=0 +//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0 +//[MSAN] compile-flags: -Zsanitizer=memory +//[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory +//[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -C lto=fat +// +// MSAN-NOT: @__msan_keep_going +// MSAN-RECOVER: @__msan_keep_going = weak_odr {{.*}}constant i32 1 +// MSAN-RECOVER-LTO: @__msan_keep_going = weak_odr {{.*}}constant i32 1 + +// ASAN-LABEL: define dso_local i32 @penguin( +// ASAN: call void @__asan_report_load4(i64 %0) +// ASAN: unreachable +// ASAN: } +// +// ASAN-RECOVER-LABEL: define dso_local i32 @penguin( +// ASAN-RECOVER: call void @__asan_report_load4_noabort( +// ASAN-RECOVER-NOT: unreachable +// ASAN: } +// +// MSAN-LABEL: define dso_local noundef i32 @penguin( +// MSAN: call void @__msan_warning{{(_with_origin_noreturn\(i32 0\)|_noreturn\(\))}} +// MSAN: unreachable +// MSAN: } +// +// MSAN-RECOVER-LABEL: define dso_local noundef i32 @penguin( +// MSAN-RECOVER: call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}} +// MSAN-RECOVER-NOT: unreachable +// MSAN-RECOVER: } +// +// MSAN-RECOVER-LTO-LABEL: define dso_local noundef i32 @penguin( +// MSAN-RECOVER-LTO: call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}} +// MSAN-RECOVER-LTO-NOT: unreachable +// MSAN-RECOVER-LTO: } +// +#[no_mangle] +pub fn penguin(p: &mut i32) -> i32 { + *p +} + +fn main() {} diff --git a/tests/codegen/sanitizer/scs-attr-check.rs b/tests/codegen/sanitizer/scs-attr-check.rs new file mode 100644 index 000000000..a885d9117 --- /dev/null +++ b/tests/codegen/sanitizer/scs-attr-check.rs @@ -0,0 +1,17 @@ +// This tests that the shadowcallstack attribute is +// applied when enabling the shadow-call-stack sanitizer. +// +// needs-sanitizer-shadow-call-stack +// compile-flags: -Zsanitizer=shadow-call-stack + +#![crate_type = "lib"] +#![feature(no_sanitize)] + +// CHECK: ; sanitizer_scs_attr_check::scs +// CHECK-NEXT: ; Function Attrs:{{.*}}shadowcallstack +pub fn scs() {} + +// CHECK: ; sanitizer_scs_attr_check::no_scs +// CHECK-NOT: ; Function Attrs:{{.*}}shadowcallstack +#[no_sanitize(shadow_call_stack)] +pub fn no_scs() {} diff --git a/tests/codegen/sanitizer_memtag_attr_check.rs b/tests/codegen/sanitizer_memtag_attr_check.rs deleted file mode 100644 index 2fd362656..000000000 --- a/tests/codegen/sanitizer_memtag_attr_check.rs +++ /dev/null @@ -1,12 +0,0 @@ -// This tests that the sanitize_memtag attribute is -// applied when enabling the memtag sanitizer. -// -// needs-sanitizer-memtag -// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte - -#![crate_type = "lib"] - -// CHECK: ; Function Attrs:{{.*}}sanitize_memtag -pub fn tagged() {} - -// CHECK: attributes #0 = {{.*}}sanitize_memtag diff --git a/tests/codegen/sanitizer_scs_attr_check.rs b/tests/codegen/sanitizer_scs_attr_check.rs deleted file mode 100644 index a885d9117..000000000 --- a/tests/codegen/sanitizer_scs_attr_check.rs +++ /dev/null @@ -1,17 +0,0 @@ -// This tests that the shadowcallstack attribute is -// applied when enabling the shadow-call-stack sanitizer. -// -// needs-sanitizer-shadow-call-stack -// compile-flags: -Zsanitizer=shadow-call-stack - -#![crate_type = "lib"] -#![feature(no_sanitize)] - -// CHECK: ; sanitizer_scs_attr_check::scs -// CHECK-NEXT: ; Function Attrs:{{.*}}shadowcallstack -pub fn scs() {} - -// CHECK: ; sanitizer_scs_attr_check::no_scs -// CHECK-NOT: ; Function Attrs:{{.*}}shadowcallstack -#[no_sanitize(shadow_call_stack)] -pub fn no_scs() {} diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs index faac7566a..0bcfacec6 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs @@ -116,150 +116,150 @@ extern "platform-intrinsic" { fn simd_saturating_sub(x: T, y: T) -> T; } -// NOTE(eddyb) `%{{x|1}}` is used because on some targets (e.g. WASM) +// NOTE(eddyb) `%{{x|0}}` is used because on some targets (e.g. WASM) // SIMD vectors are passed directly, resulting in `%x` being a vector, // while on others they're passed indirectly, resulting in `%x` being -// a pointer to a vector, and `%1` a vector loaded from that pointer. +// a pointer to a vector, and `%0` a vector loaded from that pointer. // This is controlled by the target spec option `simd_types_indirect`. -// The same applies to `%{{y|2}}` as well. +// The same applies to `%{{y|1}}` as well. // CHECK-LABEL: @sadd_i8x2 #[no_mangle] pub unsafe fn sadd_i8x2(x: i8x2, y: i8x2) -> i8x2 { - // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %{{x|1}}, <2 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %{{x|0}}, <2 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i8x4 #[no_mangle] pub unsafe fn sadd_i8x4(x: i8x4, y: i8x4) -> i8x4 { - // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %{{x|1}}, <4 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %{{x|0}}, <4 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i8x8 #[no_mangle] pub unsafe fn sadd_i8x8(x: i8x8, y: i8x8) -> i8x8 { - // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.sadd.sat.v8i8(<8 x i8> %{{x|1}}, <8 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.sadd.sat.v8i8(<8 x i8> %{{x|0}}, <8 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i8x16 #[no_mangle] pub unsafe fn sadd_i8x16(x: i8x16, y: i8x16) -> i8x16 { - // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.sadd.sat.v16i8(<16 x i8> %{{x|1}}, <16 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.sadd.sat.v16i8(<16 x i8> %{{x|0}}, <16 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i8x32 #[no_mangle] pub unsafe fn sadd_i8x32(x: i8x32, y: i8x32) -> i8x32 { - // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{x|1}}, <32 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{x|0}}, <32 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i8x64 #[no_mangle] pub unsafe fn sadd_i8x64(x: i8x64, y: i8x64) -> i8x64 { - // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.sadd.sat.v64i8(<64 x i8> %{{x|1}}, <64 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.sadd.sat.v64i8(<64 x i8> %{{x|0}}, <64 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i16x2 #[no_mangle] pub unsafe fn sadd_i16x2(x: i16x2, y: i16x2) -> i16x2 { - // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %{{x|1}}, <2 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %{{x|0}}, <2 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i16x4 #[no_mangle] pub unsafe fn sadd_i16x4(x: i16x4, y: i16x4) -> i16x4 { - // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %{{x|1}}, <4 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %{{x|0}}, <4 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i16x8 #[no_mangle] pub unsafe fn sadd_i16x8(x: i16x8, y: i16x8) -> i16x8 { - // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %{{x|1}}, <8 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %{{x|0}}, <8 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i16x16 #[no_mangle] pub unsafe fn sadd_i16x16(x: i16x16, y: i16x16) -> i16x16 { - // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16> %{{x|1}}, <16 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16> %{{x|0}}, <16 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i16x32 #[no_mangle] pub unsafe fn sadd_i16x32(x: i16x32, y: i16x32) -> i16x32 { - // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.sadd.sat.v32i16(<32 x i16> %{{x|1}}, <32 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.sadd.sat.v32i16(<32 x i16> %{{x|0}}, <32 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i32x2 #[no_mangle] pub unsafe fn sadd_i32x2(x: i32x2, y: i32x2) -> i32x2 { - // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %{{x|1}}, <2 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %{{x|0}}, <2 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i32x4 #[no_mangle] pub unsafe fn sadd_i32x4(x: i32x4, y: i32x4) -> i32x4 { - // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %{{x|1}}, <4 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %{{x|0}}, <4 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i32x8 #[no_mangle] pub unsafe fn sadd_i32x8(x: i32x8, y: i32x8) -> i32x8 { - // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.sadd.sat.v8i32(<8 x i32> %{{x|1}}, <8 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.sadd.sat.v8i32(<8 x i32> %{{x|0}}, <8 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i32x16 #[no_mangle] pub unsafe fn sadd_i32x16(x: i32x16, y: i32x16) -> i32x16 { - // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %{{x|1}}, <16 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %{{x|0}}, <16 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i64x2 #[no_mangle] pub unsafe fn sadd_i64x2(x: i64x2, y: i64x2) -> i64x2 { - // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %{{x|1}}, <2 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %{{x|0}}, <2 x i64> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i64x4 #[no_mangle] pub unsafe fn sadd_i64x4(x: i64x4, y: i64x4) -> i64x4 { - // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.sadd.sat.v4i64(<4 x i64> %{{x|1}}, <4 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.sadd.sat.v4i64(<4 x i64> %{{x|0}}, <4 x i64> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i64x8 #[no_mangle] pub unsafe fn sadd_i64x8(x: i64x8, y: i64x8) -> i64x8 { - // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.sadd.sat.v8i64(<8 x i64> %{{x|1}}, <8 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.sadd.sat.v8i64(<8 x i64> %{{x|0}}, <8 x i64> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i128x2 #[no_mangle] pub unsafe fn sadd_i128x2(x: i128x2, y: i128x2) -> i128x2 { - // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %{{x|1}}, <2 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %{{x|0}}, <2 x i128> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @sadd_i128x4 #[no_mangle] pub unsafe fn sadd_i128x4(x: i128x4, y: i128x4) -> i128x4 { - // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.sadd.sat.v4i128(<4 x i128> %{{x|1}}, <4 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.sadd.sat.v4i128(<4 x i128> %{{x|0}}, <4 x i128> %{{y|1}}) simd_saturating_add(x, y) } @@ -268,140 +268,140 @@ pub unsafe fn sadd_i128x4(x: i128x4, y: i128x4) -> i128x4 { // CHECK-LABEL: @uadd_u8x2 #[no_mangle] pub unsafe fn uadd_u8x2(x: u8x2, y: u8x2) -> u8x2 { - // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %{{x|1}}, <2 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %{{x|0}}, <2 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u8x4 #[no_mangle] pub unsafe fn uadd_u8x4(x: u8x4, y: u8x4) -> u8x4 { - // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %{{x|1}}, <4 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %{{x|0}}, <4 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u8x8 #[no_mangle] pub unsafe fn uadd_u8x8(x: u8x8, y: u8x8) -> u8x8 { - // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.uadd.sat.v8i8(<8 x i8> %{{x|1}}, <8 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.uadd.sat.v8i8(<8 x i8> %{{x|0}}, <8 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u8x16 #[no_mangle] pub unsafe fn uadd_u8x16(x: u8x16, y: u8x16) -> u8x16 { - // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.uadd.sat.v16i8(<16 x i8> %{{x|1}}, <16 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.uadd.sat.v16i8(<16 x i8> %{{x|0}}, <16 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u8x32 #[no_mangle] pub unsafe fn uadd_u8x32(x: u8x32, y: u8x32) -> u8x32 { - // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.uadd.sat.v32i8(<32 x i8> %{{x|1}}, <32 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.uadd.sat.v32i8(<32 x i8> %{{x|0}}, <32 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u8x64 #[no_mangle] pub unsafe fn uadd_u8x64(x: u8x64, y: u8x64) -> u8x64 { - // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.uadd.sat.v64i8(<64 x i8> %{{x|1}}, <64 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.uadd.sat.v64i8(<64 x i8> %{{x|0}}, <64 x i8> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u16x2 #[no_mangle] pub unsafe fn uadd_u16x2(x: u16x2, y: u16x2) -> u16x2 { - // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.uadd.sat.v2i16(<2 x i16> %{{x|1}}, <2 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.uadd.sat.v2i16(<2 x i16> %{{x|0}}, <2 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u16x4 #[no_mangle] pub unsafe fn uadd_u16x4(x: u16x4, y: u16x4) -> u16x4 { - // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.uadd.sat.v4i16(<4 x i16> %{{x|1}}, <4 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.uadd.sat.v4i16(<4 x i16> %{{x|0}}, <4 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u16x8 #[no_mangle] pub unsafe fn uadd_u16x8(x: u16x8, y: u16x8) -> u16x8 { - // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> %{{x|1}}, <8 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> %{{x|0}}, <8 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u16x16 #[no_mangle] pub unsafe fn uadd_u16x16(x: u16x16, y: u16x16) -> u16x16 { - // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.uadd.sat.v16i16(<16 x i16> %{{x|1}}, <16 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.uadd.sat.v16i16(<16 x i16> %{{x|0}}, <16 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u16x32 #[no_mangle] pub unsafe fn uadd_u16x32(x: u16x32, y: u16x32) -> u16x32 { - // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.uadd.sat.v32i16(<32 x i16> %{{x|1}}, <32 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.uadd.sat.v32i16(<32 x i16> %{{x|0}}, <32 x i16> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u32x2 #[no_mangle] pub unsafe fn uadd_u32x2(x: u32x2, y: u32x2) -> u32x2 { - // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.uadd.sat.v2i32(<2 x i32> %{{x|1}}, <2 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.uadd.sat.v2i32(<2 x i32> %{{x|0}}, <2 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u32x4 #[no_mangle] pub unsafe fn uadd_u32x4(x: u32x4, y: u32x4) -> u32x4 { - // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %{{x|1}}, <4 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %{{x|0}}, <4 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u32x8 #[no_mangle] pub unsafe fn uadd_u32x8(x: u32x8, y: u32x8) -> u32x8 { - // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.uadd.sat.v8i32(<8 x i32> %{{x|1}}, <8 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.uadd.sat.v8i32(<8 x i32> %{{x|0}}, <8 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u32x16 #[no_mangle] pub unsafe fn uadd_u32x16(x: u32x16, y: u32x16) -> u32x16 { - // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.uadd.sat.v16i32(<16 x i32> %{{x|1}}, <16 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.uadd.sat.v16i32(<16 x i32> %{{x|0}}, <16 x i32> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u64x2 #[no_mangle] pub unsafe fn uadd_u64x2(x: u64x2, y: u64x2) -> u64x2 { - // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.uadd.sat.v2i64(<2 x i64> %{{x|1}}, <2 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.uadd.sat.v2i64(<2 x i64> %{{x|0}}, <2 x i64> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u64x4 #[no_mangle] pub unsafe fn uadd_u64x4(x: u64x4, y: u64x4) -> u64x4 { - // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.uadd.sat.v4i64(<4 x i64> %{{x|1}}, <4 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.uadd.sat.v4i64(<4 x i64> %{{x|0}}, <4 x i64> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u64x8 #[no_mangle] pub unsafe fn uadd_u64x8(x: u64x8, y: u64x8) -> u64x8 { - // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.uadd.sat.v8i64(<8 x i64> %{{x|1}}, <8 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.uadd.sat.v8i64(<8 x i64> %{{x|0}}, <8 x i64> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u128x2 #[no_mangle] pub unsafe fn uadd_u128x2(x: u128x2, y: u128x2) -> u128x2 { - // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.uadd.sat.v2i128(<2 x i128> %{{x|1}}, <2 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.uadd.sat.v2i128(<2 x i128> %{{x|0}}, <2 x i128> %{{y|1}}) simd_saturating_add(x, y) } // CHECK-LABEL: @uadd_u128x4 #[no_mangle] pub unsafe fn uadd_u128x4(x: u128x4, y: u128x4) -> u128x4 { - // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.uadd.sat.v4i128(<4 x i128> %{{x|1}}, <4 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.uadd.sat.v4i128(<4 x i128> %{{x|0}}, <4 x i128> %{{y|1}}) simd_saturating_add(x, y) } @@ -412,140 +412,140 @@ pub unsafe fn uadd_u128x4(x: u128x4, y: u128x4) -> u128x4 { // CHECK-LABEL: @ssub_i8x2 #[no_mangle] pub unsafe fn ssub_i8x2(x: i8x2, y: i8x2) -> i8x2 { - // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %{{x|1}}, <2 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %{{x|0}}, <2 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i8x4 #[no_mangle] pub unsafe fn ssub_i8x4(x: i8x4, y: i8x4) -> i8x4 { - // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8> %{{x|1}}, <4 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8> %{{x|0}}, <4 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i8x8 #[no_mangle] pub unsafe fn ssub_i8x8(x: i8x8, y: i8x8) -> i8x8 { - // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.ssub.sat.v8i8(<8 x i8> %{{x|1}}, <8 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.ssub.sat.v8i8(<8 x i8> %{{x|0}}, <8 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i8x16 #[no_mangle] pub unsafe fn ssub_i8x16(x: i8x16, y: i8x16) -> i8x16 { - // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.ssub.sat.v16i8(<16 x i8> %{{x|1}}, <16 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.ssub.sat.v16i8(<16 x i8> %{{x|0}}, <16 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i8x32 #[no_mangle] pub unsafe fn ssub_i8x32(x: i8x32, y: i8x32) -> i8x32 { - // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.ssub.sat.v32i8(<32 x i8> %{{x|1}}, <32 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.ssub.sat.v32i8(<32 x i8> %{{x|0}}, <32 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i8x64 #[no_mangle] pub unsafe fn ssub_i8x64(x: i8x64, y: i8x64) -> i8x64 { - // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.ssub.sat.v64i8(<64 x i8> %{{x|1}}, <64 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.ssub.sat.v64i8(<64 x i8> %{{x|0}}, <64 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i16x2 #[no_mangle] pub unsafe fn ssub_i16x2(x: i16x2, y: i16x2) -> i16x2 { - // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.ssub.sat.v2i16(<2 x i16> %{{x|1}}, <2 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.ssub.sat.v2i16(<2 x i16> %{{x|0}}, <2 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i16x4 #[no_mangle] pub unsafe fn ssub_i16x4(x: i16x4, y: i16x4) -> i16x4 { - // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.ssub.sat.v4i16(<4 x i16> %{{x|1}}, <4 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.ssub.sat.v4i16(<4 x i16> %{{x|0}}, <4 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i16x8 #[no_mangle] pub unsafe fn ssub_i16x8(x: i16x8, y: i16x8) -> i16x8 { - // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.ssub.sat.v8i16(<8 x i16> %{{x|1}}, <8 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.ssub.sat.v8i16(<8 x i16> %{{x|0}}, <8 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i16x16 #[no_mangle] pub unsafe fn ssub_i16x16(x: i16x16, y: i16x16) -> i16x16 { - // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.ssub.sat.v16i16(<16 x i16> %{{x|1}}, <16 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.ssub.sat.v16i16(<16 x i16> %{{x|0}}, <16 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i16x32 #[no_mangle] pub unsafe fn ssub_i16x32(x: i16x32, y: i16x32) -> i16x32 { - // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.ssub.sat.v32i16(<32 x i16> %{{x|1}}, <32 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.ssub.sat.v32i16(<32 x i16> %{{x|0}}, <32 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i32x2 #[no_mangle] pub unsafe fn ssub_i32x2(x: i32x2, y: i32x2) -> i32x2 { - // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.ssub.sat.v2i32(<2 x i32> %{{x|1}}, <2 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.ssub.sat.v2i32(<2 x i32> %{{x|0}}, <2 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i32x4 #[no_mangle] pub unsafe fn ssub_i32x4(x: i32x4, y: i32x4) -> i32x4 { - // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %{{x|1}}, <4 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %{{x|0}}, <4 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i32x8 #[no_mangle] pub unsafe fn ssub_i32x8(x: i32x8, y: i32x8) -> i32x8 { - // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.ssub.sat.v8i32(<8 x i32> %{{x|1}}, <8 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.ssub.sat.v8i32(<8 x i32> %{{x|0}}, <8 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i32x16 #[no_mangle] pub unsafe fn ssub_i32x16(x: i32x16, y: i32x16) -> i32x16 { - // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.ssub.sat.v16i32(<16 x i32> %{{x|1}}, <16 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.ssub.sat.v16i32(<16 x i32> %{{x|0}}, <16 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i64x2 #[no_mangle] pub unsafe fn ssub_i64x2(x: i64x2, y: i64x2) -> i64x2 { - // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.ssub.sat.v2i64(<2 x i64> %{{x|1}}, <2 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.ssub.sat.v2i64(<2 x i64> %{{x|0}}, <2 x i64> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i64x4 #[no_mangle] pub unsafe fn ssub_i64x4(x: i64x4, y: i64x4) -> i64x4 { - // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.ssub.sat.v4i64(<4 x i64> %{{x|1}}, <4 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.ssub.sat.v4i64(<4 x i64> %{{x|0}}, <4 x i64> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i64x8 #[no_mangle] pub unsafe fn ssub_i64x8(x: i64x8, y: i64x8) -> i64x8 { - // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.ssub.sat.v8i64(<8 x i64> %{{x|1}}, <8 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.ssub.sat.v8i64(<8 x i64> %{{x|0}}, <8 x i64> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i128x2 #[no_mangle] pub unsafe fn ssub_i128x2(x: i128x2, y: i128x2) -> i128x2 { - // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.ssub.sat.v2i128(<2 x i128> %{{x|1}}, <2 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.ssub.sat.v2i128(<2 x i128> %{{x|0}}, <2 x i128> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @ssub_i128x4 #[no_mangle] pub unsafe fn ssub_i128x4(x: i128x4, y: i128x4) -> i128x4 { - // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.ssub.sat.v4i128(<4 x i128> %{{x|1}}, <4 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.ssub.sat.v4i128(<4 x i128> %{{x|0}}, <4 x i128> %{{y|1}}) simd_saturating_sub(x, y) } @@ -554,139 +554,139 @@ pub unsafe fn ssub_i128x4(x: i128x4, y: i128x4) -> i128x4 { // CHECK-LABEL: @usub_u8x2 #[no_mangle] pub unsafe fn usub_u8x2(x: u8x2, y: u8x2) -> u8x2 { - // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %{{x|1}}, <2 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %{{x|0}}, <2 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u8x4 #[no_mangle] pub unsafe fn usub_u8x4(x: u8x4, y: u8x4) -> u8x4 { - // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %{{x|1}}, <4 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %{{x|0}}, <4 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u8x8 #[no_mangle] pub unsafe fn usub_u8x8(x: u8x8, y: u8x8) -> u8x8 { - // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.usub.sat.v8i8(<8 x i8> %{{x|1}}, <8 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.usub.sat.v8i8(<8 x i8> %{{x|0}}, <8 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u8x16 #[no_mangle] pub unsafe fn usub_u8x16(x: u8x16, y: u8x16) -> u8x16 { - // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.usub.sat.v16i8(<16 x i8> %{{x|1}}, <16 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.usub.sat.v16i8(<16 x i8> %{{x|0}}, <16 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u8x32 #[no_mangle] pub unsafe fn usub_u8x32(x: u8x32, y: u8x32) -> u8x32 { - // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.usub.sat.v32i8(<32 x i8> %{{x|1}}, <32 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.usub.sat.v32i8(<32 x i8> %{{x|0}}, <32 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u8x64 #[no_mangle] pub unsafe fn usub_u8x64(x: u8x64, y: u8x64) -> u8x64 { - // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.usub.sat.v64i8(<64 x i8> %{{x|1}}, <64 x i8> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.usub.sat.v64i8(<64 x i8> %{{x|0}}, <64 x i8> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u16x2 #[no_mangle] pub unsafe fn usub_u16x2(x: u16x2, y: u16x2) -> u16x2 { - // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.usub.sat.v2i16(<2 x i16> %{{x|1}}, <2 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.usub.sat.v2i16(<2 x i16> %{{x|0}}, <2 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u16x4 #[no_mangle] pub unsafe fn usub_u16x4(x: u16x4, y: u16x4) -> u16x4 { - // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.usub.sat.v4i16(<4 x i16> %{{x|1}}, <4 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.usub.sat.v4i16(<4 x i16> %{{x|0}}, <4 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u16x8 #[no_mangle] pub unsafe fn usub_u16x8(x: u16x8, y: u16x8) -> u16x8 { - // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %{{x|1}}, <8 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %{{x|0}}, <8 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u16x16 #[no_mangle] pub unsafe fn usub_u16x16(x: u16x16, y: u16x16) -> u16x16 { - // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.usub.sat.v16i16(<16 x i16> %{{x|1}}, <16 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.usub.sat.v16i16(<16 x i16> %{{x|0}}, <16 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u16x32 #[no_mangle] pub unsafe fn usub_u16x32(x: u16x32, y: u16x32) -> u16x32 { - // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.usub.sat.v32i16(<32 x i16> %{{x|1}}, <32 x i16> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.usub.sat.v32i16(<32 x i16> %{{x|0}}, <32 x i16> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u32x2 #[no_mangle] pub unsafe fn usub_u32x2(x: u32x2, y: u32x2) -> u32x2 { - // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.usub.sat.v2i32(<2 x i32> %{{x|1}}, <2 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.usub.sat.v2i32(<2 x i32> %{{x|0}}, <2 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u32x4 #[no_mangle] pub unsafe fn usub_u32x4(x: u32x4, y: u32x4) -> u32x4 { - // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %{{x|1}}, <4 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %{{x|0}}, <4 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u32x8 #[no_mangle] pub unsafe fn usub_u32x8(x: u32x8, y: u32x8) -> u32x8 { - // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.usub.sat.v8i32(<8 x i32> %{{x|1}}, <8 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.usub.sat.v8i32(<8 x i32> %{{x|0}}, <8 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u32x16 #[no_mangle] pub unsafe fn usub_u32x16(x: u32x16, y: u32x16) -> u32x16 { - // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.usub.sat.v16i32(<16 x i32> %{{x|1}}, <16 x i32> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.usub.sat.v16i32(<16 x i32> %{{x|0}}, <16 x i32> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u64x2 #[no_mangle] pub unsafe fn usub_u64x2(x: u64x2, y: u64x2) -> u64x2 { - // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.usub.sat.v2i64(<2 x i64> %{{x|1}}, <2 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.usub.sat.v2i64(<2 x i64> %{{x|0}}, <2 x i64> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u64x4 #[no_mangle] pub unsafe fn usub_u64x4(x: u64x4, y: u64x4) -> u64x4 { - // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.usub.sat.v4i64(<4 x i64> %{{x|1}}, <4 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.usub.sat.v4i64(<4 x i64> %{{x|0}}, <4 x i64> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u64x8 #[no_mangle] pub unsafe fn usub_u64x8(x: u64x8, y: u64x8) -> u64x8 { - // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.usub.sat.v8i64(<8 x i64> %{{x|1}}, <8 x i64> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.usub.sat.v8i64(<8 x i64> %{{x|0}}, <8 x i64> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u128x2 #[no_mangle] pub unsafe fn usub_u128x2(x: u128x2, y: u128x2) -> u128x2 { - // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.usub.sat.v2i128(<2 x i128> %{{x|1}}, <2 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.usub.sat.v2i128(<2 x i128> %{{x|0}}, <2 x i128> %{{y|1}}) simd_saturating_sub(x, y) } // CHECK-LABEL: @usub_u128x4 #[no_mangle] pub unsafe fn usub_u128x4(x: u128x4, y: u128x4) -> u128x4 { - // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.usub.sat.v4i128(<4 x i128> %{{x|1}}, <4 x i128> %{{y|2}}) + // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.usub.sat.v4i128(<4 x i128> %{{x|0}}, <4 x i128> %{{y|1}}) simd_saturating_sub(x, y) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert.rs index 80583dec1..a5d2509d0 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert.rs @@ -35,13 +35,13 @@ pub unsafe fn extract_s(v: S<4>, i: u32) -> f32 { // CHECK-LABEL: @insert_m #[no_mangle] pub unsafe fn insert_m(v: M, i: u32, j: f32) -> M { - // CHECK: insertelement <4 x float> %{{v|1|2}}, float %j, i32 %i + // CHECK: insertelement <4 x float> %{{v|0|1}}, float %j, i32 %i simd_insert(v, i, j) } // CHECK-LABEL: @insert_s #[no_mangle] pub unsafe fn insert_s(v: S<4>, i: u32, j: f32) -> S<4> { - // CHECK: insertelement <4 x float> %{{v|1|2}}, float %j, i32 %i + // CHECK: insertelement <4 x float> %{{v|0|1}}, float %j, i32 %i simd_insert(v, i, j) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs index cacc32f2f..0bb210196 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs @@ -23,7 +23,7 @@ extern "platform-intrinsic" { #[no_mangle] pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2, values: Vec2) -> Vec2 { - // CHECK: call <2 x float> @llvm.masked.gather.v2f32.{{.+}}(<2 x {{float\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}}) + // CHECK: call <2 x float> @llvm.masked.gather.v2f32.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}}) simd_gather(values, pointers, mask) } @@ -31,6 +31,6 @@ pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2, #[no_mangle] pub unsafe fn gather_pf32x2(pointers: Vec2<*const *const f32>, mask: Vec2, values: Vec2<*const f32>) -> Vec2<*const f32> { - // CHECK: call <2 x {{float\*|ptr}}> @llvm.masked.gather.{{.+}}(<2 x {{float\*\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x {{float\*|ptr}}> {{.*}}) + // CHECK: call <2 x ptr> @llvm.masked.gather.v2p0.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x ptr> {{.*}}) simd_gather(values, pointers, mask) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs index 94ecaf609..51953560b 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs @@ -23,7 +23,7 @@ extern "platform-intrinsic" { #[no_mangle] pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2, values: Vec2) { - // CHECK: call void @llvm.masked.scatter.v2f32.v2p0{{.*}}(<2 x float> {{.*}}, <2 x {{float\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) + // CHECK: call void @llvm.masked.scatter.v2f32.v2p0(<2 x float> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) simd_scatter(values, pointers, mask) } @@ -32,6 +32,6 @@ pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2, #[no_mangle] pub unsafe fn scatter_pf32x2(pointers: Vec2<*mut *const f32>, mask: Vec2, values: Vec2<*const f32>) { - // CHECK: call void @llvm.masked.scatter.v2p0{{.*}}.v2p0{{.*}}(<2 x {{float\*|ptr}}> {{.*}}, <2 x {{float\*\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) + // CHECK: call void @llvm.masked.scatter.v2p0.v2p0(<2 x ptr> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) simd_scatter(values, pointers, mask) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index fd488a14b..eb4ce307e 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -2,7 +2,6 @@ // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - #![allow(non_camel_case_types)] #![feature(repr_simd, platform_intrinsics)] #![feature(inline_const)] @@ -43,8 +42,8 @@ pub fn build_array_s(x: [f32; 4]) -> S<4> { // CHECK-LABEL: @build_array_transmute_s #[no_mangle] pub fn build_array_transmute_s(x: [f32; 4]) -> S<4> { - // CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], {{ptr %0|.+>\* %.+}}, align [[VECTOR_ALIGN]] + // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } @@ -58,8 +57,8 @@ pub fn build_array_t(x: [f32; 4]) -> T { // CHECK-LABEL: @build_array_transmute_t #[no_mangle] pub fn build_array_transmute_t(x: [f32; 4]) -> T { - // CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], {{ptr %0|.+>\* %.+}}, align [[VECTOR_ALIGN]] + // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } @@ -77,7 +76,7 @@ pub fn build_array_u(x: [f32; 4]) -> U { // CHECK-LABEL: @build_array_transmute_u #[no_mangle] pub fn build_array_transmute_u(x: [f32; 4]) -> U { - // CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], {{ptr %0|.+>\* %.+}}, align [[VECTOR_ALIGN]] + // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } diff --git a/tests/codegen/simd-wide-sum.rs b/tests/codegen/simd-wide-sum.rs deleted file mode 100644 index db2aa20bd..000000000 --- a/tests/codegen/simd-wide-sum.rs +++ /dev/null @@ -1,55 +0,0 @@ -// compile-flags: -C opt-level=3 -Z merge-functions=disabled --edition=2021 -// only-x86_64 -// ignore-debug: the debug assertions get in the way - -#![crate_type = "lib"] -#![feature(portable_simd)] - -use std::simd::{Simd, SimdUint}; -const N: usize = 8; - -#[no_mangle] -// CHECK-LABEL: @wider_reduce_simd -pub fn wider_reduce_simd(x: Simd) -> u16 { - // CHECK: zext <8 x i8> - // CHECK-SAME: to <8 x i16> - // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> - let x: Simd = x.cast(); - x.reduce_sum() -} - -#[no_mangle] -// CHECK-LABEL: @wider_reduce_loop -pub fn wider_reduce_loop(x: Simd) -> u16 { - // CHECK: zext <8 x i8> - // CHECK-SAME: to <8 x i16> - // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> - let mut sum = 0_u16; - for i in 0..N { - sum += u16::from(x[i]); - } - sum -} - -#[no_mangle] -// CHECK-LABEL: @wider_reduce_iter -pub fn wider_reduce_iter(x: Simd) -> u16 { - // CHECK: zext <8 x i8> - // CHECK-SAME: to <8 x i16> - // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> - x.as_array().iter().copied().map(u16::from).sum() -} - -// This iterator one is the most interesting, as it's the one -// which used to not auto-vectorize due to a suboptimality in the -// `::fold` implementation. - -#[no_mangle] -// CHECK-LABEL: @wider_reduce_into_iter -pub fn wider_reduce_into_iter(x: Simd) -> u16 { - // FIXME MIR inlining messes up LLVM optimizations. - // WOULD-CHECK: zext <8 x i8> - // WOULD-CHECK-SAME: to <8 x i16> - // WOULD-CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> - x.to_array().into_iter().map(u16::from).sum() -} diff --git a/tests/codegen/simd/simd-wide-sum.rs b/tests/codegen/simd/simd-wide-sum.rs new file mode 100644 index 000000000..3116f9597 --- /dev/null +++ b/tests/codegen/simd/simd-wide-sum.rs @@ -0,0 +1,59 @@ +// revisions: llvm mir-opt3 +// compile-flags: -C opt-level=3 -Z merge-functions=disabled --edition=2021 +// only-x86_64 +// ignore-debug: the debug assertions get in the way +// [mir-opt3]compile-flags: -Zmir-opt-level=3 +// [mir-opt3]build-pass + +// mir-opt3 is a regression test for https://github.com/rust-lang/rust/issues/98016 + +#![crate_type = "lib"] +#![feature(portable_simd)] + +use std::simd::{Simd, SimdUint}; +const N: usize = 8; + +#[no_mangle] +// CHECK-LABEL: @wider_reduce_simd +pub fn wider_reduce_simd(x: Simd) -> u16 { + // CHECK: zext <8 x i8> + // CHECK-SAME: to <8 x i16> + // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> + let x: Simd = x.cast(); + x.reduce_sum() +} + +#[no_mangle] +// CHECK-LABEL: @wider_reduce_loop +pub fn wider_reduce_loop(x: Simd) -> u16 { + // CHECK: zext <8 x i8> + // CHECK-SAME: to <8 x i16> + // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> + let mut sum = 0_u16; + for i in 0..N { + sum += u16::from(x[i]); + } + sum +} + +#[no_mangle] +// CHECK-LABEL: @wider_reduce_iter +pub fn wider_reduce_iter(x: Simd) -> u16 { + // CHECK: zext <8 x i8> + // CHECK-SAME: to <8 x i16> + // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> + x.as_array().iter().copied().map(u16::from).sum() +} + +// This iterator one is the most interesting, as it's the one +// which used to not auto-vectorize due to a suboptimality in the +// `::fold` implementation. + +#[no_mangle] +// CHECK-LABEL: @wider_reduce_into_iter +pub fn wider_reduce_into_iter(x: Simd) -> u16 { + // CHECK: zext <8 x i8> + // CHECK-SAME: to <8 x i16> + // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> + x.to_array().into_iter().map(u16::from).sum() +} diff --git a/tests/codegen/simd/simd_arith_offset.rs b/tests/codegen/simd/simd_arith_offset.rs new file mode 100644 index 000000000..1ee73de11 --- /dev/null +++ b/tests/codegen/simd/simd_arith_offset.rs @@ -0,0 +1,26 @@ +// compile-flags: -C no-prepopulate-passes +// only-64bit (because the LLVM type of i64 for usize shows up) +// + +#![crate_type = "lib"] +#![feature(repr_simd, platform_intrinsics)] + +extern "platform-intrinsic" { + pub(crate) fn simd_arith_offset(ptrs: T, offsets: U) -> T; +} + +/// A vector of *const T. +#[derive(Debug, Copy, Clone)] +#[repr(simd)] +pub struct SimdConstPtr([*const T; LANES]); + +#[derive(Debug, Copy, Clone)] +#[repr(simd)] +pub struct Simd([T; LANES]); + +// CHECK-LABEL: smoke +#[no_mangle] +pub fn smoke(ptrs: SimdConstPtr, offsets: Simd) -> SimdConstPtr { + // CHECK: getelementptr i8, <8 x ptr> %0, <8 x i64> %1 + unsafe { simd_arith_offset(ptrs, offsets) } +} diff --git a/tests/codegen/simd/swap-simd-types.rs b/tests/codegen/simd/swap-simd-types.rs new file mode 100644 index 000000000..3472a42b0 --- /dev/null +++ b/tests/codegen/simd/swap-simd-types.rs @@ -0,0 +1,41 @@ +// compile-flags: -O -C target-feature=+avx +// only-x86_64 +// ignore-debug: the debug assertions get in the way + +#![crate_type = "lib"] + +use std::mem::swap; + +// SIMD types are highly-aligned already, so make sure the swap code leaves their +// types alone and doesn't pessimize them (such as by swapping them as `usize`s). +extern crate core; +use core::arch::x86_64::__m256; + +// CHECK-LABEL: @swap_single_m256 +#[no_mangle] +pub fn swap_single_m256(x: &mut __m256, y: &mut __m256) { +// CHECK-NOT: alloca +// CHECK: load <8 x float>{{.+}}align 32 +// CHECK: store <8 x float>{{.+}}align 32 + swap(x, y) +} + +// CHECK-LABEL: @swap_m256_slice +#[no_mangle] +pub fn swap_m256_slice(x: &mut [__m256], y: &mut [__m256]) { +// CHECK-NOT: alloca +// CHECK: load <8 x float>{{.+}}align 32 +// CHECK: store <8 x float>{{.+}}align 32 + if x.len() == y.len() { + x.swap_with_slice(y); + } +} + +// CHECK-LABEL: @swap_bytes32 +#[no_mangle] +pub fn swap_bytes32(x: &mut [u8; 32], y: &mut [u8; 32]) { +// CHECK-NOT: alloca +// CHECK: load <32 x i8>{{.+}}align 1 +// CHECK: store <32 x i8>{{.+}}align 1 + swap(x, y) +} diff --git a/tests/codegen/simd/unpadded-simd.rs b/tests/codegen/simd/unpadded-simd.rs new file mode 100644 index 000000000..eb44dbd93 --- /dev/null +++ b/tests/codegen/simd/unpadded-simd.rs @@ -0,0 +1,14 @@ +// Make sure that no 0-sized padding is inserted in structs and that +// structs are represented as expected by Neon intrinsics in LLVM. +// See #87254. + +#![crate_type = "lib"] +#![feature(repr_simd)] + +#[derive(Copy, Clone, Debug)] +#[repr(simd)] +pub struct int16x4_t(pub i16, pub i16, pub i16, pub i16); + +#[derive(Copy, Clone, Debug)] +pub struct int16x4x2_t(pub int16x4_t, pub int16x4_t); +// CHECK: %int16x4x2_t = type { <4 x i16>, <4 x i16> } diff --git a/tests/codegen/simd_arith_offset.rs b/tests/codegen/simd_arith_offset.rs deleted file mode 100644 index f23337773..000000000 --- a/tests/codegen/simd_arith_offset.rs +++ /dev/null @@ -1,26 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -// only-64bit (because the LLVM type of i64 for usize shows up) -// - -#![crate_type = "lib"] -#![feature(repr_simd, platform_intrinsics)] - -extern "platform-intrinsic" { - pub(crate) fn simd_arith_offset(ptrs: T, offsets: U) -> T; -} - -/// A vector of *const T. -#[derive(Debug, Copy, Clone)] -#[repr(simd)] -pub struct SimdConstPtr([*const T; LANES]); - -#[derive(Debug, Copy, Clone)] -#[repr(simd)] -pub struct Simd([T; LANES]); - -// CHECK-LABEL: smoke -#[no_mangle] -pub fn smoke(ptrs: SimdConstPtr, offsets: Simd) -> SimdConstPtr { - // CHECK: getelementptr i8, <8 x {{i8\*|ptr}}> %1, <8 x i64> %2 - unsafe { simd_arith_offset(ptrs, offsets) } -} diff --git a/tests/codegen/slice-init.rs b/tests/codegen/slice-init.rs index 794b773a7..c0bf1a041 100644 --- a/tests/codegen/slice-init.rs +++ b/tests/codegen/slice-init.rs @@ -8,7 +8,7 @@ pub fn zero_sized_elem() { // CHECK-NOT: br label %repeat_loop_header{{.*}} // CHECK-NOT: call void @llvm.memset.p0 let x = [(); 4]; - drop(&x); + opaque(&x); } // CHECK-LABEL: @zero_len_array @@ -17,16 +17,16 @@ pub fn zero_len_array() { // CHECK-NOT: br label %repeat_loop_header{{.*}} // CHECK-NOT: call void @llvm.memset.p0 let x = [4; 0]; - drop(&x); + opaque(&x); } // CHECK-LABEL: @byte_array #[no_mangle] pub fn byte_array() { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 7, i{{[0-9]+}} 4 + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}, i8 7, i{{[0-9]+}} 4 // CHECK-NOT: br label %repeat_loop_header{{.*}} let x = [7u8; 4]; - drop(&x); + opaque(&x); } #[allow(dead_code)] @@ -39,19 +39,19 @@ enum Init { // CHECK-LABEL: @byte_enum_array #[no_mangle] pub fn byte_enum_array() { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 {{.*}}, i{{[0-9]+}} 4 + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}, i8 {{.*}}, i{{[0-9]+}} 4 // CHECK-NOT: br label %repeat_loop_header{{.*}} let x = [Init::Memset; 4]; - drop(&x); + opaque(&x); } // CHECK-LABEL: @zeroed_integer_array #[no_mangle] pub fn zeroed_integer_array() { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 0, i{{[0-9]+}} 16 + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}, i8 0, i{{[0-9]+}} 16 // CHECK-NOT: br label %repeat_loop_header{{.*}} let x = [0u32; 4]; - drop(&x); + opaque(&x); } // CHECK-LABEL: @nonzero_integer_array @@ -60,5 +60,9 @@ pub fn nonzero_integer_array() { // CHECK: br label %repeat_loop_header{{.*}} // CHECK-NOT: call void @llvm.memset.p0 let x = [0x1a_2b_3c_4d_u32; 4]; - drop(&x); + opaque(&x); } + +// Use an opaque function to prevent rustc from removing useless drops. +#[inline(never)] +pub fn opaque(_: impl Sized) {} diff --git a/tests/codegen/slice-iter-len-eq-zero.rs b/tests/codegen/slice-iter-len-eq-zero.rs index 894b0ec3d..c7515ce35 100644 --- a/tests/codegen/slice-iter-len-eq-zero.rs +++ b/tests/codegen/slice-iter-len-eq-zero.rs @@ -9,8 +9,8 @@ type Demo = [u8; 3]; #[no_mangle] pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { // CHECK-NOT: sub - // CHECK: %2 = icmp eq {{i8\*|ptr}} {{%1|%0}}, {{%1|%0}} - // CHECK: ret i1 %2 + // CHECK: %[[RET:.+]] = icmp eq ptr {{%1|%0}}, {{%1|%0}} + // CHECK: ret i1 %[[RET]] y.len() == 0 } @@ -22,7 +22,7 @@ pub fn array_into_iter_len_eq_zero(y: std::array::IntoIter) -> bool { // CHECK-NOT: icmp // CHECK-NOT: sub - // CHECK: %1 = icmp eq {{i16|i32|i64}} - // CHECK: ret i1 %1 + // CHECK: %_0 = icmp eq {{i16|i32|i64}} + // CHECK: ret i1 %_0 y.len() == 0 } diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs index 997bdaf56..f7d164bc8 100644 --- a/tests/codegen/slice-iter-nonnull.rs +++ b/tests/codegen/slice-iter-nonnull.rs @@ -2,11 +2,16 @@ // compile-flags: -O // ignore-debug (these add extra checks that make it hard to verify) #![crate_type = "lib"] +#![feature(exact_size_is_empty)] // The slice iterator used to `assume` that the `start` pointer was non-null. // That ought to be unneeded, though, since the type is `NonNull`, so this test // confirms that the appropriate metadata is included to denote that. +// It also used to `assume` the `end` pointer was non-null, but that's no longer +// needed as the code changed to read it as a `NonNull`, and thus gets the +// appropriate `!nonnull` annotations naturally. + // CHECK-LABEL: @slice_iter_next( #[no_mangle] pub fn slice_iter_next<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { @@ -75,3 +80,37 @@ pub fn slice_iter_mut_new(slice: &mut [u32]) -> std::slice::IterMut<'_, u32> { // CHECK: } slice.iter_mut() } + +// CHECK-LABEL: @slice_iter_is_empty +#[no_mangle] +pub fn slice_iter_is_empty(it: &std::slice::Iter<'_, u32>) -> bool { + // CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + // CHECK: %[[START:.+]] = load ptr, ptr %it, + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + + // CHECK: %[[RET:.+]] = icmp eq ptr %[[START]], %[[END]] + // CHECK: ret i1 %[[RET]] + it.is_empty() +} + +// CHECK-LABEL: @slice_iter_len +#[no_mangle] +pub fn slice_iter_len(it: &std::slice::Iter<'_, u32>) -> usize { + // CHECK: %[[START:.+]] = load ptr, ptr %it, + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + // CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + + // CHECK: ptrtoint + // CHECK: ptrtoint + // CHECK: sub nuw + // CHECK: lshr exact + it.len() +} diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 8f0adab35..afbdf66ce 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -25,7 +25,7 @@ pub fn is_zero_slice_long(data: &[u8; 456]) -> bool { // CHECK-LABEL: @is_zero_slice_short #[no_mangle] pub fn is_zero_slice_short(data: &[u8; 4]) -> bool { - // CHECK: %[[LOAD:.+]] = load i32, {{i32\*|ptr}} %{{.+}}, align 1 + // CHECK: %[[LOAD:.+]] = load i32, ptr %{{.+}}, align 1 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0 // CHECK-NEXT: ret i1 %[[EQ]] &data[..] == [0; 4] @@ -34,7 +34,7 @@ pub fn is_zero_slice_short(data: &[u8; 4]) -> bool { // CHECK-LABEL: @is_zero_array #[no_mangle] pub fn is_zero_array(data: &[u8; 4]) -> bool { - // CHECK: %[[LOAD:.+]] = load i32, {{i32\*|ptr}} %{{.+}}, align 1 + // CHECK: %[[LOAD:.+]] = load i32, ptr %{{.+}}, align 1 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0 // CHECK-NEXT: ret i1 %[[EQ]] *data == [0; 4] @@ -50,7 +50,7 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool { fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { // CHECK: icmp eq [[USIZE]] %1, %3 // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %1, 3 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i8\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } @@ -62,7 +62,7 @@ fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { // CHECK: icmp eq [[USIZE]] %1, %3 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i32\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } @@ -74,7 +74,7 @@ fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { // CHECK: icmp eq [[USIZE]] %1, %3 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i32\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } @@ -86,7 +86,7 @@ fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { fn eq_slice_of_option_of_nonzero(x: &[Option], y: &[Option]) -> bool { // CHECK: icmp eq [[USIZE]] %1, %3 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i16\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } diff --git a/tests/codegen/slice_as_from_ptr_range.rs b/tests/codegen/slice_as_from_ptr_range.rs index 0e3fefd97..3d8ab0a4b 100644 --- a/tests/codegen/slice_as_from_ptr_range.rs +++ b/tests/codegen/slice_as_from_ptr_range.rs @@ -1,7 +1,6 @@ // compile-flags: -O // only-64bit (because we're using [ui]size) // ignore-debug (because the assertions get in the way) -// min-llvm-version: 15.0 (because this is a relatively new instcombine) #![crate_type = "lib"] #![feature(slice_from_ptr_range)] diff --git a/tests/codegen/sroa-fragment-debuginfo.rs b/tests/codegen/sroa-fragment-debuginfo.rs new file mode 100644 index 000000000..fb10f63be --- /dev/null +++ b/tests/codegen/sroa-fragment-debuginfo.rs @@ -0,0 +1,46 @@ +// compile-flags: -g -Zmir-opt-level=0 -Zmir-enable-passes=+ScalarReplacementOfAggregates +// compile-flags: -Cno-prepopulate-passes +// +// Tested offsets are only correct for x86_64. +// only-x86_64 + +#![crate_type = "lib"] + +pub struct ExtraSlice<'input> { + slice: &'input [u8], + extra: u32, +} + +#[no_mangle] +pub fn extra(s: &[u8]) { +// CHECK: void @extra( +// CHECK: %slice.dbg.spill1 = alloca i32, +// CHECK: %slice.dbg.spill = alloca { ptr, i64 }, +// CHECK: %s.dbg.spill = alloca { ptr, i64 }, +// CHECK: call void @llvm.dbg.declare(metadata ptr %s.dbg.spill, metadata ![[S_EXTRA:.*]], metadata !DIExpression()), +// CHECK: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata ![[SLICE_EXTRA:.*]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 128)), +// CHECK: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill1, metadata ![[SLICE_EXTRA]], metadata !DIExpression(DW_OP_LLVM_fragment, 128, 32)), + let slice = ExtraSlice { slice: s, extra: s.len() as u32 }; +} + +struct Zst; + +pub struct ZstSlice<'input> { + slice: &'input [u8], + extra: Zst, +} + +#[no_mangle] +pub fn zst(s: &[u8]) { + // The field `extra` is a ZST. The fragment for the field `slice` encompasses the whole + // variable, so is not a fragment. In that case, the variable must have no fragment. + +// CHECK: void @zst( +// CHECK-NOT: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata !{}, metadata !DIExpression(DW_OP_LLVM_fragment, +// CHECK: call void @llvm.dbg.declare(metadata ptr %{{.*}}, metadata ![[SLICE_ZST:.*]], metadata !DIExpression()), +// CHECK-NOT: call void @llvm.dbg.declare(metadata ptr %{{.*}}, metadata ![[SLICE_ZST]], + let slice = ZstSlice { slice: s, extra: Zst }; +} + +// CHECK: ![[S_EXTRA]] = !DILocalVariable(name: "s", +// CHECK: ![[SLICE_EXTRA]] = !DILocalVariable(name: "slice", diff --git a/tests/codegen/stores.rs b/tests/codegen/stores.rs index 837256e53..a8e155c4c 100644 --- a/tests/codegen/stores.rs +++ b/tests/codegen/stores.rs @@ -17,8 +17,8 @@ pub struct Bytes { pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { // CHECK: [[TMP:%.+]] = alloca i32 // CHECK: %y = alloca [4 x i8] -// CHECK: store i32 %0, {{i32\*|ptr}} [[TMP]] -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 {{.+}}, {{i8\*|ptr}} align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) +// CHECK: store i32 %0, ptr [[TMP]] +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) *x = y; } @@ -29,7 +29,7 @@ pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) { // CHECK: [[TMP:%.+]] = alloca i32 // CHECK: %y = alloca %Bytes -// CHECK: store i32 %0, {{i32\*|ptr}} [[TMP]] -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 {{.+}}, {{i8\*|ptr}} align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) +// CHECK: store i32 %0, ptr [[TMP]] +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) *x = y; } diff --git a/tests/codegen/swap-large-types.rs b/tests/codegen/swap-large-types.rs index 4a6840357..7b6611f3d 100644 --- a/tests/codegen/swap-large-types.rs +++ b/tests/codegen/swap-large-types.rs @@ -83,9 +83,9 @@ pub struct BigButHighlyAligned([u8; 64 * 3]); #[no_mangle] pub fn swap_big_aligned(x: &mut BigButHighlyAligned, y: &mut BigButHighlyAligned) { // CHECK-NOT: call void @llvm.memcpy -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} noundef nonnull align 64 dereferenceable(192) -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} noundef nonnull align 64 dereferenceable(192) -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} noundef nonnull align 64 dereferenceable(192) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192) // CHECK-NOT: call void @llvm.memcpy swap(x, y) } diff --git a/tests/codegen/swap-simd-types.rs b/tests/codegen/swap-simd-types.rs deleted file mode 100644 index 3472a42b0..000000000 --- a/tests/codegen/swap-simd-types.rs +++ /dev/null @@ -1,41 +0,0 @@ -// compile-flags: -O -C target-feature=+avx -// only-x86_64 -// ignore-debug: the debug assertions get in the way - -#![crate_type = "lib"] - -use std::mem::swap; - -// SIMD types are highly-aligned already, so make sure the swap code leaves their -// types alone and doesn't pessimize them (such as by swapping them as `usize`s). -extern crate core; -use core::arch::x86_64::__m256; - -// CHECK-LABEL: @swap_single_m256 -#[no_mangle] -pub fn swap_single_m256(x: &mut __m256, y: &mut __m256) { -// CHECK-NOT: alloca -// CHECK: load <8 x float>{{.+}}align 32 -// CHECK: store <8 x float>{{.+}}align 32 - swap(x, y) -} - -// CHECK-LABEL: @swap_m256_slice -#[no_mangle] -pub fn swap_m256_slice(x: &mut [__m256], y: &mut [__m256]) { -// CHECK-NOT: alloca -// CHECK: load <8 x float>{{.+}}align 32 -// CHECK: store <8 x float>{{.+}}align 32 - if x.len() == y.len() { - x.swap_with_slice(y); - } -} - -// CHECK-LABEL: @swap_bytes32 -#[no_mangle] -pub fn swap_bytes32(x: &mut [u8; 32], y: &mut [u8; 32]) { -// CHECK-NOT: alloca -// CHECK: load <32 x i8>{{.+}}align 1 -// CHECK: store <32 x i8>{{.+}}align 1 - swap(x, y) -} diff --git a/tests/codegen/target-feature-inline-closure.rs b/tests/codegen/target-feature-inline-closure.rs new file mode 100644 index 000000000..d07570617 --- /dev/null +++ b/tests/codegen/target-feature-inline-closure.rs @@ -0,0 +1,33 @@ +// only-x86_64 +// compile-flags: -Copt-level=3 + +#![crate_type = "lib"] +#![feature(target_feature_11)] + +#[cfg(target_arch = "x86_64")] +use std::arch::x86_64::*; + +// CHECK-LABEL: @with_avx +#[no_mangle] +#[cfg(target_arch = "x86_64")] +#[target_feature(enable = "avx")] +fn with_avx(x: __m256) -> __m256 { + // CHECK: fadd + let add = { + #[inline(always)] + |x, y| unsafe { _mm256_add_ps(x, y) } + }; + add(x, x) +} + +// CHECK-LABEL: @without_avx +#[no_mangle] +#[cfg(target_arch = "x86_64")] +unsafe fn without_avx(x: __m256) -> __m256 { + // CHECK-NOT: fadd + let add = { + #[inline(always)] + |x, y| unsafe { _mm256_add_ps(x, y) } + }; + add(x, x) +} diff --git a/tests/codegen/trailing_zeros.rs b/tests/codegen/trailing_zeros.rs new file mode 100644 index 000000000..2ea0e447a --- /dev/null +++ b/tests/codegen/trailing_zeros.rs @@ -0,0 +1,22 @@ +// compile-flags: -O +// min-llvm-version: 17 + +#![crate_type = "lib"] + +// CHECK-LABEL: @trailing_zeros_ge +#[no_mangle] +pub fn trailing_zeros_ge(val: u32) -> bool { + // CHECK: %[[AND:.*]] = and i32 %val, 7 + // CHECK: %[[ICMP:.*]] = icmp eq i32 %[[AND]], 0 + // CHECK: ret i1 %[[ICMP]] + val.trailing_zeros() >= 3 +} + +// CHECK-LABEL: @trailing_zeros_gt +#[no_mangle] +pub fn trailing_zeros_gt(val: u64) -> bool { + // CHECK: %[[AND:.*]] = and i64 %val, 15 + // CHECK: %[[ICMP:.*]] = icmp eq i64 %[[AND]], 0 + // CHECK: ret i1 %[[ICMP]] + val.trailing_zeros() > 3 +} diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs index 461dd550c..b8c51b084 100644 --- a/tests/codegen/transmute-optimized.rs +++ b/tests/codegen/transmute-optimized.rs @@ -1,5 +1,4 @@ // compile-flags: -O -Z merge-functions=disabled -// min-llvm-version: 15.0 # this test uses `ptr`s // ignore-debug #![crate_type = "lib"] diff --git a/tests/codegen/transmute-scalar.rs b/tests/codegen/transmute-scalar.rs index a0894a505..39126b024 100644 --- a/tests/codegen/transmute-scalar.rs +++ b/tests/codegen/transmute-scalar.rs @@ -1,5 +1,4 @@ // compile-flags: -C opt-level=0 -C no-prepopulate-passes -// min-llvm-version: 15.0 # this test assumes `ptr`s and thus no `pointercast`s #![crate_type = "lib"] @@ -11,24 +10,24 @@ // that allows us to avoid the `alloca`s entirely; see `rvalue_creates_operand`. // CHECK-LABEL: define{{.*}}i32 @f32_to_bits(float %x) -// CHECK: %0 = bitcast float %x to i32 -// CHECK-NEXT: ret i32 %0 +// CHECK: %_0 = bitcast float %x to i32 +// CHECK-NEXT: ret i32 %_0 #[no_mangle] pub fn f32_to_bits(x: f32) -> u32 { unsafe { std::mem::transmute(x) } } // CHECK-LABEL: define{{.*}}i8 @bool_to_byte(i1 zeroext %b) -// CHECK: %0 = zext i1 %b to i8 -// CHECK-NEXT: ret i8 %0 +// CHECK: %_0 = zext i1 %b to i8 +// CHECK-NEXT: ret i8 %_0 #[no_mangle] pub fn bool_to_byte(b: bool) -> u8 { unsafe { std::mem::transmute(b) } } // CHECK-LABEL: define{{.*}}zeroext i1 @byte_to_bool(i8 %byte) -// CHECK: %0 = trunc i8 %byte to i1 -// CHECK-NEXT: ret i1 %0 +// CHECK: %_0 = trunc i8 %byte to i1 +// CHECK-NEXT: ret i1 %_0 #[no_mangle] pub unsafe fn byte_to_bool(byte: u8) -> bool { std::mem::transmute(byte) @@ -42,16 +41,16 @@ pub fn ptr_to_ptr(p: *mut u16) -> *mut u8 { } // CHECK: define{{.*}}[[USIZE:i[0-9]+]] @ptr_to_int(ptr %p) -// CHECK: %0 = ptrtoint ptr %p to [[USIZE]] -// CHECK-NEXT: ret [[USIZE]] %0 +// CHECK: %_0 = ptrtoint ptr %p to [[USIZE]] +// CHECK-NEXT: ret [[USIZE]] %_0 #[no_mangle] pub fn ptr_to_int(p: *mut u16) -> usize { unsafe { std::mem::transmute(p) } } // CHECK: define{{.*}}ptr @int_to_ptr([[USIZE]] %i) -// CHECK: %0 = inttoptr [[USIZE]] %i to ptr -// CHECK-NEXT: ret ptr %0 +// CHECK: %_0 = inttoptr [[USIZE]] %i to ptr +// CHECK-NEXT: ret ptr %_0 #[no_mangle] pub fn int_to_ptr(i: usize) -> *mut u16 { unsafe { std::mem::transmute(i) } diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index d23938776..9d34155bd 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0 // compile-flags: -O -Z merge-functions=disabled --edition=2021 // only-x86_64 diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs index 0924dda08..d5f53bedd 100644 --- a/tests/codegen/unchecked_shifts.rs +++ b/tests/codegen/unchecked_shifts.rs @@ -1,5 +1,4 @@ // compile-flags: -O -// min-llvm-version: 15.0 (LLVM 13 in CI does this differently from submodule LLVM) // ignore-debug (because unchecked is checked in debug) #![crate_type = "lib"] diff --git a/tests/codegen/uninit-consts.rs b/tests/codegen/uninit-consts.rs index 54e9a9e9b..1313e6763 100644 --- a/tests/codegen/uninit-consts.rs +++ b/tests/codegen/uninit-consts.rs @@ -8,7 +8,7 @@ use std::mem::MaybeUninit; pub struct PartiallyUninit { x: u32, - y: MaybeUninit<[u8; 10]> + y: MaybeUninit<[u8; 10]>, } // CHECK: [[FULLY_UNINIT:@[0-9]+]] = private unnamed_addr constant <{ [10 x i8] }> undef @@ -25,7 +25,7 @@ pub struct PartiallyUninit { #[no_mangle] pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> { const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit(); - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{[0-9]+}}, {{i8\*|ptr}} align 1 {{.*}}[[FULLY_UNINIT]]{{.*}}, i{{(32|64)}} 10, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %_0, ptr align 1 {{.*}}[[FULLY_UNINIT]]{{.*}}, i{{(32|64)}} 10, i1 false) M } @@ -33,7 +33,7 @@ pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> { #[no_mangle] pub const fn partially_uninit() -> PartiallyUninit { const X: PartiallyUninit = PartiallyUninit { x: 0xdeadbeef, y: MaybeUninit::uninit() }; - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 4 %{{[0-9]+}}, {{i8\*|ptr}} align 4 {{.*}}[[PARTIALLY_UNINIT]]{{.*}}, i{{(32|64)}} 16, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[PARTIALLY_UNINIT]]{{.*}}, i{{(32|64)}} 16, i1 false) X } @@ -41,7 +41,7 @@ pub const fn partially_uninit() -> PartiallyUninit { #[no_mangle] pub const fn uninit_padding_huge() -> [(u32, u8); 4096] { const X: [(u32, u8); 4096] = [(123, 45); 4096]; - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 4 %{{[0-9]+}}, {{i8\*|ptr}} align 4 {{.*}}[[UNINIT_PADDING_HUGE]]{{.*}}, i{{(32|64)}} 32768, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[UNINIT_PADDING_HUGE]]{{.*}}, i{{(32|64)}} 32768, i1 false) X } @@ -49,6 +49,6 @@ pub const fn uninit_padding_huge() -> [(u32, u8); 4096] { #[no_mangle] pub const fn fully_uninit_huge() -> MaybeUninit<[u32; 4096]> { const F: MaybeUninit<[u32; 4096]> = MaybeUninit::uninit(); - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 4 %{{[0-9]+}}, {{i8\*|ptr}} align 4 {{.*}}[[FULLY_UNINIT_HUGE]]{{.*}}, i{{(32|64)}} 16384, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[FULLY_UNINIT_HUGE]]{{.*}}, i{{(32|64)}} 16384, i1 false) F } diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs index 8481ca8cc..4878ae5c3 100644 --- a/tests/codegen/union-abi.rs +++ b/tests/codegen/union-abi.rs @@ -17,25 +17,25 @@ pub struct i64x4(i64, i64, i64, i64); #[derive(Copy, Clone)] pub union UnionI64x4{ a:(), b: i64x4 } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4({{<4 x i64>\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4(_: UnionI64x4) { loop {} } pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_({{<4 x i64>\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} } pub union UnionI64x4I64{ a: i64x4, b: i64 } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64({{%UnionI64x4I64\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} } pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple({{%UnionI64x4Tuple\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} } @@ -65,7 +65,7 @@ pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} } #[repr(C)] pub union CUnionU128{a:u128} -// CHECK: define {{(dso_local )?}}void @test_CUnionU128({{%CUnionU128\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_CUnionU128(ptr {{.*}} %_1) #[no_mangle] pub fn test_CUnionU128(_: CUnionU128) { loop {} } @@ -73,4 +73,4 @@ pub union UnionBool { b:bool } // CHECK: define {{(dso_local )?}}noundef zeroext i1 @test_UnionBool(i8 %b) #[no_mangle] pub fn test_UnionBool(b: UnionBool) -> bool { unsafe { b.b } } -// CHECK: %0 = trunc i8 %b to i1 +// CHECK: %_0 = trunc i8 %b to i1 diff --git a/tests/codegen/unpadded-simd.rs b/tests/codegen/unpadded-simd.rs deleted file mode 100644 index eb44dbd93..000000000 --- a/tests/codegen/unpadded-simd.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Make sure that no 0-sized padding is inserted in structs and that -// structs are represented as expected by Neon intrinsics in LLVM. -// See #87254. - -#![crate_type = "lib"] -#![feature(repr_simd)] - -#[derive(Copy, Clone, Debug)] -#[repr(simd)] -pub struct int16x4_t(pub i16, pub i16, pub i16, pub i16); - -#[derive(Copy, Clone, Debug)] -pub struct int16x4x2_t(pub int16x4_t, pub int16x4_t); -// CHECK: %int16x4x2_t = type { <4 x i16>, <4 x i16> } diff --git a/tests/codegen/unwind-abis/thiscall-unwind-abi.rs b/tests/codegen/unwind-abis/thiscall-unwind-abi.rs index 7e81367fc..0a02755a2 100644 --- a/tests/codegen/unwind-abis/thiscall-unwind-abi.rs +++ b/tests/codegen/unwind-abis/thiscall-unwind-abi.rs @@ -1,7 +1,7 @@ // needs-llvm-components: x86 // compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -Cno-prepopulate-passes #![no_core] -#![feature(no_core, lang_items, c_unwind, abi_thiscall)] +#![feature(no_core, lang_items, c_unwind)] #[lang="sized"] trait Sized { } diff --git a/tests/codegen/var-names.rs b/tests/codegen/var-names.rs index 53841df32..d4715efad 100644 --- a/tests/codegen/var-names.rs +++ b/tests/codegen/var-names.rs @@ -9,7 +9,7 @@ pub fn test(a: u32, b: u32) -> u32 { // CHECK: %c = add i32 %a, %b let d = c; let e = d * a; - // CHECK-NEXT: %0 = mul i32 %c, %a + // CHECK-NEXT: %e = mul i32 %c, %a e - // CHECK-NEXT: ret i32 %0 + // CHECK-NEXT: ret i32 %e } diff --git a/tests/codegen/vec-as-ptr.rs b/tests/codegen/vec-as-ptr.rs index 8ff7ba9cb..76098bc08 100644 --- a/tests/codegen/vec-as-ptr.rs +++ b/tests/codegen/vec-as-ptr.rs @@ -4,7 +4,7 @@ // Test that even though we return a *const u8 not a &[u8] or a NonNull, LLVM knows that this // pointer is nonnull. -// CHECK: nonnull {{i8\*|ptr}} @vec_as_ptr +// CHECK: nonnull ptr @vec_as_ptr #[no_mangle] pub fn vec_as_ptr(v: &Vec) -> *const u8 { v.as_ptr() @@ -12,7 +12,7 @@ pub fn vec_as_ptr(v: &Vec) -> *const u8 { // Test that even though we return a *const u8 not a &[u8] or a NonNull, LLVM knows that this // pointer is nonnull. -// CHECK: nonnull {{i8\*|ptr}} @vec_as_mut_ptr +// CHECK: nonnull ptr @vec_as_mut_ptr #[no_mangle] pub fn vec_as_mut_ptr(v: &mut Vec) -> *mut u8 { v.as_mut_ptr() diff --git a/tests/codegen/vec-calloc-llvm14.rs b/tests/codegen/vec-calloc-llvm14.rs deleted file mode 100644 index 08302796c..000000000 --- a/tests/codegen/vec-calloc-llvm14.rs +++ /dev/null @@ -1,144 +0,0 @@ -// compile-flags: -O -// only-x86_64 -// ignore-debug - -#![crate_type = "lib"] - -// CHECK-LABEL: @vec_zero_bytes -#[no_mangle] -pub fn vec_zero_bytes(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - // CHECK-NOT: call {{.*}}llvm.memset - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - // CHECK-NOT: call {{.*}}llvm.memset - - // CHECK: ret void - vec![0; n] -} - -// CHECK-LABEL: @vec_one_bytes -#[no_mangle] -pub fn vec_one_bytes(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: call {{.*}}__rust_alloc( - // CHECK: call {{.*}}llvm.memset - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: ret void - vec![1; n] -} - -// CHECK-LABEL: @vec_zero_scalar -#[no_mangle] -pub fn vec_zero_scalar(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![0; n] -} - -// CHECK-LABEL: @vec_one_scalar -#[no_mangle] -pub fn vec_one_scalar(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: call {{.*}}__rust_alloc( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: ret void - vec![1; n] -} - -// CHECK-LABEL: @vec_zero_rgb48 -#[no_mangle] -pub fn vec_zero_rgb48(n: usize) -> Vec<[u16; 3]> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![[0, 0, 0]; n] -} - -// CHECK-LABEL: @vec_zero_array_16 -#[no_mangle] -pub fn vec_zero_array_16(n: usize) -> Vec<[i64; 16]> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![[0_i64; 16]; n] -} - -// CHECK-LABEL: @vec_zero_tuple -#[no_mangle] -pub fn vec_zero_tuple(n: usize) -> Vec<(i16, u8, char)> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![(0, 0, '\0'); n] -} - -// CHECK-LABEL: @vec_non_zero_tuple -#[no_mangle] -pub fn vec_non_zero_tuple(n: usize) -> Vec<(i16, u8, char)> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: call {{.*}}__rust_alloc( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: ret void - vec![(0, 0, 'A'); n] -} diff --git a/tests/codegen/vec-calloc.rs b/tests/codegen/vec-calloc.rs index 4481a9d1e..a5fda7b24 100644 --- a/tests/codegen/vec-calloc.rs +++ b/tests/codegen/vec-calloc.rs @@ -1,7 +1,6 @@ // compile-flags: -O -Z merge-functions=disabled // only-x86_64 // ignore-debug -// min-llvm-version: 15.0 #![crate_type = "lib"] diff --git a/tests/codegen/wasm_exceptions.rs b/tests/codegen/wasm_exceptions.rs new file mode 100644 index 000000000..2b2359f5b --- /dev/null +++ b/tests/codegen/wasm_exceptions.rs @@ -0,0 +1,51 @@ +// only-wasm32-bare +// compile-flags: -C panic=unwind + +#![crate_type = "lib"] +#![feature(core_intrinsics)] +#![feature(rustc_attrs)] + +extern { + fn may_panic(); + + #[rustc_nounwind] + fn log_number(number: usize); +} + +struct LogOnDrop; + +impl Drop for LogOnDrop { + fn drop(&mut self) { + unsafe { log_number(0); } + } +} + +// CHECK-LABEL: @test_cleanup() {{.*}} @__gxx_wasm_personality_v0 +#[no_mangle] +pub fn test_cleanup() { + let _log_on_drop = LogOnDrop; + unsafe { may_panic(); } + + // CHECK-NOT: call + // CHECK: invoke void @may_panic() + // CHECK: %cleanuppad = cleanuppad within none [] +} + +// CHECK-LABEL: @test_rtry() {{.*}} @__gxx_wasm_personality_v0 +#[no_mangle] +pub fn test_rtry() { + unsafe { + core::intrinsics::r#try(|_| { + may_panic(); + }, core::ptr::null_mut(), |data, exception| { + log_number(data as usize); + log_number(exception as usize); + }); + } + + // CHECK-NOT: call + // CHECK: invoke void @may_panic() + // CHECK: {{.*}} = catchswitch within none [label {{.*}}] unwind to caller + // CHECK: {{.*}} = catchpad within {{.*}} [ptr null] + // CHECK: catchret +} diff --git a/tests/codegen/x86_64-macosx-deployment-target.rs b/tests/codegen/x86_64-macosx-deployment-target.rs deleted file mode 100644 index 8e673d11d..000000000 --- a/tests/codegen/x86_64-macosx-deployment-target.rs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. -// See issue #60235. - -// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib -// needs-llvm-components: x86 -// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="freeze"] -trait Freeze { } -#[lang="copy"] -trait Copy { } - -#[repr(C)] -pub struct Bool { - b: bool, -} - -// CHECK: target triple = "x86_64-apple-macosx10.9.0" -#[no_mangle] -pub extern "C" fn structbool() -> Bool { - Bool { b: true } -} diff --git a/tests/codegen/x86_64-no-macosx-deployment-target.rs b/tests/codegen/x86_64-no-macosx-deployment-target.rs deleted file mode 100644 index 25ae6924d..000000000 --- a/tests/codegen/x86_64-no-macosx-deployment-target.rs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset. -// See issue #60235. - -// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib -// needs-llvm-components: x86 -// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized { } -#[lang="freeze"] -trait Freeze { } -#[lang="copy"] -trait Copy { } - -#[repr(C)] -pub struct Bool { - b: bool, -} - -// CHECK: target triple = "x86_64-apple-macosx10.7.0" -#[no_mangle] -pub extern "C" fn structbool() -> Bool { - Bool { b: true } -} diff --git a/tests/debuginfo/rc_arc.rs b/tests/debuginfo/rc_arc.rs index 5d5492d72..1d07bd76e 100644 --- a/tests/debuginfo/rc_arc.rs +++ b/tests/debuginfo/rc_arc.rs @@ -27,37 +27,37 @@ // cdb-command:g // cdb-command:dx rc,d -// cdb-check:rc,d : 111 [Type: alloc::rc::Rc] +// cdb-check:rc,d : 111 [Type: alloc::rc::Rc] // cdb-check: [Reference count] : 11 [Type: core::cell::Cell] // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] // cdb-command:dx weak_rc,d -// cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak] +// cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak] // cdb-check: [Reference count] : 11 [Type: core::cell::Cell] // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] // cdb-command:dx arc,d -// cdb-check:arc,d : 222 [Type: alloc::sync::Arc] +// cdb-check:arc,d : 222 [Type: alloc::sync::Arc] // cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] // cdb-command:dx weak_arc,d -// cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak] +// cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak] // cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] // cdb-command:dx dyn_rc,d -// cdb-check:dyn_rc,d [Type: alloc::rc::Rc >] +// cdb-check:dyn_rc,d [Type: alloc::rc::Rc,alloc::alloc::Global>] // cdb-check: [Reference count] : 31 [Type: core::cell::Cell] // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] // cdb-command:dx dyn_rc_weak,d -// cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak >] +// cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak,alloc::alloc::Global>] // cdb-check: [Reference count] : 31 [Type: core::cell::Cell] // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] // cdb-command:dx slice_rc,d -// cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc >] +// cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc,alloc::alloc::Global>] // cdb-check: [Length] : 3 [Type: [...]] // cdb-check: [Reference count] : 41 [Type: core::cell::Cell] // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] @@ -66,7 +66,7 @@ // cdb-check: [2] : 3 [Type: u32] // cdb-command:dx slice_rc_weak,d -// cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak >] +// cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak,alloc::alloc::Global>] // cdb-check: [Length] : 3 [Type: [...]] // cdb-check: [Reference count] : 41 [Type: core::cell::Cell] // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] @@ -75,17 +75,17 @@ // cdb-check: [2] : 3 [Type: u32] // cdb-command:dx dyn_arc,d -// cdb-check:dyn_arc,d [Type: alloc::sync::Arc >] +// cdb-check:dyn_arc,d [Type: alloc::sync::Arc,alloc::alloc::Global>] // cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] // cdb-command:dx dyn_arc_weak,d -// cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak >] +// cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak,alloc::alloc::Global>] // cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] // cdb-command:dx slice_arc,d -// cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc >] +// cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc,alloc::alloc::Global>] // cdb-check: [Length] : 3 [Type: [...]] // cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] @@ -94,7 +94,7 @@ // cdb-check: [2] : 6 [Type: u32] // cdb-command:dx slice_arc_weak,d -// cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak >] +// cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak,alloc::alloc::Global>] // cdb-check: [Length] : 3 [Type: [...]] // cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] diff --git a/tests/debuginfo/thread-names.rs b/tests/debuginfo/thread-names.rs index 7a35a5189..2c5b3f272 100644 --- a/tests/debuginfo/thread-names.rs +++ b/tests/debuginfo/thread-names.rs @@ -1,15 +1,8 @@ // compile-flags:-g +// revisions: macos windows // We can't set the main thread name on Linux because it renames the process (#97191) -// ignore-linux -// ignore-android -// ignore-dragonfly -// ignore-emscripten -// ignore-freebsd -// ignore-haiku -// ignore-ios -// ignore-netbsd -// ignore-openbsd -// ignore-solaris +//[macos] only-macos +//[windows] only-windows // ignore-sgx // ignore-windows-gnu diff --git a/tests/debuginfo/thread.rs b/tests/debuginfo/thread.rs index e7e83c7aa..5516f4fec 100644 --- a/tests/debuginfo/thread.rs +++ b/tests/debuginfo/thread.rs @@ -14,7 +14,7 @@ // // cdb-command:dx t,d // cdb-check:t,d : [...] [Type: std::thread::Thread *] -// cdb-check:[...] inner [...][Type: core::pin::Pin >] +// cdb-check:[...] inner [...][Type: core::pin::Pin >] use std::thread; diff --git a/tests/incremental/hashes/call_expressions.rs b/tests/incremental/hashes/call_expressions.rs index 65df2e829..a42cf6aa4 100644 --- a/tests/incremental/hashes/call_expressions.rs +++ b/tests/incremental/hashes/call_expressions.rs @@ -162,7 +162,7 @@ pub fn change_to_ufcs() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] diff --git a/tests/incremental/hashes/match_expressions.rs b/tests/incremental/hashes/match_expressions.rs index 4d1b3b683..ecb19480d 100644 --- a/tests/incremental/hashes/match_expressions.rs +++ b/tests/incremental/hashes/match_expressions.rs @@ -227,7 +227,7 @@ pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { // Ignore optimized_mir in cfail2, the only change to optimized MIR is a span. #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] diff --git a/tests/incremental/hashes/trait_defs.rs b/tests/incremental/hashes/trait_defs.rs index b583bee2f..7b8c6245d 100644 --- a/tests/incremental/hashes/trait_defs.rs +++ b/tests/incremental/hashes/trait_defs.rs @@ -420,13 +420,13 @@ trait TraitAddExternModifier { // ------------------------- // -------------------------------------------------------------------- // ------------------------- - fn method() ; + fn method(); } #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(except="hir_owner", cfg="cfail5")] +#[rustc_clean(cfg="cfail5")] #[rustc_clean(cfg="cfail6")] trait TraitAddExternModifier { #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig", cfg="cfail2")] diff --git a/tests/incremental/issue-61530.rs b/tests/incremental/issue-61530.rs index edb3d60ba..1dcb41dde 100644 --- a/tests/incremental/issue-61530.rs +++ b/tests/incremental/issue-61530.rs @@ -6,13 +6,13 @@ struct I32x2(i32, i32); extern "platform-intrinsic" { - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle(x: T, y: T, idx: I) -> U; } fn main() { unsafe { const IDX: [u32; 2] = [0, 0]; - let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), IDX); - let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), IDX); + let _: I32x2 = simd_shuffle(I32x2(1, 2), I32x2(3, 4), IDX); + let _: I32x2 = simd_shuffle(I32x2(1, 2), I32x2(3, 4), IDX); } } diff --git a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff index 9c7b3c519..15269fb8f 100644 --- a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff +++ b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff @@ -47,7 +47,8 @@ bb2 (cleanup): { _5 = move _6; - drop(_6) -> [return: bb6, unwind terminate]; +- drop(_6) -> [return: bb6, unwind terminate]; ++ goto -> bb6; } bb3: { @@ -70,7 +71,8 @@ } bb6 (cleanup): { - drop(_5) -> [return: bb7, unwind terminate]; +- drop(_5) -> [return: bb7, unwind terminate]; ++ goto -> bb7; } bb7 (cleanup): { @@ -80,10 +82,6 @@ bb8 (cleanup): { resume; -+ } -+ -+ bb9 (cleanup): { -+ unreachable; } } diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir index 074ebddf7..9be5b8509 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir @@ -30,7 +30,7 @@ fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:11:14: 11:16]> } bb2: { - assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind continue]; + assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index f774f32eb..80ac92d59 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -310,7 +310,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb28: { - assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind continue]; + assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind unreachable]; } bb29: { diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs index f12405661..123118f65 100644 --- a/tests/mir-opt/building/custom/terminators.rs +++ b/tests/mir-opt/building/custom/terminators.rs @@ -12,7 +12,7 @@ fn ident(t: T) -> T { fn direct_call(x: i32) -> i32 { mir!( { - Call(RET, retblock, ident(x)) + Call(RET = ident(x), retblock) } retblock = { @@ -26,7 +26,7 @@ fn direct_call(x: i32) -> i32 { fn indirect_call(x: i32, f: fn(i32) -> i32) -> i32 { mir!( { - Call(RET, retblock, f(x)) + Call(RET = f(x), retblock) } retblock = { diff --git a/tests/mir-opt/casts.redundant.InstSimplify.diff b/tests/mir-opt/casts.redundant.InstSimplify.diff index ff6d11c45..f5ea78aec 100644 --- a/tests/mir-opt/casts.redundant.InstSimplify.diff +++ b/tests/mir-opt/casts.redundant.InstSimplify.diff @@ -7,7 +7,7 @@ let mut _2: *const &u8; let mut _3: *const &u8; scope 1 (inlined generic_cast::<&u8, &u8>) { - debug x => _3; + debug x => _1; } bb0: { diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index 3797dbabb..8c8e69595 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -23,17 +23,17 @@ alloc1 (static: FOO, size: 8, align: 4) { alloc19 (size: 48, align: 4) { 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc6──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc9──╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc14─╼ 03 00 00 00 │ ....*...╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc10─╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc15─╼ 03 00 00 00 │ ....*...╾──╼.... } alloc6 (size: 0, align: 4) {} -alloc9 (size: 16, align: 4) { - ╾─alloc10─╼ 03 00 00 00 ╾─alloc11─╼ 03 00 00 00 │ ╾──╼....╾──╼.... +alloc10 (size: 16, align: 4) { + ╾─alloc9──╼ 03 00 00 00 ╾─alloc11─╼ 03 00 00 00 │ ╾──╼....╾──╼.... } -alloc10 (size: 3, align: 1) { +alloc9 (size: 3, align: 1) { 66 6f 6f │ foo } @@ -41,12 +41,12 @@ alloc11 (size: 3, align: 1) { 62 61 72 │ bar } -alloc14 (size: 24, align: 4) { - 0x00 │ ╾─alloc15─╼ 03 00 00 00 ╾─alloc16─╼ 03 00 00 00 │ ╾──╼....╾──╼.... +alloc15 (size: 24, align: 4) { + 0x00 │ ╾─alloc14─╼ 03 00 00 00 ╾─alloc16─╼ 03 00 00 00 │ ╾──╼....╾──╼.... 0x10 │ ╾─alloc17─╼ 04 00 00 00 │ ╾──╼.... } -alloc15 (size: 3, align: 1) { +alloc14 (size: 3, align: 1) { 6d 65 68 │ meh } diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index dc16c0640..e22547032 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -24,19 +24,19 @@ alloc1 (static: FOO, size: 16, align: 8) { alloc19 (size: 72, align: 8) { 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc6────────╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾───────alloc9────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc14───────╼ │ ....*...╾──────╼ + 0x20 │ ╾───────alloc10───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc15───────╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } alloc6 (size: 0, align: 8) {} -alloc9 (size: 32, align: 8) { - 0x00 │ ╾───────alloc10───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +alloc10 (size: 32, align: 8) { + 0x00 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ 0x10 │ ╾───────alloc11───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc10 (size: 3, align: 1) { +alloc9 (size: 3, align: 1) { 66 6f 6f │ foo } @@ -44,13 +44,13 @@ alloc11 (size: 3, align: 1) { 62 61 72 │ bar } -alloc14 (size: 48, align: 8) { - 0x00 │ ╾───────alloc15───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +alloc15 (size: 48, align: 8) { + 0x00 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ 0x10 │ ╾───────alloc16───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ 0x20 │ ╾───────alloc17───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc15 (size: 3, align: 1) { +alloc14 (size: 3, align: 1) { 6d 65 68 │ meh } diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff index 0fad23104..a4911a6d4 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff @@ -26,8 +26,9 @@ StorageLive(_4); StorageLive(_5); - _5 = _1; +- _4 = foo(move _5) -> [return: bb1, unwind unreachable]; + _5 = const 1_u8; - _4 = foo(move _5) -> [return: bb1, unwind unreachable]; ++ _4 = foo(const 1_u8) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff index e4650046b..b8b9fa5cc 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff @@ -26,8 +26,9 @@ StorageLive(_4); StorageLive(_5); - _5 = _1; +- _4 = foo(move _5) -> [return: bb1, unwind continue]; + _5 = const 1_u8; - _4 = foo(move _5) -> [return: bb1, unwind continue]; ++ _4 = foo(const 1_u8) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir index 2ab6c1bf3..44a85a563 100644 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir @@ -23,7 +23,7 @@ fn main() -> () { StorageLive(_4); StorageLive(_5); _5 = const 1_u8; - _4 = foo(move _5) -> [return: bb1, unwind unreachable]; + _4 = foo(const 1_u8) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir index 9590c7f90..2c7bdbb50 100644 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir @@ -23,7 +23,7 @@ fn main() -> () { StorageLive(_4); StorageLive(_5); _5 = const 1_u8; - _4 = foo(move _5) -> [return: bb1, unwind continue]; + _4 = foo(const 1_u8) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff index 012b11e0e..b2f58f8f7 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + _4 = const 4_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff index ec11395c3..f9e3f8f17 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 4_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff index 012b11e0e..b2f58f8f7 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + _4 = const 4_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff index ec11395c3..f9e3f8f17 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 4_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff index 34163d4d8..cead70110 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff @@ -38,11 +38,12 @@ + _5 = const false; + _6 = const false; + _7 = const false; -+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind unreachable]; ++ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32) -> [success: bb2, unwind unreachable]; } bb2: { - _2 = Div(const 1_i32, move _3); +- _2 = Div(const 1_i32, move _3); ++ _2 = Div(const 1_i32, const 0_i32); StorageDead(_3); _0 = const (); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff index a5b51681e..c9c4ba854 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff @@ -38,11 +38,12 @@ + _5 = const false; + _6 = const false; + _7 = const false; -+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; ++ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32) -> [success: bb2, unwind continue]; } bb2: { - _2 = Div(const 1_i32, move _3); +- _2 = Div(const 1_i32, move _3); ++ _2 = Div(const 1_i32, const 0_i32); StorageDead(_3); _0 = const (); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff index eb1c7d34f..2666fd9eb 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff @@ -38,11 +38,12 @@ + _5 = const false; + _6 = const false; + _7 = const false; -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind unreachable]; ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> [success: bb2, unwind unreachable]; } bb2: { - _2 = Rem(const 1_i32, move _3); +- _2 = Rem(const 1_i32, move _3); ++ _2 = Rem(const 1_i32, const 0_i32); StorageDead(_3); _0 = const (); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff index 4afddf3c9..679df90f1 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff @@ -38,11 +38,12 @@ + _5 = const false; + _6 = const false; + _7 = const false; -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> [success: bb2, unwind continue]; } bb2: { - _2 = Rem(const 1_i32, move _3); +- _2 = Rem(const 1_i32, move _3); ++ _2 = Rem(const 1_i32, const 0_i32); StorageDead(_3); _0 = const (); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff index 30402df47..55c774d55 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff @@ -38,7 +38,7 @@ - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + _8 = const false; -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff index 16d62daed..dcab570ea 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff @@ -38,7 +38,7 @@ - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _8 = const false; -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff index 30402df47..55c774d55 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff @@ -38,7 +38,7 @@ - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + _8 = const false; -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff index 16d62daed..dcab570ea 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff @@ -38,7 +38,7 @@ - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _8 = const false; -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff index 24b479694..c9670a5ee 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff @@ -24,9 +24,10 @@ StorageLive(_3); - _4 = SizeOf(i32); - _5 = AlignOf(i32); +- _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind unreachable]; + _4 = const 4_usize; + _5 = const 4_usize; - _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind unreachable]; ++ _6 = alloc::alloc::exchange_malloc(const 4_usize, const 4_usize) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff index 6214766c7..64fe72be5 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff @@ -24,9 +24,10 @@ StorageLive(_3); - _4 = SizeOf(i32); - _5 = AlignOf(i32); +- _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind continue]; + _4 = const 4_usize; + _5 = const 4_usize; - _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind continue]; ++ _6 = alloc::alloc::exchange_malloc(const 4_usize, const 4_usize) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff index e77c09848..ba2e89f0a 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff @@ -8,8 +8,9 @@ bb0: { StorageLive(_1); - _1 = const _; +- _1 = const _; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; ++ _1 = const false; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff index 7496d2543..e0a610f60 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff @@ -8,8 +8,9 @@ bb0: { StorageLive(_1); - _1 = const _; +- _1 = const _; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; ++ _1 = const false; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff index eef9282c2..ca0ce2888 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff @@ -18,7 +18,7 @@ - assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind unreachable]; + _2 = const 2_u8; + _3 = const (3_u8, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind unreachable]; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u8, const 1_u8) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff index ccfa35f00..d63fb9255 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff @@ -18,7 +18,7 @@ - assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; + _2 = const 2_u8; + _3 = const (3_u8, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u8, const 1_u8) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff index e0467e3fc..51e17cf69 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff @@ -23,7 +23,7 @@ - _4 = CheckedAdd(_2, _3); - assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable]; + _4 = const (0_u8, true); -+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable]; ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff index 4f8e0f0f5..5ef201497 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff @@ -23,7 +23,7 @@ - _4 = CheckedAdd(_2, _3); - assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; + _4 = const (0_u8, true); -+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff index 0c9d1f4a3..10e978a68 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -43,8 +43,9 @@ StorageLive(_5); _5 = InvalidTag { int: const 4_u32 }; - _4 = (_5.1: E); +- _3 = [move _4]; + _4 = const Scalar(0x00000004): E; - _3 = [move _4]; ++ _3 = [const Scalar(0x00000004): E]; StorageDead(_4); StorageDead(_5); nop; diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff index 516f13586..170c01978 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff @@ -8,8 +8,10 @@ bb0: { StorageLive(_2); - _2 = (const (), const 0_u8, const 0_u8); - _1 = encode(move _2) -> [return: bb1, unwind unreachable]; +- _2 = (const (), const 0_u8, const 0_u8); +- _1 = encode(move _2) -> [return: bb1, unwind unreachable]; ++ _2 = const ((), 0_u8, 0_u8); ++ _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff index 5e3443228..64227dfd7 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff @@ -8,8 +8,10 @@ bb0: { StorageLive(_2); - _2 = (const (), const 0_u8, const 0_u8); - _1 = encode(move _2) -> [return: bb1, unwind continue]; +- _2 = (const (), const 0_u8, const 0_u8); +- _1 = encode(move _2) -> [return: bb1, unwind continue]; ++ _2 = const ((), 0_u8, 0_u8); ++ _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff index 96b409372..e1f3f37b3 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff @@ -11,10 +11,12 @@ StorageLive(_2); StorageLive(_3); - _3 = (const 1_u8, const 2_u8); +- _2 = (move _3,); + _3 = const (1_u8, 2_u8); - _2 = (move _3,); ++ _2 = const ((1_u8, 2_u8),); StorageDead(_3); - _1 = test(move _2) -> [return: bb1, unwind unreachable]; +- _1 = test(move _2) -> [return: bb1, unwind unreachable]; ++ _1 = test(const ((1_u8, 2_u8),)) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff index 957760301..aaa376a95 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff @@ -11,10 +11,12 @@ StorageLive(_2); StorageLive(_3); - _3 = (const 1_u8, const 2_u8); +- _2 = (move _3,); + _3 = const (1_u8, 2_u8); - _2 = (move _3,); ++ _2 = const ((1_u8, 2_u8),); StorageDead(_3); - _1 = test(move _2) -> [return: bb1, unwind continue]; +- _1 = test(move _2) -> [return: bb1, unwind continue]; ++ _1 = test(const ((1_u8, 2_u8),)) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff index 61ba52fb0..20e2ee326 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + _4 = const 5000_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff index 658607116..1bdbbbf78 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 5000_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff index 61ba52fb0..20e2ee326 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + _4 = const 5000_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff index 658607116..1bdbbbf78 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff @@ -23,7 +23,7 @@ - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 5000_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff index 046a79b4b..c73d217ae 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff @@ -28,8 +28,9 @@ StorageLive(_1); StorageLive(_2); - _2 = OffsetOf(Alpha, [0]); +- _1 = must_use::(move _2) -> [return: bb1, unwind unreachable]; + _2 = const 4_usize; - _1 = must_use::(move _2) -> [return: bb1, unwind unreachable]; ++ _1 = must_use::(const 4_usize) -> [return: bb1, unwind unreachable]; } bb1: { @@ -37,8 +38,9 @@ StorageLive(_3); StorageLive(_4); - _4 = OffsetOf(Alpha, [1]); +- _3 = must_use::(move _4) -> [return: bb2, unwind unreachable]; + _4 = const 0_usize; - _3 = must_use::(move _4) -> [return: bb2, unwind unreachable]; ++ _3 = must_use::(const 0_usize) -> [return: bb2, unwind unreachable]; } bb2: { @@ -46,8 +48,9 @@ StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Alpha, [2, 0]); +- _5 = must_use::(move _6) -> [return: bb3, unwind unreachable]; + _6 = const 2_usize; - _5 = must_use::(move _6) -> [return: bb3, unwind unreachable]; ++ _5 = must_use::(const 2_usize) -> [return: bb3, unwind unreachable]; } bb3: { @@ -55,8 +58,9 @@ StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Alpha, [2, 1]); +- _7 = must_use::(move _8) -> [return: bb4, unwind unreachable]; + _8 = const 3_usize; - _7 = must_use::(move _8) -> [return: bb4, unwind unreachable]; ++ _7 = must_use::(const 3_usize) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff index bbb807d8f..913ffca4a 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff @@ -28,8 +28,9 @@ StorageLive(_1); StorageLive(_2); - _2 = OffsetOf(Alpha, [0]); +- _1 = must_use::(move _2) -> [return: bb1, unwind continue]; + _2 = const 4_usize; - _1 = must_use::(move _2) -> [return: bb1, unwind continue]; ++ _1 = must_use::(const 4_usize) -> [return: bb1, unwind continue]; } bb1: { @@ -37,8 +38,9 @@ StorageLive(_3); StorageLive(_4); - _4 = OffsetOf(Alpha, [1]); +- _3 = must_use::(move _4) -> [return: bb2, unwind continue]; + _4 = const 0_usize; - _3 = must_use::(move _4) -> [return: bb2, unwind continue]; ++ _3 = must_use::(const 0_usize) -> [return: bb2, unwind continue]; } bb2: { @@ -46,8 +48,9 @@ StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Alpha, [2, 0]); +- _5 = must_use::(move _6) -> [return: bb3, unwind continue]; + _6 = const 2_usize; - _5 = must_use::(move _6) -> [return: bb3, unwind continue]; ++ _5 = must_use::(const 2_usize) -> [return: bb3, unwind continue]; } bb3: { @@ -55,8 +58,9 @@ StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Alpha, [2, 1]); +- _7 = must_use::(move _8) -> [return: bb4, unwind continue]; + _8 = const 3_usize; - _7 = must_use::(move _8) -> [return: bb4, unwind continue]; ++ _7 = must_use::(const 3_usize) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff index e095dd01d..a55bd029e 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff @@ -25,7 +25,7 @@ - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; + _5 = const 8_usize; + _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff index 571f279a8..d49ef2e01 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff @@ -25,7 +25,7 @@ - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; + _5 = const 8_usize; + _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff index e095dd01d..a55bd029e 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff @@ -25,7 +25,7 @@ - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; + _5 = const 8_usize; + _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff index 571f279a8..d49ef2e01 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff @@ -25,7 +25,7 @@ - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; + _5 = const 8_usize; + _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff index 0677295d0..c5c09c8ed 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff @@ -16,8 +16,9 @@ StorageLive(_2); StorageLive(_3); - _3 = _1; +- _2 = consume(move _3) -> [return: bb1, unwind unreachable]; + _3 = const 1_u32; - _2 = consume(move _3) -> [return: bb1, unwind unreachable]; ++ _2 = consume(const 1_u32) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff index a7d7a7224..b256c5676 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff @@ -16,8 +16,9 @@ StorageLive(_2); StorageLive(_3); - _3 = _1; +- _2 = consume(move _3) -> [return: bb1, unwind continue]; + _3 = const 1_u32; - _2 = consume(move _3) -> [return: bb1, unwind continue]; ++ _2 = consume(const 1_u32) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff index 3c2b8e111..c2e1288b4 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff @@ -30,7 +30,7 @@ - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + _7 = const 3_usize; + _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff index 303096030..23646c3c9 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff @@ -30,7 +30,7 @@ - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _7 = const 3_usize; + _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff index 3c2b8e111..c2e1288b4 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff @@ -30,7 +30,7 @@ - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + _7 = const 3_usize; + _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff index 303096030..23646c3c9 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff @@ -30,7 +30,7 @@ - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _7 = const 3_usize; + _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff index a72f24152..9e705695a 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff @@ -17,8 +17,9 @@ StorageLive(_2); StorageLive(_3); - _3 = _1; +- _2 = consume(move _3) -> [return: bb1, unwind unreachable]; + _3 = const (1_u32, 2_u32); - _2 = consume(move _3) -> [return: bb1, unwind unreachable]; ++ _2 = consume(const (1_u32, 2_u32)) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff index 6255f9ec5..882dd97cc 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff @@ -17,8 +17,9 @@ StorageLive(_2); StorageLive(_3); - _3 = _1; +- _2 = consume(move _3) -> [return: bb1, unwind continue]; + _3 = const (1_u32, 2_u32); - _2 = consume(move _3) -> [return: bb1, unwind continue]; ++ _2 = consume(const (1_u32, 2_u32)) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index a89b64441..bf94dc57d 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -21,11 +21,11 @@ fn f() -> bool { let b = a; // We cannot propagate the place `a`. let r2 = &b; - Call(RET, next, cmp_ref(r1, r2)) + Call(RET = cmp_ref(r1, r2), next) } next = { // But we can propagate the value `a`. - Call(RET, ret, opaque(b)) + Call(RET = opaque(b), ret) } ret = { Return() diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index a90db08fa..d1c5ffdff 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -13,11 +13,11 @@ struct NotCopy(bool); fn f(_1: NotCopy) { mir!({ let _2 = _1; - Call(RET, bb1, opaque(Move(_1))) + Call(RET = opaque(Move(_1)), bb1) } bb1 = { let _3 = Move(_2); - Call(RET, bb2, opaque(_3)) + Call(RET = opaque(_3), bb2) } bb2 = { Return() diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index 40f51ce84..f94addb56 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -17,10 +17,10 @@ fn f(a: Foo) -> bool { let b = a; // This is a move out of a copy, so must become a copy of `a.0`. let c = Move(b.0); - Call(RET, bb1, opaque(Move(a))) + Call(RET = opaque(Move(a)), bb1) } bb1 = { - Call(RET, ret, opaque(Move(c))) + Call(RET = opaque(Move(c)), ret) } ret = { Return() diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.rs b/tests/mir-opt/copy-prop/mutate_through_pointer.rs index da142e339..753787089 100644 --- a/tests/mir-opt/copy-prop/mutate_through_pointer.rs +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.rs @@ -1,3 +1,5 @@ +// unit-test: CopyProp +// // This attempts to mutate `a` via a pointer derived from `addr_of!(a)`. That is UB // according to Miri. However, the decision to make this UB - and to allow // rustc to rely on that fact for the purpose of optimizations - has not been diff --git a/tests/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot b/tests/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot index 03df5c950..3b90aaeae 100644 --- a/tests/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot +++ b/tests/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot @@ -2,5 +2,5 @@ digraph Cov_0_4 { graph [fontname="Courier, monospace"]; node [fontname="Courier, monospace"]; edge [fontname="Courier, monospace"]; - bcb0__Cov_0_4 [shape="none", label=<
bcb0
Counter(bcb0) at 18:1-20:2
19:5-19:9: @0[0]: Coverage::Counter(1) for $DIR/coverage_graphviz.rs:18:1 - 20:2
20:2-20:2: @0.Return: return
bb0: Return
>]; + bcb0__Cov_0_4 [shape="none", label=<
bcb0
Counter(bcb0) at 18:1-20:2
19:5-19:9: @0[0]: Coverage::Counter(0) for $DIR/coverage_graphviz.rs:18:1 - 20:2
20:2-20:2: @0.Return: return
bb0: Return
>]; } diff --git a/tests/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot b/tests/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot index c4d389b2d..19c220e2e 100644 --- a/tests/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot +++ b/tests/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot @@ -2,8 +2,8 @@ digraph Cov_0_3 { graph [fontname="Courier, monospace"]; node [fontname="Courier, monospace"]; edge [fontname="Courier, monospace"]; - bcb3__Cov_0_3 [shape="none", label=<
bcb3
Counter(bcb3) at 13:10-13:10
13:10-13:10: @5[0]: Coverage::Counter(2) for $DIR/coverage_graphviz.rs:13:10 - 13:11
bb5: Goto
>]; - bcb2__Cov_0_3 [shape="none", label=<
bcb2
Expression(bcb1:(bcb0 + bcb3) - bcb3) at 12:13-12:18
12:13-12:18: @4[0]: Coverage::Expression(4294967293) = 4294967294 + 0 for $DIR/coverage_graphviz.rs:15:1 - 15:2
Expression(bcb2:(bcb1:(bcb0 + bcb3) - bcb3) + 0) at 15:2-15:2
15:2-15:2: @4.Return: return
bb4: Return
>]; + bcb3__Cov_0_3 [shape="none", label=<
bcb3
Counter(bcb3) at 13:10-13:10
13:10-13:10: @5[0]: Coverage::Counter(1) for $DIR/coverage_graphviz.rs:13:10 - 13:11
bb5: Goto
>]; + bcb2__Cov_0_3 [shape="none", label=<
bcb2
Expression(bcb1:(bcb0 + bcb3) - bcb3) at 12:13-12:18
12:13-12:18: @4[0]: Coverage::Expression(2) = Expression(1) + Zero for $DIR/coverage_graphviz.rs:15:1 - 15:2
Expression(bcb2:(bcb1:(bcb0 + bcb3) - bcb3) + 0) at 15:2-15:2
15:2-15:2: @4.Return: return
bb4: Return
>]; bcb1__Cov_0_3 [shape="none", label=<
bcb1
Expression(bcb0 + bcb3) at 10:5-11:17
11:12-11:17: @2.Call: _2 = bar() -> [return: bb3, unwind: bb6]
bb1: FalseUnwind
bb2: Call
bb3: SwitchInt
>]; bcb0__Cov_0_3 [shape="none", label=<
bcb0
Counter(bcb0) at 9:1-9:11
bb0: Goto
>]; bcb3__Cov_0_3 -> bcb1__Cov_0_3 [label=<>]; diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-abort.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-abort.diff new file mode 100644 index 000000000..8f799b33f --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-abort.diff @@ -0,0 +1,23 @@ +- // MIR for `move_simple` before DeadStoreElimination ++ // MIR for `move_simple` after DeadStoreElimination + + fn move_simple(_1: i32) -> () { + debug x => _1; + let mut _0: (); + let _2: (); +- let mut _3: i32; +- let mut _4: i32; + + bb0: { + StorageLive(_2); +- _2 = use_both(_1, _1) -> [return: bb1, unwind unreachable]; ++ _2 = use_both(_1, move _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-unwind.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-unwind.diff new file mode 100644 index 000000000..0551d663b --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-unwind.diff @@ -0,0 +1,23 @@ +- // MIR for `move_simple` before DeadStoreElimination ++ // MIR for `move_simple` after DeadStoreElimination + + fn move_simple(_1: i32) -> () { + debug x => _1; + let mut _0: (); + let _2: (); +- let mut _3: i32; +- let mut _4: i32; + + bb0: { + StorageLive(_2); +- _2 = use_both(_1, _1) -> [return: bb1, unwind continue]; ++ _2 = use_both(_1, move _1) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs new file mode 100644 index 000000000..41f91fc13 --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs @@ -0,0 +1,15 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// unit-test: DeadStoreElimination +// compile-flags: -Zmir-enable-passes=+CopyProp + +#[inline(never)] +fn use_both(_: i32, _: i32) {} + +// EMIT_MIR call_arg_copy.move_simple.DeadStoreElimination.diff +fn move_simple(x: i32) { + use_both(x, x); +} + +fn main() { + move_simple(1); +} diff --git a/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff index f3f4d895a..8f2baf4a3 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff @@ -5,13 +5,10 @@ let mut _0: (); let _1: (); + let mut _2: fn() {main}; -+ let mut _5: (); + scope 1 (inlined f::) { + debug g => _2; + let mut _3: &fn() {main}; + let _4: (); -+ scope 2 (inlined >::call - shim(fn() {main})) { -+ } + } bb0: { @@ -22,9 +19,7 @@ + StorageLive(_4); + StorageLive(_3); + _3 = &_2; -+ StorageLive(_5); -+ _5 = const (); -+ _4 = move (*_3)() -> [return: bb2, unwind unreachable]; ++ _4 = >::call(move _3, const ()) -> [return: bb2, unwind unreachable]; } bb1: { @@ -36,7 +31,6 @@ + } + + bb2: { -+ StorageDead(_5); + StorageDead(_3); + drop(_2) -> [return: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff index 3ce8d9acf..ad801fd28 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff @@ -5,13 +5,10 @@ let mut _0: (); let _1: (); + let mut _2: fn() {main}; -+ let mut _5: (); + scope 1 (inlined f::) { + debug g => _2; + let mut _3: &fn() {main}; + let _4: (); -+ scope 2 (inlined >::call - shim(fn() {main})) { -+ } + } bb0: { @@ -22,9 +19,7 @@ + StorageLive(_4); + StorageLive(_3); + _3 = &_2; -+ StorageLive(_5); -+ _5 = const (); -+ _4 = move (*_3)() -> [return: bb4, unwind: bb2]; ++ _4 = >::call(move _3, const ()) -> [return: bb2, unwind: bb3]; } bb1: { @@ -35,18 +30,17 @@ return; + } + -+ bb2 (cleanup): { -+ drop(_2) -> [return: bb3, unwind terminate]; ++ bb2: { ++ StorageDead(_3); ++ drop(_2) -> [return: bb1, unwind continue]; + } + + bb3 (cleanup): { -+ resume; ++ drop(_2) -> [return: bb4, unwind terminate]; + } + -+ bb4: { -+ StorageDead(_5); -+ StorageDead(_3); -+ drop(_2) -> [return: bb1, unwind continue]; ++ bb4 (cleanup): { ++ resume; } } diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff index eb0076354..fd1f698c6 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff @@ -5,21 +5,10 @@ let mut _0: (); let _1: (); + let mut _2: fn() {g}; -+ let mut _5: (); + scope 1 (inlined f::) { + debug g => _2; + let mut _3: &fn() {g}; + let _4: (); -+ scope 2 (inlined >::call - shim(fn() {g})) { -+ scope 3 (inlined g) { -+ scope 4 (inlined f::) { -+ debug g => main; -+ let _6: (); -+ scope 5 (inlined >::call - shim(fn() {main})) { -+ } -+ } -+ } -+ } + } bb0: { @@ -30,10 +19,7 @@ + StorageLive(_4); + StorageLive(_3); + _3 = &_2; -+ StorageLive(_5); -+ _5 = const (); -+ StorageLive(_6); -+ _6 = main() -> [return: bb2, unwind unreachable]; ++ _4 = >::call(move _3, const ()) -> [return: bb2, unwind unreachable]; } bb1: { @@ -45,8 +31,6 @@ + } + + bb2: { -+ StorageDead(_6); -+ StorageDead(_5); + StorageDead(_3); + drop(_2) -> [return: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff index 198a23226..99dc64115 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff @@ -5,21 +5,10 @@ let mut _0: (); let _1: (); + let mut _2: fn() {g}; -+ let mut _5: (); + scope 1 (inlined f::) { + debug g => _2; + let mut _3: &fn() {g}; + let _4: (); -+ scope 2 (inlined >::call - shim(fn() {g})) { -+ scope 3 (inlined g) { -+ scope 4 (inlined f::) { -+ debug g => main; -+ let _6: (); -+ scope 5 (inlined >::call - shim(fn() {main})) { -+ } -+ } -+ } -+ } + } bb0: { @@ -30,10 +19,7 @@ + StorageLive(_4); + StorageLive(_3); + _3 = &_2; -+ StorageLive(_5); -+ _5 = const (); -+ StorageLive(_6); -+ _6 = main() -> [return: bb4, unwind: bb2]; ++ _4 = >::call(move _3, const ()) -> [return: bb2, unwind: bb3]; } bb1: { @@ -44,19 +30,17 @@ return; + } + -+ bb2 (cleanup): { -+ drop(_2) -> [return: bb3, unwind terminate]; ++ bb2: { ++ StorageDead(_3); ++ drop(_2) -> [return: bb1, unwind continue]; + } + + bb3 (cleanup): { -+ resume; ++ drop(_2) -> [return: bb4, unwind terminate]; + } + -+ bb4: { -+ StorageDead(_6); -+ StorageDead(_5); -+ StorageDead(_3); -+ drop(_2) -> [return: bb1, unwind continue]; ++ bb4 (cleanup): { ++ resume; } } diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff new file mode 100644 index 000000000..757617e59 --- /dev/null +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff @@ -0,0 +1,29 @@ +- // MIR for `call` before Inline ++ // MIR for `call` after Inline + + fn call(_1: Box>, _2: I) -> () { + debug mock => _1; + debug input => _2; + let mut _0: (); + let mut _3: &mut std::boxed::Box>; + let mut _4: I; + + bb0: { + StorageLive(_3); + _3 = &mut _1; + StorageLive(_4); + _4 = move _2; + _0 = > as FnMut>::call_mut(move _3, move _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + drop(_1) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff new file mode 100644 index 000000000..ef85e075e --- /dev/null +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff @@ -0,0 +1,37 @@ +- // MIR for `call` before Inline ++ // MIR for `call` after Inline + + fn call(_1: Box>, _2: I) -> () { + debug mock => _1; + debug input => _2; + let mut _0: (); + let mut _3: &mut std::boxed::Box>; + let mut _4: I; + + bb0: { + StorageLive(_3); + _3 = &mut _1; + StorageLive(_4); + _4 = move _2; + _0 = > as FnMut>::call_mut(move _3, move _4) -> [return: bb1, unwind: bb3]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + drop(_1) -> [return: bb2, unwind: bb4]; + } + + bb2: { + return; + } + + bb3 (cleanup): { + drop(_1) -> [return: bb4, unwind terminate]; + } + + bb4 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs new file mode 100644 index 000000000..971223c72 --- /dev/null +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs @@ -0,0 +1,11 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib + +#![feature(fn_traits, tuple_trait, unboxed_closures)] + +use std::marker::Tuple; + +// EMIT_MIR dont_ice_on_generic_rust_call.call.Inline.diff +pub fn call(mut mock: Box>, input: I) { + mock.call_mut(input) +} diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff index 57b0849e1..9d5042caa 100644 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff @@ -32,7 +32,7 @@ - _0 = try_execute_query::<::C>(move _4) -> [return: bb2, unwind unreachable]; + StorageLive(_5); + _5 = _4 as &dyn Cache::V> (PointerCoercion(Unsize)); -+ _0 = ::V> as Cache>::store_nocache(_5) -> [return: bb2, unwind unreachable]; ++ _0 = ::V> as Cache>::store_nocache(move _5) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff index 706c1d481..9bd3855c5 100644 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff @@ -32,7 +32,7 @@ - _0 = try_execute_query::<::C>(move _4) -> [return: bb2, unwind continue]; + StorageLive(_5); + _5 = _4 as &dyn Cache::V> (PointerCoercion(Unsize)); -+ _0 = ::V> as Cache>::store_nocache(_5) -> [return: bb2, unwind continue]; ++ _0 = ::V> as Cache>::store_nocache(move _5) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff index 9a6d3596f..96e16d023 100644 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff @@ -17,7 +17,7 @@ _2 = move _3 as &dyn Cache::V> (PointerCoercion(Unsize)); StorageDead(_3); - _0 = mk_cycle::<::V>(move _2) -> [return: bb1, unwind unreachable]; -+ _0 = ::V> as Cache>::store_nocache(_2) -> [return: bb1, unwind unreachable]; ++ _0 = ::V> as Cache>::store_nocache(move _2) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff index 1a08df2b0..06d65abcb 100644 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff @@ -17,7 +17,7 @@ _2 = move _3 as &dyn Cache::V> (PointerCoercion(Unsize)); StorageDead(_3); - _0 = mk_cycle::<::V>(move _2) -> [return: bb1, unwind continue]; -+ _0 = ::V> as Cache>::store_nocache(_2) -> [return: bb1, unwind continue]; ++ _0 = ::V> as Cache>::store_nocache(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff new file mode 100644 index 000000000..4fa04b05e --- /dev/null +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff @@ -0,0 +1,32 @@ +- // MIR for `call` before Inline ++ // MIR for `call` after Inline + + fn call(_1: Box) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: &std::boxed::Box; + let mut _4: (i32,); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + StorageLive(_4); + _4 = (const 1_i32,); + _2 = as Fn<(i32,)>>::call(move _3, move _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff new file mode 100644 index 000000000..5df730a99 --- /dev/null +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff @@ -0,0 +1,40 @@ +- // MIR for `call` before Inline ++ // MIR for `call` after Inline + + fn call(_1: Box) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: &std::boxed::Box; + let mut _4: (i32,); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + StorageLive(_4); + _4 = (const 1_i32,); + _2 = as Fn<(i32,)>>::call(move _3, move _4) -> [return: bb1, unwind: bb3]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb2, unwind: bb4]; + } + + bb2: { + return; + } + + bb3 (cleanup): { + drop(_1) -> [return: bb4, unwind terminate]; + } + + bb4 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/inline/inline_box_fn.rs b/tests/mir-opt/inline/inline_box_fn.rs new file mode 100644 index 000000000..348f0e77f --- /dev/null +++ b/tests/mir-opt/inline/inline_box_fn.rs @@ -0,0 +1,8 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// unit-test: Inline +// compile-flags: --crate-type=lib + +// EMIT_MIR inline_box_fn.call.Inline.diff +fn call(x: Box) { + x(1); +} diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff index d83c8d585..8a6eec335 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff @@ -5,20 +5,9 @@ let mut _0: (); let _1: (); + let mut _2: fn() {f}; -+ let mut _4: (); + scope 1 (inlined call::) { + debug f => _2; + let _3: (); -+ scope 2 (inlined >::call_once - shim(fn() {f})) { -+ scope 3 (inlined f) { -+ scope 4 (inlined call::) { -+ debug f => f; -+ let _5: (); -+ scope 5 (inlined >::call_once - shim(fn() {f})) { -+ } -+ } -+ } -+ } + } bb0: { @@ -27,15 +16,10 @@ + StorageLive(_2); + _2 = f; + StorageLive(_3); -+ StorageLive(_4); -+ _4 = const (); -+ StorageLive(_5); -+ _5 = f() -> [return: bb1, unwind unreachable]; ++ _3 = >::call_once(move _2, const ()) -> [return: bb1, unwind unreachable]; } bb1: { -+ StorageDead(_5); -+ StorageDead(_4); + StorageDead(_3); + StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff index a08662959..a24649c1e 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff @@ -5,20 +5,9 @@ let mut _0: (); let _1: (); + let mut _2: fn() {f}; -+ let mut _4: (); + scope 1 (inlined call::) { + debug f => _2; + let _3: (); -+ scope 2 (inlined >::call_once - shim(fn() {f})) { -+ scope 3 (inlined f) { -+ scope 4 (inlined call::) { -+ debug f => f; -+ let _5: (); -+ scope 5 (inlined >::call_once - shim(fn() {f})) { -+ } -+ } -+ } -+ } + } bb0: { @@ -27,15 +16,10 @@ + StorageLive(_2); + _2 = f; + StorageLive(_3); -+ StorageLive(_4); -+ _4 = const (); -+ StorageLive(_5); -+ _5 = f() -> [return: bb1, unwind continue]; ++ _3 = >::call_once(move _2, const ()) -> [return: bb1, unwind continue]; } bb1: { -+ StorageDead(_5); -+ StorageDead(_4); + StorageDead(_3); + StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff index 0dcd5fae8..7d5553b2f 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff @@ -5,7 +5,6 @@ let mut _0: (); let _1: (!, !); + let mut _2: fn() -> ! {sleep}; -+ let mut _7: (); + scope 1 (inlined call_twice:: ! {sleep}>) { + debug f => _2; + let mut _3: &fn() -> ! {sleep}; @@ -18,10 +17,6 @@ + debug b => _6; + } + } -+ scope 4 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { -+ scope 5 (inlined sleep) { -+ } -+ } + } bb0: { @@ -33,13 +28,24 @@ + StorageLive(_6); + StorageLive(_3); + _3 = &_2; -+ StorageLive(_7); -+ _7 = const (); -+ goto -> bb1; ++ _4 = ! {sleep} as Fn<()>>::call(move _3, const ()) -> [return: bb1, unwind unreachable]; + } + + bb1: { -+ goto -> bb1; ++ StorageDead(_3); ++ StorageLive(_5); ++ _5 = &_2; ++ _6 = ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb2, unwind unreachable]; ++ } ++ ++ bb2: { ++ StorageDead(_5); ++ _1 = (move _4, move _6); ++ drop(_2) -> [return: bb3, unwind unreachable]; ++ } ++ ++ bb3: { ++ unreachable; } } diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff index dfc12db12..073ddeff7 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -5,7 +5,6 @@ let mut _0: (); let _1: (!, !); + let mut _2: fn() -> ! {sleep}; -+ let mut _8: (); + scope 1 (inlined call_twice:: ! {sleep}>) { + debug f => _2; + let mut _3: &fn() -> ! {sleep}; @@ -19,10 +18,6 @@ + debug b => _6; + } + } -+ scope 4 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { -+ scope 5 (inlined sleep) { -+ } -+ } + } bb0: { @@ -34,13 +29,40 @@ + StorageLive(_4); + StorageLive(_3); + _3 = &_2; -+ StorageLive(_8); -+ _8 = const (); -+ goto -> bb1; ++ _4 = ! {sleep} as Fn<()>>::call(move _3, const ()) -> [return: bb1, unwind: bb5]; + } + + bb1: { -+ goto -> bb1; ++ StorageDead(_3); ++ StorageLive(_5); ++ _5 = &_2; ++ _6 = ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb2, unwind: bb4]; ++ } ++ ++ bb2: { ++ StorageDead(_5); ++ StorageLive(_7); ++ _7 = move _4; ++ _1 = (move _7, move _6); ++ StorageDead(_7); ++ StorageDead(_4); ++ drop(_2) -> [return: bb3, unwind continue]; ++ } ++ ++ bb3: { ++ unreachable; ++ } ++ ++ bb4 (cleanup): { ++ drop(_4) -> [return: bb5, unwind terminate]; ++ } ++ ++ bb5 (cleanup): { ++ drop(_2) -> [return: bb6, unwind terminate]; ++ } ++ ++ bb6 (cleanup): { ++ resume; } } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff index 3848196ec..dc0ab255a 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff @@ -33,37 +33,36 @@ + debug ptr => _11; + scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { + debug self => _11; -+ let mut _16: std::ptr::NonNull; ++ let mut _15: std::ptr::NonNull; + scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { + debug self => _11; -+ let mut _17: *mut u8; -+ let mut _18: *mut [u8]; ++ let mut _16: *mut u8; ++ let mut _17: *mut [u8]; + scope 20 { + scope 21 (inlined NonNull::<[u8]>::as_ptr) { + debug self => _11; -+ let mut _19: *const [u8]; ++ let mut _18: *const [u8]; + } + scope 22 (inlined ptr::mut_ptr::::as_mut_ptr) { -+ debug self => _18; ++ debug self => _17; + } + scope 23 (inlined NonNull::::new_unchecked) { -+ debug ptr => _17; -+ let mut _20: *const u8; -+ let mut _21: *mut u8; ++ debug ptr => _16; ++ let mut _19: *const u8; + scope 24 { + scope 25 (inlined NonNull::::new_unchecked::runtime::) { -+ debug ptr => _21; ++ debug ptr => _16; + scope 26 (inlined ptr::mut_ptr::::is_null) { -+ debug self => _21; -+ let mut _22: *mut u8; ++ debug self => _16; ++ let mut _20: *mut u8; + scope 27 { + scope 28 (inlined ptr::mut_ptr::::is_null::runtime_impl) { -+ debug ptr => _22; ++ debug ptr => _20; + scope 29 (inlined ptr::mut_ptr::::addr) { -+ debug self => _22; ++ debug self => _20; + scope 30 { + scope 31 (inlined ptr::mut_ptr::::cast::<()>) { -+ debug self => _22; ++ debug self => _20; + } + } + } @@ -76,8 +75,8 @@ + } + } + scope 32 (inlined NonNull::::as_ptr) { -+ debug self => _16; -+ let mut _23: *const u8; ++ debug self => _15; ++ let mut _21: *const u8; + } + } + } @@ -94,14 +93,13 @@ + scope 10 { + scope 11 (inlined std::ptr::Alignment::new_unchecked) { + debug align => _5; -+ let mut _15: usize; + scope 12 { + scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { -+ debug align => _15; ++ debug align => _5; + scope 15 (inlined core::num::::is_power_of_two) { -+ debug self => _15; ++ debug self => _5; + scope 16 (inlined core::num::::count_ones) { -+ debug self => _15; ++ debug self => _5; + } + } + } @@ -131,14 +129,12 @@ + StorageLive(_12); + StorageLive(_13); + StorageLive(_14); -+ StorageLive(_15); + _14 = _5 as std::ptr::Alignment (Transmute); -+ StorageDead(_15); + _8 = Layout { size: _4, align: move _14 }; + StorageDead(_14); + StorageLive(_9); + _13 = const _; -+ _9 = std::alloc::Global::alloc_impl(_13, _8, const false) -> [return: bb5, unwind unreachable]; ++ _9 = std::alloc::Global::alloc_impl(move _13, _8, const false) -> [return: bb5, unwind unreachable]; } bb1: { @@ -148,7 +144,7 @@ } bb2: { -+ _12 = handle_alloc_error(_8) -> unwind unreachable; ++ _12 = handle_alloc_error(move _8) -> unwind unreachable; + } + + bb3: { @@ -157,29 +153,27 @@ + + bb4: { + _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); ++ StorageLive(_15); + StorageLive(_16); + StorageLive(_17); + StorageLive(_18); -+ StorageLive(_19); -+ _19 = (_11.0: *const [u8]); -+ _18 = move _19 as *mut [u8] (PtrToPtr); -+ StorageDead(_19); -+ _17 = _18 as *mut u8 (PtrToPtr); ++ _18 = (_11.0: *const [u8]); ++ _17 = move _18 as *mut [u8] (PtrToPtr); + StorageDead(_18); ++ _16 = _17 as *mut u8 (PtrToPtr); ++ StorageDead(_17); ++ StorageLive(_19); + StorageLive(_20); -+ StorageLive(_21); -+ StorageLive(_22); -+ _20 = _17 as *const u8 (PointerCoercion(MutToConstPointer)); -+ _16 = NonNull:: { pointer: _20 }; -+ StorageDead(_22); -+ StorageDead(_21); ++ _19 = _16 as *const u8 (PointerCoercion(MutToConstPointer)); ++ _15 = NonNull:: { pointer: _19 }; + StorageDead(_20); -+ StorageDead(_17); -+ StorageLive(_23); -+ _23 = (_16.0: *const u8); -+ _6 = move _23 as *mut u8 (PtrToPtr); -+ StorageDead(_23); ++ StorageDead(_19); + StorageDead(_16); ++ StorageLive(_21); ++ _21 = (_15.0: *const u8); ++ _6 = move _21 as *mut u8 (PtrToPtr); ++ StorageDead(_21); ++ StorageDead(_15); + StorageDead(_9); + StorageDead(_13); + StorageDead(_12); diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff index 80b5810aa..54c33aac9 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff @@ -33,37 +33,36 @@ + debug ptr => _11; + scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { + debug self => _11; -+ let mut _16: std::ptr::NonNull; ++ let mut _15: std::ptr::NonNull; + scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { + debug self => _11; -+ let mut _17: *mut u8; -+ let mut _18: *mut [u8]; ++ let mut _16: *mut u8; ++ let mut _17: *mut [u8]; + scope 20 { + scope 21 (inlined NonNull::<[u8]>::as_ptr) { + debug self => _11; -+ let mut _19: *const [u8]; ++ let mut _18: *const [u8]; + } + scope 22 (inlined ptr::mut_ptr::::as_mut_ptr) { -+ debug self => _18; ++ debug self => _17; + } + scope 23 (inlined NonNull::::new_unchecked) { -+ debug ptr => _17; -+ let mut _20: *const u8; -+ let mut _21: *mut u8; ++ debug ptr => _16; ++ let mut _19: *const u8; + scope 24 { + scope 25 (inlined NonNull::::new_unchecked::runtime::) { -+ debug ptr => _21; ++ debug ptr => _16; + scope 26 (inlined ptr::mut_ptr::::is_null) { -+ debug self => _21; -+ let mut _22: *mut u8; ++ debug self => _16; ++ let mut _20: *mut u8; + scope 27 { + scope 28 (inlined ptr::mut_ptr::::is_null::runtime_impl) { -+ debug ptr => _22; ++ debug ptr => _20; + scope 29 (inlined ptr::mut_ptr::::addr) { -+ debug self => _22; ++ debug self => _20; + scope 30 { + scope 31 (inlined ptr::mut_ptr::::cast::<()>) { -+ debug self => _22; ++ debug self => _20; + } + } + } @@ -76,8 +75,8 @@ + } + } + scope 32 (inlined NonNull::::as_ptr) { -+ debug self => _16; -+ let mut _23: *const u8; ++ debug self => _15; ++ let mut _21: *const u8; + } + } + } @@ -94,14 +93,13 @@ + scope 10 { + scope 11 (inlined std::ptr::Alignment::new_unchecked) { + debug align => _5; -+ let mut _15: usize; + scope 12 { + scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { -+ debug align => _15; ++ debug align => _5; + scope 15 (inlined core::num::::is_power_of_two) { -+ debug self => _15; ++ debug self => _5; + scope 16 (inlined core::num::::count_ones) { -+ debug self => _15; ++ debug self => _5; + } + } + } @@ -131,14 +129,12 @@ + StorageLive(_12); + StorageLive(_13); + StorageLive(_14); -+ StorageLive(_15); + _14 = _5 as std::ptr::Alignment (Transmute); -+ StorageDead(_15); + _8 = Layout { size: _4, align: move _14 }; + StorageDead(_14); + StorageLive(_9); + _13 = const _; -+ _9 = std::alloc::Global::alloc_impl(_13, _8, const false) -> [return: bb7, unwind: bb3]; ++ _9 = std::alloc::Global::alloc_impl(move _13, _8, const false) -> [return: bb7, unwind: bb3]; } bb1: { @@ -165,7 +161,7 @@ - bb4 (cleanup): { - resume; + bb4: { -+ _12 = handle_alloc_error(_8) -> bb3; ++ _12 = handle_alloc_error(move _8) -> bb3; + } + + bb5: { @@ -174,29 +170,27 @@ + + bb6: { + _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); ++ StorageLive(_15); + StorageLive(_16); + StorageLive(_17); + StorageLive(_18); -+ StorageLive(_19); -+ _19 = (_11.0: *const [u8]); -+ _18 = move _19 as *mut [u8] (PtrToPtr); -+ StorageDead(_19); -+ _17 = _18 as *mut u8 (PtrToPtr); ++ _18 = (_11.0: *const [u8]); ++ _17 = move _18 as *mut [u8] (PtrToPtr); + StorageDead(_18); ++ _16 = _17 as *mut u8 (PtrToPtr); ++ StorageDead(_17); ++ StorageLive(_19); + StorageLive(_20); -+ StorageLive(_21); -+ StorageLive(_22); -+ _20 = _17 as *const u8 (PointerCoercion(MutToConstPointer)); -+ _16 = NonNull:: { pointer: _20 }; -+ StorageDead(_22); -+ StorageDead(_21); ++ _19 = _16 as *const u8 (PointerCoercion(MutToConstPointer)); ++ _15 = NonNull:: { pointer: _19 }; + StorageDead(_20); -+ StorageDead(_17); -+ StorageLive(_23); -+ _23 = (_16.0: *const u8); -+ _6 = move _23 as *mut u8 (PtrToPtr); -+ StorageDead(_23); ++ StorageDead(_19); + StorageDead(_16); ++ StorageLive(_21); ++ _21 = (_15.0: *const u8); ++ _6 = move _21 as *mut u8 (PtrToPtr); ++ StorageDead(_21); ++ StorageDead(_15); + StorageDead(_9); + StorageDead(_13); + StorageDead(_12); diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir index 503f15308..f0d1cfe03 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir @@ -15,7 +15,7 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); _2 = move _3 as &dyn X (PointerCoercion(Unsize)); StorageDead(_3); - _0 = ::y(_2) -> [return: bb1, unwind unreachable]; + _0 = ::y(move _2) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir index 37bb53e79..f37b08143 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir @@ -15,7 +15,7 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); _2 = move _3 as &dyn X (PointerCoercion(Unsize)); StorageDead(_3); - _0 = ::y(_2) -> [return: bb1, unwind continue]; + _0 = ::y(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff index b86eb5f35..bee01a5f9 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff @@ -8,8 +8,6 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); -+ scope 1 (inlined >::call - shim(fn() {foo})) { -+ } bb0: { StorageLive(_2); @@ -22,26 +20,20 @@ _3 = &_4; StorageLive(_5); _5 = (); -- _2 = >::call(move _3, move _5) -> [return: bb2, unwind unreachable]; -+ _2 = move (*_3)() -> [return: bb3, unwind unreachable]; + _2 = >::call(move _3, move _5) -> [return: bb2, unwind unreachable]; } bb2: { -+ return; -+ } -+ -+ bb3: { StorageDead(_5); StorageDead(_3); StorageDead(_4); StorageDead(_2); _0 = const (); -- drop(_1) -> [return: bb3, unwind unreachable]; -- } -- -- bb3: { -- return; -+ drop(_1) -> [return: bb2, unwind unreachable]; + drop(_1) -> [return: bb3, unwind unreachable]; + } + + bb3: { + return; } } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff index c67babba2..b750330df 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -8,55 +8,40 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); -+ scope 1 (inlined >::call - shim(fn() {foo})) { -+ } bb0: { StorageLive(_2); StorageLive(_3); StorageLive(_4); -- _4 = hide_foo() -> [return: bb1, unwind: bb4]; -+ _4 = hide_foo() -> [return: bb1, unwind: bb3]; + _4 = hide_foo() -> [return: bb1, unwind: bb4]; } bb1: { _3 = &_4; StorageLive(_5); _5 = (); -- _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; -+ _2 = move (*_3)() -> [return: bb5, unwind: bb3]; + _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; } bb2: { -- StorageDead(_5); -- StorageDead(_3); -- StorageDead(_4); -- StorageDead(_2); -- _0 = const (); -- drop(_1) -> [return: bb3, unwind: bb5]; -+ return; + StorageDead(_5); + StorageDead(_3); + StorageDead(_4); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb3, unwind: bb5]; } -- bb3: { -- return; -+ bb3 (cleanup): { -+ drop(_1) -> [return: bb4, unwind terminate]; + bb3: { + return; } bb4 (cleanup): { -- drop(_1) -> [return: bb5, unwind terminate]; -+ resume; + drop(_1) -> [return: bb5, unwind terminate]; } -- bb5 (cleanup): { -- resume; -+ bb5: { -+ StorageDead(_5); -+ StorageDead(_3); -+ StorageDead(_4); -+ StorageDead(_2); -+ _0 = const (); -+ drop(_1) -> [return: bb2, unwind: bb4]; + bb5 (cleanup): { + resume; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index 90b32247c..d05221966 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -12,7 +12,6 @@ + debug rhs => _4; + let mut _5: u16; + let mut _6: bool; -+ let mut _7: u32; + scope 2 { + } + } @@ -28,10 +27,7 @@ - bb1: { + StorageLive(_5); + StorageLive(_6); -+ StorageLive(_7); -+ _7 = const 65535_u32; -+ _6 = Le(_4, move _7); -+ StorageDead(_7); ++ _6 = Le(_4, const 65535_u32); + assume(move _6); + StorageDead(_6); + _5 = _4 as u16 (IntToInt); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index cae25759c..67a5ac248 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -12,7 +12,6 @@ + debug rhs => _4; + let mut _5: u16; + let mut _6: bool; -+ let mut _7: u32; + scope 2 { + } + } @@ -28,10 +27,7 @@ - bb1: { + StorageLive(_5); + StorageLive(_6); -+ StorageLive(_7); -+ _7 = const 65535_u32; -+ _6 = Le(_4, move _7); -+ StorageDead(_7); ++ _6 = Le(_4, const 65535_u32); + assume(move _6); + StorageDead(_6); + _5 = _4 as u16 (IntToInt); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir index 3f388a69d..f9dff62e0 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir @@ -7,25 +7,21 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { scope 1 (inlined core::num::::unchecked_shl) { debug self => _1; debug rhs => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: u16; + let mut _3: bool; + let mut _4: u16; scope 2 { } } bb0: { - StorageLive(_5); StorageLive(_4); StorageLive(_3); - _3 = const 65535_u32; - _4 = Le(_2, move _3); + _3 = Le(_2, const 65535_u32); + assume(move _3); StorageDead(_3); - assume(move _4); + _4 = _2 as u16 (IntToInt); + _0 = ShlUnchecked(_1, move _4); StorageDead(_4); - _5 = _2 as u16 (IntToInt); - _0 = ShlUnchecked(_1, move _5); - StorageDead(_5); return; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir index 3f388a69d..f9dff62e0 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir @@ -7,25 +7,21 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { scope 1 (inlined core::num::::unchecked_shl) { debug self => _1; debug rhs => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: u16; + let mut _3: bool; + let mut _4: u16; scope 2 { } } bb0: { - StorageLive(_5); StorageLive(_4); StorageLive(_3); - _3 = const 65535_u32; - _4 = Le(_2, move _3); + _3 = Le(_2, const 65535_u32); + assume(move _3); StorageDead(_3); - assume(move _4); + _4 = _2 as u16 (IntToInt); + _0 = ShlUnchecked(_1, move _4); StorageDead(_4); - _5 = _2 as u16 (IntToInt); - _0 = ShlUnchecked(_1, move _5); - StorageDead(_5); return; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff index fa7e5d16e..15b36b284 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff @@ -12,7 +12,6 @@ + debug rhs => _4; + let mut _5: i16; + let mut _6: bool; -+ let mut _7: u32; + scope 2 { + } + } @@ -28,10 +27,7 @@ - bb1: { + StorageLive(_5); + StorageLive(_6); -+ StorageLive(_7); -+ _7 = const 32767_u32; -+ _6 = Le(_4, move _7); -+ StorageDead(_7); ++ _6 = Le(_4, const 32767_u32); + assume(move _6); + StorageDead(_6); + _5 = _4 as i16 (IntToInt); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff index fe5331214..8629f92db 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff @@ -12,7 +12,6 @@ + debug rhs => _4; + let mut _5: i16; + let mut _6: bool; -+ let mut _7: u32; + scope 2 { + } + } @@ -28,10 +27,7 @@ - bb1: { + StorageLive(_5); + StorageLive(_6); -+ StorageLive(_7); -+ _7 = const 32767_u32; -+ _6 = Le(_4, move _7); -+ StorageDead(_7); ++ _6 = Le(_4, const 32767_u32); + assume(move _6); + StorageDead(_6); + _5 = _4 as i16 (IntToInt); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir index 64ea25349..65fa0d956 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir @@ -7,25 +7,21 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { scope 1 (inlined core::num::::unchecked_shr) { debug self => _1; debug rhs => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: i16; + let mut _3: bool; + let mut _4: i16; scope 2 { } } bb0: { - StorageLive(_5); StorageLive(_4); StorageLive(_3); - _3 = const 32767_u32; - _4 = Le(_2, move _3); + _3 = Le(_2, const 32767_u32); + assume(move _3); StorageDead(_3); - assume(move _4); + _4 = _2 as i16 (IntToInt); + _0 = ShrUnchecked(_1, move _4); StorageDead(_4); - _5 = _2 as i16 (IntToInt); - _0 = ShrUnchecked(_1, move _5); - StorageDead(_5); return; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir index 64ea25349..65fa0d956 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir @@ -7,25 +7,21 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { scope 1 (inlined core::num::::unchecked_shr) { debug self => _1; debug rhs => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: i16; + let mut _3: bool; + let mut _4: i16; scope 2 { } } bb0: { - StorageLive(_5); StorageLive(_4); StorageLive(_3); - _3 = const 32767_u32; - _4 = Le(_2, move _3); + _3 = Le(_2, const 32767_u32); + assume(move _3); StorageDead(_3); - assume(move _4); + _4 = _2 as i16 (IntToInt); + _0 = ShrUnchecked(_1, move _4); StorageDead(_4); - _5 = _2 as i16 (IntToInt); - _0 = ShrUnchecked(_1, move _5); - StorageDead(_5); return; } } diff --git a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff index 0aece766b..afcfde09c 100644 --- a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff @@ -5,7 +5,7 @@ let mut _0: bool; bb0: { -+ Coverage::Counter(1) for /the/src/instrument_coverage.rs:20:1 - 22:2; ++ Coverage::Counter(0) for /the/src/instrument_coverage.rs:20:1 - 22:2; _0 = const true; return; } diff --git a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff index 7ec9011a5..e17c6ddc5 100644 --- a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff @@ -8,12 +8,12 @@ let mut _3: !; bb0: { -+ Coverage::Counter(1) for /the/src/instrument_coverage.rs:11:1 - 11:11; ++ Coverage::Counter(0) for /the/src/instrument_coverage.rs:11:1 - 11:11; goto -> bb1; } bb1: { -+ Coverage::Expression(4294967295) = 1 + 2 for /the/src/instrument_coverage.rs:12:5 - 13:17; ++ Coverage::Expression(0) = Counter(0) + Counter(1) for /the/src/instrument_coverage.rs:12:5 - 13:17; falseUnwind -> [real: bb2, unwind: bb6]; } @@ -27,15 +27,15 @@ } bb4: { -+ Coverage::Expression(4294967293) = 4294967294 + 0 for /the/src/instrument_coverage.rs:17:1 - 17:2; -+ Coverage::Expression(4294967294) = 4294967295 - 2 for /the/src/instrument_coverage.rs:14:13 - 14:18; ++ Coverage::Expression(2) = Expression(1) + Zero for /the/src/instrument_coverage.rs:17:1 - 17:2; ++ Coverage::Expression(1) = Expression(0) - Counter(1) for /the/src/instrument_coverage.rs:14:13 - 14:18; _0 = const (); StorageDead(_2); return; } bb5: { -+ Coverage::Counter(2) for /the/src/instrument_coverage.rs:15:10 - 15:11; ++ Coverage::Counter(1) for /the/src/instrument_coverage.rs:15:10 - 15:11; _1 = const (); StorageDead(_2); goto -> bb1; diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff b/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff index e018563db..ce490e894 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff +++ b/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff @@ -66,7 +66,7 @@ bb2: { _6 = Shl(move _7, const 1_i32); StorageDead(_7); - _3 = rotate_right::(_4, _6) -> [return: bb3, unwind unreachable]; + _3 = rotate_right::(move _4, move _6) -> [return: bb3, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff index a6bd29e1c..254557b99 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff @@ -66,7 +66,7 @@ bb2: { _6 = Shl(move _7, const 1_i32); StorageDead(_7); - _3 = rotate_right::(_4, _6) -> [return: bb3, unwind unreachable]; + _3 = rotate_right::(move _4, move _6) -> [return: bb3, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff index eb03a347a..65f4806aa 100644 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff @@ -47,7 +47,8 @@ bb3 (cleanup): { _2 = move _5; - drop(_5) -> [return: bb8, unwind terminate]; +- drop(_5) -> [return: bb8, unwind terminate]; ++ goto -> bb8; } bb4: { @@ -80,7 +81,7 @@ bb9 (cleanup): { - drop(_1) -> [return: bb10, unwind terminate]; -+ goto -> bb13; ++ goto -> bb12; } bb10 (cleanup): { @@ -88,15 +89,11 @@ + } + + bb11 (cleanup): { -+ unreachable; -+ } -+ -+ bb12 (cleanup): { + drop(_1) -> [return: bb10, unwind terminate]; + } + -+ bb13 (cleanup): { -+ switchInt(_6) -> [0: bb10, otherwise: bb12]; ++ bb12 (cleanup): { ++ switchInt(_6) -> [0: bb10, otherwise: bb11]; } } diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff index 254658c81..4845fc732 100644 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff @@ -47,7 +47,8 @@ bb3 (cleanup): { _2 = move _5; - drop(_5) -> [return: bb8, unwind terminate]; +- drop(_5) -> [return: bb8, unwind terminate]; ++ goto -> bb8; } bb4: { @@ -80,7 +81,7 @@ bb9 (cleanup): { - drop(_1) -> [return: bb10, unwind terminate]; -+ goto -> bb13; ++ goto -> bb12; } bb10 (cleanup): { @@ -88,15 +89,11 @@ + } + + bb11 (cleanup): { -+ unreachable; -+ } -+ -+ bb12 (cleanup): { + drop(_1) -> [return: bb10, unwind terminate]; + } + -+ bb13 (cleanup): { -+ switchInt(_6) -> [0: bb10, otherwise: bb12]; ++ bb12 (cleanup): { ++ switchInt(_6) -> [0: bb10, otherwise: bb11]; } } diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff index 7c2503f9d..aca7fe95c 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff @@ -54,8 +54,12 @@ } bb4 (cleanup): { ++ _7 = const true; ++ _8 = const true; ++ _9 = const true; _1 = move _3; - drop(_3) -> [return: bb11, unwind terminate]; +- drop(_3) -> [return: bb11, unwind terminate]; ++ goto -> bb11; } bb5: { @@ -86,7 +90,7 @@ bb9: { StorageDead(_2); - drop(_1) -> [return: bb10, unwind: bb12]; -+ goto -> bb19; ++ goto -> bb18; } bb10: { @@ -106,43 +110,39 @@ resume; + } + -+ bb13 (cleanup): { -+ unreachable; -+ } -+ -+ bb14: { ++ bb13: { + _7 = const false; + goto -> bb10; + } + -+ bb15 (cleanup): { ++ bb14 (cleanup): { + goto -> bb12; + } + -+ bb16: { -+ drop(_1) -> [return: bb14, unwind: bb12]; ++ bb15: { ++ drop(_1) -> [return: bb13, unwind: bb12]; + } + -+ bb17 (cleanup): { ++ bb16 (cleanup): { + drop(_1) -> [return: bb12, unwind terminate]; + } + -+ bb18: { ++ bb17: { + _10 = discriminant(_1); -+ switchInt(move _10) -> [0: bb14, otherwise: bb16]; ++ switchInt(move _10) -> [0: bb13, otherwise: bb15]; + } + -+ bb19: { -+ switchInt(_7) -> [0: bb14, otherwise: bb18]; ++ bb18: { ++ switchInt(_7) -> [0: bb13, otherwise: bb17]; + } + -+ bb20 (cleanup): { ++ bb19 (cleanup): { + _11 = discriminant(_1); -+ switchInt(move _11) -> [0: bb15, otherwise: bb17]; ++ switchInt(move _11) -> [0: bb14, otherwise: bb16]; + } + -+ bb21 (cleanup): { -+ switchInt(_7) -> [0: bb12, otherwise: bb20]; ++ bb20 (cleanup): { ++ switchInt(_7) -> [0: bb12, otherwise: bb19]; } } diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff index 4ef3650cd..60ce9cd8a 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff @@ -54,8 +54,12 @@ } bb4 (cleanup): { ++ _7 = const true; ++ _8 = const true; ++ _9 = const true; _1 = move _3; - drop(_3) -> [return: bb11, unwind terminate]; +- drop(_3) -> [return: bb11, unwind terminate]; ++ goto -> bb11; } bb5: { @@ -86,7 +90,7 @@ bb9: { StorageDead(_2); - drop(_1) -> [return: bb10, unwind continue]; -+ goto -> bb19; ++ goto -> bb18; } bb10: { @@ -106,43 +110,39 @@ resume; + } + -+ bb13 (cleanup): { -+ unreachable; -+ } -+ -+ bb14: { ++ bb13: { + _7 = const false; + goto -> bb10; + } + -+ bb15 (cleanup): { ++ bb14 (cleanup): { + goto -> bb12; + } + -+ bb16: { -+ drop(_1) -> [return: bb14, unwind: bb12]; ++ bb15: { ++ drop(_1) -> [return: bb13, unwind: bb12]; + } + -+ bb17 (cleanup): { ++ bb16 (cleanup): { + drop(_1) -> [return: bb12, unwind terminate]; + } + -+ bb18: { ++ bb17: { + _10 = discriminant(_1); -+ switchInt(move _10) -> [0: bb14, otherwise: bb16]; ++ switchInt(move _10) -> [0: bb13, otherwise: bb15]; + } + -+ bb19: { -+ switchInt(_7) -> [0: bb14, otherwise: bb18]; ++ bb18: { ++ switchInt(_7) -> [0: bb13, otherwise: bb17]; + } + -+ bb20 (cleanup): { ++ bb19 (cleanup): { + _11 = discriminant(_1); -+ switchInt(move _11) -> [0: bb15, otherwise: bb17]; ++ switchInt(move _11) -> [0: bb14, otherwise: bb16]; + } + -+ bb21 (cleanup): { -+ switchInt(_7) -> [0: bb12, otherwise: bb20]; ++ bb20 (cleanup): { ++ switchInt(_7) -> [0: bb12, otherwise: bb19]; } } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index 1cc44ce06..f61632728 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -6,48 +6,56 @@ let mut _0: (); let _2: &[T]; let mut _3: &[T; 3]; - let _4: &[T; 3]; - let _5: [T; 3]; + let _4: [T; 3]; + let mut _5: T; let mut _6: T; let mut _7: T; - let mut _8: T; + let mut _8: usize; let mut _9: usize; - let mut _10: usize; - let mut _11: bool; - let mut _15: !; + let mut _10: bool; + let mut _14: !; scope 1 { debug v => _2; + let _11: &T; let _12: &T; let _13: &T; - let _14: &T; scope 2 { - debug v1 => &(*_2)[0 of 3]; - debug v2 => &(*_2)[1 of 3]; - debug v3 => &(*_2)[2 of 3]; + debug v1 => _11; + debug v2 => _12; + debug v3 => _13; } } bb0: { - StorageLive(_2); - StorageLive(_5); - _5 = [_1, _1, _1]; - _4 = &_5; - _2 = _4 as &[T] (PointerCoercion(Unsize)); - _9 = Len((*_2)); - _10 = const 3_usize; -- _11 = Eq(move _9, const 3_usize); -- switchInt(move _11) -> [0: bb1, otherwise: bb2]; + StorageLive(_3); + StorageLive(_4); + _4 = [_1, _1, _1]; + _3 = &_4; + _2 = move _3 as &[T] (PointerCoercion(Unsize)); + StorageDead(_3); + _8 = Len((*_2)); + _9 = const 3_usize; +- _10 = Eq(move _8, const 3_usize); +- switchInt(move _10) -> [0: bb1, otherwise: bb2]; + nop; -+ switchInt(move _9) -> [3: bb2, otherwise: bb1]; ++ switchInt(move _8) -> [3: bb2, otherwise: bb1]; } bb1: { - _15 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable; + _14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable; } bb2: { - StorageDead(_5); - StorageDead(_2); + StorageLive(_11); + _11 = &(*_2)[0 of 3]; + StorageLive(_12); + _12 = &(*_2)[1 of 3]; + StorageLive(_13); + _13 = &(*_2)[2 of 3]; + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index b708f6674..f6c337be1 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -6,48 +6,56 @@ let mut _0: (); let _2: &[T]; let mut _3: &[T; 3]; - let _4: &[T; 3]; - let _5: [T; 3]; + let _4: [T; 3]; + let mut _5: T; let mut _6: T; let mut _7: T; - let mut _8: T; + let mut _8: usize; let mut _9: usize; - let mut _10: usize; - let mut _11: bool; - let mut _15: !; + let mut _10: bool; + let mut _14: !; scope 1 { debug v => _2; + let _11: &T; let _12: &T; let _13: &T; - let _14: &T; scope 2 { - debug v1 => &(*_2)[0 of 3]; - debug v2 => &(*_2)[1 of 3]; - debug v3 => &(*_2)[2 of 3]; + debug v1 => _11; + debug v2 => _12; + debug v3 => _13; } } bb0: { - StorageLive(_2); - StorageLive(_5); - _5 = [_1, _1, _1]; - _4 = &_5; - _2 = _4 as &[T] (PointerCoercion(Unsize)); - _9 = Len((*_2)); - _10 = const 3_usize; -- _11 = Eq(move _9, const 3_usize); -- switchInt(move _11) -> [0: bb1, otherwise: bb2]; + StorageLive(_3); + StorageLive(_4); + _4 = [_1, _1, _1]; + _3 = &_4; + _2 = move _3 as &[T] (PointerCoercion(Unsize)); + StorageDead(_3); + _8 = Len((*_2)); + _9 = const 3_usize; +- _10 = Eq(move _8, const 3_usize); +- switchInt(move _10) -> [0: bb1, otherwise: bb2]; + nop; -+ switchInt(move _9) -> [3: bb2, otherwise: bb1]; ++ switchInt(move _8) -> [3: bb2, otherwise: bb1]; } bb1: { - _15 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; + _14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; } bb2: { - StorageDead(_5); - StorageDead(_2); + StorageLive(_11); + _11 = &(*_2)[0 of 3]; + StorageLive(_12); + _12 = &(*_2)[1 of 3]; + StorageLive(_13); + _13 = &(*_2)[2 of 3]; + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index 0fe66d3fb..aef89c7f9 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)]) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), substs: [] } }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [Const { ty: &'static [u8; 4], kind: Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)]) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [Const { ty: &'static [u8; 4], kind: UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] } }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir index 787f9ee09..f8c859418 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir @@ -3,57 +3,56 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; let mut _0: u32; - let mut _5: std::option::Option; + let mut _4: std::option::Option; scope 1 (inlined char::methods::::is_digit) { debug self => _1; debug radix => const 8_u32; let _2: std::option::Option; - let mut _3: &std::option::Option; + let mut _7: &std::option::Option; scope 2 (inlined Option::::is_some) { - debug self => _3; - let mut _4: isize; + debug self => _7; + let mut _3: isize; } } scope 3 (inlined #[track_caller] Option::::unwrap) { - debug self => _5; - let mut _6: isize; - let mut _7: !; + debug self => _4; + let mut _5: isize; + let mut _6: !; scope 4 { debug val => _0; } } bb0: { - StorageLive(_3); + StorageLive(_7); StorageLive(_2); _2 = char::methods::::to_digit(_1, const 8_u32) -> [return: bb1, unwind unreachable]; } bb1: { - _3 = &_2; - _4 = discriminant((*_3)); - StorageDead(_3); + _3 = discriminant(_2); + StorageDead(_7); StorageDead(_2); - switchInt(move _4) -> [1: bb2, otherwise: bb7]; + switchInt(move _3) -> [1: bb2, otherwise: bb7]; } bb2: { - StorageLive(_5); - _5 = char::methods::::to_digit(_1, const 8_u32) -> [return: bb3, unwind unreachable]; + StorageLive(_4); + _4 = char::methods::::to_digit(move _1, const 8_u32) -> [return: bb3, unwind unreachable]; } bb3: { - _6 = discriminant(_5); - switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb6]; + _5 = discriminant(_4); + switchInt(move _5) -> [0: bb4, 1: bb5, otherwise: bb6]; } bb4: { - _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind unreachable; + _6 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind unreachable; } bb5: { - _0 = move ((_5 as Some).0: u32); - StorageDead(_5); + _0 = move ((_4 as Some).0: u32); + StorageDead(_4); goto -> bb8; } diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir index 43a1a1eed..df7392edc 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir @@ -3,57 +3,56 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; let mut _0: u32; - let mut _5: std::option::Option; + let mut _4: std::option::Option; scope 1 (inlined char::methods::::is_digit) { debug self => _1; debug radix => const 8_u32; let _2: std::option::Option; - let mut _3: &std::option::Option; + let mut _7: &std::option::Option; scope 2 (inlined Option::::is_some) { - debug self => _3; - let mut _4: isize; + debug self => _7; + let mut _3: isize; } } scope 3 (inlined #[track_caller] Option::::unwrap) { - debug self => _5; - let mut _6: isize; - let mut _7: !; + debug self => _4; + let mut _5: isize; + let mut _6: !; scope 4 { debug val => _0; } } bb0: { - StorageLive(_3); + StorageLive(_7); StorageLive(_2); _2 = char::methods::::to_digit(_1, const 8_u32) -> [return: bb1, unwind continue]; } bb1: { - _3 = &_2; - _4 = discriminant((*_3)); - StorageDead(_3); + _3 = discriminant(_2); + StorageDead(_7); StorageDead(_2); - switchInt(move _4) -> [1: bb2, otherwise: bb7]; + switchInt(move _3) -> [1: bb2, otherwise: bb7]; } bb2: { - StorageLive(_5); - _5 = char::methods::::to_digit(_1, const 8_u32) -> [return: bb3, unwind continue]; + StorageLive(_4); + _4 = char::methods::::to_digit(move _1, const 8_u32) -> [return: bb3, unwind continue]; } bb3: { - _6 = discriminant(_5); - switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb6]; + _5 = discriminant(_4); + switchInt(move _5) -> [0: bb4, 1: bb5, otherwise: bb6]; } bb4: { - _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind continue; + _6 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind continue; } bb5: { - _0 = move ((_5 as Some).0: u32); - StorageDead(_5); + _0 = move ((_4 as Some).0: u32); + StorageDead(_4); goto -> bb8; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir index 70461b445..8304cb45b 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir @@ -7,28 +7,24 @@ fn checked_shl(_1: u32, _2: u32) -> Option { scope 1 (inlined core::num::::checked_shl) { debug self => _1; debug rhs => _2; - let mut _7: (u32, bool); - let _8: u32; - let _9: bool; - let mut _10: bool; + let mut _6: bool; scope 2 { - debug a => _8; - debug b => _9; + debug a => _4; + debug b => _5; } scope 3 (inlined core::num::::overflowing_shl) { debug self => _1; debug rhs => _2; - let mut _5: u32; - let mut _6: bool; + let mut _4: u32; + let mut _5: bool; scope 4 (inlined core::num::::wrapping_shl) { debug self => _1; debug rhs => _2; let mut _3: u32; - let mut _4: u32; scope 5 { scope 6 (inlined core::num::::unchecked_shl) { debug self => _1; - debug rhs => _4; + debug rhs => _3; scope 7 { } } @@ -38,35 +34,23 @@ fn checked_shl(_1: u32, _2: u32) -> Option { } bb0: { - StorageLive(_8); - StorageLive(_9); - StorageLive(_7); - StorageLive(_5); StorageLive(_4); + StorageLive(_5); StorageLive(_3); - _3 = const 31_u32; - _4 = BitAnd(_2, move _3); + _3 = BitAnd(_2, const 31_u32); + _4 = ShlUnchecked(_1, _3); StorageDead(_3); - _5 = ShlUnchecked(_1, _4); - StorageDead(_4); + _5 = Ge(_2, const _); StorageLive(_6); - _6 = Ge(_2, const _); - _7 = (move _5, move _6); - StorageDead(_6); - StorageDead(_5); - _8 = (_7.0: u32); - _9 = (_7.1: bool); - StorageDead(_7); - StorageLive(_10); - _10 = unlikely(_9) -> [return: bb1, unwind unreachable]; + _6 = unlikely(move _5) -> [return: bb1, unwind unreachable]; } bb1: { - switchInt(move _10) -> [0: bb2, otherwise: bb3]; + switchInt(move _6) -> [0: bb2, otherwise: bb3]; } bb2: { - _0 = Option::::Some(_8); + _0 = Option::::Some(_4); goto -> bb4; } @@ -76,9 +60,9 @@ fn checked_shl(_1: u32, _2: u32) -> Option { } bb4: { - StorageDead(_10); - StorageDead(_9); - StorageDead(_8); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir index 98c267e8e..b2ea96f03 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir @@ -8,42 +8,41 @@ fn step_forward(_1: u32, _2: usize) -> u32 { debug start => _1; debug n => _2; let _3: std::option::Option; - let mut _4: &std::option::Option; - let mut _7: bool; - let mut _8: u32; + let mut _6: bool; + let mut _7: u32; + let mut _8: &std::option::Option; scope 2 { } scope 3 (inlined Option::::is_none) { - debug self => _4; - let mut _6: bool; + debug self => _8; + let mut _5: bool; scope 4 (inlined Option::::is_some) { - debug self => _4; - let mut _5: isize; + debug self => _8; + let mut _4: isize; } } scope 5 (inlined core::num::::wrapping_add) { debug self => _1; - debug rhs => _8; + debug rhs => _7; } } bb0: { - StorageLive(_7); - StorageLive(_4); + StorageLive(_6); + StorageLive(_8); StorageLive(_3); _3 = ::forward_checked(_1, _2) -> [return: bb1, unwind continue]; } bb1: { - _4 = &_3; - StorageLive(_6); - _5 = discriminant((*_4)); - _6 = Eq(_5, const 1_isize); - _7 = Not(move _6); - StorageDead(_6); + StorageLive(_5); + _4 = discriminant(_3); + _5 = Eq(_4, const 1_isize); + _6 = Not(move _5); + StorageDead(_5); StorageDead(_3); - StorageDead(_4); - switchInt(move _7) -> [0: bb3, otherwise: bb2]; + StorageDead(_8); + switchInt(move _6) -> [0: bb3, otherwise: bb2]; } bb2: { @@ -51,11 +50,11 @@ fn step_forward(_1: u32, _2: usize) -> u32 { } bb3: { + StorageDead(_6); + StorageLive(_7); + _7 = _2 as u32 (IntToInt); + _0 = Add(_1, _7); StorageDead(_7); - StorageLive(_8); - _8 = _2 as u32 (IntToInt); - _0 = Add(_1, _8); - StorageDead(_8); return; } } diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir index 66acbbbb2..174fb2c0c 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir @@ -2,22 +2,18 @@ fn f_u64() -> () { let mut _0: (); - let mut _1: u64; scope 1 (inlined f_dispatch::) { debug t => const 0_u64; - let _2: (); + let _1: (); scope 2 (inlined std::mem::size_of::) { } } bb0: { - StorageLive(_1); - _1 = const 0_u64; - _2 = f_non_zst::(move _1) -> [return: bb1, unwind unreachable]; + _1 = f_non_zst::(const 0_u64) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir index 3b49cb711..940b9ae11 100644 --- a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir @@ -7,20 +7,20 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () let mut _3: std::iter::FilterMap, impl Fn(T) -> Option>; let mut _4: std::iter::FilterMap, impl Fn(T) -> Option>; let mut _5: std::iter::FilterMap, impl Fn(T) -> Option>; - let mut _6: &mut std::iter::FilterMap, impl Fn(T) -> Option>; - let mut _9: std::option::Option; - let mut _10: isize; - let _12: (); + let mut _8: std::option::Option; + let mut _9: isize; + let _11: (); + let mut _12: &mut std::iter::FilterMap, impl Fn(T) -> Option>; scope 1 { debug iter => _5; - let _11: U; + let _10: U; scope 2 { - debug x => _11; + debug x => _10; } scope 4 (inlined , impl Fn(T) -> Option> as Iterator>::next) { - debug self => _6; - let mut _7: &mut impl Iterator; - let mut _8: &mut impl Fn(T) -> Option; + debug self => _12; + let mut _6: &mut impl Iterator; + let mut _7: &mut impl Fn(T) -> Option; } } scope 3 (inlined , impl Fn(T) -> Option> as IntoIterator>::into_iter) { @@ -42,24 +42,23 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb2: { - StorageLive(_9); - _6 = &mut _5; - StorageLive(_7); - _7 = &mut ((*_6).0: impl Iterator); StorageLive(_8); - _8 = &mut ((*_6).1: impl Fn(T) -> Option); - _9 = as Iterator>::find_map:: Option>(move _7, move _8) -> [return: bb3, unwind: bb9]; + StorageLive(_6); + _6 = &mut (_5.0: impl Iterator); + StorageLive(_7); + _7 = &mut (_5.1: impl Fn(T) -> Option); + _8 = as Iterator>::find_map:: Option>(move _6, move _7) -> [return: bb3, unwind: bb9]; } bb3: { - StorageDead(_8); StorageDead(_7); - _10 = discriminant(_9); - switchInt(move _10) -> [0: bb4, 1: bb6, otherwise: bb8]; + StorageDead(_6); + _9 = discriminant(_8); + switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb8]; } bb4: { - StorageDead(_9); + StorageDead(_8); drop(_5) -> [return: bb5, unwind continue]; } @@ -70,12 +69,12 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb6: { - _11 = move ((_9 as Some).0: U); - _12 = opaque::(move _11) -> [return: bb7, unwind: bb9]; + _10 = move ((_8 as Some).0: U); + _11 = opaque::(move _10) -> [return: bb7, unwind: bb9]; } bb7: { - StorageDead(_9); + StorageDead(_8); goto -> bb2; } diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 40bb3a37c..2e51faeba 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -6,35 +6,35 @@ fn int_range(_1: usize, _2: usize) -> () { let mut _0: (); let mut _3: std::ops::Range; let mut _4: std::ops::Range; - let mut _5: &mut std::ops::Range; - let mut _11: std::option::Option; - let mut _14: isize; - let _16: (); + let mut _8: std::option::Option; + let mut _11: isize; + let _13: (); + let mut _14: &mut std::ops::Range; scope 1 { debug iter => _4; - let _15: usize; + let _12: usize; scope 2 { - debug i => _15; + debug i => _12; } scope 4 (inlined iter::range::>::next) { - debug self => _5; + debug self => _14; scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _5; - let mut _6: &usize; - let mut _7: &usize; - let mut _10: bool; - let _12: usize; - let mut _13: usize; + debug self => _14; + let mut _7: bool; + let _9: usize; + let mut _10: usize; + let mut _15: &usize; + let mut _16: &usize; scope 6 { - debug old => _12; + debug old => _9; scope 7 { } } scope 8 (inlined cmp::impls::::lt) { - debug self => _6; - debug other => _7; - let mut _8: usize; - let mut _9: usize; + debug self => _15; + debug other => _16; + let mut _5: usize; + let mut _6: usize; } } } @@ -51,64 +51,61 @@ fn int_range(_1: usize, _2: usize) -> () { } bb1: { - StorageLive(_11); - _5 = &mut _4; - StorageLive(_12); - StorageLive(_10); - StorageLive(_6); - _6 = &((*_5).0: usize); - StorageLive(_7); - _7 = &((*_5).1: usize); StorageLive(_8); - _8 = (*_6); StorageLive(_9); - _9 = (*_7); - _10 = Lt(move _8, move _9); - StorageDead(_9); - StorageDead(_8); - StorageDead(_7); + StorageLive(_7); + StorageLive(_15); + StorageLive(_16); + StorageLive(_5); + _5 = (_4.0: usize); + StorageLive(_6); + _6 = (_4.1: usize); + _7 = Lt(move _5, move _6); StorageDead(_6); - switchInt(move _10) -> [0: bb2, otherwise: bb3]; + StorageDead(_5); + StorageDead(_16); + StorageDead(_15); + switchInt(move _7) -> [0: bb2, otherwise: bb3]; } bb2: { - _11 = Option::::None; + _8 = Option::::None; goto -> bb5; } bb3: { - _12 = ((*_5).0: usize); - StorageLive(_13); - _13 = ::forward_unchecked(_12, const 1_usize) -> [return: bb4, unwind continue]; + _9 = (_4.0: usize); + StorageLive(_10); + _10 = ::forward_unchecked(_9, const 1_usize) -> [return: bb4, unwind continue]; } bb4: { - ((*_5).0: usize) = move _13; - StorageDead(_13); - _11 = Option::::Some(_12); + (_4.0: usize) = move _10; + StorageDead(_10); + _8 = Option::::Some(_9); goto -> bb5; } bb5: { - StorageDead(_10); - StorageDead(_12); - _14 = discriminant(_11); - switchInt(move _14) -> [0: bb6, 1: bb7, otherwise: bb9]; + StorageDead(_7); + StorageDead(_9); + _11 = discriminant(_8); + switchInt(move _11) -> [0: bb6, 1: bb7, otherwise: bb9]; } bb6: { - StorageDead(_11); + StorageDead(_8); StorageDead(_4); return; } bb7: { - _15 = ((_11 as Some).0: usize); - _16 = opaque::(_15) -> [return: bb8, unwind continue]; + _12 = ((_8 as Some).0: usize); + _13 = opaque::(move _12) -> [return: bb8, unwind continue]; } bb8: { - StorageDead(_11); + StorageDead(_8); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir index e4e1d052e..261416036 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -38,11 +38,13 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { bb2: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; - _7 = , impl Fn(T) -> U> as Iterator>::next(_6) -> [return: bb3, unwind: bb9]; + _7 = , impl Fn(T) -> U> as Iterator>::next(move _6) -> [return: bb3, unwind: bb9]; } bb3: { + StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb8]; } diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index 1b5f2a088..8eff46fb9 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -30,11 +30,13 @@ fn vec_move(_1: Vec) -> () { bb2: { StorageLive(_5); + StorageLive(_4); _4 = &mut _3; - _5 = as Iterator>::next(_4) -> [return: bb3, unwind: bb9]; + _5 = as Iterator>::next(move _4) -> [return: bb3, unwind: bb9]; } bb3: { + StorageDead(_4); _6 = discriminant(_5); switchInt(move _6) -> [0: bb4, 1: bb6, otherwise: bb8]; } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir index f8f4f5b99..26919dd98 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -7,47 +7,27 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { scope 1 (inlined std::mem::replace::) { debug dest => _1; debug src => _2; - let mut _3: *const u32; - let mut _4: *mut u32; scope 2 { scope 3 { debug result => _0; - scope 7 (inlined std::ptr::write::) { - debug dst => _4; + scope 6 (inlined std::ptr::write::) { + debug dst => _1; debug src => _2; - let mut _6: *mut u32; - scope 8 { - scope 9 (inlined std::ptr::write::runtime::) { - debug dst => _6; - } + scope 7 { } } } scope 4 (inlined std::ptr::read::) { - debug src => _3; - let mut _5: *const u32; + debug src => _1; scope 5 { - scope 6 (inlined std::ptr::read::runtime::) { - debug src => _5; - } } } } } bb0: { - StorageLive(_3); - _3 = &raw const (*_1); - StorageLive(_5); - _0 = (*_3); - StorageDead(_5); - StorageDead(_3); - StorageLive(_4); - _4 = &raw mut (*_1); - StorageLive(_6); - (*_4) = _2; - StorageDead(_6); - StorageDead(_4); + _0 = (*_1); + (*_1) = _2; return; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index 2344a3c0f..d76b46bdd 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -7,37 +7,37 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _0: (); let mut _4: std::ops::Range; let mut _5: std::ops::Range; - let mut _6: &mut std::ops::Range; - let mut _12: std::option::Option; - let mut _15: isize; - let mut _17: &impl Fn(u32); - let mut _18: (u32,); - let _19: (); + let mut _9: std::option::Option; + let mut _12: isize; + let mut _14: &impl Fn(u32); + let mut _15: (u32,); + let _16: (); + let mut _17: &mut std::ops::Range; scope 1 { debug iter => _5; - let _16: u32; + let _13: u32; scope 2 { - debug x => _16; + debug x => _13; } scope 4 (inlined iter::range::>::next) { - debug self => _6; + debug self => _17; scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &u32; - let mut _8: &u32; - let mut _11: bool; - let _13: u32; - let mut _14: u32; + debug self => _17; + let mut _8: bool; + let _10: u32; + let mut _11: u32; + let mut _18: &u32; + let mut _19: &u32; scope 6 { - debug old => _13; + debug old => _10; scope 7 { } } scope 8 (inlined cmp::impls::::lt) { - debug self => _7; - debug other => _8; - let mut _9: u32; - let mut _10: u32; + debug self => _18; + debug other => _19; + let mut _6: u32; + let mut _7: u32; } } } @@ -54,53 +54,50 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_12); - _6 = &mut _5; - StorageLive(_13); - StorageLive(_11); - StorageLive(_7); - _7 = &((*_6).0: u32); - StorageLive(_8); - _8 = &((*_6).1: u32); StorageLive(_9); - _9 = (*_7); StorageLive(_10); - _10 = (*_8); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - StorageDead(_8); + StorageLive(_8); + StorageLive(_18); + StorageLive(_19); + StorageLive(_6); + _6 = (_5.0: u32); + StorageLive(_7); + _7 = (_5.1: u32); + _8 = Lt(move _6, move _7); StorageDead(_7); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + StorageDead(_6); + StorageDead(_19); + StorageDead(_18); + switchInt(move _8) -> [0: bb2, otherwise: bb3]; } bb2: { - _12 = Option::::None; + _9 = Option::::None; goto -> bb5; } bb3: { - _13 = ((*_6).0: u32); - StorageLive(_14); - _14 = ::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable]; + _10 = (_5.0: u32); + StorageLive(_11); + _11 = ::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind unreachable]; } bb4: { - ((*_6).0: u32) = move _14; - StorageDead(_14); - _12 = Option::::Some(_13); + (_5.0: u32) = move _11; + StorageDead(_11); + _9 = Option::::Some(_10); goto -> bb5; } bb5: { - StorageDead(_11); - StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_8); + StorageDead(_10); + _12 = discriminant(_9); + switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_12); + StorageDead(_9); StorageDead(_5); drop(_3) -> [return: bb7, unwind unreachable]; } @@ -110,18 +107,18 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb8: { - _16 = ((_12 as Some).0: u32); - StorageLive(_17); - _17 = &_3; - StorageLive(_18); - _18 = (_16,); - _19 = >::call(move _17, move _18) -> [return: bb9, unwind unreachable]; + _13 = ((_9 as Some).0: u32); + StorageLive(_14); + _14 = &_3; + StorageLive(_15); + _15 = (_13,); + _16 = >::call(move _14, move _15) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_18); - StorageDead(_17); - StorageDead(_12); + StorageDead(_15); + StorageDead(_14); + StorageDead(_9); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index fbe16dc3c..4d7c017da 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -7,37 +7,37 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _0: (); let mut _4: std::ops::Range; let mut _5: std::ops::Range; - let mut _6: &mut std::ops::Range; - let mut _12: std::option::Option; - let mut _15: isize; - let mut _17: &impl Fn(u32); - let mut _18: (u32,); - let _19: (); + let mut _9: std::option::Option; + let mut _12: isize; + let mut _14: &impl Fn(u32); + let mut _15: (u32,); + let _16: (); + let mut _17: &mut std::ops::Range; scope 1 { debug iter => _5; - let _16: u32; + let _13: u32; scope 2 { - debug x => _16; + debug x => _13; } scope 4 (inlined iter::range::>::next) { - debug self => _6; + debug self => _17; scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &u32; - let mut _8: &u32; - let mut _11: bool; - let _13: u32; - let mut _14: u32; + debug self => _17; + let mut _8: bool; + let _10: u32; + let mut _11: u32; + let mut _18: &u32; + let mut _19: &u32; scope 6 { - debug old => _13; + debug old => _10; scope 7 { } } scope 8 (inlined cmp::impls::::lt) { - debug self => _7; - debug other => _8; - let mut _9: u32; - let mut _10: u32; + debug self => _18; + debug other => _19; + let mut _6: u32; + let mut _7: u32; } } } @@ -54,53 +54,50 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_12); - _6 = &mut _5; - StorageLive(_13); - StorageLive(_11); - StorageLive(_7); - _7 = &((*_6).0: u32); - StorageLive(_8); - _8 = &((*_6).1: u32); StorageLive(_9); - _9 = (*_7); StorageLive(_10); - _10 = (*_8); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - StorageDead(_8); + StorageLive(_8); + StorageLive(_18); + StorageLive(_19); + StorageLive(_6); + _6 = (_5.0: u32); + StorageLive(_7); + _7 = (_5.1: u32); + _8 = Lt(move _6, move _7); StorageDead(_7); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + StorageDead(_6); + StorageDead(_19); + StorageDead(_18); + switchInt(move _8) -> [0: bb2, otherwise: bb3]; } bb2: { - _12 = Option::::None; + _9 = Option::::None; goto -> bb5; } bb3: { - _13 = ((*_6).0: u32); - StorageLive(_14); - _14 = ::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb11]; + _10 = (_5.0: u32); + StorageLive(_11); + _11 = ::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind: bb11]; } bb4: { - ((*_6).0: u32) = move _14; - StorageDead(_14); - _12 = Option::::Some(_13); + (_5.0: u32) = move _11; + StorageDead(_11); + _9 = Option::::Some(_10); goto -> bb5; } bb5: { - StorageDead(_11); - StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_8); + StorageDead(_10); + _12 = discriminant(_9); + switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_12); + StorageDead(_9); StorageDead(_5); drop(_3) -> [return: bb7, unwind continue]; } @@ -110,18 +107,18 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb8: { - _16 = ((_12 as Some).0: u32); - StorageLive(_17); - _17 = &_3; - StorageLive(_18); - _18 = (_16,); - _19 = >::call(move _17, move _18) -> [return: bb9, unwind: bb11]; + _13 = ((_9 as Some).0: u32); + StorageLive(_14); + _14 = &_3; + StorageLive(_15); + _15 = (_13,); + _16 = >::call(move _14, move _15) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_18); - StorageDead(_17); - StorageDead(_12); + StorageDead(_15); + StorageDead(_14); + StorageDead(_9); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir index 9737c9a87..1b23e4213 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -40,11 +40,13 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; - _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(_6) -> [return: bb2, unwind unreachable]; + _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable]; } bb2: { + StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index 04d6da1d9..bbab4e47a 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -40,11 +40,13 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; - _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(_6) -> [return: bb2, unwind: bb8]; + _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8]; } bb2: { + StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir index 0a71b6b2c..b0f475b4d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir @@ -8,7 +8,7 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive) -> Option { } bb0: { - _0 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> [return: bb1, unwind unreachable]; + _0 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir index fd565fe75..663ec229f 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir @@ -8,7 +8,7 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive) -> Option { } bb0: { - _0 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> [return: bb1, unwind continue]; + _0 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir index 1dfd00bf3..7360aa3e6 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir @@ -7,42 +7,40 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { debug self => _1; scope 2 (inlined as iter::range::RangeIteratorImpl>::spec_next) { debug self => _1; - let mut _2: &u32; - let mut _3: &u32; - let mut _6: bool; - let _7: u32; - let mut _8: u32; + let mut _4: bool; + let _5: u32; + let mut _6: u32; + let mut _7: &u32; + let mut _8: &u32; scope 3 { - debug old => _7; + debug old => _5; scope 4 { } } scope 5 (inlined cmp::impls::::lt) { - debug self => _2; - debug other => _3; - let mut _4: u32; - let mut _5: u32; + debug self => _7; + debug other => _8; + let mut _2: u32; + let mut _3: u32; } } } bb0: { + StorageLive(_5); + StorageLive(_4); StorageLive(_7); - StorageLive(_6); + StorageLive(_8); StorageLive(_2); - _2 = &((*_1).0: u32); + _2 = ((*_1).0: u32); StorageLive(_3); - _3 = &((*_1).1: u32); - StorageLive(_4); - _4 = (*_2); - StorageLive(_5); - _5 = (*_3); - _6 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); + _3 = ((*_1).1: u32); + _4 = Lt(move _2, move _3); StorageDead(_3); StorageDead(_2); - switchInt(move _6) -> [0: bb1, otherwise: bb2]; + StorageDead(_8); + StorageDead(_7); + switchInt(move _4) -> [0: bb1, otherwise: bb2]; } bb1: { @@ -51,21 +49,21 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { } bb2: { - _7 = ((*_1).0: u32); - StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind unreachable]; + _5 = ((*_1).0: u32); + StorageLive(_6); + _6 = ::forward_unchecked(_5, const 1_usize) -> [return: bb3, unwind unreachable]; } bb3: { - ((*_1).0: u32) = move _8; - StorageDead(_8); - _0 = Option::::Some(_7); + ((*_1).0: u32) = move _6; + StorageDead(_6); + _0 = Option::::Some(_5); goto -> bb4; } bb4: { - StorageDead(_6); - StorageDead(_7); + StorageDead(_4); + StorageDead(_5); return; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index 65870f693..61957082d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -7,42 +7,40 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { debug self => _1; scope 2 (inlined as iter::range::RangeIteratorImpl>::spec_next) { debug self => _1; - let mut _2: &u32; - let mut _3: &u32; - let mut _6: bool; - let _7: u32; - let mut _8: u32; + let mut _4: bool; + let _5: u32; + let mut _6: u32; + let mut _7: &u32; + let mut _8: &u32; scope 3 { - debug old => _7; + debug old => _5; scope 4 { } } scope 5 (inlined cmp::impls::::lt) { - debug self => _2; - debug other => _3; - let mut _4: u32; - let mut _5: u32; + debug self => _7; + debug other => _8; + let mut _2: u32; + let mut _3: u32; } } } bb0: { + StorageLive(_5); + StorageLive(_4); StorageLive(_7); - StorageLive(_6); + StorageLive(_8); StorageLive(_2); - _2 = &((*_1).0: u32); + _2 = ((*_1).0: u32); StorageLive(_3); - _3 = &((*_1).1: u32); - StorageLive(_4); - _4 = (*_2); - StorageLive(_5); - _5 = (*_3); - _6 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); + _3 = ((*_1).1: u32); + _4 = Lt(move _2, move _3); StorageDead(_3); StorageDead(_2); - switchInt(move _6) -> [0: bb1, otherwise: bb2]; + StorageDead(_8); + StorageDead(_7); + switchInt(move _4) -> [0: bb1, otherwise: bb2]; } bb1: { @@ -51,21 +49,21 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { } bb2: { - _7 = ((*_1).0: u32); - StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind continue]; + _5 = ((*_1).0: u32); + StorageLive(_6); + _6 = ::forward_unchecked(_5, const 1_usize) -> [return: bb3, unwind continue]; } bb3: { - ((*_1).0: u32) = move _8; - StorageDead(_8); - _0 = Option::::Some(_7); + ((*_1).0: u32) = move _6; + StorageDead(_6); + _0 = Option::::Some(_5); goto -> bb4; } bb4: { - StorageDead(_6); - StorageDead(_7); + StorageDead(_4); + StorageDead(_5); return; } } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir index df45b1589..68d78f743 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -3,24 +3,21 @@ fn ezmap(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _5: i32; scope 1 (inlined map::) { debug slf => _1; debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15]; let mut _2: isize; let _3: i32; - let mut _4: (i32,); - let mut _6: i32; + let mut _4: i32; scope 2 { debug x => _3; scope 3 (inlined ezmap::{closure#0}) { - debug n => _5; + debug n => _3; } } } bb0: { - StorageLive(_3); _2 = discriminant(_1); switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; } @@ -32,21 +29,14 @@ fn ezmap(_1: Option) -> Option { bb2: { _3 = ((_1 as Some).0: i32); - StorageLive(_6); StorageLive(_4); - _4 = (move _3,); - StorageLive(_5); - _5 = move (_4.0: i32); - _6 = Add(_5, const 1_i32); - StorageDead(_5); + _4 = Add(_3, const 1_i32); + _0 = Option::::Some(move _4); StorageDead(_4); - _0 = Option::::Some(move _6); - StorageDead(_6); goto -> bb3; } bb3: { - StorageDead(_3); return; } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index 499bee2ae..1488779f9 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -10,75 +10,75 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2 let _8: &usize; let mut _9: &(usize, usize, usize, usize); let _10: &usize; - let mut _11: &&usize; - let _12: &usize; - let mut _13: &&usize; - let mut _18: bool; - let mut _19: bool; - let mut _20: &&usize; - let _21: &usize; - let mut _22: &&usize; - let mut _27: bool; - let mut _28: &&usize; - let _29: &usize; - let mut _30: &&usize; - let mut _35: bool; + let _11: &usize; + let mut _16: bool; + let mut _17: bool; + let _18: &usize; + let mut _23: bool; + let _24: &usize; + let mut _29: bool; + let mut _30: bool; + let _31: &usize; let mut _36: bool; let mut _37: &&usize; - let _38: &usize; + let mut _38: &&usize; let mut _39: &&usize; - let mut _44: bool; + let mut _40: &&usize; + let mut _41: &&usize; + let mut _42: &&usize; + let mut _43: &&usize; + let mut _44: &&usize; scope 1 { debug a => _4; debug b => _6; debug c => _8; debug d => _10; scope 2 (inlined cmp::impls::::le) { - debug self => _11; - debug other => _13; - let mut _14: &usize; - let mut _15: &usize; + debug self => _37; + debug other => _38; + let mut _12: &usize; + let mut _13: &usize; scope 3 (inlined cmp::impls::::le) { - debug self => _14; - debug other => _15; - let mut _16: usize; - let mut _17: usize; + debug self => _12; + debug other => _13; + let mut _14: usize; + let mut _15: usize; } } scope 4 (inlined cmp::impls::::le) { - debug self => _28; - debug other => _30; - let mut _31: &usize; - let mut _32: &usize; + debug self => _41; + debug other => _42; + let mut _25: &usize; + let mut _26: &usize; scope 5 (inlined cmp::impls::::le) { - debug self => _31; - debug other => _32; - let mut _33: usize; - let mut _34: usize; + debug self => _25; + debug other => _26; + let mut _27: usize; + let mut _28: usize; } } scope 6 (inlined cmp::impls::::le) { - debug self => _20; - debug other => _22; - let mut _23: &usize; - let mut _24: &usize; + debug self => _39; + debug other => _40; + let mut _19: &usize; + let mut _20: &usize; scope 7 (inlined cmp::impls::::le) { - debug self => _23; - debug other => _24; - let mut _25: usize; - let mut _26: usize; + debug self => _19; + debug other => _20; + let mut _21: usize; + let mut _22: usize; } } scope 8 (inlined cmp::impls::::le) { - debug self => _37; - debug other => _39; - let mut _40: &usize; - let mut _41: &usize; + debug self => _43; + debug other => _44; + let mut _32: &usize; + let mut _33: &usize; scope 9 (inlined cmp::impls::::le) { - debug self => _40; - debug other => _41; - let mut _42: usize; - let mut _43: usize; + debug self => _32; + debug other => _33; + let mut _34: usize; + let mut _35: usize; } } } @@ -96,121 +96,113 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2 StorageLive(_10); _9 = deref_copy (*_2); _10 = &((*_9).3: usize); - StorageLive(_19); - StorageLive(_18); - StorageLive(_11); - _11 = &_4; - StorageLive(_13); - StorageLive(_12); - _12 = _8; - _13 = &_12; - _14 = deref_copy (*_11); - _15 = deref_copy (*_13); - StorageLive(_16); - _16 = (*_14); StorageLive(_17); - _17 = (*_15); - _18 = Le(move _16, move _17); - StorageDead(_17); - StorageDead(_16); - StorageDead(_12); - StorageDead(_13); + StorageLive(_16); + StorageLive(_37); + StorageLive(_38); + StorageLive(_11); + _11 = _8; + _12 = deref_copy _4; + _13 = deref_copy _11; + StorageLive(_14); + _14 = (*_12); + StorageLive(_15); + _15 = (*_13); + _16 = Le(move _14, move _15); + StorageDead(_15); + StorageDead(_14); StorageDead(_11); - switchInt(move _18) -> [0: bb1, otherwise: bb2]; + StorageDead(_38); + StorageDead(_37); + switchInt(move _16) -> [0: bb1, otherwise: bb2]; } bb1: { - _19 = const false; + _17 = const false; goto -> bb3; } bb2: { - StorageLive(_27); - StorageLive(_20); - _20 = &_10; - StorageLive(_22); + StorageLive(_23); + StorageLive(_39); + StorageLive(_40); + StorageLive(_18); + _18 = _6; + _19 = deref_copy _10; + _20 = deref_copy _18; StorageLive(_21); - _21 = _6; - _22 = &_21; - _23 = deref_copy (*_20); - _24 = deref_copy (*_22); - StorageLive(_25); - _25 = (*_23); - StorageLive(_26); - _26 = (*_24); - _27 = Le(move _25, move _26); - StorageDead(_26); - StorageDead(_25); - StorageDead(_21); + _21 = (*_19); + StorageLive(_22); + _22 = (*_20); + _23 = Le(move _21, move _22); StorageDead(_22); - StorageDead(_20); - _19 = move _27; + StorageDead(_21); + StorageDead(_18); + StorageDead(_40); + StorageDead(_39); + _17 = move _23; goto -> bb3; } bb3: { - StorageDead(_27); - StorageDead(_18); - switchInt(move _19) -> [0: bb4, otherwise: bb8]; + StorageDead(_23); + StorageDead(_16); + switchInt(move _17) -> [0: bb4, otherwise: bb8]; } bb4: { - StorageLive(_36); - StorageLive(_35); - StorageLive(_28); - _28 = &_8; StorageLive(_30); StorageLive(_29); - _29 = _4; - _30 = &_29; - _31 = deref_copy (*_28); - _32 = deref_copy (*_30); - StorageLive(_33); - _33 = (*_31); - StorageLive(_34); - _34 = (*_32); - _35 = Le(move _33, move _34); - StorageDead(_34); - StorageDead(_33); - StorageDead(_29); - StorageDead(_30); + StorageLive(_41); + StorageLive(_42); + StorageLive(_24); + _24 = _4; + _25 = deref_copy _8; + _26 = deref_copy _24; + StorageLive(_27); + _27 = (*_25); + StorageLive(_28); + _28 = (*_26); + _29 = Le(move _27, move _28); StorageDead(_28); - switchInt(move _35) -> [0: bb5, otherwise: bb6]; + StorageDead(_27); + StorageDead(_24); + StorageDead(_42); + StorageDead(_41); + switchInt(move _29) -> [0: bb5, otherwise: bb6]; } bb5: { - _36 = const false; + _30 = const false; goto -> bb7; } bb6: { - StorageLive(_44); - StorageLive(_37); - _37 = &_6; - StorageLive(_39); - StorageLive(_38); - _38 = _10; - _39 = &_38; - _40 = deref_copy (*_37); - _41 = deref_copy (*_39); - StorageLive(_42); - _42 = (*_40); + StorageLive(_36); StorageLive(_43); - _43 = (*_41); - _44 = Le(move _42, move _43); + StorageLive(_44); + StorageLive(_31); + _31 = _10; + _32 = deref_copy _6; + _33 = deref_copy _31; + StorageLive(_34); + _34 = (*_32); + StorageLive(_35); + _35 = (*_33); + _36 = Le(move _34, move _35); + StorageDead(_35); + StorageDead(_34); + StorageDead(_31); + StorageDead(_44); StorageDead(_43); - StorageDead(_42); - StorageDead(_38); - StorageDead(_39); - StorageDead(_37); - _36 = move _44; + _30 = move _36; goto -> bb7; } bb7: { - StorageDead(_44); - StorageDead(_35); - _0 = move _36; + StorageDead(_36); + StorageDead(_29); + _0 = move _30; goto -> bb9; } @@ -220,8 +212,8 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2 } bb9: { - StorageDead(_36); - StorageDead(_19); + StorageDead(_30); + StorageDead(_17); StorageDead(_10); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index 43efe034d..07a58309e 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -10,40 +10,37 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { scope 2 (inlined >::get_mut) { debug self => _2; debug slice => _1; - let mut _3: &[u32]; - let mut _4: usize; - let mut _5: bool; - let mut _6: *mut [u32]; - let mut _8: *mut u32; - let mut _9: &mut u32; + let mut _3: usize; + let mut _4: bool; + let mut _5: *mut [u32]; + let mut _7: *mut u32; + let mut _8: &mut u32; scope 3 { scope 4 (inlined >::get_unchecked_mut) { debug self => _2; - debug slice => _6; - let mut _7: *mut u32; - let mut _10: usize; - let mut _11: *mut [u32]; + debug slice => _5; + let mut _6: *mut u32; scope 5 { debug this => _2; scope 6 { scope 7 (inlined >::get_unchecked_mut::runtime::) { - debug this => _10; - debug slice => _11; + debug this => _2; + debug slice => _5; scope 8 (inlined ptr::mut_ptr::::len) { - debug self => _11; - let mut _12: *const [u32]; + debug self => _5; + let mut _9: *const [u32]; scope 9 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _12; + debug ptr => _9; scope 10 { } } } } scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _6; + debug self => _5; } scope 12 (inlined ptr::mut_ptr::::add) { - debug self => _7; + debug self => _6; debug count => _2; scope 13 { } @@ -56,16 +53,13 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { - StorageLive(_9); - StorageLive(_5); + StorageLive(_7); StorageLive(_4); StorageLive(_3); - _3 = &(*_1); - _4 = Len((*_3)); + _3 = Len((*_1)); + _4 = Lt(_2, move _3); StorageDead(_3); - _5 = Lt(_2, move _4); - StorageDead(_4); - switchInt(move _5) -> [0: bb1, otherwise: bb2]; + switchInt(move _4) -> [0: bb1, otherwise: bb2]; } bb1: { @@ -75,28 +69,24 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb2: { StorageLive(_8); + StorageLive(_5); + _5 = &raw mut (*_1); + StorageLive(_9); StorageLive(_6); - _6 = &raw mut (*_1); - StorageLive(_10); - StorageLive(_11); - StorageLive(_12); - StorageLive(_7); - _7 = _6 as *mut u32 (PtrToPtr); - _8 = Offset(_7, _2); - StorageDead(_7); - StorageDead(_12); - StorageDead(_11); - StorageDead(_10); + _6 = _5 as *mut u32 (PtrToPtr); + _7 = Offset(_6, _2); StorageDead(_6); - _9 = &mut (*_8); - _0 = Option::<&mut u32>::Some(_9); + StorageDead(_9); + StorageDead(_5); + _8 = &mut (*_7); + _0 = Option::<&mut u32>::Some(move _8); StorageDead(_8); goto -> bb3; } bb3: { - StorageDead(_5); - StorageDead(_9); + StorageDead(_4); + StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index 43efe034d..07a58309e 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -10,40 +10,37 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { scope 2 (inlined >::get_mut) { debug self => _2; debug slice => _1; - let mut _3: &[u32]; - let mut _4: usize; - let mut _5: bool; - let mut _6: *mut [u32]; - let mut _8: *mut u32; - let mut _9: &mut u32; + let mut _3: usize; + let mut _4: bool; + let mut _5: *mut [u32]; + let mut _7: *mut u32; + let mut _8: &mut u32; scope 3 { scope 4 (inlined >::get_unchecked_mut) { debug self => _2; - debug slice => _6; - let mut _7: *mut u32; - let mut _10: usize; - let mut _11: *mut [u32]; + debug slice => _5; + let mut _6: *mut u32; scope 5 { debug this => _2; scope 6 { scope 7 (inlined >::get_unchecked_mut::runtime::) { - debug this => _10; - debug slice => _11; + debug this => _2; + debug slice => _5; scope 8 (inlined ptr::mut_ptr::::len) { - debug self => _11; - let mut _12: *const [u32]; + debug self => _5; + let mut _9: *const [u32]; scope 9 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _12; + debug ptr => _9; scope 10 { } } } } scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _6; + debug self => _5; } scope 12 (inlined ptr::mut_ptr::::add) { - debug self => _7; + debug self => _6; debug count => _2; scope 13 { } @@ -56,16 +53,13 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { - StorageLive(_9); - StorageLive(_5); + StorageLive(_7); StorageLive(_4); StorageLive(_3); - _3 = &(*_1); - _4 = Len((*_3)); + _3 = Len((*_1)); + _4 = Lt(_2, move _3); StorageDead(_3); - _5 = Lt(_2, move _4); - StorageDead(_4); - switchInt(move _5) -> [0: bb1, otherwise: bb2]; + switchInt(move _4) -> [0: bb1, otherwise: bb2]; } bb1: { @@ -75,28 +69,24 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb2: { StorageLive(_8); + StorageLive(_5); + _5 = &raw mut (*_1); + StorageLive(_9); StorageLive(_6); - _6 = &raw mut (*_1); - StorageLive(_10); - StorageLive(_11); - StorageLive(_12); - StorageLive(_7); - _7 = _6 as *mut u32 (PtrToPtr); - _8 = Offset(_7, _2); - StorageDead(_7); - StorageDead(_12); - StorageDead(_11); - StorageDead(_10); + _6 = _5 as *mut u32 (PtrToPtr); + _7 = Offset(_6, _2); StorageDead(_6); - _9 = &mut (*_8); - _0 = Option::<&mut u32>::Some(_9); + StorageDead(_9); + StorageDead(_5); + _8 = &mut (*_7); + _0 = Option::<&mut u32>::Some(move _8); StorageDead(_8); goto -> bb3; } bb3: { - StorageDead(_5); - StorageDead(_9); + StorageDead(_4); + StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index 0c44873b7..2f5d356a2 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -4,49 +4,49 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug slice => _1; debug index => _2; let mut _0: &mut [u32]; + let mut _3: usize; + let mut _4: usize; scope 1 (inlined core::slice::::get_unchecked_mut::>) { debug self => _1; - debug index => _2; - let mut _3: *mut [u32]; - let mut _14: *mut [u32]; + debug index => std::ops::Range{ .0 => _3, .1 => _4, }; + let mut _5: *mut [u32]; + let mut _13: *mut [u32]; scope 2 { scope 3 (inlined as SliceIndex<[u32]>>::get_unchecked_mut) { - debug self => _2; - debug slice => _3; - let mut _4: usize; - let mut _5: usize; + debug self => std::ops::Range{ .0 => _3, .1 => _4, }; + debug slice => _5; let mut _7: *mut u32; - let mut _8: usize; - let mut _9: *mut u32; - let _15: std::ops::Range; + let mut _8: *mut u32; + let _14: usize; + let _15: usize; scope 4 { - debug this => _15; + debug this => std::ops::Range{ .0 => _14, .1 => _15, }; scope 5 { let _6: usize; scope 6 { debug new_len => _6; scope 7 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _3; + debug self => _5; } scope 8 (inlined ptr::mut_ptr::::add) { debug self => _7; - debug count => _8; + debug count => _3; scope 9 { } } scope 10 (inlined slice_from_raw_parts_mut::) { - debug data => _9; + debug data => _8; debug len => _6; - let mut _10: *mut (); + let mut _9: *mut (); scope 11 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _9; + debug self => _8; } scope 12 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { - debug data_address => _10; + debug data_address => _9; debug metadata => _6; - let mut _11: *const (); - let mut _12: std::ptr::metadata::PtrComponents<[u32]>; - let mut _13: std::ptr::metadata::PtrRepr<[u32]>; + let mut _10: *const (); + let mut _11: std::ptr::metadata::PtrComponents<[u32]>; + let mut _12: std::ptr::metadata::PtrRepr<[u32]>; scope 13 { } } @@ -59,45 +59,38 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + _3 = move (_2.0: usize); + _4 = move (_2.1: usize); + StorageLive(_5); + _5 = &raw mut (*_1); StorageLive(_14); - StorageLive(_3); - _3 = &raw mut (*_1); StorageLive(_15); StorageLive(_6); - StorageLive(_4); - _4 = (_2.1: usize); - StorageLive(_5); - _5 = (_2.0: usize); - _6 = SubUnchecked(move _4, move _5); - StorageDead(_5); - StorageDead(_4); - StorageLive(_9); - StorageLive(_7); - _7 = _3 as *mut u32 (PtrToPtr); + _6 = SubUnchecked(_4, _3); StorageLive(_8); - _8 = (_2.0: usize); - _9 = Offset(_7, _8); - StorageDead(_8); + StorageLive(_7); + _7 = _5 as *mut u32 (PtrToPtr); + _8 = Offset(_7, _3); StorageDead(_7); - StorageLive(_10); - _10 = _9 as *mut () (PtrToPtr); - StorageLive(_13); + StorageLive(_9); + _9 = _8 as *mut () (PtrToPtr); StorageLive(_12); StorageLive(_11); - _11 = _10 as *const () (PointerCoercion(MutToConstPointer)); - _12 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _11, metadata: _6 }; + StorageLive(_10); + _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); + _11 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _10, metadata: _6 }; + StorageDead(_10); + _12 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; StorageDead(_11); - _13 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _12 }; + _13 = (_12.1: *mut [u32]); StorageDead(_12); - _14 = (_13.1: *mut [u32]); - StorageDead(_13); - StorageDead(_10); StorageDead(_9); + StorageDead(_8); StorageDead(_6); - StorageDead(_15); - StorageDead(_3); - _0 = &mut (*_14); StorageDead(_14); + StorageDead(_15); + StorageDead(_5); + _0 = &mut (*_13); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 0c44873b7..2f5d356a2 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -4,49 +4,49 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug slice => _1; debug index => _2; let mut _0: &mut [u32]; + let mut _3: usize; + let mut _4: usize; scope 1 (inlined core::slice::::get_unchecked_mut::>) { debug self => _1; - debug index => _2; - let mut _3: *mut [u32]; - let mut _14: *mut [u32]; + debug index => std::ops::Range{ .0 => _3, .1 => _4, }; + let mut _5: *mut [u32]; + let mut _13: *mut [u32]; scope 2 { scope 3 (inlined as SliceIndex<[u32]>>::get_unchecked_mut) { - debug self => _2; - debug slice => _3; - let mut _4: usize; - let mut _5: usize; + debug self => std::ops::Range{ .0 => _3, .1 => _4, }; + debug slice => _5; let mut _7: *mut u32; - let mut _8: usize; - let mut _9: *mut u32; - let _15: std::ops::Range; + let mut _8: *mut u32; + let _14: usize; + let _15: usize; scope 4 { - debug this => _15; + debug this => std::ops::Range{ .0 => _14, .1 => _15, }; scope 5 { let _6: usize; scope 6 { debug new_len => _6; scope 7 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _3; + debug self => _5; } scope 8 (inlined ptr::mut_ptr::::add) { debug self => _7; - debug count => _8; + debug count => _3; scope 9 { } } scope 10 (inlined slice_from_raw_parts_mut::) { - debug data => _9; + debug data => _8; debug len => _6; - let mut _10: *mut (); + let mut _9: *mut (); scope 11 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _9; + debug self => _8; } scope 12 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { - debug data_address => _10; + debug data_address => _9; debug metadata => _6; - let mut _11: *const (); - let mut _12: std::ptr::metadata::PtrComponents<[u32]>; - let mut _13: std::ptr::metadata::PtrRepr<[u32]>; + let mut _10: *const (); + let mut _11: std::ptr::metadata::PtrComponents<[u32]>; + let mut _12: std::ptr::metadata::PtrRepr<[u32]>; scope 13 { } } @@ -59,45 +59,38 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + _3 = move (_2.0: usize); + _4 = move (_2.1: usize); + StorageLive(_5); + _5 = &raw mut (*_1); StorageLive(_14); - StorageLive(_3); - _3 = &raw mut (*_1); StorageLive(_15); StorageLive(_6); - StorageLive(_4); - _4 = (_2.1: usize); - StorageLive(_5); - _5 = (_2.0: usize); - _6 = SubUnchecked(move _4, move _5); - StorageDead(_5); - StorageDead(_4); - StorageLive(_9); - StorageLive(_7); - _7 = _3 as *mut u32 (PtrToPtr); + _6 = SubUnchecked(_4, _3); StorageLive(_8); - _8 = (_2.0: usize); - _9 = Offset(_7, _8); - StorageDead(_8); + StorageLive(_7); + _7 = _5 as *mut u32 (PtrToPtr); + _8 = Offset(_7, _3); StorageDead(_7); - StorageLive(_10); - _10 = _9 as *mut () (PtrToPtr); - StorageLive(_13); + StorageLive(_9); + _9 = _8 as *mut () (PtrToPtr); StorageLive(_12); StorageLive(_11); - _11 = _10 as *const () (PointerCoercion(MutToConstPointer)); - _12 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _11, metadata: _6 }; + StorageLive(_10); + _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); + _11 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _10, metadata: _6 }; + StorageDead(_10); + _12 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; StorageDead(_11); - _13 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _12 }; + _13 = (_12.1: *mut [u32]); StorageDead(_12); - _14 = (_13.1: *mut [u32]); - StorageDead(_13); - StorageDead(_10); StorageDead(_9); + StorageDead(_8); StorageDead(_6); - StorageDead(_15); - StorageDead(_3); - _0 = &mut (*_14); StorageDead(_14); + StorageDead(_15); + StorageDead(_5); + _0 = &mut (*_13); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir index aff718566..df6d2263d 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir @@ -12,7 +12,7 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { bb0: { StorageLive(_3); - _3 = as SliceIndex<[u32]>>::index(move _2, _1) -> [return: bb1, unwind unreachable]; + _3 = as SliceIndex<[u32]>>::index(move _2, move _1) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir index a6b931d2c..cc1795c3f 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir @@ -12,7 +12,7 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { bb0: { StorageLive(_3); - _3 = as SliceIndex<[u32]>>::index(move _2, _1) -> [return: bb1, unwind continue]; + _3 = as SliceIndex<[u32]>>::index(move _2, move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index 3c4140257..89009864c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -38,25 +38,24 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 6 { let _7: *const T; scope 7 { - debug end => _7; + debug end_or_len => _7; scope 13 (inlined NonNull::::new_unchecked) { debug ptr => _9; let mut _10: *const T; - let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { - debug ptr => _24; + debug ptr => _9; scope 16 (inlined ptr::mut_ptr::::is_null) { - debug self => _24; - let mut _25: *mut u8; + debug self => _9; + let mut _24: *mut u8; scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { - debug ptr => _25; + debug ptr => _24; scope 19 (inlined ptr::mut_ptr::::addr) { - debug self => _25; + debug self => _24; scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _25; + debug self => _24; } } } @@ -132,16 +131,14 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); - StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull:: { pointer: _10 }; - StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); StorageLive(_12); _12 = _7; - _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_12); StorageDead(_11); StorageDead(_7); @@ -155,11 +152,13 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb4: { StorageLive(_17); + StorageLive(_16); _16 = &mut _15; - _17 = > as Iterator>::next(_16) -> [return: bb5, unwind unreachable]; + _17 = > as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; } bb5: { + StorageDead(_16); _18 = discriminant(_17); switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index e3df8b961..836fa2677 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -38,25 +38,24 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 6 { let _7: *const T; scope 7 { - debug end => _7; + debug end_or_len => _7; scope 13 (inlined NonNull::::new_unchecked) { debug ptr => _9; let mut _10: *const T; - let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { - debug ptr => _24; + debug ptr => _9; scope 16 (inlined ptr::mut_ptr::::is_null) { - debug self => _24; - let mut _25: *mut u8; + debug self => _9; + let mut _24: *mut u8; scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { - debug ptr => _25; + debug ptr => _24; scope 19 (inlined ptr::mut_ptr::::addr) { - debug self => _25; + debug self => _24; scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _25; + debug self => _24; } } } @@ -132,16 +131,14 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); - StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull:: { pointer: _10 }; - StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); StorageLive(_12); _12 = _7; - _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_12); StorageDead(_11); StorageDead(_7); @@ -155,11 +152,13 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb4: { StorageLive(_17); + StorageLive(_16); _16 = &mut _15; - _17 = > as Iterator>::next(_16) -> [return: bb5, unwind: bb11]; + _17 = > as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { + StorageDead(_16); _18 = discriminant(_17); switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 49de4b463..146fa57a0 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -35,25 +35,24 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 6 { let _7: *const T; scope 7 { - debug end => _7; + debug end_or_len => _7; scope 13 (inlined NonNull::::new_unchecked) { debug ptr => _9; let mut _10: *const T; - let mut _22: *mut T; scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { - debug ptr => _22; + debug ptr => _9; scope 16 (inlined ptr::mut_ptr::::is_null) { - debug self => _22; - let mut _23: *mut u8; + debug self => _9; + let mut _22: *mut u8; scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { - debug ptr => _23; + debug ptr => _22; scope 19 (inlined ptr::mut_ptr::::addr) { - debug self => _23; + debug self => _22; scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _23; + debug self => _22; } } } @@ -122,16 +121,14 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_22); - StorageLive(_23); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull:: { pointer: _10 }; - StorageDead(_23); StorageDead(_22); StorageDead(_10); StorageDead(_9); StorageLive(_12); _12 = _7; - _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_12); StorageDead(_11); StorageDead(_7); @@ -143,11 +140,13 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb4: { StorageLive(_16); + StorageLive(_15); _15 = &mut _14; - _16 = as Iterator>::next(_15) -> [return: bb5, unwind unreachable]; + _16 = as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { + StorageDead(_15); _17 = discriminant(_16); switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index cfc304987..65baaf64a 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -35,25 +35,24 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 6 { let _7: *const T; scope 7 { - debug end => _7; + debug end_or_len => _7; scope 13 (inlined NonNull::::new_unchecked) { debug ptr => _9; let mut _10: *const T; - let mut _22: *mut T; scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { - debug ptr => _22; + debug ptr => _9; scope 16 (inlined ptr::mut_ptr::::is_null) { - debug self => _22; - let mut _23: *mut u8; + debug self => _9; + let mut _22: *mut u8; scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { - debug ptr => _23; + debug ptr => _22; scope 19 (inlined ptr::mut_ptr::::addr) { - debug self => _23; + debug self => _22; scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _23; + debug self => _22; } } } @@ -122,16 +121,14 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_22); - StorageLive(_23); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull:: { pointer: _10 }; - StorageDead(_23); StorageDead(_22); StorageDead(_10); StorageDead(_9); StorageLive(_12); _12 = _7; - _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_12); StorageDead(_11); StorageDead(_7); @@ -143,11 +140,13 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb4: { StorageLive(_16); + StorageLive(_15); _15 = &mut _14; - _16 = as Iterator>::next(_15) -> [return: bb5, unwind: bb11]; + _16 = as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { + StorageDead(_15); _17 = discriminant(_16); switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index 00177033b..4edf4b4fb 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -7,43 +7,43 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _3: usize; let mut _4: std::ops::Range; let mut _5: std::ops::Range; - let mut _6: &mut std::ops::Range; - let mut _12: std::option::Option; - let mut _15: isize; - let mut _17: usize; - let mut _18: bool; - let mut _20: &impl Fn(usize, &T); - let mut _21: (usize, &T); - let _22: (); + let mut _9: std::option::Option; + let mut _12: isize; + let mut _14: usize; + let mut _15: bool; + let mut _17: &impl Fn(usize, &T); + let mut _18: (usize, &T); + let _19: (); + let mut _20: &mut std::ops::Range; scope 1 { debug iter => _5; - let _16: usize; + let _13: usize; scope 2 { - debug i => _16; - let _19: &T; + debug i => _13; + let _16: &T; scope 3 { - debug x => _19; + debug x => _16; } } scope 5 (inlined iter::range::>::next) { - debug self => _6; + debug self => _20; scope 6 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &usize; - let mut _8: &usize; - let mut _11: bool; - let _13: usize; - let mut _14: usize; + debug self => _20; + let mut _8: bool; + let _10: usize; + let mut _11: usize; + let mut _21: &usize; + let mut _22: &usize; scope 7 { - debug old => _13; + debug old => _10; scope 8 { } } scope 9 (inlined cmp::impls::::lt) { - debug self => _7; - debug other => _8; - let mut _9: usize; - let mut _10: usize; + debug self => _21; + debug other => _22; + let mut _6: usize; + let mut _7: usize; } } } @@ -63,53 +63,50 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb1: { - StorageLive(_12); - _6 = &mut _5; - StorageLive(_13); - StorageLive(_11); - StorageLive(_7); - _7 = &((*_6).0: usize); - StorageLive(_8); - _8 = &((*_6).1: usize); StorageLive(_9); - _9 = (*_7); StorageLive(_10); - _10 = (*_8); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - StorageDead(_8); + StorageLive(_8); + StorageLive(_21); + StorageLive(_22); + StorageLive(_6); + _6 = (_5.0: usize); + StorageLive(_7); + _7 = (_5.1: usize); + _8 = Lt(move _6, move _7); StorageDead(_7); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + StorageDead(_6); + StorageDead(_22); + StorageDead(_21); + switchInt(move _8) -> [0: bb2, otherwise: bb3]; } bb2: { - _12 = Option::::None; + _9 = Option::::None; goto -> bb5; } bb3: { - _13 = ((*_6).0: usize); - StorageLive(_14); - _14 = ::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable]; + _10 = (_5.0: usize); + StorageLive(_11); + _11 = ::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind unreachable]; } bb4: { - ((*_6).0: usize) = move _14; - StorageDead(_14); - _12 = Option::::Some(_13); + (_5.0: usize) = move _11; + StorageDead(_11); + _9 = Option::::Some(_10); goto -> bb5; } bb5: { - StorageDead(_11); - StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11]; + StorageDead(_8); + StorageDead(_10); + _12 = discriminant(_9); + switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb11]; } bb6: { - StorageDead(_12); + StorageDead(_9); StorageDead(_5); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -119,25 +116,25 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _16 = ((_12 as Some).0: usize); - _17 = Len((*_1)); - _18 = Lt(_16, _17); - assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind unreachable]; + _13 = ((_9 as Some).0: usize); + _14 = Len((*_1)); + _15 = Lt(_13, _14); + assert(move _15, "index out of bounds: the length is {} but the index is {}", move _14, _13) -> [success: bb9, unwind unreachable]; } bb9: { - _19 = &(*_1)[_16]; - StorageLive(_20); - _20 = &_2; - StorageLive(_21); - _21 = (_16, _19); - _22 = >::call(move _20, move _21) -> [return: bb10, unwind unreachable]; + _16 = &(*_1)[_13]; + StorageLive(_17); + _17 = &_2; + StorageLive(_18); + _18 = (_13, _16); + _19 = >::call(move _17, move _18) -> [return: bb10, unwind unreachable]; } bb10: { - StorageDead(_21); - StorageDead(_20); - StorageDead(_12); + StorageDead(_18); + StorageDead(_17); + StorageDead(_9); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 3423c5d86..f7b19e80e 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -7,43 +7,43 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _3: usize; let mut _4: std::ops::Range; let mut _5: std::ops::Range; - let mut _6: &mut std::ops::Range; - let mut _12: std::option::Option; - let mut _15: isize; - let mut _17: usize; - let mut _18: bool; - let mut _20: &impl Fn(usize, &T); - let mut _21: (usize, &T); - let _22: (); + let mut _9: std::option::Option; + let mut _12: isize; + let mut _14: usize; + let mut _15: bool; + let mut _17: &impl Fn(usize, &T); + let mut _18: (usize, &T); + let _19: (); + let mut _20: &mut std::ops::Range; scope 1 { debug iter => _5; - let _16: usize; + let _13: usize; scope 2 { - debug i => _16; - let _19: &T; + debug i => _13; + let _16: &T; scope 3 { - debug x => _19; + debug x => _16; } } scope 5 (inlined iter::range::>::next) { - debug self => _6; + debug self => _20; scope 6 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &usize; - let mut _8: &usize; - let mut _11: bool; - let _13: usize; - let mut _14: usize; + debug self => _20; + let mut _8: bool; + let _10: usize; + let mut _11: usize; + let mut _21: &usize; + let mut _22: &usize; scope 7 { - debug old => _13; + debug old => _10; scope 8 { } } scope 9 (inlined cmp::impls::::lt) { - debug self => _7; - debug other => _8; - let mut _9: usize; - let mut _10: usize; + debug self => _21; + debug other => _22; + let mut _6: usize; + let mut _7: usize; } } } @@ -63,53 +63,50 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb1: { - StorageLive(_12); - _6 = &mut _5; - StorageLive(_13); - StorageLive(_11); - StorageLive(_7); - _7 = &((*_6).0: usize); - StorageLive(_8); - _8 = &((*_6).1: usize); StorageLive(_9); - _9 = (*_7); StorageLive(_10); - _10 = (*_8); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - StorageDead(_8); + StorageLive(_8); + StorageLive(_21); + StorageLive(_22); + StorageLive(_6); + _6 = (_5.0: usize); + StorageLive(_7); + _7 = (_5.1: usize); + _8 = Lt(move _6, move _7); StorageDead(_7); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + StorageDead(_6); + StorageDead(_22); + StorageDead(_21); + switchInt(move _8) -> [0: bb2, otherwise: bb3]; } bb2: { - _12 = Option::::None; + _9 = Option::::None; goto -> bb5; } bb3: { - _13 = ((*_6).0: usize); - StorageLive(_14); - _14 = ::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb12]; + _10 = (_5.0: usize); + StorageLive(_11); + _11 = ::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind: bb12]; } bb4: { - ((*_6).0: usize) = move _14; - StorageDead(_14); - _12 = Option::::Some(_13); + (_5.0: usize) = move _11; + StorageDead(_11); + _9 = Option::::Some(_10); goto -> bb5; } bb5: { - StorageDead(_11); - StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11]; + StorageDead(_8); + StorageDead(_10); + _12 = discriminant(_9); + switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb11]; } bb6: { - StorageDead(_12); + StorageDead(_9); StorageDead(_5); drop(_2) -> [return: bb7, unwind continue]; } @@ -119,25 +116,25 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _16 = ((_12 as Some).0: usize); - _17 = Len((*_1)); - _18 = Lt(_16, _17); - assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind: bb12]; + _13 = ((_9 as Some).0: usize); + _14 = Len((*_1)); + _15 = Lt(_13, _14); + assert(move _15, "index out of bounds: the length is {} but the index is {}", move _14, _13) -> [success: bb9, unwind: bb12]; } bb9: { - _19 = &(*_1)[_16]; - StorageLive(_20); - _20 = &_2; - StorageLive(_21); - _21 = (_16, _19); - _22 = >::call(move _20, move _21) -> [return: bb10, unwind: bb12]; + _16 = &(*_1)[_13]; + StorageLive(_17); + _17 = &_2; + StorageLive(_18); + _18 = (_13, _16); + _19 = >::call(move _17, move _18) -> [return: bb10, unwind: bb12]; } bb10: { - StorageDead(_21); - StorageDead(_20); - StorageDead(_12); + StorageDead(_18); + StorageDead(_17); + StorageDead(_9); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 1b4ac793f..549cb4f46 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -7,21 +7,21 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _13: std::slice::Iter<'_, T>; let mut _14: std::iter::Rev>; let mut _15: std::iter::Rev>; - let mut _16: &mut std::iter::Rev>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _17: std::option::Option<&T>; + let mut _18: isize; + let mut _20: &impl Fn(&T); + let mut _21: (&T,); + let _22: (); + let mut _23: &mut std::iter::Rev>; scope 1 { debug iter => _15; - let _20: &T; + let _19: &T; scope 2 { - debug x => _20; + debug x => _19; } scope 25 (inlined > as Iterator>::next) { - debug self => _16; - let mut _17: &mut std::slice::Iter<'_, T>; + debug self => _23; + let mut _16: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::::iter) { @@ -40,25 +40,24 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 6 { let _7: *const T; scope 7 { - debug end => _7; + debug end_or_len => _7; scope 13 (inlined NonNull::::new_unchecked) { debug ptr => _9; let mut _10: *const T; - let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { - debug ptr => _24; + debug ptr => _9; scope 16 (inlined ptr::mut_ptr::::is_null) { - debug self => _24; - let mut _25: *mut u8; + debug self => _9; + let mut _24: *mut u8; scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { - debug ptr => _25; + debug ptr => _24; scope 19 (inlined ptr::mut_ptr::::addr) { - debug self => _25; + debug self => _24; scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _25; + debug self => _24; } } } @@ -134,16 +133,14 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); - StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull:: { pointer: _10 }; - StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); StorageLive(_12); _12 = _7; - _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_12); StorageDead(_11); StorageDead(_7); @@ -156,21 +153,20 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_18); - _16 = &mut _15; StorageLive(_17); - _17 = &mut ((*_16).0: std::slice::Iter<'_, T>); - _18 = as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind unreachable]; + StorageLive(_16); + _16 = &mut (_15.0: std::slice::Iter<'_, T>); + _17 = as DoubleEndedIterator>::next_back(move _16) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); + StorageDead(_17); StorageDead(_15); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -180,18 +176,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); + _19 = ((_17 as Some).0: &T); + StorageLive(_20); + _20 = &_2; StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = >::call(move _21, move _22) -> [return: bb9, unwind unreachable]; + _21 = (_19,); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_22); StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index f75a9a03d..43f8806e1 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -7,21 +7,21 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _13: std::slice::Iter<'_, T>; let mut _14: std::iter::Rev>; let mut _15: std::iter::Rev>; - let mut _16: &mut std::iter::Rev>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _17: std::option::Option<&T>; + let mut _18: isize; + let mut _20: &impl Fn(&T); + let mut _21: (&T,); + let _22: (); + let mut _23: &mut std::iter::Rev>; scope 1 { debug iter => _15; - let _20: &T; + let _19: &T; scope 2 { - debug x => _20; + debug x => _19; } scope 25 (inlined > as Iterator>::next) { - debug self => _16; - let mut _17: &mut std::slice::Iter<'_, T>; + debug self => _23; + let mut _16: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::::iter) { @@ -40,25 +40,24 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 6 { let _7: *const T; scope 7 { - debug end => _7; + debug end_or_len => _7; scope 13 (inlined NonNull::::new_unchecked) { debug ptr => _9; let mut _10: *const T; - let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { - debug ptr => _24; + debug ptr => _9; scope 16 (inlined ptr::mut_ptr::::is_null) { - debug self => _24; - let mut _25: *mut u8; + debug self => _9; + let mut _24: *mut u8; scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { - debug ptr => _25; + debug ptr => _24; scope 19 (inlined ptr::mut_ptr::::addr) { - debug self => _25; + debug self => _24; scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _25; + debug self => _24; } } } @@ -134,16 +133,14 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); - StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull:: { pointer: _10 }; - StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); StorageLive(_12); _12 = _7; - _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_12); StorageDead(_11); StorageDead(_7); @@ -156,21 +153,20 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_18); - _16 = &mut _15; StorageLive(_17); - _17 = &mut ((*_16).0: std::slice::Iter<'_, T>); - _18 = as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind: bb11]; + StorageLive(_16); + _16 = &mut (_15.0: std::slice::Iter<'_, T>); + _17 = as DoubleEndedIterator>::next_back(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); + StorageDead(_17); StorageDead(_15); drop(_2) -> [return: bb7, unwind continue]; } @@ -180,18 +176,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); + _19 = ((_17 as Some).0: &T); + StorageLive(_20); + _20 = &_2; StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = >::call(move _21, move _22) -> [return: bb9, unwind: bb11]; + _21 = (_19,); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_22); StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir index 0471d0757..78f96bf41 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir @@ -5,7 +5,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut let mut _0: std::option::Option<&mut T>; bb0: { - _0 = as DoubleEndedIterator>::next_back(_1) -> [return: bb1, unwind unreachable]; + _0 = as DoubleEndedIterator>::next_back(move _1) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir index 386f3a9ed..dfe5e206f 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir @@ -5,7 +5,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut let mut _0: std::option::Option<&mut T>; bb0: { - _0 = as DoubleEndedIterator>::next_back(_1) -> [return: bb1, unwind continue]; + _0 = as DoubleEndedIterator>::next_back(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir index 8c0209ae1..8edac638c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir @@ -5,7 +5,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let mut _0: std::option::Option<&T>; bb0: { - _0 = as Iterator>::next(_1) -> [return: bb1, unwind unreachable]; + _0 = as Iterator>::next(move _1) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir index e76ec0039..fdde07173 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir @@ -5,7 +5,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let mut _0: std::option::Option<&T>; bb0: { - _0 = as Iterator>::next(_1) -> [return: bb1, unwind continue]; + _0 = as Iterator>::next(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir index b9329520b..ed7107e53 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir @@ -3,17 +3,19 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 - let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 bb0: { + StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 - _0 = inner(_2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/spans.rs:11:5: 11:14 + _0 = inner(move _2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/spans.rs:11:5: 11:14 // mir::Constant // + span: $DIR/spans.rs:11:5: 11:10 // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value() } } bb1: { + StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir index 1e20b1be5..dc436dc26 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir @@ -3,17 +3,19 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 - let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 bb0: { + StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 - _0 = inner(_2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:11:5: 11:14 + _0 = inner(move _2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:11:5: 11:14 // mir::Constant // + span: $DIR/spans.rs:11:5: 11:10 // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value() } } bb1: { + StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } } diff --git a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff index 132f66a1a..8fe361f2b 100644 --- a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff @@ -22,27 +22,23 @@ let _24: &mut u8; let mut _25: debuginfo::T; scope 1 { -- debug ref_mut_u8 => _1; -+ debug ref_mut_u8 => &_2; + debug ref_mut_u8 => _1; let _3: &u8; let mut _28: &debuginfo::T; scope 2 { -- debug field => _3; -+ debug field => &((*_28).0: u8); + debug field => _3; let _5: &u8; scope 3 { - debug reborrow => _5; -+ debug reborrow => &_2; ++ debug reborrow => _1; let _9: &i32; let _22: &&&mut u8; let mut _27: &std::option::Option; scope 4 { -- debug variant_field => _9; -+ debug variant_field => &(((*_27) as Some).0: i32); + debug variant_field => _9; } scope 5 { -- debug constant_index => _19; -+ debug constant_index => &(*_11)[1 of 3]; + debug constant_index => _19; debug subslice => _20; debug constant_index_from_end => _21; let _19: &i32; @@ -51,21 +47,20 @@ let mut _26: &[i32; 10]; } scope 6 { -- debug multiple_borrow => _22; -+ debug multiple_borrow => &&&(_25.0: u8); + debug multiple_borrow => _22; } } } } bb0: { -- StorageLive(_1); + StorageLive(_1); StorageLive(_2); _2 = const 5_u8; -- _1 = &mut _2; -- StorageLive(_3); + _1 = &mut _2; + StorageLive(_3); _28 = const _; -- _3 = &((*_28).0: u8); + _3 = &((*_28).0: u8); - StorageLive(_5); - _5 = &(*_1); - StorageLive(_6); @@ -76,11 +71,11 @@ } bb1: { -- StorageLive(_9); + StorageLive(_9); _27 = const _; -- _9 = &(((*_27) as Some).0: i32); + _9 = &(((*_27) as Some).0: i32); - _6 = const (); -- StorageDead(_9); + StorageDead(_9); goto -> bb4; } @@ -118,8 +113,8 @@ } bb6: { -- StorageLive(_19); -- _19 = &(*_11)[1 of 3]; + StorageLive(_19); + _19 = &(*_11)[1 of 3]; StorageLive(_20); _20 = &(*_11)[2:-1]; StorageLive(_21); @@ -127,7 +122,7 @@ - _10 = const (); StorageDead(_21); StorageDead(_20); -- StorageDead(_19); + StorageDead(_19); goto -> bb8; } @@ -140,23 +135,23 @@ StorageDead(_12); StorageDead(_11); - StorageDead(_10); -- StorageLive(_22); -- StorageLive(_23); -- StorageLive(_24); + StorageLive(_22); + StorageLive(_23); + StorageLive(_24); StorageLive(_25); _25 = T(const 6_u8); -- _24 = &mut (_25.0: u8); -- _23 = &_24; -- _22 = &_23; + _24 = &mut (_25.0: u8); + _23 = &_24; + _22 = &_23; _0 = const (); StorageDead(_25); -- StorageDead(_24); -- StorageDead(_23); -- StorageDead(_22); + StorageDead(_24); + StorageDead(_23); + StorageDead(_22); - StorageDead(_5); -- StorageDead(_3); + StorageDead(_3); StorageDead(_2); -- StorageDead(_1); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff index 9ec8f9d78..747028e12 100644 --- a/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff @@ -13,16 +13,15 @@ debug x => _1; let _2: &mut i32; scope 2 { -- debug xref => _2; -+ debug xref => &_1; + debug xref => _2; let _3: *mut i32; scope 3 { - debug xraw => _3; -+ debug xraw => &_1; ++ debug xraw => _2; let _6: &i32; scope 4 { - debug xshr => _6; -+ debug xshr => &_1; ++ debug xshr => _2; let _7: i32; scope 5 { debug a => _7; @@ -38,7 +37,7 @@ StorageLive(_1); _1 = const 2_i32; - StorageLive(_2); -- _2 = &mut _1; + _2 = &mut _1; - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); diff --git a/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff index f1f77cffd..1be2ce8d0 100644 --- a/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff @@ -52,8 +52,7 @@ debug a => _4; let _5: &usize; scope 2 { -- debug b => _5; -+ debug b => &_4; + debug b => _5; let _6: usize; scope 3 { debug c => _6; @@ -158,12 +157,10 @@ debug a => _60; let _61: &usize; scope 30 { -- debug b => _61; -+ debug b => &_60; + debug b => _61; let _62: &&usize; scope 31 { -- debug d => _62; -+ debug d => &&_60; + debug d => _62; let _63: usize; scope 32 { debug c => _63; @@ -175,12 +172,10 @@ debug a => _66; let mut _67: &usize; scope 34 { -- debug b => _67; -+ debug b => &_66; + debug b => _67; let _68: &mut &usize; scope 35 { -- debug d => _68; -+ debug d => &&_66; + debug d => _68; let _69: usize; scope 36 { debug c => _69; @@ -193,8 +188,8 @@ - StorageLive(_3); StorageLive(_4); _4 = const 5_usize; -- StorageLive(_5); -- _5 = &_4; + StorageLive(_5); + _5 = &_4; StorageLive(_6); - _6 = (*_5); + _6 = _4; @@ -209,7 +204,7 @@ StorageDead(_7); - _3 = const (); StorageDead(_6); -- StorageDead(_5); + StorageDead(_5); StorageDead(_4); - StorageDead(_3); - StorageLive(_9); @@ -394,13 +389,12 @@ - StorageLive(_59); StorageLive(_60); _60 = const 5_usize; -- StorageLive(_61); -- _61 = &_60; -- StorageLive(_62); -- _62 = &_61; + StorageLive(_61); + _61 = &_60; + StorageLive(_62); + _62 = &_61; StorageLive(_63); -- _63 = (*_61); -+ _63 = _60; + _63 = (*_61); StorageLive(_64); StorageLive(_65); _65 = (); @@ -412,19 +406,18 @@ StorageDead(_64); - _59 = const (); StorageDead(_63); -- StorageDead(_62); -- StorageDead(_61); + StorageDead(_62); + StorageDead(_61); StorageDead(_60); - StorageDead(_59); StorageLive(_66); _66 = const 5_usize; -- StorageLive(_67); -- _67 = &_66; -- StorageLive(_68); -- _68 = &mut _67; + StorageLive(_67); + _67 = &_66; + StorageLive(_68); + _68 = &mut _67; StorageLive(_69); -- _69 = (*_67); -+ _69 = _66; + _69 = (*_67); StorageLive(_70); StorageLive(_71); _71 = (); @@ -436,8 +429,8 @@ StorageDead(_70); _0 = const (); StorageDead(_69); -- StorageDead(_68); -- StorageDead(_67); + StorageDead(_68); + StorageDead(_67); StorageDead(_66); return; } diff --git a/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff index 05eab7989..ce5ddbfdd 100644 --- a/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff @@ -45,8 +45,7 @@ debug a => _4; let _5: *const usize; scope 3 { -- debug b => _5; -+ debug b => &_4; + debug b => _5; let _6: usize; scope 4 { debug c => _6; @@ -175,12 +174,10 @@ debug a => _58; let _59: *const usize; scope 39 { -- debug b => _59; -+ debug b => &_58; + debug b => _59; let _60: *const usize; scope 40 { -- debug c => _60; -+ debug c => &_58; + debug c => _60; let _61: usize; scope 41 { debug e => _61; @@ -195,12 +192,10 @@ debug a => _65; let _66: *const usize; scope 44 { -- debug b => _66; -+ debug b => &_65; + debug b => _66; let _67: &*const usize; scope 45 { -- debug d => _67; -+ debug d => &&_65; + debug d => _67; let _68: usize; scope 46 { debug c => _68; @@ -215,12 +210,10 @@ debug a => _71; let mut _72: *const usize; scope 49 { -- debug b => _72; -+ debug b => &_71; + debug b => _72; let _73: &mut *const usize; scope 50 { -- debug d => _73; -+ debug d => &&_71; + debug d => _73; let _74: usize; scope 51 { debug c => _74; @@ -234,8 +227,8 @@ - StorageLive(_3); StorageLive(_4); _4 = const 5_usize; -- StorageLive(_5); -- _5 = &raw const _4; + StorageLive(_5); + _5 = &raw const _4; StorageLive(_6); - _6 = (*_5); + _6 = _4; @@ -250,7 +243,7 @@ StorageDead(_7); - _3 = const (); StorageDead(_6); -- StorageDead(_5); + StorageDead(_5); StorageDead(_4); - StorageDead(_3); - StorageLive(_9); @@ -427,10 +420,11 @@ - StorageLive(_57); StorageLive(_58); _58 = const 13_usize; -- StorageLive(_59); -- _59 = &raw const _58; -- StorageLive(_60); + StorageLive(_59); + _59 = &raw const _58; + StorageLive(_60); - _60 = &raw const (*_59); ++ _60 = &raw const _58; StorageLive(_61); - _61 = (*_60); + _61 = _58; @@ -445,20 +439,19 @@ StorageDead(_62); - _57 = const (); StorageDead(_61); -- StorageDead(_60); -- StorageDead(_59); + StorageDead(_60); + StorageDead(_59); StorageDead(_58); - StorageDead(_57); - StorageLive(_64); StorageLive(_65); _65 = const 5_usize; -- StorageLive(_66); -- _66 = &raw const _65; -- StorageLive(_67); -- _67 = &_66; + StorageLive(_66); + _66 = &raw const _65; + StorageLive(_67); + _67 = &_66; StorageLive(_68); -- _68 = (*_66); -+ _68 = _65; + _68 = (*_66); StorageLive(_69); StorageLive(_70); _70 = (); @@ -470,19 +463,18 @@ StorageDead(_69); - _64 = const (); StorageDead(_68); -- StorageDead(_67); -- StorageDead(_66); + StorageDead(_67); + StorageDead(_66); StorageDead(_65); - StorageDead(_64); StorageLive(_71); _71 = const 5_usize; -- StorageLive(_72); -- _72 = &raw const _71; -- StorageLive(_73); -- _73 = &mut _72; + StorageLive(_72); + _72 = &raw const _71; + StorageLive(_73); + _73 = &mut _72; StorageLive(_74); -- _74 = (*_72); -+ _74 = _71; + _74 = (*_72); StorageLive(_75); StorageLive(_76); _76 = (); @@ -494,8 +486,8 @@ StorageDead(_75); _0 = const (); StorageDead(_74); -- StorageDead(_73); -- StorageDead(_72); + StorageDead(_73); + StorageDead(_72); StorageDead(_71); return; } diff --git a/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff index ee680fdb3..7c7f424bb 100644 --- a/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff @@ -52,8 +52,7 @@ debug a => _4; let _5: &mut usize; scope 2 { -- debug b => _5; -+ debug b => &_4; + debug b => _5; let _6: usize; scope 3 { debug c => _6; @@ -158,12 +157,10 @@ debug a => _60; let _61: &mut usize; scope 30 { -- debug b => _61; -+ debug b => &_60; + debug b => _61; let _62: &&mut usize; scope 31 { -- debug d => _62; -+ debug d => &&_60; + debug d => _62; let _63: usize; scope 32 { debug c => _63; @@ -175,12 +172,10 @@ debug a => _66; let mut _67: &mut usize; scope 34 { -- debug b => _67; -+ debug b => &_66; + debug b => _67; let _68: &mut &mut usize; scope 35 { -- debug d => _68; -+ debug d => &&_66; + debug d => _68; let _69: usize; scope 36 { debug c => _69; @@ -193,8 +188,8 @@ - StorageLive(_3); StorageLive(_4); _4 = const 5_usize; -- StorageLive(_5); -- _5 = &mut _4; + StorageLive(_5); + _5 = &mut _4; StorageLive(_6); - _6 = (*_5); + _6 = _4; @@ -209,7 +204,7 @@ StorageDead(_7); - _3 = const (); StorageDead(_6); -- StorageDead(_5); + StorageDead(_5); StorageDead(_4); - StorageDead(_3); - StorageLive(_9); @@ -391,13 +386,12 @@ - StorageLive(_59); StorageLive(_60); _60 = const 5_usize; -- StorageLive(_61); -- _61 = &mut _60; -- StorageLive(_62); -- _62 = &_61; + StorageLive(_61); + _61 = &mut _60; + StorageLive(_62); + _62 = &_61; StorageLive(_63); -- _63 = (*_61); -+ _63 = _60; + _63 = (*_61); StorageLive(_64); StorageLive(_65); _65 = (); @@ -409,19 +403,18 @@ StorageDead(_64); - _59 = const (); StorageDead(_63); -- StorageDead(_62); -- StorageDead(_61); + StorageDead(_62); + StorageDead(_61); StorageDead(_60); - StorageDead(_59); StorageLive(_66); _66 = const 5_usize; -- StorageLive(_67); -- _67 = &mut _66; -- StorageLive(_68); -- _68 = &mut _67; + StorageLive(_67); + _67 = &mut _66; + StorageLive(_68); + _68 = &mut _67; StorageLive(_69); -- _69 = (*_67); -+ _69 = _66; + _69 = (*_67); StorageLive(_70); StorageLive(_71); _71 = (); @@ -433,8 +426,8 @@ StorageDead(_70); _0 = const (); StorageDead(_69); -- StorageDead(_68); -- StorageDead(_67); + StorageDead(_68); + StorageDead(_67); StorageDead(_66); return; } diff --git a/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff index fb0ef3184..b6b2acc0b 100644 --- a/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff @@ -42,8 +42,7 @@ debug a => _4; let _5: *mut usize; scope 3 { -- debug b => _5; -+ debug b => &_4; + debug b => _5; let _6: usize; scope 4 { debug c => _6; @@ -172,12 +171,10 @@ debug a => _58; let _59: *mut usize; scope 39 { -- debug b => _59; -+ debug b => &_58; + debug b => _59; let _60: &*mut usize; scope 40 { -- debug d => _60; -+ debug d => &&_58; + debug d => _60; let _61: usize; scope 41 { debug c => _61; @@ -192,12 +189,10 @@ debug a => _64; let mut _65: *mut usize; scope 44 { -- debug b => _65; -+ debug b => &_64; + debug b => _65; let _66: &mut *mut usize; scope 45 { -- debug d => _66; -+ debug d => &&_64; + debug d => _66; let _67: usize; scope 46 { debug c => _67; @@ -211,8 +206,8 @@ - StorageLive(_3); StorageLive(_4); _4 = const 5_usize; -- StorageLive(_5); -- _5 = &raw mut _4; + StorageLive(_5); + _5 = &raw mut _4; StorageLive(_6); - _6 = (*_5); + _6 = _4; @@ -227,7 +222,7 @@ StorageDead(_7); - _3 = const (); StorageDead(_6); -- StorageDead(_5); + StorageDead(_5); StorageDead(_4); - StorageDead(_3); - StorageLive(_9); @@ -401,13 +396,12 @@ - StorageLive(_57); StorageLive(_58); _58 = const 5_usize; -- StorageLive(_59); -- _59 = &raw mut _58; -- StorageLive(_60); -- _60 = &_59; + StorageLive(_59); + _59 = &raw mut _58; + StorageLive(_60); + _60 = &_59; StorageLive(_61); -- _61 = (*_59); -+ _61 = _58; + _61 = (*_59); StorageLive(_62); StorageLive(_63); _63 = (); @@ -419,19 +413,18 @@ StorageDead(_62); - _57 = const (); StorageDead(_61); -- StorageDead(_60); -- StorageDead(_59); + StorageDead(_60); + StorageDead(_59); StorageDead(_58); - StorageDead(_57); StorageLive(_64); _64 = const 5_usize; -- StorageLive(_65); -- _65 = &raw mut _64; -- StorageLive(_66); -- _66 = &mut _65; + StorageLive(_65); + _65 = &raw mut _64; + StorageLive(_66); + _66 = &mut _65; StorageLive(_67); -- _67 = (*_65); -+ _67 = _64; + _67 = (*_65); StorageLive(_68); StorageLive(_69); _69 = (); @@ -443,8 +436,8 @@ StorageDead(_68); _0 = const (); StorageDead(_67); -- StorageDead(_66); -- StorageDead(_65); + StorageDead(_66); + StorageDead(_65); StorageDead(_64); return; } diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs index 4083b4547..610660131 100644 --- a/tests/mir-opt/reference_prop.rs +++ b/tests/mir-opt/reference_prop.rs @@ -426,7 +426,7 @@ fn multiple_storage() { // As there are multiple `StorageLive` statements for `x`, we cannot know if this `z`'s // pointer address is the address of `x`, so do nothing. let y = *z; - Call(RET, retblock, opaque(y)) + Call(RET = opaque(y), retblock) } retblock = { @@ -452,7 +452,7 @@ fn dominate_storage() { } bb1 = { let c = *r; - Call(RET, bb2, opaque(c)) + Call(RET = opaque(c), bb2) } bb2 = { StorageDead(x); @@ -486,18 +486,18 @@ fn maybe_dead(m: bool) { bb1 = { StorageDead(x); StorageDead(y); - Call(RET, bb2, opaque(u)) + Call(RET = opaque(u), bb2) } bb2 = { // As `x` may be `StorageDead`, `a` may be dangling, so we do nothing. let z = *a; - Call(RET, bb3, opaque(z)) + Call(RET = opaque(z), bb3) } bb3 = { // As `y` may be `StorageDead`, `b` may be dangling, so we do nothing. // This implies that we also do not substitute `b` in `bb0`. let t = *b; - Call(RET, retblock, opaque(t)) + Call(RET = opaque(t), retblock) } retblock = { Return() diff --git a/tests/run-coverage-rustdoc/doctest.coverage b/tests/run-coverage-rustdoc/doctest.coverage index 0fce73a60..07f1e6b3e 100644 --- a/tests/run-coverage-rustdoc/doctest.coverage +++ b/tests/run-coverage-rustdoc/doctest.coverage @@ -1,115 +1,115 @@ $DIR/auxiliary/doctest_crate.rs: - 1| |/// A function run only from within doctests - 2| 3|pub fn fn_run_in_doctests(conditional: usize) { - 3| 3| match conditional { - 4| 1| 1 => assert_eq!(1, 1), // this is run, - 5| 1| 2 => assert_eq!(1, 1), // this, - 6| 1| 3 => assert_eq!(1, 1), // and this too - 7| 0| _ => assert_eq!(1, 2), // however this is not - 8| | } - 9| 3|} + LL| |/// A function run only from within doctests + LL| 3|pub fn fn_run_in_doctests(conditional: usize) { + LL| 3| match conditional { + LL| 1| 1 => assert_eq!(1, 1), // this is run, + LL| 1| 2 => assert_eq!(1, 1), // this, + LL| 1| 3 => assert_eq!(1, 1), // and this too + LL| 0| _ => assert_eq!(1, 2), // however this is not + LL| | } + LL| 3|} $DIR/doctest.rs: - 1| |//! This test ensures that code from doctests is properly re-mapped. - 2| |//! See for more info. - 3| |//! - 4| |//! Just some random code: - 5| 1|//! ``` - 6| 1|//! if true { - 7| |//! // this is executed! - 8| 1|//! assert_eq!(1, 1); - 9| |//! } else { - 10| |//! // this is not! - 11| 0|//! assert_eq!(1, 2); - 12| |//! } - 13| 1|//! ``` - 14| |//! - 15| |//! doctest testing external code: - 16| |//! ``` - 17| 1|//! extern crate doctest_crate; - 18| 1|//! doctest_crate::fn_run_in_doctests(1); - 19| 1|//! ``` - 20| |//! - 21| |//! doctest returning a result: - 22| 1|//! ``` - 23| 2|//! #[derive(Debug, PartialEq)] + LL| |//! This test ensures that code from doctests is properly re-mapped. + LL| |//! See for more info. + LL| |//! + LL| |//! Just some random code: + LL| 1|//! ``` + LL| 1|//! if true { + LL| |//! // this is executed! + LL| 1|//! assert_eq!(1, 1); + LL| |//! } else { + LL| |//! // this is not! + LL| 0|//! assert_eq!(1, 2); + LL| |//! } + LL| 1|//! ``` + LL| |//! + LL| |//! doctest testing external code: + LL| |//! ``` + LL| 1|//! extern crate doctest_crate; + LL| 1|//! doctest_crate::fn_run_in_doctests(1); + LL| 1|//! ``` + LL| |//! + LL| |//! doctest returning a result: + LL| 1|//! ``` + LL| 2|//! #[derive(Debug, PartialEq)] ^1 - 24| 1|//! struct SomeError { - 25| 1|//! msg: String, - 26| 1|//! } - 27| 1|//! let mut res = Err(SomeError { msg: String::from("a message") }); - 28| 1|//! if res.is_ok() { - 29| 0|//! res?; - 30| |//! } else { - 31| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { - 32| 1|//! println!("{:?}", res); - 33| 1|//! } + LL| 1|//! struct SomeError { + LL| 1|//! msg: String, + LL| 1|//! } + LL| 1|//! let mut res = Err(SomeError { msg: String::from("a message") }); + LL| 1|//! if res.is_ok() { + LL| 0|//! res?; + LL| |//! } else { + LL| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { + LL| 1|//! println!("{:?}", res); + LL| 1|//! } ^0 - 34| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { - 35| 1|//! res = Ok(1); - 36| 1|//! } + LL| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { + LL| 1|//! res = Ok(1); + LL| 1|//! } ^0 - 37| 1|//! res = Ok(0); - 38| |//! } - 39| |//! // need to be explicit because rustdoc cant infer the return type - 40| 1|//! Ok::<(), SomeError>(()) - 41| 1|//! ``` - 42| |//! - 43| |//! doctest with custom main: - 44| |//! ``` - 45| 1|//! fn some_func() { - 46| 1|//! println!("called some_func()"); - 47| 1|//! } - 48| |//! - 49| 0|//! #[derive(Debug)] - 50| |//! struct SomeError; - 51| |//! - 52| |//! extern crate doctest_crate; - 53| |//! - 54| 1|//! fn doctest_main() -> Result<(), SomeError> { - 55| 1|//! some_func(); - 56| 1|//! doctest_crate::fn_run_in_doctests(2); - 57| 1|//! Ok(()) - 58| 1|//! } - 59| |//! - 60| |//! // this `main` is not shown as covered, as it clashes with all the other - 61| |//! // `main` functions that were automatically generated for doctests - 62| |//! fn main() -> Result<(), SomeError> { - 63| |//! doctest_main() - 64| |//! } - 65| |//! ``` - 66| |// aux-build:doctest_crate.rs - 67| |/// doctest attached to fn testing external code: - 68| |/// ``` - 69| 1|/// extern crate doctest_crate; - 70| 1|/// doctest_crate::fn_run_in_doctests(3); - 71| 1|/// ``` - 72| |/// - 73| 1|fn main() { - 74| 1| if true { - 75| 1| assert_eq!(1, 1); - 76| | } else { - 77| 0| assert_eq!(1, 2); - 78| | } - 79| 1|} - 80| | - 81| |// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the - 82| |// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc - 83| |// comment characters). This test produces `llvm-cov show` results demonstrating the problem. - 84| |// - 85| |// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show` - 86| |// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong - 87| |// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or - 88| |// one character past, the `if` block's closing brace. In both cases, these are most likely off - 89| |// by the number of characters stripped from the beginning of each doc comment line: indent - 90| |// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character - 91| |// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are - 92| |// more pronounced, and show up in more places, with background color used to show some distinct - 93| |// code regions with different coverage counts. - 94| |// - 95| |// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each - 96| |// character stripped from the beginning of doc comment lines with a space. This will give coverage - 97| |// results the correct column offsets, and I think it should compile correctly, but I don't know - 98| |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care - 99| |// if the indentation changed. I don't know if there is a more viable solution. + LL| 1|//! res = Ok(0); + LL| |//! } + LL| |//! // need to be explicit because rustdoc cant infer the return type + LL| 1|//! Ok::<(), SomeError>(()) + LL| 1|//! ``` + LL| |//! + LL| |//! doctest with custom main: + LL| |//! ``` + LL| 1|//! fn some_func() { + LL| 1|//! println!("called some_func()"); + LL| 1|//! } + LL| |//! + LL| 0|//! #[derive(Debug)] + LL| |//! struct SomeError; + LL| |//! + LL| |//! extern crate doctest_crate; + LL| |//! + LL| 1|//! fn doctest_main() -> Result<(), SomeError> { + LL| 1|//! some_func(); + LL| 1|//! doctest_crate::fn_run_in_doctests(2); + LL| 1|//! Ok(()) + LL| 1|//! } + LL| |//! + LL| |//! // this `main` is not shown as covered, as it clashes with all the other + LL| |//! // `main` functions that were automatically generated for doctests + LL| |//! fn main() -> Result<(), SomeError> { + LL| |//! doctest_main() + LL| |//! } + LL| |//! ``` + LL| |// aux-build:doctest_crate.rs + LL| |/// doctest attached to fn testing external code: + LL| |/// ``` + LL| 1|/// extern crate doctest_crate; + LL| 1|/// doctest_crate::fn_run_in_doctests(3); + LL| 1|/// ``` + LL| |/// + LL| 1|fn main() { + LL| 1| if true { + LL| 1| assert_eq!(1, 1); + LL| | } else { + LL| 0| assert_eq!(1, 2); + LL| | } + LL| 1|} + LL| | + LL| |// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the + LL| |// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc + LL| |// comment characters). This test produces `llvm-cov show` results demonstrating the problem. + LL| |// + LL| |// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show` + LL| |// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong + LL| |// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or + LL| |// one character past, the `if` block's closing brace. In both cases, these are most likely off + LL| |// by the number of characters stripped from the beginning of each doc comment line: indent + LL| |// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character + LL| |// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are + LL| |// more pronounced, and show up in more places, with background color used to show some distinct + LL| |// code regions with different coverage counts. + LL| |// + LL| |// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each + LL| |// character stripped from the beginning of doc comment lines with a space. This will give coverage + LL| |// results the correct column offsets, and I think it should compile correctly, but I don't know + LL| |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care + LL| |// if the indentation changed. I don't know if there is a more viable solution. diff --git a/tests/run-coverage/abort.coverage b/tests/run-coverage/abort.coverage index a71c58d61..ceef63867 100644 --- a/tests/run-coverage/abort.coverage +++ b/tests/run-coverage/abort.coverage @@ -1,69 +1,69 @@ - 1| |#![feature(c_unwind)] - 2| |#![allow(unused_assignments)] - 3| | - 4| 12|extern "C" fn might_abort(should_abort: bool) { - 5| 12| if should_abort { - 6| 0| println!("aborting..."); - 7| 0| panic!("panics and aborts"); - 8| 12| } else { - 9| 12| println!("Don't Panic"); - 10| 12| } - 11| 12|} - 12| | - 13| 1|fn main() -> Result<(), u8> { - 14| 1| let mut countdown = 10; - 15| 11| while countdown > 0 { - 16| 10| if countdown < 5 { - 17| 4| might_abort(false); - 18| 6| } - 19| | // See discussion (below the `Notes` section) on coverage results for the closing brace. - 20| 10| if countdown < 5 { might_abort(false); } // Counts for different regions on one line. + LL| |#![feature(c_unwind)] + LL| |#![allow(unused_assignments)] + LL| | + LL| 12|extern "C" fn might_abort(should_abort: bool) { + LL| 12| if should_abort { + LL| 0| println!("aborting..."); + LL| 0| panic!("panics and aborts"); + LL| 12| } else { + LL| 12| println!("Don't Panic"); + LL| 12| } + LL| 12|} + LL| | + LL| 1|fn main() -> Result<(), u8> { + LL| 1| let mut countdown = 10; + LL| 11| while countdown > 0 { + LL| 10| if countdown < 5 { + LL| 4| might_abort(false); + LL| 6| } + LL| | // See discussion (below the `Notes` section) on coverage results for the closing brace. + LL| 10| if countdown < 5 { might_abort(false); } // Counts for different regions on one line. ^4 ^6 - 21| | // For the following example, the closing brace is the last character on the line. - 22| | // This shows the character after the closing brace is highlighted, even if that next - 23| | // character is a newline. - 24| 10| if countdown < 5 { might_abort(false); } + LL| | // For the following example, the closing brace is the last character on the line. + LL| | // This shows the character after the closing brace is highlighted, even if that next + LL| | // character is a newline. + LL| 10| if countdown < 5 { might_abort(false); } ^4 ^6 - 25| 10| countdown -= 1; - 26| | } - 27| 1| Ok(()) - 28| 1|} - 29| | - 30| |// Notes: - 31| |// 1. Compare this program and its coverage results to those of the similar tests - 32| |// `panic_unwind.rs` and `try_error_result.rs`. - 33| |// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`. - 34| |// 3. The test does not invoke the abort. By executing to a successful completion, the coverage - 35| |// results show where the program did and did not execute. - 36| |// 4. If the program actually aborted, the coverage counters would not be saved (which "works as - 37| |// intended"). Coverage results would show no executed coverage regions. - 38| |// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status - 39| |// (on Linux at least). - 40| | - 41| |/* - 42| | - 43| |Expect the following coverage results: - 44| | - 45| |```text - 46| | 16| 11| while countdown > 0 { - 47| | 17| 10| if countdown < 5 { - 48| | 18| 4| might_abort(false); - 49| | 19| 6| } - 50| |``` - 51| | - 52| |This is actually correct. - 53| | - 54| |The condition `countdown < 5` executed 10 times (10 loop iterations). - 55| | - 56| |It evaluated to `true` 4 times, and executed the `might_abort()` call. - 57| | - 58| |It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit - 59| |`else`, the coverage implementation injects a counter, at the character immediately after the `if`s - 60| |closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the - 61| |non-true condition. - 62| | - 63| |As another example of why this is important, say the condition was `countdown < 50`, which is always - 64| |`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called. - 65| |The closing brace would have a count of `0`, highlighting the missed coverage. - 66| |*/ + LL| 10| countdown -= 1; + LL| | } + LL| 1| Ok(()) + LL| 1|} + LL| | + LL| |// Notes: + LL| |// 1. Compare this program and its coverage results to those of the similar tests + LL| |// `panic_unwind.rs` and `try_error_result.rs`. + LL| |// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`. + LL| |// 3. The test does not invoke the abort. By executing to a successful completion, the coverage + LL| |// results show where the program did and did not execute. + LL| |// 4. If the program actually aborted, the coverage counters would not be saved (which "works as + LL| |// intended"). Coverage results would show no executed coverage regions. + LL| |// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status + LL| |// (on Linux at least). + LL| | + LL| |/* + LL| | + LL| |Expect the following coverage results: + LL| | + LL| |```text + LL| | 16| 11| while countdown > 0 { + LL| | 17| 10| if countdown < 5 { + LL| | 18| 4| might_abort(false); + LL| | 19| 6| } + LL| |``` + LL| | + LL| |This is actually correct. + LL| | + LL| |The condition `countdown < 5` executed 10 times (10 loop iterations). + LL| | + LL| |It evaluated to `true` 4 times, and executed the `might_abort()` call. + LL| | + LL| |It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit + LL| |`else`, the coverage implementation injects a counter, at the character immediately after the `if`s + LL| |closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the + LL| |non-true condition. + LL| | + LL| |As another example of why this is important, say the condition was `countdown < 50`, which is always + LL| |`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called. + LL| |The closing brace would have a count of `0`, highlighting the missed coverage. + LL| |*/ diff --git a/tests/run-coverage/assert.coverage b/tests/run-coverage/assert.coverage index a7134a149..3c6108e43 100644 --- a/tests/run-coverage/assert.coverage +++ b/tests/run-coverage/assert.coverage @@ -1,34 +1,34 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 101 - 3| | - 4| 4|fn might_fail_assert(one_plus_one: u32) { - 5| 4| println!("does 1 + 1 = {}?", one_plus_one); - 6| 4| assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 101 + LL| | + LL| 4|fn might_fail_assert(one_plus_one: u32) { + LL| 4| println!("does 1 + 1 = {}?", one_plus_one); + LL| 4| assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); ^1 - 7| 3|} - 8| | - 9| 1|fn main() -> Result<(),u8> { - 10| 1| let mut countdown = 10; - 11| 11| while countdown > 0 { - 12| 11| if countdown == 1 { - 13| 1| might_fail_assert(3); - 14| 10| } else if countdown < 5 { - 15| 3| might_fail_assert(2); - 16| 6| } - 17| 10| countdown -= 1; - 18| | } - 19| 0| Ok(()) - 20| 0|} - 21| | - 22| |// Notes: - 23| |// 1. Compare this program and its coverage results to those of the very similar test - 24| |// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`. - 25| |// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or - 26| |// related `assert_*!()` macro. - 27| |// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce - 28| |// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to - 29| |// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails). - 30| |// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test - 31| |// (and in many other coverage tests). The `Assert` terminator is typically generated by the - 32| |// Rust compiler to check for runtime failures, such as numeric overflows. + LL| 3|} + LL| | + LL| 1|fn main() -> Result<(),u8> { + LL| 1| let mut countdown = 10; + LL| 11| while countdown > 0 { + LL| 11| if countdown == 1 { + LL| 1| might_fail_assert(3); + LL| 10| } else if countdown < 5 { + LL| 3| might_fail_assert(2); + LL| 6| } + LL| 10| countdown -= 1; + LL| | } + LL| 0| Ok(()) + LL| 0|} + LL| | + LL| |// Notes: + LL| |// 1. Compare this program and its coverage results to those of the very similar test + LL| |// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`. + LL| |// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or + LL| |// related `assert_*!()` macro. + LL| |// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce + LL| |// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to + LL| |// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails). + LL| |// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test + LL| |// (and in many other coverage tests). The `Assert` terminator is typically generated by the + LL| |// Rust compiler to check for runtime failures, such as numeric overflows. diff --git a/tests/run-coverage/async.coverage b/tests/run-coverage/async.coverage index 93c1535b0..07bc16c2d 100644 --- a/tests/run-coverage/async.coverage +++ b/tests/run-coverage/async.coverage @@ -1,139 +1,139 @@ - 1| |#![allow(unused_assignments, dead_code)] - 2| | - 3| |// compile-flags: --edition=2018 -C opt-level=1 - 4| | - 5| 1|async fn c(x: u8) -> u8 { - 6| 1| if x == 8 { - 7| 1| 1 - 8| | } else { - 9| 0| 0 - 10| | } - 11| 1|} - 12| | - 13| 0|async fn d() -> u8 { 1 } - 14| | - 15| 0|async fn e() -> u8 { 1 } // unused function; executor does not block on `g()` - 16| | - 17| 1|async fn f() -> u8 { 1 } - 18| | - 19| 0|async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()` - 20| | - 21| 1|pub async fn g(x: u8) { - 22| 0| match x { - 23| 0| y if e().await == y => (), - 24| 0| y if f().await == y => (), - 25| 0| _ => (), - 26| | } - 27| 0|} - 28| | - 29| 1|async fn h(x: usize) { // The function signature is counted when called, but the body is not - 30| 0| // executed (not awaited) so the open brace has a `0` count (at least when - 31| 0| // displayed with `llvm-cov show` in color-mode). - 32| 0| match x { - 33| 0| y if foo().await[y] => (), - 34| 0| _ => (), - 35| | } - 36| 0|} - 37| | - 38| 1|async fn i(x: u8) { // line coverage is 1, but there are 2 regions: - 39| 1| // (a) the function signature, counted when the function is called; and - 40| 1| // (b) the open brace for the function body, counted once when the body is - 41| 1| // executed asynchronously. - 42| 1| match x { - 43| 1| y if c(x).await == y + 1 => { d().await; } + LL| |#![allow(unused_assignments, dead_code)] + LL| | + LL| |// compile-flags: --edition=2018 -C opt-level=1 + LL| | + LL| 1|async fn c(x: u8) -> u8 { + LL| 1| if x == 8 { + LL| 1| 1 + LL| | } else { + LL| 0| 0 + LL| | } + LL| 1|} + LL| | + LL| 0|async fn d() -> u8 { 1 } + LL| | + LL| 0|async fn e() -> u8 { 1 } // unused function; executor does not block on `g()` + LL| | + LL| 1|async fn f() -> u8 { 1 } + LL| | + LL| 0|async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()` + LL| | + LL| 1|pub async fn g(x: u8) { + LL| 0| match x { + LL| 0| y if e().await == y => (), + LL| 0| y if f().await == y => (), + LL| 0| _ => (), + LL| | } + LL| 0|} + LL| | + LL| 1|async fn h(x: usize) { // The function signature is counted when called, but the body is not + LL| 0| // executed (not awaited) so the open brace has a `0` count (at least when + LL| 0| // displayed with `llvm-cov show` in color-mode). + LL| 0| match x { + LL| 0| y if foo().await[y] => (), + LL| 0| _ => (), + LL| | } + LL| 0|} + LL| | + LL| 1|async fn i(x: u8) { // line coverage is 1, but there are 2 regions: + LL| 1| // (a) the function signature, counted when the function is called; and + LL| 1| // (b) the open brace for the function body, counted once when the body is + LL| 1| // executed asynchronously. + LL| 1| match x { + LL| 1| y if c(x).await == y + 1 => { d().await; } ^0 ^0 ^0 ^0 - 44| 1| y if f().await == y + 1 => (), + LL| 1| y if f().await == y + 1 => (), ^0 ^0 ^0 - 45| 1| _ => (), - 46| | } - 47| 1|} - 48| | - 49| 1|fn j(x: u8) { - 50| 1| // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`. - 51| 1| fn c(x: u8) -> u8 { - 52| 1| if x == 8 { - 53| 1| 1 // This line appears covered, but the 1-character expression span covering the `1` + LL| 1| _ => (), + LL| | } + LL| 1|} + LL| | + LL| 1|fn j(x: u8) { + LL| 1| // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`. + LL| 1| fn c(x: u8) -> u8 { + LL| 1| if x == 8 { + LL| 1| 1 // This line appears covered, but the 1-character expression span covering the `1` ^0 - 54| 1| // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because - 55| 1| // `fn j()` executes the open brace for the function body, followed by the function's - 56| 1| // first executable statement, `match x`. Inner function declarations are not - 57| 1| // "visible" to the MIR for `j()`, so the code region counts all lines between the - 58| 1| // open brace and the first statement as executed, which is, in a sense, true. - 59| 1| // `llvm-cov show` overcomes this kind of situation by showing the actual counts - 60| 1| // of the enclosed coverages, (that is, the `1` expression was not executed, and - 61| 1| // accurately displays a `0`). - 62| 1| } else { - 63| 1| 0 - 64| 1| } - 65| 1| } - 66| 1| fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed + LL| 1| // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because + LL| 1| // `fn j()` executes the open brace for the function body, followed by the function's + LL| 1| // first executable statement, `match x`. Inner function declarations are not + LL| 1| // "visible" to the MIR for `j()`, so the code region counts all lines between the + LL| 1| // open brace and the first statement as executed, which is, in a sense, true. + LL| 1| // `llvm-cov show` overcomes this kind of situation by showing the actual counts + LL| 1| // of the enclosed coverages, (that is, the `1` expression was not executed, and + LL| 1| // accurately displays a `0`). + LL| 1| } else { + LL| 1| 0 + LL| 1| } + LL| 1| } + LL| 1| fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed ^0 - 67| 1| fn f() -> u8 { 1 } - 68| 1| match x { - 69| 1| y if c(x) == y + 1 => { d(); } + LL| 1| fn f() -> u8 { 1 } + LL| 1| match x { + LL| 1| y if c(x) == y + 1 => { d(); } ^0 ^0 - 70| 1| y if f() == y + 1 => (), + LL| 1| y if f() == y + 1 => (), ^0 ^0 - 71| 1| _ => (), - 72| | } - 73| 1|} - 74| | - 75| 0|fn k(x: u8) { // unused function - 76| 0| match x { - 77| 0| 1 => (), - 78| 0| 2 => (), - 79| 0| _ => (), - 80| | } - 81| 0|} - 82| | - 83| 1|fn l(x: u8) { - 84| 1| match x { - 85| 0| 1 => (), - 86| 0| 2 => (), - 87| 1| _ => (), - 88| | } - 89| 1|} - 90| | - 91| 1|async fn m(x: u8) -> u8 { x - 1 } + LL| 1| _ => (), + LL| | } + LL| 1|} + LL| | + LL| 0|fn k(x: u8) { // unused function + LL| 0| match x { + LL| 0| 1 => (), + LL| 0| 2 => (), + LL| 0| _ => (), + LL| | } + LL| 0|} + LL| | + LL| 1|fn l(x: u8) { + LL| 1| match x { + LL| 0| 1 => (), + LL| 0| 2 => (), + LL| 1| _ => (), + LL| | } + LL| 1|} + LL| | + LL| 1|async fn m(x: u8) -> u8 { x - 1 } ^0 - 92| | - 93| 1|fn main() { - 94| 1| let _ = g(10); - 95| 1| let _ = h(9); - 96| 1| let mut future = Box::pin(i(8)); - 97| 1| j(7); - 98| 1| l(6); - 99| 1| let _ = m(5); - 100| 1| executor::block_on(future.as_mut()); - 101| 1|} - 102| | - 103| |mod executor { - 104| | use core::{ - 105| | future::Future, - 106| | pin::Pin, - 107| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - 108| | }; - 109| | - 110| 1| pub fn block_on(mut future: F) -> F::Output { - 111| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - 112| 1| use std::hint::unreachable_unchecked; - 113| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( - 114| 1| |_| unsafe { unreachable_unchecked() }, // clone + LL| | + LL| 1|fn main() { + LL| 1| let _ = g(10); + LL| 1| let _ = h(9); + LL| 1| let mut future = Box::pin(i(8)); + LL| 1| j(7); + LL| 1| l(6); + LL| 1| let _ = m(5); + LL| 1| executor::block_on(future.as_mut()); + LL| 1|} + LL| | + LL| |mod executor { + LL| | use core::{ + LL| | future::Future, + LL| | pin::Pin, + LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + LL| | }; + LL| | + LL| 1| pub fn block_on(mut future: F) -> F::Output { + LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; + LL| 1| use std::hint::unreachable_unchecked; + LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( + LL| 1| |_| unsafe { unreachable_unchecked() }, // clone ^0 - 115| 1| |_| unsafe { unreachable_unchecked() }, // wake + LL| 1| |_| unsafe { unreachable_unchecked() }, // wake ^0 - 116| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref + LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref ^0 - 117| 1| |_| (), - 118| 1| ); - 119| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - 120| 1| let mut context = Context::from_waker(&waker); - 121| | - 122| | loop { - 123| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - 124| 1| break val; - 125| 0| } - 126| | } - 127| 1| } - 128| |} + LL| 1| |_| (), + LL| 1| ); + LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + LL| 1| let mut context = Context::from_waker(&waker); + LL| | + LL| | loop { + LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + LL| 1| break val; + LL| 0| } + LL| | } + LL| 1| } + LL| |} diff --git a/tests/run-coverage/async2.coverage b/tests/run-coverage/async2.coverage index 500dde1f2..7e0139ae0 100644 --- a/tests/run-coverage/async2.coverage +++ b/tests/run-coverage/async2.coverage @@ -1,116 +1,116 @@ - 1| |// compile-flags: --edition=2018 - 2| | - 3| |use core::{ - 4| | future::Future, - 5| | marker::Send, - 6| | pin::Pin, - 7| |}; - 8| | - 9| 1|fn non_async_func() { - 10| 1| println!("non_async_func was covered"); - 11| 1| let b = true; - 12| 1| if b { - 13| 1| println!("non_async_func println in block"); - 14| 1| } + LL| |// compile-flags: --edition=2018 + LL| | + LL| |use core::{ + LL| | future::Future, + LL| | marker::Send, + LL| | pin::Pin, + LL| |}; + LL| | + LL| 1|fn non_async_func() { + LL| 1| println!("non_async_func was covered"); + LL| 1| let b = true; + LL| 1| if b { + LL| 1| println!("non_async_func println in block"); + LL| 1| } ^0 - 15| 1|} - 16| | - 17| | - 18| | - 19| | - 20| 1|async fn async_func() { - 21| 1| println!("async_func was covered"); - 22| 1| let b = true; - 23| 1| if b { - 24| 1| println!("async_func println in block"); - 25| 1| } + LL| 1|} + LL| | + LL| | + LL| | + LL| | + LL| 1|async fn async_func() { + LL| 1| println!("async_func was covered"); + LL| 1| let b = true; + LL| 1| if b { + LL| 1| println!("async_func println in block"); + LL| 1| } ^0 - 26| 1|} - 27| | - 28| | - 29| | - 30| | - 31| 1|async fn async_func_just_println() { - 32| 1| println!("async_func_just_println was covered"); - 33| 1|} - 34| | - 35| 1|fn main() { - 36| 1| println!("codecovsample::main"); - 37| 1| - 38| 1| non_async_func(); - 39| 1| - 40| 1| executor::block_on(async_func()); - 41| 1| executor::block_on(async_func_just_println()); - 42| 1|} - 43| | - 44| |mod executor { - 45| | use core::{ - 46| | future::Future, - 47| | pin::Pin, - 48| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - 49| | }; - 50| | - 51| 2| pub fn block_on(mut future: F) -> F::Output { - 52| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - 53| 2| use std::hint::unreachable_unchecked; - 54| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new( - 55| 2| |_| unsafe { unreachable_unchecked() }, // clone + LL| 1|} + LL| | + LL| | + LL| | + LL| | + LL| 1|async fn async_func_just_println() { + LL| 1| println!("async_func_just_println was covered"); + LL| 1|} + LL| | + LL| 1|fn main() { + LL| 1| println!("codecovsample::main"); + LL| 1| + LL| 1| non_async_func(); + LL| 1| + LL| 1| executor::block_on(async_func()); + LL| 1| executor::block_on(async_func_just_println()); + LL| 1|} + LL| | + LL| |mod executor { + LL| | use core::{ + LL| | future::Future, + LL| | pin::Pin, + LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + LL| | }; + LL| | + LL| 2| pub fn block_on(mut future: F) -> F::Output { + LL| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) }; + LL| 2| use std::hint::unreachable_unchecked; + LL| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new( + LL| 2| |_| unsafe { unreachable_unchecked() }, // clone ^0 - 56| 2| |_| unsafe { unreachable_unchecked() }, // wake + LL| 2| |_| unsafe { unreachable_unchecked() }, // wake ^0 - 57| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref + LL| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref ^0 - 58| 2| |_| (), - 59| 2| ); - 60| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - 61| 2| let mut context = Context::from_waker(&waker); - 62| | - 63| | loop { - 64| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - 65| 2| break val; - 66| 0| } - 67| | } - 68| 2| } + LL| 2| |_| (), + LL| 2| ); + LL| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + LL| 2| let mut context = Context::from_waker(&waker); + LL| | + LL| | loop { + LL| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + LL| 2| break val; + LL| 0| } + LL| | } + LL| 2| } ------------------ | async2::executor::block_on::: - | 51| 1| pub fn block_on(mut future: F) -> F::Output { - | 52| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - | 53| 1| use std::hint::unreachable_unchecked; - | 54| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( - | 55| 1| |_| unsafe { unreachable_unchecked() }, // clone - | 56| 1| |_| unsafe { unreachable_unchecked() }, // wake - | 57| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref - | 58| 1| |_| (), - | 59| 1| ); - | 60| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - | 61| 1| let mut context = Context::from_waker(&waker); - | 62| | - | 63| | loop { - | 64| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - | 65| 1| break val; - | 66| 0| } - | 67| | } - | 68| 1| } + | LL| 1| pub fn block_on(mut future: F) -> F::Output { + | LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; + | LL| 1| use std::hint::unreachable_unchecked; + | LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( + | LL| 1| |_| unsafe { unreachable_unchecked() }, // clone + | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake + | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref + | LL| 1| |_| (), + | LL| 1| ); + | LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + | LL| 1| let mut context = Context::from_waker(&waker); + | LL| | + | LL| | loop { + | LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + | LL| 1| break val; + | LL| 0| } + | LL| | } + | LL| 1| } ------------------ | async2::executor::block_on::: - | 51| 1| pub fn block_on(mut future: F) -> F::Output { - | 52| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - | 53| 1| use std::hint::unreachable_unchecked; - | 54| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( - | 55| 1| |_| unsafe { unreachable_unchecked() }, // clone - | 56| 1| |_| unsafe { unreachable_unchecked() }, // wake - | 57| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref - | 58| 1| |_| (), - | 59| 1| ); - | 60| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - | 61| 1| let mut context = Context::from_waker(&waker); - | 62| | - | 63| | loop { - | 64| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - | 65| 1| break val; - | 66| 0| } - | 67| | } - | 68| 1| } + | LL| 1| pub fn block_on(mut future: F) -> F::Output { + | LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; + | LL| 1| use std::hint::unreachable_unchecked; + | LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( + | LL| 1| |_| unsafe { unreachable_unchecked() }, // clone + | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake + | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref + | LL| 1| |_| (), + | LL| 1| ); + | LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + | LL| 1| let mut context = Context::from_waker(&waker); + | LL| | + | LL| | loop { + | LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + | LL| 1| break val; + | LL| 0| } + | LL| | } + | LL| 1| } ------------------ - 69| |} + LL| |} diff --git a/tests/run-coverage/closure.coverage b/tests/run-coverage/closure.coverage index 45d36b72e..809cf1f48 100644 --- a/tests/run-coverage/closure.coverage +++ b/tests/run-coverage/closure.coverage @@ -1,222 +1,222 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| |// compile-flags: -C opt-level=2 - 3| 1|fn main() { // ^^ fix described in rustc_middle/mir/mono.rs - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| let is_false = ! is_true; - 9| 1| - 10| 1| let mut some_string = Some(String::from("the string content")); - 11| 1| println!( - 12| 1| "The string or alt: {}" - 13| 1| , - 14| 1| some_string - 15| 1| . - 16| 1| unwrap_or_else - 17| 1| ( - 18| 1| || - 19| 0| { - 20| 0| let mut countdown = 0; - 21| 0| if is_false { - 22| 0| countdown = 10; - 23| 0| } - 24| 0| "alt string 1".to_owned() - 25| 1| } - 26| 1| ) - 27| 1| ); - 28| 1| - 29| 1| some_string = Some(String::from("the string content")); - 30| 1| let - 31| 1| a - 32| | = - 33| | || - 34| 0| { - 35| 0| let mut countdown = 0; - 36| 0| if is_false { - 37| 0| countdown = 10; - 38| 0| } - 39| 0| "alt string 2".to_owned() - 40| 0| }; - 41| 1| println!( - 42| 1| "The string or alt: {}" - 43| 1| , - 44| 1| some_string - 45| 1| . - 46| 1| unwrap_or_else - 47| 1| ( - 48| 1| a - 49| 1| ) - 50| 1| ); - 51| 1| - 52| 1| some_string = None; - 53| 1| println!( - 54| 1| "The string or alt: {}" - 55| 1| , - 56| 1| some_string - 57| 1| . - 58| 1| unwrap_or_else - 59| 1| ( - 60| 1| || - 61| 1| { - 62| 1| let mut countdown = 0; - 63| 1| if is_false { - 64| 0| countdown = 10; - 65| 1| } - 66| 1| "alt string 3".to_owned() - 67| 1| } - 68| 1| ) - 69| 1| ); - 70| 1| - 71| 1| some_string = None; - 72| 1| let - 73| 1| a - 74| 1| = - 75| 1| || - 76| 1| { - 77| 1| let mut countdown = 0; - 78| 1| if is_false { - 79| 0| countdown = 10; - 80| 1| } - 81| 1| "alt string 4".to_owned() - 82| 1| }; - 83| 1| println!( - 84| 1| "The string or alt: {}" - 85| 1| , - 86| 1| some_string - 87| 1| . - 88| 1| unwrap_or_else - 89| 1| ( - 90| 1| a - 91| 1| ) - 92| 1| ); - 93| 1| - 94| 1| let - 95| 1| quote_closure - 96| 1| = - 97| 1| |val| - 98| 5| { - 99| 5| let mut countdown = 0; - 100| 5| if is_false { - 101| 0| countdown = 10; - 102| 5| } - 103| 5| format!("'{}'", val) - 104| 5| }; - 105| 1| println!( - 106| 1| "Repeated, quoted string: {:?}" - 107| 1| , - 108| 1| std::iter::repeat("repeat me") - 109| 1| .take(5) - 110| 1| .map - 111| 1| ( - 112| 1| quote_closure - 113| 1| ) - 114| 1| .collect::>() - 115| 1| ); - 116| 1| - 117| 1| let - 118| 1| _unused_closure - 119| | = - 120| | | - 121| | mut countdown - 122| | | - 123| 0| { - 124| 0| if is_false { - 125| 0| countdown = 10; - 126| 0| } - 127| 0| "closure should be unused".to_owned() - 128| 0| }; - 129| | - 130| 1| let mut countdown = 10; - 131| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1; + LL| |#![allow(unused_assignments, unused_variables)] + LL| |// compile-flags: -C opt-level=2 + LL| 1|fn main() { // ^^ fix described in rustc_middle/mir/mono.rs + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let is_false = ! is_true; + LL| 1| + LL| 1| let mut some_string = Some(String::from("the string content")); + LL| 1| println!( + LL| 1| "The string or alt: {}" + LL| 1| , + LL| 1| some_string + LL| 1| . + LL| 1| unwrap_or_else + LL| 1| ( + LL| 1| || + LL| 0| { + LL| 0| let mut countdown = 0; + LL| 0| if is_false { + LL| 0| countdown = 10; + LL| 0| } + LL| 0| "alt string 1".to_owned() + LL| 1| } + LL| 1| ) + LL| 1| ); + LL| 1| + LL| 1| some_string = Some(String::from("the string content")); + LL| 1| let + LL| 1| a + LL| | = + LL| | || + LL| 0| { + LL| 0| let mut countdown = 0; + LL| 0| if is_false { + LL| 0| countdown = 10; + LL| 0| } + LL| 0| "alt string 2".to_owned() + LL| 0| }; + LL| 1| println!( + LL| 1| "The string or alt: {}" + LL| 1| , + LL| 1| some_string + LL| 1| . + LL| 1| unwrap_or_else + LL| 1| ( + LL| 1| a + LL| 1| ) + LL| 1| ); + LL| 1| + LL| 1| some_string = None; + LL| 1| println!( + LL| 1| "The string or alt: {}" + LL| 1| , + LL| 1| some_string + LL| 1| . + LL| 1| unwrap_or_else + LL| 1| ( + LL| 1| || + LL| 1| { + LL| 1| let mut countdown = 0; + LL| 1| if is_false { + LL| 0| countdown = 10; + LL| 1| } + LL| 1| "alt string 3".to_owned() + LL| 1| } + LL| 1| ) + LL| 1| ); + LL| 1| + LL| 1| some_string = None; + LL| 1| let + LL| 1| a + LL| 1| = + LL| 1| || + LL| 1| { + LL| 1| let mut countdown = 0; + LL| 1| if is_false { + LL| 0| countdown = 10; + LL| 1| } + LL| 1| "alt string 4".to_owned() + LL| 1| }; + LL| 1| println!( + LL| 1| "The string or alt: {}" + LL| 1| , + LL| 1| some_string + LL| 1| . + LL| 1| unwrap_or_else + LL| 1| ( + LL| 1| a + LL| 1| ) + LL| 1| ); + LL| 1| + LL| 1| let + LL| 1| quote_closure + LL| 1| = + LL| 1| |val| + LL| 5| { + LL| 5| let mut countdown = 0; + LL| 5| if is_false { + LL| 0| countdown = 10; + LL| 5| } + LL| 5| format!("'{}'", val) + LL| 5| }; + LL| 1| println!( + LL| 1| "Repeated, quoted string: {:?}" + LL| 1| , + LL| 1| std::iter::repeat("repeat me") + LL| 1| .take(5) + LL| 1| .map + LL| 1| ( + LL| 1| quote_closure + LL| 1| ) + LL| 1| .collect::>() + LL| 1| ); + LL| 1| + LL| 1| let + LL| 1| _unused_closure + LL| | = + LL| | | + LL| | mut countdown + LL| | | + LL| 0| { + LL| 0| if is_false { + LL| 0| countdown = 10; + LL| 0| } + LL| 0| "closure should be unused".to_owned() + LL| 0| }; + LL| | + LL| 1| let mut countdown = 10; + LL| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1; ^0 - 132| | - 133| | - 134| 1| let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); - 135| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); + LL| | + LL| | + LL| 1| let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); + LL| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); ^0 - 136| 1| let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); + LL| 1| let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); ^0 - 137| | - 138| | - 139| | - 140| | - 141| 1| let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") }; + LL| | + LL| | + LL| | + LL| | + LL| 1| let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") }; ^0 - 142| | - 143| 1| let _shortish_unused_closure = | _unused_arg: u8 | { - 144| 0| println!("not called") - 145| 0| }; - 146| | - 147| 1| let _as_short_unused_closure = | - 148| | _unused_arg: u8 - 149| 0| | { println!("not called") }; - 150| | - 151| 1| let _almost_as_short_unused_closure = | - 152| | _unused_arg: u8 - 153| 0| | { println!("not called") } - 154| | ; - 155| | - 156| | - 157| | - 158| | - 159| | - 160| 1| let _short_unused_closure_line_break_no_block = | _unused_arg: u8 | - 161| 0|println!("not called") - 162| | ; - 163| | - 164| 1| let _short_unused_closure_line_break_no_block2 = - 165| | | _unused_arg: u8 | - 166| 0| println!( - 167| 0| "not called" - 168| 0| ) - 169| | ; - 170| | - 171| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch = - 172| | | _unused_arg: u8 | - 173| 0| println!( - 174| 0| "not called: {}", - 175| 0| if is_true { "check" } else { "me" } - 176| 0| ) - 177| | ; - 178| | - 179| 1| let short_used_not_covered_closure_line_break_block_embedded_branch = - 180| 1| | _unused_arg: u8 | - 181| 0| { - 182| 0| println!( - 183| 0| "not called: {}", - 184| 0| if is_true { "check" } else { "me" } - 185| | ) - 186| 0| } - 187| | ; - 188| | - 189| 1| let short_used_covered_closure_line_break_no_block_embedded_branch = - 190| 1| | _unused_arg: u8 | - 191| 1| println!( - 192| 1| "not called: {}", - 193| 1| if is_true { "check" } else { "me" } + LL| | + LL| 1| let _shortish_unused_closure = | _unused_arg: u8 | { + LL| 0| println!("not called") + LL| 0| }; + LL| | + LL| 1| let _as_short_unused_closure = | + LL| | _unused_arg: u8 + LL| 0| | { println!("not called") }; + LL| | + LL| 1| let _almost_as_short_unused_closure = | + LL| | _unused_arg: u8 + LL| 0| | { println!("not called") } + LL| | ; + LL| | + LL| | + LL| | + LL| | + LL| | + LL| 1| let _short_unused_closure_line_break_no_block = | _unused_arg: u8 | + LL| 0|println!("not called") + LL| | ; + LL| | + LL| 1| let _short_unused_closure_line_break_no_block2 = + LL| | | _unused_arg: u8 | + LL| 0| println!( + LL| 0| "not called" + LL| 0| ) + LL| | ; + LL| | + LL| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch = + LL| | | _unused_arg: u8 | + LL| 0| println!( + LL| 0| "not called: {}", + LL| 0| if is_true { "check" } else { "me" } + LL| 0| ) + LL| | ; + LL| | + LL| 1| let short_used_not_covered_closure_line_break_block_embedded_branch = + LL| 1| | _unused_arg: u8 | + LL| 0| { + LL| 0| println!( + LL| 0| "not called: {}", + LL| 0| if is_true { "check" } else { "me" } + LL| | ) + LL| 0| } + LL| | ; + LL| | + LL| 1| let short_used_covered_closure_line_break_no_block_embedded_branch = + LL| 1| | _unused_arg: u8 | + LL| 1| println!( + LL| 1| "not called: {}", + LL| 1| if is_true { "check" } else { "me" } ^0 - 194| 1| ) - 195| | ; - 196| | - 197| 1| let short_used_covered_closure_line_break_block_embedded_branch = - 198| 1| | _unused_arg: u8 | - 199| 1| { - 200| 1| println!( - 201| 1| "not called: {}", - 202| 1| if is_true { "check" } else { "me" } + LL| 1| ) + LL| | ; + LL| | + LL| 1| let short_used_covered_closure_line_break_block_embedded_branch = + LL| 1| | _unused_arg: u8 | + LL| 1| { + LL| 1| println!( + LL| 1| "not called: {}", + LL| 1| if is_true { "check" } else { "me" } ^0 - 203| | ) - 204| 1| } - 205| | ; - 206| | - 207| 1| if is_false { - 208| 0| short_used_not_covered_closure_macro(0); - 209| 0| short_used_not_covered_closure_line_break_no_block_embedded_branch(0); - 210| 0| short_used_not_covered_closure_line_break_block_embedded_branch(0); - 211| 1| } - 212| 1| short_used_covered_closure_macro(0); - 213| 1| short_used_covered_closure_line_break_no_block_embedded_branch(0); - 214| 1| short_used_covered_closure_line_break_block_embedded_branch(0); - 215| 1|} + LL| | ) + LL| 1| } + LL| | ; + LL| | + LL| 1| if is_false { + LL| 0| short_used_not_covered_closure_macro(0); + LL| 0| short_used_not_covered_closure_line_break_no_block_embedded_branch(0); + LL| 0| short_used_not_covered_closure_line_break_block_embedded_branch(0); + LL| 1| } + LL| 1| short_used_covered_closure_macro(0); + LL| 1| short_used_covered_closure_line_break_no_block_embedded_branch(0); + LL| 1| short_used_covered_closure_line_break_block_embedded_branch(0); + LL| 1|} diff --git a/tests/run-coverage/closure_macro.coverage b/tests/run-coverage/closure_macro.coverage index 87f701476..1bfd2013d 100644 --- a/tests/run-coverage/closure_macro.coverage +++ b/tests/run-coverage/closure_macro.coverage @@ -1,42 +1,42 @@ - 1| |// compile-flags: --edition=2018 - 2| |#![feature(no_coverage)] - 3| | - 4| |macro_rules! bail { - 5| | ($msg:literal $(,)?) => { - 6| | if $msg.len() > 0 { - 7| | println!("no msg"); - 8| | } else { - 9| | println!($msg); - 10| | } - 11| | return Err(String::from($msg)); - 12| | }; - 13| |} - 14| | - 15| |macro_rules! on_error { - 16| | ($value:expr, $error_message:expr) => { - 17| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros - 18| | let message = format!($error_message, e); - 19| | if message.len() > 0 { - 20| | println!("{}", message); - 21| | Ok(String::from("ok")) - 22| | } else { - 23| | bail!("error"); - 24| | } - 25| | }) - 26| | }; - 27| |} - 28| | - 29| 1|fn load_configuration_files() -> Result { - 30| 1| Ok(String::from("config")) - 31| 1|} - 32| | - 33| 1|pub fn main() -> Result<(), String> { - 34| 1| println!("Starting service"); - 35| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; + LL| |// compile-flags: --edition=2018 + LL| |#![feature(no_coverage)] + LL| | + LL| |macro_rules! bail { + LL| | ($msg:literal $(,)?) => { + LL| | if $msg.len() > 0 { + LL| | println!("no msg"); + LL| | } else { + LL| | println!($msg); + LL| | } + LL| | return Err(String::from($msg)); + LL| | }; + LL| |} + LL| | + LL| |macro_rules! on_error { + LL| | ($value:expr, $error_message:expr) => { + LL| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros + LL| | let message = format!($error_message, e); + LL| | if message.len() > 0 { + LL| | println!("{}", message); + LL| | Ok(String::from("ok")) + LL| | } else { + LL| | bail!("error"); + LL| | } + LL| | }) + LL| | }; + LL| |} + LL| | + LL| 1|fn load_configuration_files() -> Result { + LL| 1| Ok(String::from("config")) + LL| 1|} + LL| | + LL| 1|pub fn main() -> Result<(), String> { + LL| 1| println!("Starting service"); + LL| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; ^0 - 36| | - 37| 1| let startup_delay_duration = String::from("arg"); - 38| 1| let _ = (config, startup_delay_duration); - 39| 1| Ok(()) - 40| 1|} + LL| | + LL| 1| let startup_delay_duration = String::from("arg"); + LL| 1| let _ = (config, startup_delay_duration); + LL| 1| Ok(()) + LL| 1|} diff --git a/tests/run-coverage/closure_macro_async.coverage b/tests/run-coverage/closure_macro_async.coverage index 2b5418132..0e4365fc7 100644 --- a/tests/run-coverage/closure_macro_async.coverage +++ b/tests/run-coverage/closure_macro_async.coverage @@ -1,83 +1,83 @@ - 1| |// compile-flags: --edition=2018 - 2| |#![feature(no_coverage)] - 3| | - 4| |macro_rules! bail { - 5| | ($msg:literal $(,)?) => { - 6| | if $msg.len() > 0 { - 7| | println!("no msg"); - 8| | } else { - 9| | println!($msg); - 10| | } - 11| | return Err(String::from($msg)); - 12| | }; - 13| |} - 14| | - 15| |macro_rules! on_error { - 16| | ($value:expr, $error_message:expr) => { - 17| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros - 18| | let message = format!($error_message, e); - 19| | if message.len() > 0 { - 20| | println!("{}", message); - 21| | Ok(String::from("ok")) - 22| | } else { - 23| | bail!("error"); - 24| | } - 25| | }) - 26| | }; - 27| |} - 28| | - 29| 1|fn load_configuration_files() -> Result { - 30| 1| Ok(String::from("config")) - 31| 1|} - 32| | - 33| 1|pub async fn test() -> Result<(), String> { - 34| 1| println!("Starting service"); - 35| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; + LL| |// compile-flags: --edition=2018 + LL| |#![feature(no_coverage)] + LL| | + LL| |macro_rules! bail { + LL| | ($msg:literal $(,)?) => { + LL| | if $msg.len() > 0 { + LL| | println!("no msg"); + LL| | } else { + LL| | println!($msg); + LL| | } + LL| | return Err(String::from($msg)); + LL| | }; + LL| |} + LL| | + LL| |macro_rules! on_error { + LL| | ($value:expr, $error_message:expr) => { + LL| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros + LL| | let message = format!($error_message, e); + LL| | if message.len() > 0 { + LL| | println!("{}", message); + LL| | Ok(String::from("ok")) + LL| | } else { + LL| | bail!("error"); + LL| | } + LL| | }) + LL| | }; + LL| |} + LL| | + LL| 1|fn load_configuration_files() -> Result { + LL| 1| Ok(String::from("config")) + LL| 1|} + LL| | + LL| 1|pub async fn test() -> Result<(), String> { + LL| 1| println!("Starting service"); + LL| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; ^0 - 36| | - 37| 1| let startup_delay_duration = String::from("arg"); - 38| 1| let _ = (config, startup_delay_duration); - 39| 1| Ok(()) - 40| 1|} - 41| | - 42| |#[no_coverage] - 43| |fn main() { - 44| | executor::block_on(test()); - 45| |} - 46| | - 47| |mod executor { - 48| | use core::{ - 49| | future::Future, - 50| | pin::Pin, - 51| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - 52| | }; - 53| | - 54| | #[no_coverage] - 55| | pub fn block_on(mut future: F) -> F::Output { - 56| | let mut future = unsafe { Pin::new_unchecked(&mut future) }; - 57| | use std::hint::unreachable_unchecked; - 58| | static VTABLE: RawWakerVTable = RawWakerVTable::new( - 59| | - 60| | #[no_coverage] - 61| | |_| unsafe { unreachable_unchecked() }, // clone - 62| | - 63| | #[no_coverage] - 64| | |_| unsafe { unreachable_unchecked() }, // wake - 65| | - 66| | #[no_coverage] - 67| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref - 68| | - 69| | #[no_coverage] - 70| | |_| (), - 71| | ); - 72| | let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - 73| | let mut context = Context::from_waker(&waker); - 74| | - 75| | loop { - 76| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - 77| | break val; - 78| | } - 79| | } - 80| | } - 81| |} + LL| | + LL| 1| let startup_delay_duration = String::from("arg"); + LL| 1| let _ = (config, startup_delay_duration); + LL| 1| Ok(()) + LL| 1|} + LL| | + LL| |#[no_coverage] + LL| |fn main() { + LL| | executor::block_on(test()); + LL| |} + LL| | + LL| |mod executor { + LL| | use core::{ + LL| | future::Future, + LL| | pin::Pin, + LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + LL| | }; + LL| | + LL| | #[no_coverage] + LL| | pub fn block_on(mut future: F) -> F::Output { + LL| | let mut future = unsafe { Pin::new_unchecked(&mut future) }; + LL| | use std::hint::unreachable_unchecked; + LL| | static VTABLE: RawWakerVTable = RawWakerVTable::new( + LL| | + LL| | #[no_coverage] + LL| | |_| unsafe { unreachable_unchecked() }, // clone + LL| | + LL| | #[no_coverage] + LL| | |_| unsafe { unreachable_unchecked() }, // wake + LL| | + LL| | #[no_coverage] + LL| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref + LL| | + LL| | #[no_coverage] + LL| | |_| (), + LL| | ); + LL| | let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + LL| | let mut context = Context::from_waker(&waker); + LL| | + LL| | loop { + LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + LL| | break val; + LL| | } + LL| | } + LL| | } + LL| |} diff --git a/tests/run-coverage/conditions.coverage b/tests/run-coverage/conditions.coverage index 2d8a98a5d..4749c353a 100644 --- a/tests/run-coverage/conditions.coverage +++ b/tests/run-coverage/conditions.coverage @@ -1,94 +1,94 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| let mut countdown = 0; - 5| 1| if true { - 6| 1| countdown = 10; - 7| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| let mut countdown = 0; + LL| 1| if true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 8| | - 9| | const B: u32 = 100; - 10| 1| let x = if countdown > 7 { - 11| 1| countdown -= 4; - 12| 1| B - 13| 0| } else if countdown > 2 { - 14| 0| if countdown < 1 || countdown > 5 || countdown != 9 { - 15| 0| countdown = 0; - 16| 0| } - 17| 0| countdown -= 5; - 18| 0| countdown - 19| | } else { - 20| 0| return; - 21| | }; - 22| | - 23| 1| let mut countdown = 0; - 24| 1| if true { - 25| 1| countdown = 10; - 26| 1| } + LL| | + LL| | const B: u32 = 100; + LL| 1| let x = if countdown > 7 { + LL| 1| countdown -= 4; + LL| 1| B + LL| 0| } else if countdown > 2 { + LL| 0| if countdown < 1 || countdown > 5 || countdown != 9 { + LL| 0| countdown = 0; + LL| 0| } + LL| 0| countdown -= 5; + LL| 0| countdown + LL| | } else { + LL| 0| return; + LL| | }; + LL| | + LL| 1| let mut countdown = 0; + LL| 1| if true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 27| | - 28| 1| if countdown > 7 { - 29| 1| countdown -= 4; - 30| 1| } else if countdown > 2 { + LL| | + LL| 1| if countdown > 7 { + LL| 1| countdown -= 4; + LL| 1| } else if countdown > 2 { ^0 - 31| 0| if countdown < 1 || countdown > 5 || countdown != 9 { - 32| 0| countdown = 0; - 33| 0| } - 34| 0| countdown -= 5; - 35| | } else { - 36| 0| return; - 37| | } - 38| | - 39| 1| if true { - 40| 1| let mut countdown = 0; - 41| 1| if true { - 42| 1| countdown = 10; - 43| 1| } + LL| 0| if countdown < 1 || countdown > 5 || countdown != 9 { + LL| 0| countdown = 0; + LL| 0| } + LL| 0| countdown -= 5; + LL| | } else { + LL| 0| return; + LL| | } + LL| | + LL| 1| if true { + LL| 1| let mut countdown = 0; + LL| 1| if true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 44| | - 45| 1| if countdown > 7 { - 46| 1| countdown -= 4; - 47| 1| } - 48| 0| else if countdown > 2 { - 49| 0| if countdown < 1 || countdown > 5 || countdown != 9 { - 50| 0| countdown = 0; - 51| 0| } - 52| 0| countdown -= 5; - 53| | } else { - 54| 0| return; - 55| | } - 56| 0| } - 57| | - 58| | - 59| 1| let mut countdown = 0; - 60| 1| if true { - 61| 1| countdown = 1; - 62| 1| } + LL| | + LL| 1| if countdown > 7 { + LL| 1| countdown -= 4; + LL| 1| } + LL| 0| else if countdown > 2 { + LL| 0| if countdown < 1 || countdown > 5 || countdown != 9 { + LL| 0| countdown = 0; + LL| 0| } + LL| 0| countdown -= 5; + LL| | } else { + LL| 0| return; + LL| | } + LL| 0| } + LL| | + LL| | + LL| 1| let mut countdown = 0; + LL| 1| if true { + LL| 1| countdown = 1; + LL| 1| } ^0 - 63| | - 64| 1| let z = if countdown > 7 { + LL| | + LL| 1| let z = if countdown > 7 { ^0 - 65| 0| countdown -= 4; - 66| 1| } else if countdown > 2 { - 67| 0| if countdown < 1 || countdown > 5 || countdown != 9 { - 68| 0| countdown = 0; - 69| 0| } - 70| 0| countdown -= 5; - 71| | } else { - 72| 1| let should_be_reachable = countdown; - 73| 1| println!("reached"); - 74| 1| return; - 75| | }; - 76| | - 77| 0| let w = if countdown > 7 { - 78| 0| countdown -= 4; - 79| 0| } else if countdown > 2 { - 80| 0| if countdown < 1 || countdown > 5 || countdown != 9 { - 81| 0| countdown = 0; - 82| 0| } - 83| 0| countdown -= 5; - 84| | } else { - 85| 0| return; - 86| | }; - 87| 1|} + LL| 0| countdown -= 4; + LL| 1| } else if countdown > 2 { + LL| 0| if countdown < 1 || countdown > 5 || countdown != 9 { + LL| 0| countdown = 0; + LL| 0| } + LL| 0| countdown -= 5; + LL| | } else { + LL| 1| let should_be_reachable = countdown; + LL| 1| println!("reached"); + LL| 1| return; + LL| | }; + LL| | + LL| 0| let w = if countdown > 7 { + LL| 0| countdown -= 4; + LL| 0| } else if countdown > 2 { + LL| 0| if countdown < 1 || countdown > 5 || countdown != 9 { + LL| 0| countdown = 0; + LL| 0| } + LL| 0| countdown -= 5; + LL| | } else { + LL| 0| return; + LL| | }; + LL| 1|} diff --git a/tests/run-coverage/continue.coverage b/tests/run-coverage/continue.coverage index bf42924b1..4916cac00 100644 --- a/tests/run-coverage/continue.coverage +++ b/tests/run-coverage/continue.coverage @@ -1,70 +1,70 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| let is_true = std::env::args().len() == 1; - 5| 1| - 6| 1| let mut x = 0; - 7| 11| for _ in 0..10 { - 8| 10| match is_true { - 9| | true => { - 10| 10| continue; - 11| | } - 12| 0| _ => { - 13| 0| x = 1; - 14| 0| } - 15| 0| } - 16| 0| x = 3; - 17| | } - 18| 11| for _ in 0..10 { - 19| 10| match is_true { - 20| 0| false => { - 21| 0| x = 1; - 22| 0| } - 23| | _ => { - 24| 10| continue; - 25| | } - 26| | } - 27| 0| x = 3; - 28| | } - 29| 11| for _ in 0..10 { - 30| 10| match is_true { - 31| 10| true => { - 32| 10| x = 1; - 33| 10| } - 34| | _ => { - 35| 0| continue; - 36| | } - 37| | } - 38| 10| x = 3; - 39| | } - 40| 11| for _ in 0..10 { - 41| 10| if is_true { - 42| 10| continue; - 43| 0| } - 44| 0| x = 3; - 45| | } - 46| 11| for _ in 0..10 { - 47| 10| match is_true { - 48| 0| false => { - 49| 0| x = 1; - 50| 0| } - 51| 10| _ => { - 52| 10| let _ = x; - 53| 10| } - 54| | } - 55| 10| x = 3; - 56| | } - 57| 1| for _ in 0..10 { - 58| 1| match is_true { - 59| 0| false => { - 60| 0| x = 1; - 61| 0| } - 62| | _ => { - 63| 1| break; - 64| | } - 65| | } - 66| 0| x = 3; - 67| | } - 68| 1| let _ = x; - 69| 1|} + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut x = 0; + LL| 11| for _ in 0..10 { + LL| 10| match is_true { + LL| | true => { + LL| 10| continue; + LL| | } + LL| 0| _ => { + LL| 0| x = 1; + LL| 0| } + LL| 0| } + LL| 0| x = 3; + LL| | } + LL| 11| for _ in 0..10 { + LL| 10| match is_true { + LL| 0| false => { + LL| 0| x = 1; + LL| 0| } + LL| | _ => { + LL| 10| continue; + LL| | } + LL| | } + LL| 0| x = 3; + LL| | } + LL| 11| for _ in 0..10 { + LL| 10| match is_true { + LL| 10| true => { + LL| 10| x = 1; + LL| 10| } + LL| | _ => { + LL| 0| continue; + LL| | } + LL| | } + LL| 10| x = 3; + LL| | } + LL| 11| for _ in 0..10 { + LL| 10| if is_true { + LL| 10| continue; + LL| 0| } + LL| 0| x = 3; + LL| | } + LL| 11| for _ in 0..10 { + LL| 10| match is_true { + LL| 0| false => { + LL| 0| x = 1; + LL| 0| } + LL| 10| _ => { + LL| 10| let _ = x; + LL| 10| } + LL| | } + LL| 10| x = 3; + LL| | } + LL| 1| for _ in 0..10 { + LL| 1| match is_true { + LL| 0| false => { + LL| 0| x = 1; + LL| 0| } + LL| | _ => { + LL| 1| break; + LL| | } + LL| | } + LL| 0| x = 3; + LL| | } + LL| 1| let _ = x; + LL| 1|} diff --git a/tests/run-coverage/dead_code.coverage b/tests/run-coverage/dead_code.coverage index 09ff14c6f..5074d8b3c 100644 --- a/tests/run-coverage/dead_code.coverage +++ b/tests/run-coverage/dead_code.coverage @@ -1,39 +1,39 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 0|pub fn unused_pub_fn_not_in_library() { - 4| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 0| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 0| // dependent conditions. - 7| 0| let is_true = std::env::args().len() == 1; - 8| 0| - 9| 0| let mut countdown = 0; - 10| 0| if is_true { - 11| 0| countdown = 10; - 12| 0| } - 13| 0|} - 14| | - 15| 0|fn unused_fn() { - 16| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 17| 0| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 18| 0| // dependent conditions. - 19| 0| let is_true = std::env::args().len() == 1; - 20| 0| - 21| 0| let mut countdown = 0; - 22| 0| if is_true { - 23| 0| countdown = 10; - 24| 0| } - 25| 0|} - 26| | - 27| 1|fn main() { - 28| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 29| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 30| 1| // dependent conditions. - 31| 1| let is_true = std::env::args().len() == 1; - 32| 1| - 33| 1| let mut countdown = 0; - 34| 1| if is_true { - 35| 1| countdown = 10; - 36| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 0|pub fn unused_pub_fn_not_in_library() { + LL| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 0| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 0| // dependent conditions. + LL| 0| let is_true = std::env::args().len() == 1; + LL| 0| + LL| 0| let mut countdown = 0; + LL| 0| if is_true { + LL| 0| countdown = 10; + LL| 0| } + LL| 0|} + LL| | + LL| 0|fn unused_fn() { + LL| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 0| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 0| // dependent conditions. + LL| 0| let is_true = std::env::args().len() == 1; + LL| 0| + LL| 0| let mut countdown = 0; + LL| 0| if is_true { + LL| 0| countdown = 10; + LL| 0| } + LL| 0|} + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut countdown = 0; + LL| 1| if is_true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 37| 1|} + LL| 1|} diff --git a/tests/run-coverage/drop_trait.coverage b/tests/run-coverage/drop_trait.coverage index 293001e95..c99b980a3 100644 --- a/tests/run-coverage/drop_trait.coverage +++ b/tests/run-coverage/drop_trait.coverage @@ -1,34 +1,34 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 1 - 3| | - 4| |struct Firework { - 5| | strength: i32, - 6| |} - 7| | - 8| |impl Drop for Firework { - 9| 2| fn drop(&mut self) { - 10| 2| println!("BOOM times {}!!!", self.strength); - 11| 2| } - 12| |} - 13| | - 14| 1|fn main() -> Result<(),u8> { - 15| 1| let _firecracker = Firework { strength: 1 }; - 16| 1| - 17| 1| let _tnt = Firework { strength: 100 }; - 18| 1| - 19| 1| if true { - 20| 1| println!("Exiting with error..."); - 21| 1| return Err(1); - 22| 0| } - 23| 0| - 24| 0| let _ = Firework { strength: 1000 }; - 25| 0| - 26| 0| Ok(()) - 27| 1|} - 28| | - 29| |// Expected program output: - 30| |// Exiting with error... - 31| |// BOOM times 100!!! - 32| |// BOOM times 1!!! - 33| |// Error: 1 + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 1 + LL| | + LL| |struct Firework { + LL| | strength: i32, + LL| |} + LL| | + LL| |impl Drop for Firework { + LL| 2| fn drop(&mut self) { + LL| 2| println!("BOOM times {}!!!", self.strength); + LL| 2| } + LL| |} + LL| | + LL| 1|fn main() -> Result<(),u8> { + LL| 1| let _firecracker = Firework { strength: 1 }; + LL| 1| + LL| 1| let _tnt = Firework { strength: 100 }; + LL| 1| + LL| 1| if true { + LL| 1| println!("Exiting with error..."); + LL| 1| return Err(1); + LL| 0| } + LL| 0| + LL| 0| let _ = Firework { strength: 1000 }; + LL| 0| + LL| 0| Ok(()) + LL| 1|} + LL| | + LL| |// Expected program output: + LL| |// Exiting with error... + LL| |// BOOM times 100!!! + LL| |// BOOM times 1!!! + LL| |// Error: 1 diff --git a/tests/run-coverage/generator.coverage b/tests/run-coverage/generator.coverage index 0fb3808ff..daba2bea8 100644 --- a/tests/run-coverage/generator.coverage +++ b/tests/run-coverage/generator.coverage @@ -1,32 +1,32 @@ - 1| |#![feature(generators, generator_trait)] - 2| | - 3| |use std::ops::{Generator, GeneratorState}; - 4| |use std::pin::Pin; - 5| | - 6| |// The following implementation of a function called from a `yield` statement - 7| |// (apparently requiring the Result and the `String` type or constructor) - 8| |// creates conditions where the `generator::StateTransform` MIR transform will - 9| |// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic - 10| |// to handle this condition, and still report dead block coverage. - 11| 1|fn get_u32(val: bool) -> Result { - 12| 1| if val { Ok(1) } else { Err(String::from("some error")) } + LL| |#![feature(generators, generator_trait)] + LL| | + LL| |use std::ops::{Generator, GeneratorState}; + LL| |use std::pin::Pin; + LL| | + LL| |// The following implementation of a function called from a `yield` statement + LL| |// (apparently requiring the Result and the `String` type or constructor) + LL| |// creates conditions where the `generator::StateTransform` MIR transform will + LL| |// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic + LL| |// to handle this condition, and still report dead block coverage. + LL| 1|fn get_u32(val: bool) -> Result { + LL| 1| if val { Ok(1) } else { Err(String::from("some error")) } ^0 - 13| 1|} - 14| | - 15| 1|fn main() { - 16| 1| let is_true = std::env::args().len() == 1; - 17| 1| let mut generator = || { - 18| 1| yield get_u32(is_true); - 19| 1| return "foo"; - 20| 1| }; - 21| | - 22| 1| match Pin::new(&mut generator).resume(()) { - 23| 1| GeneratorState::Yielded(Ok(1)) => {} - 24| 0| _ => panic!("unexpected return from resume"), - 25| | } - 26| 1| match Pin::new(&mut generator).resume(()) { - 27| 1| GeneratorState::Complete("foo") => {} - 28| 0| _ => panic!("unexpected return from resume"), - 29| | } - 30| 1|} + LL| 1|} + LL| | + LL| 1|fn main() { + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let mut generator = || { + LL| 1| yield get_u32(is_true); + LL| 1| return "foo"; + LL| 1| }; + LL| | + LL| 1| match Pin::new(&mut generator).resume(()) { + LL| 1| GeneratorState::Yielded(Ok(1)) => {} + LL| 0| _ => panic!("unexpected return from resume"), + LL| | } + LL| 1| match Pin::new(&mut generator).resume(()) { + LL| 1| GeneratorState::Complete("foo") => {} + LL| 0| _ => panic!("unexpected return from resume"), + LL| | } + LL| 1|} diff --git a/tests/run-coverage/generics.coverage b/tests/run-coverage/generics.coverage index 7a7649674..2ff8f917e 100644 --- a/tests/run-coverage/generics.coverage +++ b/tests/run-coverage/generics.coverage @@ -1,71 +1,71 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 1 - 3| | - 4| |struct Firework where T: Copy + std::fmt::Display { - 5| | strength: T, - 6| |} - 7| | - 8| |impl Firework where T: Copy + std::fmt::Display { - 9| | #[inline(always)] - 10| 3| fn set_strength(&mut self, new_strength: T) { - 11| 3| self.strength = new_strength; - 12| 3| } + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 1 + LL| | + LL| |struct Firework where T: Copy + std::fmt::Display { + LL| | strength: T, + LL| |} + LL| | + LL| |impl Firework where T: Copy + std::fmt::Display { + LL| | #[inline(always)] + LL| 3| fn set_strength(&mut self, new_strength: T) { + LL| 3| self.strength = new_strength; + LL| 3| } ------------------ | >::set_strength: - | 10| 2| fn set_strength(&mut self, new_strength: T) { - | 11| 2| self.strength = new_strength; - | 12| 2| } + | LL| 2| fn set_strength(&mut self, new_strength: T) { + | LL| 2| self.strength = new_strength; + | LL| 2| } ------------------ | >::set_strength: - | 10| 1| fn set_strength(&mut self, new_strength: T) { - | 11| 1| self.strength = new_strength; - | 12| 1| } + | LL| 1| fn set_strength(&mut self, new_strength: T) { + | LL| 1| self.strength = new_strength; + | LL| 1| } ------------------ - 13| |} - 14| | - 15| |impl Drop for Firework where T: Copy + std::fmt::Display { - 16| | #[inline(always)] - 17| 2| fn drop(&mut self) { - 18| 2| println!("BOOM times {}!!!", self.strength); - 19| 2| } + LL| |} + LL| | + LL| |impl Drop for Firework where T: Copy + std::fmt::Display { + LL| | #[inline(always)] + LL| 2| fn drop(&mut self) { + LL| 2| println!("BOOM times {}!!!", self.strength); + LL| 2| } ------------------ | as core::ops::drop::Drop>::drop: - | 17| 1| fn drop(&mut self) { - | 18| 1| println!("BOOM times {}!!!", self.strength); - | 19| 1| } + | LL| 1| fn drop(&mut self) { + | LL| 1| println!("BOOM times {}!!!", self.strength); + | LL| 1| } ------------------ | as core::ops::drop::Drop>::drop: - | 17| 1| fn drop(&mut self) { - | 18| 1| println!("BOOM times {}!!!", self.strength); - | 19| 1| } + | LL| 1| fn drop(&mut self) { + | LL| 1| println!("BOOM times {}!!!", self.strength); + | LL| 1| } ------------------ - 20| |} - 21| | - 22| 1|fn main() -> Result<(),u8> { - 23| 1| let mut firecracker = Firework { strength: 1 }; - 24| 1| firecracker.set_strength(2); - 25| 1| - 26| 1| let mut tnt = Firework { strength: 100.1 }; - 27| 1| tnt.set_strength(200.1); - 28| 1| tnt.set_strength(300.3); - 29| 1| - 30| 1| if true { - 31| 1| println!("Exiting with error..."); - 32| 1| return Err(1); - 33| 0| } - 34| 0| - 35| 0| - 36| 0| - 37| 0| - 38| 0| - 39| 0| let _ = Firework { strength: 1000 }; - 40| 0| - 41| 0| Ok(()) - 42| 1|} - 43| | - 44| |// Expected program output: - 45| |// Exiting with error... - 46| |// BOOM times 100!!! - 47| |// BOOM times 1!!! - 48| |// Error: 1 + LL| |} + LL| | + LL| 1|fn main() -> Result<(),u8> { + LL| 1| let mut firecracker = Firework { strength: 1 }; + LL| 1| firecracker.set_strength(2); + LL| 1| + LL| 1| let mut tnt = Firework { strength: 100.1 }; + LL| 1| tnt.set_strength(200.1); + LL| 1| tnt.set_strength(300.3); + LL| 1| + LL| 1| if true { + LL| 1| println!("Exiting with error..."); + LL| 1| return Err(1); + LL| 0| } + LL| 0| + LL| 0| + LL| 0| + LL| 0| + LL| 0| + LL| 0| let _ = Firework { strength: 1000 }; + LL| 0| + LL| 0| Ok(()) + LL| 1|} + LL| | + LL| |// Expected program output: + LL| |// Exiting with error... + LL| |// BOOM times 100!!! + LL| |// BOOM times 1!!! + LL| |// Error: 1 diff --git a/tests/run-coverage/if.coverage b/tests/run-coverage/if.coverage index 0c9eff227..2e6845190 100644 --- a/tests/run-coverage/if.coverage +++ b/tests/run-coverage/if.coverage @@ -1,30 +1,30 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let - 8| 1| is_true - 9| 1| = - 10| 1| std::env::args().len() - 11| 1| == - 12| 1| 1 - 13| 1| ; - 14| 1| let - 15| 1| mut - 16| 1| countdown - 17| 1| = - 18| 1| 0 - 19| 1| ; - 20| 1| if - 21| 1| is_true - 22| 1| { - 23| 1| countdown - 24| 1| = - 25| 1| 10 - 26| 1| ; - 27| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let + LL| 1| is_true + LL| 1| = + LL| 1| std::env::args().len() + LL| 1| == + LL| 1| 1 + LL| 1| ; + LL| 1| let + LL| 1| mut + LL| 1| countdown + LL| 1| = + LL| 1| 0 + LL| 1| ; + LL| 1| if + LL| 1| is_true + LL| 1| { + LL| 1| countdown + LL| 1| = + LL| 1| 10 + LL| 1| ; + LL| 1| } ^0 - 28| 1|} + LL| 1|} diff --git a/tests/run-coverage/if_else.coverage b/tests/run-coverage/if_else.coverage index 4285d3186..0274401f0 100644 --- a/tests/run-coverage/if_else.coverage +++ b/tests/run-coverage/if_else.coverage @@ -1,41 +1,41 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| - 9| 1| let mut countdown = 0; - 10| 1| if - 11| 1| is_true - 12| 1| { - 13| 1| countdown - 14| 1| = - 15| 1| 10 - 16| 1| ; - 17| 1| } - 18| | else // Note coverage region difference without semicolon - 19| | { - 20| 0| countdown - 21| 0| = - 22| 0| 100 - 23| | } - 24| | - 25| | if - 26| 1| is_true - 27| 1| { - 28| 1| countdown - 29| 1| = - 30| 1| 10 - 31| 1| ; - 32| 1| } - 33| | else - 34| 0| { - 35| 0| countdown - 36| 0| = - 37| 0| 100 - 38| 0| ; - 39| 0| } - 40| 1|} + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut countdown = 0; + LL| 1| if + LL| 1| is_true + LL| 1| { + LL| 1| countdown + LL| 1| = + LL| 1| 10 + LL| 1| ; + LL| 1| } + LL| | else // Note coverage region difference without semicolon + LL| | { + LL| 0| countdown + LL| 0| = + LL| 0| 100 + LL| | } + LL| | + LL| | if + LL| 1| is_true + LL| 1| { + LL| 1| countdown + LL| 1| = + LL| 1| 10 + LL| 1| ; + LL| 1| } + LL| | else + LL| 0| { + LL| 0| countdown + LL| 0| = + LL| 0| 100 + LL| 0| ; + LL| 0| } + LL| 1|} diff --git a/tests/run-coverage/inline-dead.coverage b/tests/run-coverage/inline-dead.coverage index a59fe1146..de96aa17a 100644 --- a/tests/run-coverage/inline-dead.coverage +++ b/tests/run-coverage/inline-dead.coverage @@ -1,28 +1,28 @@ - 1| |// Regression test for issue #98833. - 2| |// compile-flags: -Zinline-mir -Cdebug-assertions=off - 3| | - 4| 1|fn main() { - 5| 1| println!("{}", live::()); - 6| 1| - 7| 1| let f = |x: bool| { - 8| | debug_assert!( - 9| 0| x - 10| | ); - 11| 1| }; - 12| 1| f(false); - 13| 1|} - 14| | - 15| |#[inline] - 16| 1|fn live() -> u32 { - 17| 1| if B { - 18| 0| dead() - 19| | } else { - 20| 1| 0 - 21| | } - 22| 1|} - 23| | - 24| |#[inline] - 25| 0|fn dead() -> u32 { - 26| 0| 42 - 27| 0|} + LL| |// Regression test for issue #98833. + LL| |// compile-flags: -Zinline-mir -Cdebug-assertions=off + LL| | + LL| 1|fn main() { + LL| 1| println!("{}", live::()); + LL| 1| + LL| 1| let f = |x: bool| { + LL| | debug_assert!( + LL| 0| x + LL| | ); + LL| 1| }; + LL| 1| f(false); + LL| 1|} + LL| | + LL| |#[inline] + LL| 1|fn live() -> u32 { + LL| 1| if B { + LL| 0| dead() + LL| | } else { + LL| 1| 0 + LL| | } + LL| 1|} + LL| | + LL| |#[inline] + LL| 0|fn dead() -> u32 { + LL| 0| 42 + LL| 0|} diff --git a/tests/run-coverage/inline.coverage b/tests/run-coverage/inline.coverage index 6f5d1544f..6efd9a083 100644 --- a/tests/run-coverage/inline.coverage +++ b/tests/run-coverage/inline.coverage @@ -1,54 +1,54 @@ - 1| |// compile-flags: -Zinline-mir - 2| | - 3| |use std::fmt::Display; - 4| | - 5| 1|fn main() { - 6| 1| permutations(&['a', 'b', 'c']); - 7| 1|} - 8| | - 9| |#[inline(always)] - 10| 1|fn permutations(xs: &[T]) { - 11| 1| let mut ys = xs.to_owned(); - 12| 1| permutate(&mut ys, 0); - 13| 1|} - 14| | - 15| 16|fn permutate(xs: &mut [T], k: usize) { - 16| 16| let n = length(xs); - 17| 16| if k == n { - 18| 6| display(xs); - 19| 10| } else if k < n { - 20| 15| for i in k..n { + LL| |// compile-flags: -Zinline-mir + LL| | + LL| |use std::fmt::Display; + LL| | + LL| 1|fn main() { + LL| 1| permutations(&['a', 'b', 'c']); + LL| 1|} + LL| | + LL| |#[inline(always)] + LL| 1|fn permutations(xs: &[T]) { + LL| 1| let mut ys = xs.to_owned(); + LL| 1| permutate(&mut ys, 0); + LL| 1|} + LL| | + LL| 16|fn permutate(xs: &mut [T], k: usize) { + LL| 16| let n = length(xs); + LL| 16| if k == n { + LL| 6| display(xs); + LL| 10| } else if k < n { + LL| 15| for i in k..n { ^10 - 21| 15| swap(xs, i, k); - 22| 15| permutate(xs, k + 1); - 23| 15| swap(xs, i, k); - 24| 15| } - 25| 0| } else { - 26| 0| error(); - 27| 0| } - 28| 16|} - 29| | - 30| 16|fn length(xs: &[T]) -> usize { - 31| 16| xs.len() - 32| 16|} - 33| | - 34| |#[inline] - 35| 30|fn swap(xs: &mut [T], i: usize, j: usize) { - 36| 30| let t = xs[i]; - 37| 30| xs[i] = xs[j]; - 38| 30| xs[j] = t; - 39| 30|} - 40| | - 41| 6|fn display(xs: &[T]) { - 42| 24| for x in xs { + LL| 15| swap(xs, i, k); + LL| 15| permutate(xs, k + 1); + LL| 15| swap(xs, i, k); + LL| 15| } + LL| 0| } else { + LL| 0| error(); + LL| 0| } + LL| 16|} + LL| | + LL| 16|fn length(xs: &[T]) -> usize { + LL| 16| xs.len() + LL| 16|} + LL| | + LL| |#[inline] + LL| 30|fn swap(xs: &mut [T], i: usize, j: usize) { + LL| 30| let t = xs[i]; + LL| 30| xs[i] = xs[j]; + LL| 30| xs[j] = t; + LL| 30|} + LL| | + LL| 6|fn display(xs: &[T]) { + LL| 24| for x in xs { ^18 - 43| 18| print!("{}", x); - 44| 18| } - 45| 6| println!(); - 46| 6|} - 47| | - 48| |#[inline(always)] - 49| 0|fn error() { - 50| 0| panic!("error"); - 51| 0|} + LL| 18| print!("{}", x); + LL| 18| } + LL| 6| println!(); + LL| 6|} + LL| | + LL| |#[inline(always)] + LL| 0|fn error() { + LL| 0| panic!("error"); + LL| 0|} diff --git a/tests/run-coverage/inner_items.coverage b/tests/run-coverage/inner_items.coverage index 883254a09..65493bcd9 100644 --- a/tests/run-coverage/inner_items.coverage +++ b/tests/run-coverage/inner_items.coverage @@ -1,60 +1,60 @@ - 1| |#![allow(unused_assignments, unused_variables, dead_code)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| - 9| 1| let mut countdown = 0; - 10| 1| if is_true { - 11| 1| countdown = 10; - 12| 1| } + LL| |#![allow(unused_assignments, unused_variables, dead_code)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut countdown = 0; + LL| 1| if is_true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 13| | - 14| | mod in_mod { - 15| | const IN_MOD_CONST: u32 = 1000; - 16| | } - 17| | - 18| 3| fn in_func(a: u32) { - 19| 3| let b = 1; - 20| 3| let c = a + b; - 21| 3| println!("c = {}", c) - 22| 3| } - 23| | - 24| | struct InStruct { - 25| | in_struct_field: u32, - 26| | } - 27| | - 28| | const IN_CONST: u32 = 1234; - 29| | - 30| | trait InTrait { - 31| | fn trait_func(&mut self, incr: u32); - 32| | - 33| 1| fn default_trait_func(&mut self) { - 34| 1| in_func(IN_CONST); - 35| 1| self.trait_func(IN_CONST); - 36| 1| } - 37| | } - 38| | - 39| | impl InTrait for InStruct { - 40| 1| fn trait_func(&mut self, incr: u32) { - 41| 1| self.in_struct_field += incr; - 42| 1| in_func(self.in_struct_field); - 43| 1| } - 44| | } - 45| | - 46| | type InType = String; - 47| | - 48| 1| if is_true { - 49| 1| in_func(countdown); - 50| 1| } + LL| | + LL| | mod in_mod { + LL| | const IN_MOD_CONST: u32 = 1000; + LL| | } + LL| | + LL| 3| fn in_func(a: u32) { + LL| 3| let b = 1; + LL| 3| let c = a + b; + LL| 3| println!("c = {}", c) + LL| 3| } + LL| | + LL| | struct InStruct { + LL| | in_struct_field: u32, + LL| | } + LL| | + LL| | const IN_CONST: u32 = 1234; + LL| | + LL| | trait InTrait { + LL| | fn trait_func(&mut self, incr: u32); + LL| | + LL| 1| fn default_trait_func(&mut self) { + LL| 1| in_func(IN_CONST); + LL| 1| self.trait_func(IN_CONST); + LL| 1| } + LL| | } + LL| | + LL| | impl InTrait for InStruct { + LL| 1| fn trait_func(&mut self, incr: u32) { + LL| 1| self.in_struct_field += incr; + LL| 1| in_func(self.in_struct_field); + LL| 1| } + LL| | } + LL| | + LL| | type InType = String; + LL| | + LL| 1| if is_true { + LL| 1| in_func(countdown); + LL| 1| } ^0 - 51| | - 52| 1| let mut val = InStruct { - 53| 1| in_struct_field: 101, - 54| 1| }; - 55| 1| - 56| 1| val.default_trait_func(); - 57| 1|} + LL| | + LL| 1| let mut val = InStruct { + LL| 1| in_struct_field: 101, + LL| 1| }; + LL| 1| + LL| 1| val.default_trait_func(); + LL| 1|} diff --git a/tests/run-coverage/issue-83601.coverage b/tests/run-coverage/issue-83601.coverage index 25c74ab2e..7995332ca 100644 --- a/tests/run-coverage/issue-83601.coverage +++ b/tests/run-coverage/issue-83601.coverage @@ -1,16 +1,16 @@ - 1| |// Shows that rust-lang/rust/83601 is resolved - 2| | - 3| 3|#[derive(Debug, PartialEq, Eq)] + LL| |// Shows that rust-lang/rust/83601 is resolved + LL| | + LL| 3|#[derive(Debug, PartialEq, Eq)] ^2 - 4| |struct Foo(u32); - 5| | - 6| 1|fn main() { - 7| 1| let bar = Foo(1); - 8| 1| assert_eq!(bar, Foo(1)); - 9| 1| let baz = Foo(0); - 10| 1| assert_ne!(baz, Foo(1)); - 11| 1| println!("{:?}", Foo(1)); - 12| 1| println!("{:?}", bar); - 13| 1| println!("{:?}", baz); - 14| 1|} + LL| |struct Foo(u32); + LL| | + LL| 1|fn main() { + LL| 1| let bar = Foo(1); + LL| 1| assert_eq!(bar, Foo(1)); + LL| 1| let baz = Foo(0); + LL| 1| assert_ne!(baz, Foo(1)); + LL| 1| println!("{:?}", Foo(1)); + LL| 1| println!("{:?}", bar); + LL| 1| println!("{:?}", baz); + LL| 1|} diff --git a/tests/run-coverage/issue-84561.coverage b/tests/run-coverage/issue-84561.coverage index 7a97e3532..222f877d3 100644 --- a/tests/run-coverage/issue-84561.coverage +++ b/tests/run-coverage/issue-84561.coverage @@ -1,189 +1,189 @@ - 1| |// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results. - 2| | - 3| |// failure-status: 101 - 4| 21|#[derive(PartialEq, Eq)] - 5| |struct Foo(u32); - 6| 1|fn test3() { - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| let bar = Foo(1); - 9| 1| assert_eq!(bar, Foo(1)); - 10| 1| let baz = Foo(0); - 11| 1| assert_ne!(baz, Foo(1)); - 12| 1| println!("{:?}", Foo(1)); - 13| 1| println!("{:?}", bar); - 14| 1| println!("{:?}", baz); - 15| 1| - 16| 1| assert_eq!(Foo(1), Foo(1)); - 17| 1| assert_ne!(Foo(0), Foo(1)); - 18| 1| assert_eq!(Foo(2), Foo(2)); - 19| 1| let bar = Foo(0); - 20| 1| assert_ne!(bar, Foo(3)); - 21| 1| assert_ne!(Foo(0), Foo(4)); - 22| 1| assert_eq!(Foo(3), Foo(3), "with a message"); + LL| |// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results. + LL| | + LL| |// failure-status: 101 + LL| 21|#[derive(PartialEq, Eq)] + LL| |struct Foo(u32); + LL| 1|fn test3() { + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let bar = Foo(1); + LL| 1| assert_eq!(bar, Foo(1)); + LL| 1| let baz = Foo(0); + LL| 1| assert_ne!(baz, Foo(1)); + LL| 1| println!("{:?}", Foo(1)); + LL| 1| println!("{:?}", bar); + LL| 1| println!("{:?}", baz); + LL| 1| + LL| 1| assert_eq!(Foo(1), Foo(1)); + LL| 1| assert_ne!(Foo(0), Foo(1)); + LL| 1| assert_eq!(Foo(2), Foo(2)); + LL| 1| let bar = Foo(0); + LL| 1| assert_ne!(bar, Foo(3)); + LL| 1| assert_ne!(Foo(0), Foo(4)); + LL| 1| assert_eq!(Foo(3), Foo(3), "with a message"); ^0 - 23| 1| println!("{:?}", bar); - 24| 1| println!("{:?}", Foo(1)); - 25| 1| - 26| 1| assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" }); + LL| 1| println!("{:?}", bar); + LL| 1| println!("{:?}", Foo(1)); + LL| 1| + LL| 1| assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" }); ^0 ^0 ^0 - 27| 1| assert_ne!( - 28| | Foo(0) - 29| | , - 30| | Foo(5) - 31| | , - 32| 0| "{}" - 33| 0| , - 34| 0| if - 35| 0| is_true - 36| | { - 37| 0| "true message" - 38| | } else { - 39| 0| "false message" - 40| | } - 41| | ); - 42| | - 43| 1| let is_true = std::env::args().len() == 1; - 44| 1| - 45| 1| assert_eq!( - 46| 1| Foo(1), - 47| 1| Foo(1) - 48| 1| ); - 49| 1| assert_ne!( - 50| 1| Foo(0), - 51| 1| Foo(1) - 52| 1| ); - 53| 1| assert_eq!( - 54| 1| Foo(2), - 55| 1| Foo(2) - 56| 1| ); - 57| 1| let bar = Foo(1); - 58| 1| assert_ne!( - 59| 1| bar, - 60| 1| Foo(3) - 61| 1| ); - 62| 1| if is_true { - 63| 1| assert_ne!( - 64| 1| Foo(0), - 65| 1| Foo(4) - 66| 1| ); - 67| | } else { - 68| 0| assert_eq!( - 69| 0| Foo(3), - 70| 0| Foo(3) - 71| 0| ); - 72| | } - 73| 1| if is_true { - 74| 1| assert_ne!( - 75| | Foo(0), - 76| | Foo(4), - 77| 0| "with a message" - 78| | ); - 79| | } else { - 80| 0| assert_eq!( - 81| | Foo(3), - 82| | Foo(3), - 83| 0| "with a message" - 84| | ); - 85| | } - 86| 1| assert_ne!( - 87| 1| if is_true { - 88| 1| Foo(0) - 89| | } else { - 90| 0| Foo(1) - 91| | }, - 92| | Foo(5) - 93| | ); - 94| 1| assert_ne!( - 95| 1| Foo(5), - 96| 1| if is_true { - 97| 1| Foo(0) - 98| | } else { - 99| 0| Foo(1) - 100| | } - 101| | ); - 102| 1| assert_ne!( - 103| 1| if is_true { - 104| 1| assert_eq!( - 105| 1| Foo(3), - 106| 1| Foo(3) - 107| 1| ); - 108| 1| Foo(0) - 109| | } else { - 110| 0| assert_ne!( - 111| 0| if is_true { - 112| 0| Foo(0) - 113| | } else { - 114| 0| Foo(1) - 115| | }, - 116| | Foo(5) - 117| | ); - 118| 0| Foo(1) - 119| | }, - 120| | Foo(5), - 121| 0| "with a message" - 122| | ); - 123| 1| assert_eq!( - 124| | Foo(1), - 125| | Foo(3), - 126| 1| "this assert should fail" - 127| | ); - 128| 0| assert_eq!( - 129| | Foo(3), - 130| | Foo(3), - 131| 0| "this assert should not be reached" - 132| | ); - 133| 0|} - 134| | - 135| |impl std::fmt::Debug for Foo { - 136| | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - 137| 7| write!(f, "try and succeed")?; + LL| 1| assert_ne!( + LL| | Foo(0) + LL| | , + LL| | Foo(5) + LL| | , + LL| 0| "{}" + LL| 0| , + LL| 0| if + LL| 0| is_true + LL| | { + LL| 0| "true message" + LL| | } else { + LL| 0| "false message" + LL| | } + LL| | ); + LL| | + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| assert_eq!( + LL| 1| Foo(1), + LL| 1| Foo(1) + LL| 1| ); + LL| 1| assert_ne!( + LL| 1| Foo(0), + LL| 1| Foo(1) + LL| 1| ); + LL| 1| assert_eq!( + LL| 1| Foo(2), + LL| 1| Foo(2) + LL| 1| ); + LL| 1| let bar = Foo(1); + LL| 1| assert_ne!( + LL| 1| bar, + LL| 1| Foo(3) + LL| 1| ); + LL| 1| if is_true { + LL| 1| assert_ne!( + LL| 1| Foo(0), + LL| 1| Foo(4) + LL| 1| ); + LL| | } else { + LL| 0| assert_eq!( + LL| 0| Foo(3), + LL| 0| Foo(3) + LL| 0| ); + LL| | } + LL| 1| if is_true { + LL| 1| assert_ne!( + LL| | Foo(0), + LL| | Foo(4), + LL| 0| "with a message" + LL| | ); + LL| | } else { + LL| 0| assert_eq!( + LL| | Foo(3), + LL| | Foo(3), + LL| 0| "with a message" + LL| | ); + LL| | } + LL| 1| assert_ne!( + LL| 1| if is_true { + LL| 1| Foo(0) + LL| | } else { + LL| 0| Foo(1) + LL| | }, + LL| | Foo(5) + LL| | ); + LL| 1| assert_ne!( + LL| 1| Foo(5), + LL| 1| if is_true { + LL| 1| Foo(0) + LL| | } else { + LL| 0| Foo(1) + LL| | } + LL| | ); + LL| 1| assert_ne!( + LL| 1| if is_true { + LL| 1| assert_eq!( + LL| 1| Foo(3), + LL| 1| Foo(3) + LL| 1| ); + LL| 1| Foo(0) + LL| | } else { + LL| 0| assert_ne!( + LL| 0| if is_true { + LL| 0| Foo(0) + LL| | } else { + LL| 0| Foo(1) + LL| | }, + LL| | Foo(5) + LL| | ); + LL| 0| Foo(1) + LL| | }, + LL| | Foo(5), + LL| 0| "with a message" + LL| | ); + LL| 1| assert_eq!( + LL| | Foo(1), + LL| | Foo(3), + LL| 1| "this assert should fail" + LL| | ); + LL| 0| assert_eq!( + LL| | Foo(3), + LL| | Foo(3), + LL| 0| "this assert should not be reached" + LL| | ); + LL| 0|} + LL| | + LL| |impl std::fmt::Debug for Foo { + LL| | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + LL| 7| write!(f, "try and succeed")?; ^0 - 138| 7| Ok(()) - 139| 7| } - 140| |} - 141| | - 142| |static mut DEBUG_LEVEL_ENABLED: bool = false; - 143| | - 144| |macro_rules! debug { - 145| | ($($arg:tt)+) => ( - 146| | if unsafe { DEBUG_LEVEL_ENABLED } { - 147| | println!($($arg)+); - 148| | } - 149| | ); - 150| |} - 151| | - 152| 1|fn test1() { - 153| 1| debug!("debug is enabled"); + LL| 7| Ok(()) + LL| 7| } + LL| |} + LL| | + LL| |static mut DEBUG_LEVEL_ENABLED: bool = false; + LL| | + LL| |macro_rules! debug { + LL| | ($($arg:tt)+) => ( + LL| | if unsafe { DEBUG_LEVEL_ENABLED } { + LL| | println!($($arg)+); + LL| | } + LL| | ); + LL| |} + LL| | + LL| 1|fn test1() { + LL| 1| debug!("debug is enabled"); ^0 - 154| 1| debug!("debug is enabled"); + LL| 1| debug!("debug is enabled"); ^0 - 155| 1| let _ = 0; - 156| 1| debug!("debug is enabled"); + LL| 1| let _ = 0; + LL| 1| debug!("debug is enabled"); ^0 - 157| 1| unsafe { - 158| 1| DEBUG_LEVEL_ENABLED = true; - 159| 1| } - 160| 1| debug!("debug is enabled"); - 161| 1|} - 162| | - 163| |macro_rules! call_debug { - 164| | ($($arg:tt)+) => ( - 165| 1| fn call_print(s: &str) { - 166| 1| print!("{}", s); - 167| 1| } - 168| | - 169| | call_print("called from call_debug: "); - 170| | debug!($($arg)+); - 171| | ); - 172| |} - 173| | - 174| 1|fn test2() { - 175| 1| call_debug!("debug is enabled"); - 176| 1|} - 177| | - 178| 1|fn main() { - 179| 1| test1(); - 180| 1| test2(); - 181| 1| test3(); - 182| 1|} + LL| 1| unsafe { + LL| 1| DEBUG_LEVEL_ENABLED = true; + LL| 1| } + LL| 1| debug!("debug is enabled"); + LL| 1|} + LL| | + LL| |macro_rules! call_debug { + LL| | ($($arg:tt)+) => ( + LL| 1| fn call_print(s: &str) { + LL| 1| print!("{}", s); + LL| 1| } + LL| | + LL| | call_print("called from call_debug: "); + LL| | debug!($($arg)+); + LL| | ); + LL| |} + LL| | + LL| 1|fn test2() { + LL| 1| call_debug!("debug is enabled"); + LL| 1|} + LL| | + LL| 1|fn main() { + LL| 1| test1(); + LL| 1| test2(); + LL| 1| test3(); + LL| 1|} diff --git a/tests/run-coverage/issue-85461.coverage b/tests/run-coverage/issue-85461.coverage index d78a4a112..f97ab2303 100644 --- a/tests/run-coverage/issue-85461.coverage +++ b/tests/run-coverage/issue-85461.coverage @@ -1,36 +1,36 @@ $DIR/auxiliary/inline_always_with_dead_code.rs: - 1| |// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0 - 2| | - 3| |#![allow(dead_code)] - 4| | - 5| |mod foo { - 6| | #[inline(always)] - 7| 2| pub fn called() { } - 8| | - 9| 0| fn uncalled() { } - 10| |} - 11| | - 12| |pub mod bar { - 13| 1| pub fn call_me() { - 14| 1| super::foo::called(); - 15| 1| } - 16| |} - 17| | - 18| |pub mod baz { - 19| 1| pub fn call_me() { - 20| 1| super::foo::called(); - 21| 1| } - 22| |} + LL| |// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0 + LL| | + LL| |#![allow(dead_code)] + LL| | + LL| |mod foo { + LL| | #[inline(always)] + LL| 2| pub fn called() { } + LL| | + LL| 0| fn uncalled() { } + LL| |} + LL| | + LL| |pub mod bar { + LL| 1| pub fn call_me() { + LL| 1| super::foo::called(); + LL| 1| } + LL| |} + LL| | + LL| |pub mod baz { + LL| 1| pub fn call_me() { + LL| 1| super::foo::called(); + LL| 1| } + LL| |} $DIR/issue-85461.rs: - 1| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] - 2| |// aux-build:inline_always_with_dead_code.rs - 3| |extern crate inline_always_with_dead_code; - 4| | - 5| |use inline_always_with_dead_code::{bar, baz}; - 6| | - 7| 1|fn main() { - 8| 1| bar::call_me(); - 9| 1| baz::call_me(); - 10| 1|} + LL| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] + LL| |// aux-build:inline_always_with_dead_code.rs + LL| |extern crate inline_always_with_dead_code; + LL| | + LL| |use inline_always_with_dead_code::{bar, baz}; + LL| | + LL| 1|fn main() { + LL| 1| bar::call_me(); + LL| 1| baz::call_me(); + LL| 1|} diff --git a/tests/run-coverage/issue-93054.coverage b/tests/run-coverage/issue-93054.coverage index a1655aded..074e6b983 100644 --- a/tests/run-coverage/issue-93054.coverage +++ b/tests/run-coverage/issue-93054.coverage @@ -1,29 +1,29 @@ - 1| |// Regression test for #93054: Functions using uninhabited types often only have a single, - 2| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. - 3| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. - 4| | - 5| |// compile-flags: --edition=2021 - 6| | - 7| |enum Never { } - 8| | - 9| |impl Never { - 10| | fn foo(self) { - 11| | match self { } - 12| | make().map(|never| match never { }); - 13| | } - 14| | - 15| | fn bar(&self) { - 16| | match *self { } - 17| | } - 18| |} - 19| | - 20| 0|async fn foo2(never: Never) { - 21| | match never { } - 22| |} - 23| | - 24| 0|fn make() -> Option { - 25| 0| None - 26| 0|} - 27| | - 28| 1|fn main() { } + LL| |// Regression test for #93054: Functions using uninhabited types often only have a single, + LL| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. + LL| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. + LL| | + LL| |// compile-flags: --edition=2021 + LL| | + LL| |enum Never { } + LL| | + LL| |impl Never { + LL| | fn foo(self) { + LL| | match self { } + LL| | make().map(|never| match never { }); + LL| | } + LL| | + LL| | fn bar(&self) { + LL| | match *self { } + LL| | } + LL| |} + LL| | + LL| 0|async fn foo2(never: Never) { + LL| | match never { } + LL| |} + LL| | + LL| 0|fn make() -> Option { + LL| 0| None + LL| 0|} + LL| | + LL| 1|fn main() { } diff --git a/tests/run-coverage/lazy_boolean.coverage b/tests/run-coverage/lazy_boolean.coverage index bd349df2f..2d927a083 100644 --- a/tests/run-coverage/lazy_boolean.coverage +++ b/tests/run-coverage/lazy_boolean.coverage @@ -1,64 +1,64 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| - 9| 1| let (mut a, mut b, mut c) = (0, 0, 0); - 10| 1| if is_true { - 11| 1| a = 1; - 12| 1| b = 10; - 13| 1| c = 100; - 14| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let (mut a, mut b, mut c) = (0, 0, 0); + LL| 1| if is_true { + LL| 1| a = 1; + LL| 1| b = 10; + LL| 1| c = 100; + LL| 1| } ^0 - 15| | let - 16| 1| somebool - 17| | = - 18| 1| a < b - 19| | || - 20| 0| b < c - 21| | ; - 22| | let - 23| 1| somebool - 24| | = - 25| 1| b < a - 26| | || - 27| 1| b < c - 28| | ; - 29| 1| let somebool = a < b && b < c; - 30| 1| let somebool = b < a && b < c; + LL| | let + LL| 1| somebool + LL| | = + LL| 1| a < b + LL| | || + LL| 0| b < c + LL| | ; + LL| | let + LL| 1| somebool + LL| | = + LL| 1| b < a + LL| | || + LL| 1| b < c + LL| | ; + LL| 1| let somebool = a < b && b < c; + LL| 1| let somebool = b < a && b < c; ^0 - 31| | - 32| | if - 33| 1| ! - 34| 1| is_true - 35| 0| { - 36| 0| a = 2 - 37| 0| ; - 38| 1| } - 39| | - 40| | if - 41| 1| is_true - 42| 1| { - 43| 1| b = 30 - 44| 1| ; - 45| 1| } - 46| | else - 47| 0| { - 48| 0| c = 400 - 49| 0| ; - 50| 0| } - 51| | - 52| 1| if !is_true { - 53| 0| a = 2; - 54| 1| } - 55| | - 56| 1| if is_true { - 57| 1| b = 30; - 58| 1| } else { - 59| 0| c = 400; - 60| 0| } - 61| 1|} + LL| | + LL| | if + LL| 1| ! + LL| 1| is_true + LL| 0| { + LL| 0| a = 2 + LL| 0| ; + LL| 1| } + LL| | + LL| | if + LL| 1| is_true + LL| 1| { + LL| 1| b = 30 + LL| 1| ; + LL| 1| } + LL| | else + LL| 0| { + LL| 0| c = 400 + LL| 0| ; + LL| 0| } + LL| | + LL| 1| if !is_true { + LL| 0| a = 2; + LL| 1| } + LL| | + LL| 1| if is_true { + LL| 1| b = 30; + LL| 1| } else { + LL| 0| c = 400; + LL| 0| } + LL| 1|} diff --git a/tests/run-coverage/loop_break_value.coverage b/tests/run-coverage/loop_break_value.coverage index 022fe4c59..1f0630636 100644 --- a/tests/run-coverage/loop_break_value.coverage +++ b/tests/run-coverage/loop_break_value.coverage @@ -1,14 +1,14 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| let result - 5| 1| = - 6| 1| loop - 7| 1| { - 8| 1| break - 9| 1| 10 - 10| 1| ; - 11| 1| } - 12| 1| ; - 13| 1|} + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| let result + LL| 1| = + LL| 1| loop + LL| 1| { + LL| 1| break + LL| 1| 10 + LL| 1| ; + LL| 1| } + LL| 1| ; + LL| 1|} diff --git a/tests/run-coverage/loops_branches.coverage b/tests/run-coverage/loops_branches.coverage index b7ad79a24..148a22377 100644 --- a/tests/run-coverage/loops_branches.coverage +++ b/tests/run-coverage/loops_branches.coverage @@ -1,68 +1,68 @@ - 1| |#![allow(unused_assignments, unused_variables, while_true)] - 2| | - 3| |// This test confirms that (1) unexecuted infinite loops are handled correctly by the - 4| |// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped. - 5| | - 6| |struct DebugTest; - 7| | - 8| |impl std::fmt::Debug for DebugTest { - 9| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - 10| 1| if true { - 11| 1| if false { - 12| 0| while true { - 13| 0| } - 14| 1| } - 15| 1| write!(f, "cool")?; + LL| |#![allow(unused_assignments, unused_variables, while_true)] + LL| | + LL| |// This test confirms that (1) unexecuted infinite loops are handled correctly by the + LL| |// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped. + LL| | + LL| |struct DebugTest; + LL| | + LL| |impl std::fmt::Debug for DebugTest { + LL| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + LL| 1| if true { + LL| 1| if false { + LL| 0| while true { + LL| 0| } + LL| 1| } + LL| 1| write!(f, "cool")?; ^0 - 16| 0| } else { - 17| 0| } - 18| | - 19| 11| for i in 0..10 { + LL| 0| } else { + LL| 0| } + LL| | + LL| 11| for i in 0..10 { ^10 - 20| 10| if true { - 21| 10| if false { - 22| 0| while true {} - 23| 10| } - 24| 10| write!(f, "cool")?; + LL| 10| if true { + LL| 10| if false { + LL| 0| while true {} + LL| 10| } + LL| 10| write!(f, "cool")?; ^0 - 25| 0| } else { - 26| 0| } - 27| | } - 28| 1| Ok(()) - 29| 1| } - 30| |} - 31| | - 32| |struct DisplayTest; - 33| | - 34| |impl std::fmt::Display for DisplayTest { - 35| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - 36| 1| if false { - 37| 0| } else { - 38| 1| if false { - 39| 0| while true {} - 40| 1| } - 41| 1| write!(f, "cool")?; + LL| 0| } else { + LL| 0| } + LL| | } + LL| 1| Ok(()) + LL| 1| } + LL| |} + LL| | + LL| |struct DisplayTest; + LL| | + LL| |impl std::fmt::Display for DisplayTest { + LL| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + LL| 1| if false { + LL| 0| } else { + LL| 1| if false { + LL| 0| while true {} + LL| 1| } + LL| 1| write!(f, "cool")?; ^0 - 42| | } - 43| 11| for i in 0..10 { + LL| | } + LL| 11| for i in 0..10 { ^10 - 44| 10| if false { - 45| 0| } else { - 46| 10| if false { - 47| 0| while true {} - 48| 10| } - 49| 10| write!(f, "cool")?; + LL| 10| if false { + LL| 0| } else { + LL| 10| if false { + LL| 0| while true {} + LL| 10| } + LL| 10| write!(f, "cool")?; ^0 - 50| | } - 51| | } - 52| 1| Ok(()) - 53| 1| } - 54| |} - 55| | - 56| 1|fn main() { - 57| 1| let debug_test = DebugTest; - 58| 1| println!("{:?}", debug_test); - 59| 1| let display_test = DisplayTest; - 60| 1| println!("{}", display_test); - 61| 1|} + LL| | } + LL| | } + LL| 1| Ok(()) + LL| 1| } + LL| |} + LL| | + LL| 1|fn main() { + LL| 1| let debug_test = DebugTest; + LL| 1| println!("{:?}", debug_test); + LL| 1| let display_test = DisplayTest; + LL| 1| println!("{}", display_test); + LL| 1|} diff --git a/tests/run-coverage/match_or_pattern.coverage b/tests/run-coverage/match_or_pattern.coverage index a0fccb24f..0b5a2c03d 100644 --- a/tests/run-coverage/match_or_pattern.coverage +++ b/tests/run-coverage/match_or_pattern.coverage @@ -1,50 +1,50 @@ - 1| |#![feature(or_patterns)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| - 9| 1| let mut a: u8 = 0; - 10| 1| let mut b: u8 = 0; - 11| 1| if is_true { - 12| 1| a = 2; - 13| 1| b = 0; - 14| 1| } + LL| |#![feature(or_patterns)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut a: u8 = 0; + LL| 1| let mut b: u8 = 0; + LL| 1| if is_true { + LL| 1| a = 2; + LL| 1| b = 0; + LL| 1| } ^0 - 15| 1| match (a, b) { - 16| | // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`. - 17| | // This test confirms a fix for Issue #79569. - 18| 0| (0 | 1, 2 | 3) => {} - 19| 1| _ => {} - 20| | } - 21| 1| if is_true { - 22| 1| a = 0; - 23| 1| b = 0; - 24| 1| } + LL| 1| match (a, b) { + LL| | // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`. + LL| | // This test confirms a fix for Issue #79569. + LL| 0| (0 | 1, 2 | 3) => {} + LL| 1| _ => {} + LL| | } + LL| 1| if is_true { + LL| 1| a = 0; + LL| 1| b = 0; + LL| 1| } ^0 - 25| 1| match (a, b) { - 26| 0| (0 | 1, 2 | 3) => {} - 27| 1| _ => {} - 28| | } - 29| 1| if is_true { - 30| 1| a = 2; - 31| 1| b = 2; - 32| 1| } + LL| 1| match (a, b) { + LL| 0| (0 | 1, 2 | 3) => {} + LL| 1| _ => {} + LL| | } + LL| 1| if is_true { + LL| 1| a = 2; + LL| 1| b = 2; + LL| 1| } ^0 - 33| 1| match (a, b) { - 34| 0| (0 | 1, 2 | 3) => {} - 35| 1| _ => {} - 36| | } - 37| 1| if is_true { - 38| 1| a = 0; - 39| 1| b = 2; - 40| 1| } + LL| 1| match (a, b) { + LL| 0| (0 | 1, 2 | 3) => {} + LL| 1| _ => {} + LL| | } + LL| 1| if is_true { + LL| 1| a = 0; + LL| 1| b = 2; + LL| 1| } ^0 - 41| 1| match (a, b) { - 42| 1| (0 | 1, 2 | 3) => {} - 43| 0| _ => {} - 44| | } - 45| 1|} + LL| 1| match (a, b) { + LL| 1| (0 | 1, 2 | 3) => {} + LL| 0| _ => {} + LL| | } + LL| 1|} diff --git a/tests/run-coverage/nested_loops.coverage b/tests/run-coverage/nested_loops.coverage index 0dbd6bcf3..143d0d26a 100644 --- a/tests/run-coverage/nested_loops.coverage +++ b/tests/run-coverage/nested_loops.coverage @@ -1,26 +1,26 @@ - 1| 1|fn main() { - 2| 1| let is_true = std::env::args().len() == 1; - 3| 1| let mut countdown = 10; - 4| | - 5| 1| 'outer: while countdown > 0 { - 6| 1| let mut a = 100; - 7| 1| let mut b = 100; - 8| 3| for _ in 0..50 { - 9| 3| if a < 30 { - 10| 0| break; - 11| 3| } - 12| 3| a -= 5; - 13| 3| b -= 5; - 14| 3| if b < 90 { - 15| 1| a -= 10; - 16| 1| if is_true { - 17| 1| break 'outer; - 18| 0| } else { - 19| 0| a -= 2; - 20| 0| } - 21| 2| } - 22| | } - 23| 0| countdown -= 1; - 24| | } - 25| 1|} + LL| 1|fn main() { + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let mut countdown = 10; + LL| | + LL| 1| 'outer: while countdown > 0 { + LL| 1| let mut a = 100; + LL| 1| let mut b = 100; + LL| 3| for _ in 0..50 { + LL| 3| if a < 30 { + LL| 0| break; + LL| 3| } + LL| 3| a -= 5; + LL| 3| b -= 5; + LL| 3| if b < 90 { + LL| 1| a -= 10; + LL| 1| if is_true { + LL| 1| break 'outer; + LL| 0| } else { + LL| 0| a -= 2; + LL| 0| } + LL| 2| } + LL| | } + LL| 0| countdown -= 1; + LL| | } + LL| 1|} diff --git a/tests/run-coverage/no_cov_crate.coverage b/tests/run-coverage/no_cov_crate.coverage index 83a920413..c34dbde88 100644 --- a/tests/run-coverage/no_cov_crate.coverage +++ b/tests/run-coverage/no_cov_crate.coverage @@ -1,87 +1,87 @@ - 1| |// Enables `no_coverage` on the entire crate - 2| |#![feature(no_coverage)] - 3| | - 4| |#[no_coverage] - 5| |fn do_not_add_coverage_1() { - 6| | println!("called but not covered"); - 7| |} - 8| | - 9| |fn do_not_add_coverage_2() { - 10| | #![no_coverage] - 11| | println!("called but not covered"); - 12| |} - 13| | - 14| |#[no_coverage] - 15| |fn do_not_add_coverage_not_called() { - 16| | println!("not called and not covered"); - 17| |} - 18| | - 19| 1|fn add_coverage_1() { - 20| 1| println!("called and covered"); - 21| 1|} - 22| | - 23| 1|fn add_coverage_2() { - 24| 1| println!("called and covered"); - 25| 1|} - 26| | - 27| 0|fn add_coverage_not_called() { - 28| 0| println!("not called but covered"); - 29| 0|} - 30| | - 31| |// FIXME: These test-cases illustrate confusing results of nested functions. - 32| |// See https://github.com/rust-lang/rust/issues/93319 - 33| |mod nested_fns { - 34| | #[no_coverage] - 35| | pub fn outer_not_covered(is_true: bool) { - 36| 1| fn inner(is_true: bool) { - 37| 1| if is_true { - 38| 1| println!("called and covered"); - 39| 1| } else { - 40| 0| println!("absolutely not covered"); - 41| 0| } - 42| 1| } - 43| | println!("called but not covered"); - 44| | inner(is_true); - 45| | } - 46| | - 47| 1| pub fn outer(is_true: bool) { - 48| 1| println!("called and covered"); - 49| 1| inner_not_covered(is_true); - 50| 1| - 51| 1| #[no_coverage] - 52| 1| fn inner_not_covered(is_true: bool) { - 53| 1| if is_true { - 54| 1| println!("called but not covered"); - 55| 1| } else { - 56| 1| println!("absolutely not covered"); - 57| 1| } - 58| 1| } - 59| 1| } - 60| | - 61| 1| pub fn outer_both_covered(is_true: bool) { - 62| 1| println!("called and covered"); - 63| 1| inner(is_true); - 64| 1| - 65| 1| fn inner(is_true: bool) { - 66| 1| if is_true { - 67| 1| println!("called and covered"); - 68| 1| } else { - 69| 0| println!("absolutely not covered"); - 70| 0| } - 71| 1| } - 72| 1| } - 73| |} - 74| | - 75| 1|fn main() { - 76| 1| let is_true = std::env::args().len() == 1; - 77| 1| - 78| 1| do_not_add_coverage_1(); - 79| 1| do_not_add_coverage_2(); - 80| 1| add_coverage_1(); - 81| 1| add_coverage_2(); - 82| 1| - 83| 1| nested_fns::outer_not_covered(is_true); - 84| 1| nested_fns::outer(is_true); - 85| 1| nested_fns::outer_both_covered(is_true); - 86| 1|} + LL| |// Enables `no_coverage` on the entire crate + LL| |#![feature(no_coverage)] + LL| | + LL| |#[no_coverage] + LL| |fn do_not_add_coverage_1() { + LL| | println!("called but not covered"); + LL| |} + LL| | + LL| |fn do_not_add_coverage_2() { + LL| | #![no_coverage] + LL| | println!("called but not covered"); + LL| |} + LL| | + LL| |#[no_coverage] + LL| |fn do_not_add_coverage_not_called() { + LL| | println!("not called and not covered"); + LL| |} + LL| | + LL| 1|fn add_coverage_1() { + LL| 1| println!("called and covered"); + LL| 1|} + LL| | + LL| 1|fn add_coverage_2() { + LL| 1| println!("called and covered"); + LL| 1|} + LL| | + LL| 0|fn add_coverage_not_called() { + LL| 0| println!("not called but covered"); + LL| 0|} + LL| | + LL| |// FIXME: These test-cases illustrate confusing results of nested functions. + LL| |// See https://github.com/rust-lang/rust/issues/93319 + LL| |mod nested_fns { + LL| | #[no_coverage] + LL| | pub fn outer_not_covered(is_true: bool) { + LL| 1| fn inner(is_true: bool) { + LL| 1| if is_true { + LL| 1| println!("called and covered"); + LL| 1| } else { + LL| 0| println!("absolutely not covered"); + LL| 0| } + LL| 1| } + LL| | println!("called but not covered"); + LL| | inner(is_true); + LL| | } + LL| | + LL| 1| pub fn outer(is_true: bool) { + LL| 1| println!("called and covered"); + LL| 1| inner_not_covered(is_true); + LL| 1| + LL| 1| #[no_coverage] + LL| 1| fn inner_not_covered(is_true: bool) { + LL| 1| if is_true { + LL| 1| println!("called but not covered"); + LL| 1| } else { + LL| 1| println!("absolutely not covered"); + LL| 1| } + LL| 1| } + LL| 1| } + LL| | + LL| 1| pub fn outer_both_covered(is_true: bool) { + LL| 1| println!("called and covered"); + LL| 1| inner(is_true); + LL| 1| + LL| 1| fn inner(is_true: bool) { + LL| 1| if is_true { + LL| 1| println!("called and covered"); + LL| 1| } else { + LL| 0| println!("absolutely not covered"); + LL| 0| } + LL| 1| } + LL| 1| } + LL| |} + LL| | + LL| 1|fn main() { + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| do_not_add_coverage_1(); + LL| 1| do_not_add_coverage_2(); + LL| 1| add_coverage_1(); + LL| 1| add_coverage_2(); + LL| 1| + LL| 1| nested_fns::outer_not_covered(is_true); + LL| 1| nested_fns::outer(is_true); + LL| 1| nested_fns::outer_both_covered(is_true); + LL| 1|} diff --git a/tests/run-coverage/overflow.coverage b/tests/run-coverage/overflow.coverage index 950437591..2d60316e2 100644 --- a/tests/run-coverage/overflow.coverage +++ b/tests/run-coverage/overflow.coverage @@ -1,64 +1,64 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 101 - 3| | - 4| 4|fn might_overflow(to_add: u32) -> u32 { - 5| 4| if to_add > 5 { - 6| 1| println!("this will probably overflow"); - 7| 3| } - 8| 4| let add_to = u32::MAX - 5; - 9| 4| println!("does {} + {} overflow?", add_to, to_add); - 10| 4| let result = to_add + add_to; - 11| 4| println!("continuing after overflow check"); - 12| 4| result - 13| 4|} - 14| | - 15| 1|fn main() -> Result<(),u8> { - 16| 1| let mut countdown = 10; - 17| 11| while countdown > 0 { - 18| 11| if countdown == 1 { - 19| 1| let result = might_overflow(10); - 20| 1| println!("Result: {}", result); - 21| 10| } else if countdown < 5 { - 22| 3| let result = might_overflow(1); - 23| 3| println!("Result: {}", result); - 24| 6| } - 25| 10| countdown -= 1; - 26| | } - 27| 0| Ok(()) - 28| 0|} - 29| | - 30| |// Notes: - 31| |// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`, - 32| |// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`. - 33| |// 2. This test confirms the coverage generated when a program passes or fails a - 34| |// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case). - 35| |// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`, - 36| |// compiler-generated assertion failures are assumed to be a symptom of a program bug, not - 37| |// expected behavior. To simplify the coverage graphs and keep instrumented programs as - 38| |// small and fast as possible, `Assert` terminators are assumed to always succeed, and - 39| |// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not - 40| |// get its own coverage counter. - 41| |// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive. - 42| |// In this test, the final count for the statements after the `if` block in `might_overflow()` - 43| |// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending - 44| |// on the MIR graph and the structure of the code, this count could have been 3 (which might - 45| |// have been valid for the overflowed add `+`, but should have been 4 for the lines before - 46| |// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented - 47| |// via StatementKind::Counter at the end of the block, but (as in the case in this test), - 48| |// a CounterKind::Expression is always evaluated. In this case, the expression was based on - 49| |// a `Counter` incremented as part of the evaluation of the `if` expression, which was - 50| |// executed, and counted, 4 times, before reaching the overflow add. - 51| | - 52| |// If the program did not overflow, the coverage for `might_overflow()` would look like this: - 53| |// - 54| |// 4| |fn might_overflow(to_add: u32) -> u32 { - 55| |// 5| 4| if to_add > 5 { - 56| |// 6| 0| println!("this will probably overflow"); - 57| |// 7| 4| } - 58| |// 8| 4| let add_to = u32::MAX - 5; - 59| |// 9| 4| println!("does {} + {} overflow?", add_to, to_add); - 60| |// 10| 4| let result = to_add + add_to; - 61| |// 11| 4| println!("continuing after overflow check"); - 62| |// 12| 4| result - 63| |// 13| 4|} + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 101 + LL| | + LL| 4|fn might_overflow(to_add: u32) -> u32 { + LL| 4| if to_add > 5 { + LL| 1| println!("this will probably overflow"); + LL| 3| } + LL| 4| let add_to = u32::MAX - 5; + LL| 4| println!("does {} + {} overflow?", add_to, to_add); + LL| 4| let result = to_add + add_to; + LL| 4| println!("continuing after overflow check"); + LL| 4| result + LL| 4|} + LL| | + LL| 1|fn main() -> Result<(),u8> { + LL| 1| let mut countdown = 10; + LL| 11| while countdown > 0 { + LL| 11| if countdown == 1 { + LL| 1| let result = might_overflow(10); + LL| 1| println!("Result: {}", result); + LL| 10| } else if countdown < 5 { + LL| 3| let result = might_overflow(1); + LL| 3| println!("Result: {}", result); + LL| 6| } + LL| 10| countdown -= 1; + LL| | } + LL| 0| Ok(()) + LL| 0|} + LL| | + LL| |// Notes: + LL| |// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`, + LL| |// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`. + LL| |// 2. This test confirms the coverage generated when a program passes or fails a + LL| |// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case). + LL| |// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`, + LL| |// compiler-generated assertion failures are assumed to be a symptom of a program bug, not + LL| |// expected behavior. To simplify the coverage graphs and keep instrumented programs as + LL| |// small and fast as possible, `Assert` terminators are assumed to always succeed, and + LL| |// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not + LL| |// get its own coverage counter. + LL| |// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive. + LL| |// In this test, the final count for the statements after the `if` block in `might_overflow()` + LL| |// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending + LL| |// on the MIR graph and the structure of the code, this count could have been 3 (which might + LL| |// have been valid for the overflowed add `+`, but should have been 4 for the lines before + LL| |// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented + LL| |// via StatementKind::Counter at the end of the block, but (as in the case in this test), + LL| |// a CounterKind::Expression is always evaluated. In this case, the expression was based on + LL| |// a `Counter` incremented as part of the evaluation of the `if` expression, which was + LL| |// executed, and counted, 4 times, before reaching the overflow add. + LL| | + LL| |// If the program did not overflow, the coverage for `might_overflow()` would look like this: + LL| |// + LL| |// 4| |fn might_overflow(to_add: u32) -> u32 { + LL| |// 5| 4| if to_add > 5 { + LL| |// 6| 0| println!("this will probably overflow"); + LL| |// 7| 4| } + LL| |// 8| 4| let add_to = u32::MAX - 5; + LL| |// 9| 4| println!("does {} + {} overflow?", add_to, to_add); + LL| |// 10| 4| let result = to_add + add_to; + LL| |// 11| 4| println!("continuing after overflow check"); + LL| |// 12| 4| result + LL| |// 13| 4|} diff --git a/tests/run-coverage/panic_unwind.coverage b/tests/run-coverage/panic_unwind.coverage index 58b9ba448..2b0777ef2 100644 --- a/tests/run-coverage/panic_unwind.coverage +++ b/tests/run-coverage/panic_unwind.coverage @@ -1,32 +1,32 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 101 - 3| | - 4| 4|fn might_panic(should_panic: bool) { - 5| 4| if should_panic { - 6| 1| println!("panicking..."); - 7| 1| panic!("panics"); - 8| 3| } else { - 9| 3| println!("Don't Panic"); - 10| 3| } - 11| 3|} - 12| | - 13| 1|fn main() -> Result<(), u8> { - 14| 1| let mut countdown = 10; - 15| 11| while countdown > 0 { - 16| 11| if countdown == 1 { - 17| 1| might_panic(true); - 18| 10| } else if countdown < 5 { - 19| 3| might_panic(false); - 20| 6| } - 21| 10| countdown -= 1; - 22| | } - 23| 0| Ok(()) - 24| 0|} - 25| | - 26| |// Notes: - 27| |// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and - 28| |// `try_error_result.rs`. - 29| |// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the - 30| |// normal program exit cleanup, including writing out the current values of the coverage - 31| |// counters. + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 101 + LL| | + LL| 4|fn might_panic(should_panic: bool) { + LL| 4| if should_panic { + LL| 1| println!("panicking..."); + LL| 1| panic!("panics"); + LL| 3| } else { + LL| 3| println!("Don't Panic"); + LL| 3| } + LL| 3|} + LL| | + LL| 1|fn main() -> Result<(), u8> { + LL| 1| let mut countdown = 10; + LL| 11| while countdown > 0 { + LL| 11| if countdown == 1 { + LL| 1| might_panic(true); + LL| 10| } else if countdown < 5 { + LL| 3| might_panic(false); + LL| 6| } + LL| 10| countdown -= 1; + LL| | } + LL| 0| Ok(()) + LL| 0|} + LL| | + LL| |// Notes: + LL| |// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and + LL| |// `try_error_result.rs`. + LL| |// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the + LL| |// normal program exit cleanup, including writing out the current values of the coverage + LL| |// counters. diff --git a/tests/run-coverage/partial_eq.coverage b/tests/run-coverage/partial_eq.coverage index a77175af6..c6d9ad6cf 100644 --- a/tests/run-coverage/partial_eq.coverage +++ b/tests/run-coverage/partial_eq.coverage @@ -1,48 +1,48 @@ - 1| |// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the - 2| |// structure of this test. - 3| | - 4| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] + LL| |// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the + LL| |// structure of this test. + LL| | + LL| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] ^0 ^0 ^0 ^1 ^1 ^0^0 - 5| |pub struct Version { - 6| | major: usize, - 7| | minor: usize, - 8| | patch: usize, - 9| |} - 10| | - 11| |impl Version { - 12| 2| pub fn new(major: usize, minor: usize, patch: usize) -> Self { - 13| 2| Self { - 14| 2| major, - 15| 2| minor, - 16| 2| patch, - 17| 2| } - 18| 2| } - 19| |} - 20| | - 21| 1|fn main() { - 22| 1| let version_3_2_1 = Version::new(3, 2, 1); - 23| 1| let version_3_3_0 = Version::new(3, 3, 0); - 24| 1| - 25| 1| println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0); - 26| 1|} - 27| | - 28| |/* - 29| | - 30| |This test verifies a bug was fixed that otherwise generated this error: - 31| | - 32| |thread 'rustc' panicked at 'No counters provided the source_hash for function: - 33| | Instance { - 34| | def: Item(WithOptConstParam { - 35| | did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp), - 36| | const_param_did: None - 37| | }), - 38| | substs: [] - 39| | }' - 40| |The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage - 41| |without a code region associated with any `Counter`. Code regions were associated with at least - 42| |one expression, which is allowed, but the `function_source_hash` was only passed to the codegen - 43| |(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the - 44| |`function_source_hash` without a code region, if necessary. - 45| | - 46| |*/ + LL| |pub struct Version { + LL| | major: usize, + LL| | minor: usize, + LL| | patch: usize, + LL| |} + LL| | + LL| |impl Version { + LL| 2| pub fn new(major: usize, minor: usize, patch: usize) -> Self { + LL| 2| Self { + LL| 2| major, + LL| 2| minor, + LL| 2| patch, + LL| 2| } + LL| 2| } + LL| |} + LL| | + LL| 1|fn main() { + LL| 1| let version_3_2_1 = Version::new(3, 2, 1); + LL| 1| let version_3_3_0 = Version::new(3, 3, 0); + LL| 1| + LL| 1| println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0); + LL| 1|} + LL| | + LL| |/* + LL| | + LL| |This test verifies a bug was fixed that otherwise generated this error: + LL| | + LL| |thread 'rustc' panicked at 'No counters provided the source_hash for function: + LL| | Instance { + LL| | def: Item(WithOptConstParam { + LL| | did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp), + LL| | const_param_did: None + LL| | }), + LL| | args: [] + LL| | }' + LL| |The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage + LL| |without a code region associated with any `Counter`. Code regions were associated with at least + LL| |one expression, which is allowed, but the `function_source_hash` was only passed to the codegen + LL| |(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the + LL| |`function_source_hash` without a code region, if necessary. + LL| | + LL| |*/ diff --git a/tests/run-coverage/partial_eq.rs b/tests/run-coverage/partial_eq.rs index 4ceaba9b1..dd8b42c18 100644 --- a/tests/run-coverage/partial_eq.rs +++ b/tests/run-coverage/partial_eq.rs @@ -35,7 +35,7 @@ thread 'rustc' panicked at 'No counters provided the source_hash for function: did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp), const_param_did: None }), - substs: [] + args: [] }' The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage without a code region associated with any `Counter`. Code regions were associated with at least diff --git a/tests/run-coverage/simple_loop.coverage b/tests/run-coverage/simple_loop.coverage index feb83bad6..691c6cd1e 100644 --- a/tests/run-coverage/simple_loop.coverage +++ b/tests/run-coverage/simple_loop.coverage @@ -1,37 +1,37 @@ - 1| |#![allow(unused_assignments)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| - 9| 1| let mut countdown = 0; - 10| 1| - 11| 1| if - 12| 1| is_true - 13| 1| { - 14| 1| countdown - 15| 1| = - 16| 1| 10 - 17| 1| ; - 18| 1| } + LL| |#![allow(unused_assignments)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut countdown = 0; + LL| 1| + LL| 1| if + LL| 1| is_true + LL| 1| { + LL| 1| countdown + LL| 1| = + LL| 1| 10 + LL| 1| ; + LL| 1| } ^0 - 19| | - 20| | loop - 21| | { - 22| | if - 23| 11| countdown - 24| 11| == - 25| 11| 0 - 26| | { - 27| 1| break - 28| | ; - 29| 10| } - 30| 10| countdown - 31| 10| -= - 32| 10| 1 - 33| | ; - 34| | } - 35| 1|} + LL| | + LL| | loop + LL| | { + LL| | if + LL| 11| countdown + LL| 11| == + LL| 11| 0 + LL| | { + LL| 1| break + LL| | ; + LL| 10| } + LL| 10| countdown + LL| 10| -= + LL| 10| 1 + LL| | ; + LL| | } + LL| 1|} diff --git a/tests/run-coverage/simple_match.coverage b/tests/run-coverage/simple_match.coverage index b92982131..7f5dd3bb6 100644 --- a/tests/run-coverage/simple_match.coverage +++ b/tests/run-coverage/simple_match.coverage @@ -1,45 +1,45 @@ - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| 1|fn main() { - 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 6| 1| // dependent conditions. - 7| 1| let is_true = std::env::args().len() == 1; - 8| 1| - 9| 1| let mut countdown = 1; - 10| 1| if is_true { - 11| 1| countdown = 0; - 12| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| 1|fn main() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| + LL| 1| let mut countdown = 1; + LL| 1| if is_true { + LL| 1| countdown = 0; + LL| 1| } ^0 - 13| | - 14| | for - 15| | _ - 16| | in - 17| 3| 0..2 - 18| | { - 19| | let z - 20| | ; - 21| | match - 22| 2| countdown - 23| | { - 24| 1| x - 25| | if - 26| 2| x - 27| 2| < - 28| 2| 1 - 29| | => - 30| 1| { - 31| 1| z = countdown - 32| 1| ; - 33| 1| let y = countdown - 34| 1| ; - 35| 1| countdown = 10 - 36| 1| ; - 37| 1| } - 38| | _ - 39| | => - 40| 1| {} - 41| | } - 42| | } - 43| 1|} + LL| | + LL| | for + LL| | _ + LL| | in + LL| 3| 0..2 + LL| | { + LL| | let z + LL| | ; + LL| | match + LL| 2| countdown + LL| | { + LL| 1| x + LL| | if + LL| 2| x + LL| 2| < + LL| 2| 1 + LL| | => + LL| 1| { + LL| 1| z = countdown + LL| 1| ; + LL| 1| let y = countdown + LL| 1| ; + LL| 1| countdown = 10 + LL| 1| ; + LL| 1| } + LL| | _ + LL| | => + LL| 1| {} + LL| | } + LL| | } + LL| 1|} diff --git a/tests/run-coverage/sort_groups.coverage b/tests/run-coverage/sort_groups.coverage index 81468cb35..8733bf48a 100644 --- a/tests/run-coverage/sort_groups.coverage +++ b/tests/run-coverage/sort_groups.coverage @@ -1,49 +1,49 @@ - 1| |// compile-flags: --edition=2021 - 2| | - 3| |// Demonstrate that `sort_subviews.py` can sort instantiation groups into a - 4| |// predictable order, while preserving their heterogeneous contents. - 5| | - 6| 1|fn main() { - 7| 1| let cond = std::env::args().len() > 1; - 8| 1| generic_fn::<()>(cond); - 9| 1| generic_fn::<&'static str>(!cond); - 10| 1| if false { - 11| 0| generic_fn::(cond); - 12| 1| } - 13| 1| generic_fn::(cond); - 14| 1| other_fn(); - 15| 1|} - 16| | - 17| 3|fn generic_fn(cond: bool) { - 18| 3| if cond { - 19| 1| println!("{}", std::any::type_name::()); - 20| 2| } - 21| 3|} + LL| |// compile-flags: --edition=2021 + LL| | + LL| |// Demonstrate that `sort_subviews.py` can sort instantiation groups into a + LL| |// predictable order, while preserving their heterogeneous contents. + LL| | + LL| 1|fn main() { + LL| 1| let cond = std::env::args().len() > 1; + LL| 1| generic_fn::<()>(cond); + LL| 1| generic_fn::<&'static str>(!cond); + LL| 1| if false { + LL| 0| generic_fn::(cond); + LL| 1| } + LL| 1| generic_fn::(cond); + LL| 1| other_fn(); + LL| 1|} + LL| | + LL| 3|fn generic_fn(cond: bool) { + LL| 3| if cond { + LL| 1| println!("{}", std::any::type_name::()); + LL| 2| } + LL| 3|} ------------------ | Unexecuted instantiation: sort_groups::generic_fn:: ------------------ | sort_groups::generic_fn::<&str>: - | 17| 1|fn generic_fn(cond: bool) { - | 18| 1| if cond { - | 19| 1| println!("{}", std::any::type_name::()); - | 20| 1| } + | LL| 1|fn generic_fn(cond: bool) { + | LL| 1| if cond { + | LL| 1| println!("{}", std::any::type_name::()); + | LL| 1| } | ^0 - | 21| 1|} + | LL| 1|} ------------------ | sort_groups::generic_fn::<()>: - | 17| 1|fn generic_fn(cond: bool) { - | 18| 1| if cond { - | 19| 0| println!("{}", std::any::type_name::()); - | 20| 1| } - | 21| 1|} + | LL| 1|fn generic_fn(cond: bool) { + | LL| 1| if cond { + | LL| 0| println!("{}", std::any::type_name::()); + | LL| 1| } + | LL| 1|} ------------------ | sort_groups::generic_fn::: - | 17| 1|fn generic_fn(cond: bool) { - | 18| 1| if cond { - | 19| 0| println!("{}", std::any::type_name::()); - | 20| 1| } - | 21| 1|} + | LL| 1|fn generic_fn(cond: bool) { + | LL| 1| if cond { + | LL| 0| println!("{}", std::any::type_name::()); + | LL| 1| } + | LL| 1|} ------------------ - 22| | - 23| 1|fn other_fn() {} + LL| | + LL| 1|fn other_fn() {} diff --git a/tests/run-coverage/test_harness.coverage b/tests/run-coverage/test_harness.coverage index 93bd1cfcb..ff6009f6f 100644 --- a/tests/run-coverage/test_harness.coverage +++ b/tests/run-coverage/test_harness.coverage @@ -1,11 +1,11 @@ - 1| |// Verify that the entry point injected by the test harness doesn't cause - 2| |// weird artifacts in the coverage report (e.g. issue #10749). - 3| | - 4| |// compile-flags: --test - 5| | - 6| |#[allow(dead_code)] - 7| 0|fn unused() {} - 8| | - 9| 1|#[test] - 10| 1|fn my_test() {} + LL| |// Verify that the entry point injected by the test harness doesn't cause + LL| |// weird artifacts in the coverage report (e.g. issue #10749). + LL| | + LL| |// compile-flags: --test + LL| | + LL| |#[allow(dead_code)] + LL| 0|fn unused() {} + LL| | + LL| 1|#[test] + LL| 1|fn my_test() {} diff --git a/tests/run-coverage/tight_inf_loop.coverage b/tests/run-coverage/tight_inf_loop.coverage index 2d4c57f45..c15c76b3a 100644 --- a/tests/run-coverage/tight_inf_loop.coverage +++ b/tests/run-coverage/tight_inf_loop.coverage @@ -1,6 +1,6 @@ - 1| 1|fn main() { - 2| 1| if false { - 3| 0| loop {} - 4| 1| } - 5| 1|} + LL| 1|fn main() { + LL| 1| if false { + LL| 0| loop {} + LL| 1| } + LL| 1|} diff --git a/tests/run-coverage/try_error_result.coverage b/tests/run-coverage/try_error_result.coverage index efe573a56..fcdb7437d 100644 --- a/tests/run-coverage/try_error_result.coverage +++ b/tests/run-coverage/try_error_result.coverage @@ -1,125 +1,125 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 1 - 3| | - 4| 6|fn call(return_error: bool) -> Result<(),()> { - 5| 6| if return_error { - 6| 1| Err(()) - 7| | } else { - 8| 5| Ok(()) - 9| | } - 10| 6|} - 11| | - 12| 1|fn test1() -> Result<(),()> { - 13| 1| let mut - 14| 1| countdown = 10 - 15| | ; - 16| | for - 17| | _ - 18| | in - 19| 6| 0..10 - 20| | { - 21| 6| countdown - 22| 6| -= 1 - 23| 6| ; - 24| 6| if - 25| 6| countdown < 5 - 26| | { - 27| 1| call(/*return_error=*/ true)?; - 28| 0| call(/*return_error=*/ false)?; - 29| | } - 30| | else - 31| | { - 32| 5| call(/*return_error=*/ false)?; + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 1 + LL| | + LL| 6|fn call(return_error: bool) -> Result<(),()> { + LL| 6| if return_error { + LL| 1| Err(()) + LL| | } else { + LL| 5| Ok(()) + LL| | } + LL| 6|} + LL| | + LL| 1|fn test1() -> Result<(),()> { + LL| 1| let mut + LL| 1| countdown = 10 + LL| | ; + LL| | for + LL| | _ + LL| | in + LL| 6| 0..10 + LL| | { + LL| 6| countdown + LL| 6| -= 1 + LL| 6| ; + LL| 6| if + LL| 6| countdown < 5 + LL| | { + LL| 1| call(/*return_error=*/ true)?; + LL| 0| call(/*return_error=*/ false)?; + LL| | } + LL| | else + LL| | { + LL| 5| call(/*return_error=*/ false)?; ^0 - 33| | } - 34| | } - 35| 0| Ok(()) - 36| 1|} - 37| | - 38| |struct Thing1; - 39| |impl Thing1 { - 40| 18| fn get_thing_2(&self, return_error: bool) -> Result { - 41| 18| if return_error { - 42| 1| Err(()) - 43| | } else { - 44| 17| Ok(Thing2{}) - 45| | } - 46| 18| } - 47| |} - 48| | - 49| |struct Thing2; - 50| |impl Thing2 { - 51| 17| fn call(&self, return_error: bool) -> Result { - 52| 17| if return_error { - 53| 2| Err(()) - 54| | } else { - 55| 15| Ok(57) - 56| | } - 57| 17| } - 58| |} - 59| | - 60| 1|fn test2() -> Result<(),()> { - 61| 1| let thing1 = Thing1{}; - 62| 1| let mut - 63| 1| countdown = 10 - 64| | ; - 65| | for - 66| | _ - 67| | in - 68| 6| 0..10 - 69| | { - 70| 6| countdown - 71| 6| -= 1 - 72| 6| ; - 73| 6| if - 74| 6| countdown < 5 - 75| | { - 76| 1| thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail"); + LL| | } + LL| | } + LL| 0| Ok(()) + LL| 1|} + LL| | + LL| |struct Thing1; + LL| |impl Thing1 { + LL| 18| fn get_thing_2(&self, return_error: bool) -> Result { + LL| 18| if return_error { + LL| 1| Err(()) + LL| | } else { + LL| 17| Ok(Thing2{}) + LL| | } + LL| 18| } + LL| |} + LL| | + LL| |struct Thing2; + LL| |impl Thing2 { + LL| 17| fn call(&self, return_error: bool) -> Result { + LL| 17| if return_error { + LL| 2| Err(()) + LL| | } else { + LL| 15| Ok(57) + LL| | } + LL| 17| } + LL| |} + LL| | + LL| 1|fn test2() -> Result<(),()> { + LL| 1| let thing1 = Thing1{}; + LL| 1| let mut + LL| 1| countdown = 10 + LL| | ; + LL| | for + LL| | _ + LL| | in + LL| 6| 0..10 + LL| | { + LL| 6| countdown + LL| 6| -= 1 + LL| 6| ; + LL| 6| if + LL| 6| countdown < 5 + LL| | { + LL| 1| thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail"); ^0 - 77| 1| thing1 - 78| 1| . - 79| 1| get_thing_2(/*return_error=*/ false) - 80| 0| ? - 81| | . - 82| 1| call(/*return_error=*/ true) - 83| 1| . - 84| 1| expect_err( - 85| 1| "call should fail" - 86| 1| ); - 87| 1| let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?; + LL| 1| thing1 + LL| 1| . + LL| 1| get_thing_2(/*return_error=*/ false) + LL| 0| ? + LL| | . + LL| 1| call(/*return_error=*/ true) + LL| 1| . + LL| 1| expect_err( + LL| 1| "call should fail" + LL| 1| ); + LL| 1| let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?; ^0 ^0 ^0 - 88| 0| assert_eq!(val, 57); - 89| 0| let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?; - 90| 0| assert_eq!(val, 57); - 91| | } - 92| | else - 93| | { - 94| 5| let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?; + LL| 0| assert_eq!(val, 57); + LL| 0| let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?; + LL| 0| assert_eq!(val, 57); + LL| | } + LL| | else + LL| | { + LL| 5| let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?; ^0 ^0 - 95| 5| assert_eq!(val, 57); - 96| 5| let val = thing1 - 97| 5| .get_thing_2(/*return_error=*/ false)? + LL| 5| assert_eq!(val, 57); + LL| 5| let val = thing1 + LL| 5| .get_thing_2(/*return_error=*/ false)? ^0 - 98| 5| .call(/*return_error=*/ false)?; + LL| 5| .call(/*return_error=*/ false)?; ^0 - 99| 5| assert_eq!(val, 57); - 100| 5| let val = thing1 - 101| 5| .get_thing_2(/*return_error=*/ false) - 102| 0| ? - 103| 5| .call(/*return_error=*/ false) - 104| 0| ? - 105| | ; - 106| 5| assert_eq!(val, 57); - 107| | } - 108| | } - 109| 0| Ok(()) - 110| 1|} - 111| | - 112| 1|fn main() -> Result<(),()> { - 113| 1| test1().expect_err("test1 should fail"); - 114| 1| test2() - 115| 1| ? - 116| | ; - 117| 0| Ok(()) - 118| 1|} + LL| 5| assert_eq!(val, 57); + LL| 5| let val = thing1 + LL| 5| .get_thing_2(/*return_error=*/ false) + LL| 0| ? + LL| 5| .call(/*return_error=*/ false) + LL| 0| ? + LL| | ; + LL| 5| assert_eq!(val, 57); + LL| | } + LL| | } + LL| 0| Ok(()) + LL| 1|} + LL| | + LL| 1|fn main() -> Result<(),()> { + LL| 1| test1().expect_err("test1 should fail"); + LL| 1| test2() + LL| 1| ? + LL| | ; + LL| 0| Ok(()) + LL| 1|} diff --git a/tests/run-coverage/unused.coverage b/tests/run-coverage/unused.coverage index 15fcf21c0..ba25e34bf 100644 --- a/tests/run-coverage/unused.coverage +++ b/tests/run-coverage/unused.coverage @@ -1,62 +1,62 @@ - 1| 2|fn foo(x: T) { - 2| 2| let mut i = 0; - 3| 22| while i < 10 { - 4| 20| i != 0 || i != 0; + LL| 2|fn foo(x: T) { + LL| 2| let mut i = 0; + LL| 22| while i < 10 { + LL| 20| i != 0 || i != 0; ^2 - 5| 20| i += 1; - 6| | } - 7| 2|} + LL| 20| i += 1; + LL| | } + LL| 2|} ------------------ | unused::foo::: - | 1| 1|fn foo(x: T) { - | 2| 1| let mut i = 0; - | 3| 11| while i < 10 { - | 4| 10| i != 0 || i != 0; + | LL| 1|fn foo(x: T) { + | LL| 1| let mut i = 0; + | LL| 11| while i < 10 { + | LL| 10| i != 0 || i != 0; | ^1 - | 5| 10| i += 1; - | 6| | } - | 7| 1|} + | LL| 10| i += 1; + | LL| | } + | LL| 1|} ------------------ | unused::foo::: - | 1| 1|fn foo(x: T) { - | 2| 1| let mut i = 0; - | 3| 11| while i < 10 { - | 4| 10| i != 0 || i != 0; + | LL| 1|fn foo(x: T) { + | LL| 1| let mut i = 0; + | LL| 11| while i < 10 { + | LL| 10| i != 0 || i != 0; | ^1 - | 5| 10| i += 1; - | 6| | } - | 7| 1|} + | LL| 10| i += 1; + | LL| | } + | LL| 1|} ------------------ - 8| | - 9| 0|fn unused_template_func(x: T) { - 10| 0| let mut i = 0; - 11| 0| while i < 10 { - 12| 0| i != 0 || i != 0; - 13| 0| i += 1; - 14| | } - 15| 0|} - 16| | - 17| 0|fn unused_func(mut a: u32) { - 18| 0| if a != 0 { - 19| 0| a += 1; - 20| 0| } - 21| 0|} - 22| | - 23| 0|fn unused_func2(mut a: u32) { - 24| 0| if a != 0 { - 25| 0| a += 1; - 26| 0| } - 27| 0|} - 28| | - 29| 0|fn unused_func3(mut a: u32) { - 30| 0| if a != 0 { - 31| 0| a += 1; - 32| 0| } - 33| 0|} - 34| | - 35| 1|fn main() -> Result<(), u8> { - 36| 1| foo::(0); - 37| 1| foo::(0.0); - 38| 1| Ok(()) - 39| 1|} + LL| | + LL| 0|fn unused_template_func(x: T) { + LL| 0| let mut i = 0; + LL| 0| while i < 10 { + LL| 0| i != 0 || i != 0; + LL| 0| i += 1; + LL| | } + LL| 0|} + LL| | + LL| 0|fn unused_func(mut a: u32) { + LL| 0| if a != 0 { + LL| 0| a += 1; + LL| 0| } + LL| 0|} + LL| | + LL| 0|fn unused_func2(mut a: u32) { + LL| 0| if a != 0 { + LL| 0| a += 1; + LL| 0| } + LL| 0|} + LL| | + LL| 0|fn unused_func3(mut a: u32) { + LL| 0| if a != 0 { + LL| 0| a += 1; + LL| 0| } + LL| 0|} + LL| | + LL| 1|fn main() -> Result<(), u8> { + LL| 1| foo::(0); + LL| 1| foo::(0.0); + LL| 1| Ok(()) + LL| 1|} diff --git a/tests/run-coverage/unused_mod.coverage b/tests/run-coverage/unused_mod.coverage index e1d82f66f..558dfaa5c 100644 --- a/tests/run-coverage/unused_mod.coverage +++ b/tests/run-coverage/unused_mod.coverage @@ -1,13 +1,13 @@ $DIR/auxiliary/unused_mod_helper.rs: - 1| 0|pub fn never_called_function() { - 2| 0| println!("I am never called"); - 3| 0|} + LL| 0|pub fn never_called_function() { + LL| 0| println!("I am never called"); + LL| 0|} $DIR/unused_mod.rs: - 1| |#[path = "auxiliary/unused_mod_helper.rs"] - 2| |mod unused_module; - 3| | - 4| 1|fn main() { - 5| 1| println!("hello world!"); - 6| 1|} + LL| |#[path = "auxiliary/unused_mod_helper.rs"] + LL| |mod unused_module; + LL| | + LL| 1|fn main() { + LL| 1| println!("hello world!"); + LL| 1|} diff --git a/tests/run-coverage/uses_crate.coverage b/tests/run-coverage/uses_crate.coverage index a3b78e214..9da096dbd 100644 --- a/tests/run-coverage/uses_crate.coverage +++ b/tests/run-coverage/uses_crate.coverage @@ -1,170 +1,170 @@ $DIR/auxiliary/used_crate.rs: - 1| |#![allow(unused_assignments, unused_variables)] - 2| |// compile-flags: -C opt-level=3 - 3| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations - 4| | - 5| 1|pub fn used_function() { - 6| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 7| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 8| 1| // dependent conditions. - 9| 1| let is_true = std::env::args().len() == 1; - 10| 1| let mut countdown = 0; - 11| 1| if is_true { - 12| 1| countdown = 10; - 13| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| |// compile-flags: -C opt-level=3 + LL| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations + LL| | + LL| 1|pub fn used_function() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let mut countdown = 0; + LL| 1| if is_true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 14| 1| use_this_lib_crate(); - 15| 1|} - 16| | - 17| 2|pub fn used_only_from_bin_crate_generic_function(arg: T) { - 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); - 19| 2|} + LL| 1| use_this_lib_crate(); + LL| 1|} + LL| | + LL| 2|pub fn used_only_from_bin_crate_generic_function(arg: T) { + LL| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); + LL| 2|} ------------------ | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> ------------------ | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec>: - | 17| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { - | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); - | 19| 1|} + | LL| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { + | LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ | used_crate::used_only_from_bin_crate_generic_function::<&str>: - | 17| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { - | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); - | 19| 1|} + | LL| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { + | LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ - 20| |// Expect for above function: `Unexecuted instantiation` (see below) - 21| 2|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - 22| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); - 23| 2|} + LL| |// Expect for above function: `Unexecuted instantiation` (see below) + LL| 2|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + LL| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); + LL| 2|} ------------------ | used_crate::used_only_from_this_lib_crate_generic_function::<&str>: - | 21| 1|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); - | 23| 1|} + | LL| 1|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ | used_crate::used_only_from_this_lib_crate_generic_function::>: - | 21| 1|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); - | 23| 1|} + | LL| 1|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ - 24| | - 25| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - 26| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - 27| 2|} + LL| | + LL| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + LL| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + LL| 2|} ------------------ | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>: - | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 27| 1|} + | LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ | used_crate::used_from_bin_crate_and_lib_crate_generic_function::>: - | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 27| 1|} + | LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ - 28| | - 29| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - 30| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - 31| 2|} + LL| | + LL| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + LL| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + LL| 2|} ------------------ | used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>: - | 29| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 30| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 31| 1|} + | LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ | used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>: - | 29| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 30| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 31| 1|} + | LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ - 32| | - 33| 0|pub fn unused_generic_function(arg: T) { - 34| 0| println!("unused_generic_function with {:?}", arg); - 35| 0|} - 36| | - 37| 0|pub fn unused_function() { - 38| 0| let is_true = std::env::args().len() == 1; - 39| 0| let mut countdown = 2; - 40| 0| if !is_true { - 41| 0| countdown = 20; - 42| 0| } - 43| 0|} - 44| | - 45| 0|fn unused_private_function() { - 46| 0| let is_true = std::env::args().len() == 1; - 47| 0| let mut countdown = 2; - 48| 0| if !is_true { - 49| 0| countdown = 20; - 50| 0| } - 51| 0|} - 52| | - 53| 1|fn use_this_lib_crate() { - 54| 1| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); - 55| 1| used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - 56| 1| "used from library used_crate.rs", - 57| 1| ); - 58| 1| let some_vec = vec![5, 6, 7, 8]; - 59| 1| used_only_from_this_lib_crate_generic_function(some_vec); - 60| 1| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); - 61| 1|} - 62| | - 63| |// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results, - 64| |// for example: - 65| |// - 66| |// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> - 67| |// - 68| |// These notices appear when `llvm-cov` shows instantiations. This may be a - 69| |// default option, but it can be suppressed with: - 70| |// - 71| |// ```shell - 72| |// $ `llvm-cov show --show-instantiations=0 ...` - 73| |// ``` - 74| |// - 75| |// The notice is triggered because the function is unused by the library itself, - 76| |// and when the library is compiled, a synthetic function is generated, so - 77| |// unused function coverage can be reported. Coverage can be skipped for unused - 78| |// generic functions with: - 79| |// - 80| |// ```shell - 81| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...` - 82| |// ``` - 83| |// - 84| |// Even though this function is used by `uses_crate.rs` (and - 85| |// counted), with substitutions for `T`, those instantiations are only generated - 86| |// when the generic function is actually used (from the binary, not from this - 87| |// library crate). So the test result shows coverage for all instantiated - 88| |// versions and their generic type substitutions, plus the `Unexecuted - 89| |// instantiation` message for the non-substituted version. This is valid, but - 90| |// unfortunately a little confusing. - 91| |// - 92| |// The library crate has its own coverage map, and the only way to show unused - 93| |// coverage of a generic function is to include the generic function in the - 94| |// coverage map, marked as an "unused function". If the library were used by - 95| |// another binary that never used this generic function, then it would be valid - 96| |// to show the unused generic, with unknown substitution (`_`). - 97| |// - 98| |// The alternative is to exclude all generics from being included in the "unused - 99| |// functions" list, which would then omit coverage results for - 100| |// `unused_generic_function()`, below. + LL| | + LL| 0|pub fn unused_generic_function(arg: T) { + LL| 0| println!("unused_generic_function with {:?}", arg); + LL| 0|} + LL| | + LL| 0|pub fn unused_function() { + LL| 0| let is_true = std::env::args().len() == 1; + LL| 0| let mut countdown = 2; + LL| 0| if !is_true { + LL| 0| countdown = 20; + LL| 0| } + LL| 0|} + LL| | + LL| 0|fn unused_private_function() { + LL| 0| let is_true = std::env::args().len() == 1; + LL| 0| let mut countdown = 2; + LL| 0| if !is_true { + LL| 0| countdown = 20; + LL| 0| } + LL| 0|} + LL| | + LL| 1|fn use_this_lib_crate() { + LL| 1| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); + LL| 1| used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + LL| 1| "used from library used_crate.rs", + LL| 1| ); + LL| 1| let some_vec = vec![5, 6, 7, 8]; + LL| 1| used_only_from_this_lib_crate_generic_function(some_vec); + LL| 1| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); + LL| 1|} + LL| | + LL| |// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results, + LL| |// for example: + LL| |// + LL| |// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> + LL| |// + LL| |// These notices appear when `llvm-cov` shows instantiations. This may be a + LL| |// default option, but it can be suppressed with: + LL| |// + LL| |// ```shell + LL| |// $ `llvm-cov show --show-instantiations=0 ...` + LL| |// ``` + LL| |// + LL| |// The notice is triggered because the function is unused by the library itself, + LL| |// and when the library is compiled, a synthetic function is generated, so + LL| |// unused function coverage can be reported. Coverage can be skipped for unused + LL| |// generic functions with: + LL| |// + LL| |// ```shell + LL| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...` + LL| |// ``` + LL| |// + LL| |// Even though this function is used by `uses_crate.rs` (and + LL| |// counted), with substitutions for `T`, those instantiations are only generated + LL| |// when the generic function is actually used (from the binary, not from this + LL| |// library crate). So the test result shows coverage for all instantiated + LL| |// versions and their generic type substitutions, plus the `Unexecuted + LL| |// instantiation` message for the non-substituted version. This is valid, but + LL| |// unfortunately a little confusing. + LL| |// + LL| |// The library crate has its own coverage map, and the only way to show unused + LL| |// coverage of a generic function is to include the generic function in the + LL| |// coverage map, marked as an "unused function". If the library were used by + LL| |// another binary that never used this generic function, then it would be valid + LL| |// to show the unused generic, with unknown substitution (`_`). + LL| |// + LL| |// The alternative is to exclude all generics from being included in the "unused + LL| |// functions" list, which would then omit coverage results for + LL| |// `unused_generic_function()`, below. $DIR/uses_crate.rs: - 1| |// FIXME #110395 - 2| |// ignore-linux - 3| | - 4| |// Validates coverage now works with optimizations - 5| |// compile-flags: -C opt-level=3 - 6| | - 7| |#![allow(unused_assignments, unused_variables)] - 8| | - 9| |// aux-build:used_crate.rs - 10| |extern crate used_crate; - 11| | - 12| 1|fn main() { - 13| 1| used_crate::used_function(); - 14| 1| let some_vec = vec![1, 2, 3, 4]; - 15| 1| used_crate::used_only_from_bin_crate_generic_function(&some_vec); - 16| 1| used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); - 17| 1| used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); - 18| 1| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); - 19| 1|} + LL| |// This test was failing on Linux for a while due to #110393 somehow making + LL| |// the unused functions not instrumented, but it seems to be fine now. + LL| | + LL| |// Validates coverage now works with optimizations + LL| |// compile-flags: -C opt-level=3 + LL| | + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| |// aux-build:used_crate.rs + LL| |extern crate used_crate; + LL| | + LL| 1|fn main() { + LL| 1| used_crate::used_function(); + LL| 1| let some_vec = vec![1, 2, 3, 4]; + LL| 1| used_crate::used_only_from_bin_crate_generic_function(&some_vec); + LL| 1| used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); + LL| 1| used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); + LL| 1| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); + LL| 1|} diff --git a/tests/run-coverage/uses_crate.rs b/tests/run-coverage/uses_crate.rs index ab466970f..ab203ad78 100644 --- a/tests/run-coverage/uses_crate.rs +++ b/tests/run-coverage/uses_crate.rs @@ -1,5 +1,5 @@ -// FIXME #110395 -// ignore-linux +// This test was failing on Linux for a while due to #110393 somehow making +// the unused functions not instrumented, but it seems to be fine now. // Validates coverage now works with optimizations // compile-flags: -C opt-level=3 diff --git a/tests/run-coverage/uses_inline_crate.coverage b/tests/run-coverage/uses_inline_crate.coverage index f878d8107..48493e207 100644 --- a/tests/run-coverage/uses_inline_crate.coverage +++ b/tests/run-coverage/uses_inline_crate.coverage @@ -1,164 +1,164 @@ $DIR/auxiliary/used_inline_crate.rs: - 1| |#![allow(unused_assignments, unused_variables)] - 2| | - 3| |// compile-flags: -C opt-level=3 - 4| |// ^^ validates coverage now works with optimizations - 5| |use std::fmt::Debug; - 6| | - 7| 1|pub fn used_function() { - 8| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 9| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 10| 1| // dependent conditions. - 11| 1| let is_true = std::env::args().len() == 1; - 12| 1| let mut countdown = 0; - 13| 1| if is_true { - 14| 1| countdown = 10; - 15| 1| } + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| |// compile-flags: -C opt-level=3 + LL| |// ^^ validates coverage now works with optimizations + LL| |use std::fmt::Debug; + LL| | + LL| 1|pub fn used_function() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let mut countdown = 0; + LL| 1| if is_true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 16| 1| use_this_lib_crate(); - 17| 1|} - 18| | - 19| |#[inline(always)] - 20| 1|pub fn used_inline_function() { - 21| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure - 22| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - 23| 1| // dependent conditions. - 24| 1| let is_true = std::env::args().len() == 1; - 25| 1| let mut countdown = 0; - 26| 1| if is_true { - 27| 1| countdown = 10; - 28| 1| } + LL| 1| use_this_lib_crate(); + LL| 1|} + LL| | + LL| |#[inline(always)] + LL| 1|pub fn used_inline_function() { + LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure + LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + LL| 1| // dependent conditions. + LL| 1| let is_true = std::env::args().len() == 1; + LL| 1| let mut countdown = 0; + LL| 1| if is_true { + LL| 1| countdown = 10; + LL| 1| } ^0 - 29| 1| use_this_lib_crate(); - 30| 1|} - 31| | - 32| | - 33| | - 34| | - 35| | - 36| | - 37| | - 38| |#[inline(always)] - 39| 2|pub fn used_only_from_bin_crate_generic_function(arg: T) { - 40| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); - 41| 2|} + LL| 1| use_this_lib_crate(); + LL| 1|} + LL| | + LL| | + LL| | + LL| | + LL| | + LL| | + LL| | + LL| |#[inline(always)] + LL| 2|pub fn used_only_from_bin_crate_generic_function(arg: T) { + LL| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); + LL| 2|} ------------------ | Unexecuted instantiation: used_inline_crate::used_only_from_bin_crate_generic_function::<_> ------------------ | used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec>: - | 39| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { - | 40| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); - | 41| 1|} + | LL| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { + | LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ | used_inline_crate::used_only_from_bin_crate_generic_function::<&str>: - | 39| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { - | 40| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); - | 41| 1|} + | LL| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { + | LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ - 42| |// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`) - 43| | - 44| |#[inline(always)] - 45| 4|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - 46| 4| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); - 47| 4|} + LL| |// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`) + LL| | + LL| |#[inline(always)] + LL| 4|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + LL| 4| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); + LL| 4|} ------------------ | used_inline_crate::used_only_from_this_lib_crate_generic_function::<&str>: - | 45| 2|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - | 46| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); - | 47| 2|} + | LL| 2|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + | LL| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); + | LL| 2|} ------------------ | used_inline_crate::used_only_from_this_lib_crate_generic_function::>: - | 45| 2|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - | 46| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); - | 47| 2|} + | LL| 2|pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + | LL| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); + | LL| 2|} ------------------ - 48| | - 49| |#[inline(always)] - 50| 3|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - 51| 3| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - 52| 3|} + LL| | + LL| |#[inline(always)] + LL| 3|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + LL| 3| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + LL| 3|} ------------------ | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>: - | 50| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 51| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 52| 2|} + | LL| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 2|} ------------------ | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::>: - | 50| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 51| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 52| 1|} + | LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ - 53| | - 54| |#[inline(always)] - 55| 3|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - 56| 3| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - 57| 3|} + LL| | + LL| |#[inline(always)] + LL| 3|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + LL| 3| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + LL| 3|} ------------------ | used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>: - | 55| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 56| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 57| 1|} + | LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 1|} ------------------ | used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>: - | 55| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - | 56| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 57| 2|} + | LL| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + | LL| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | LL| 2|} ------------------ - 58| | - 59| |#[inline(always)] - 60| 0|pub fn unused_generic_function(arg: T) { - 61| 0| println!("unused_generic_function with {:?}", arg); - 62| 0|} - 63| | - 64| |#[inline(always)] - 65| 0|pub fn unused_function() { - 66| 0| let is_true = std::env::args().len() == 1; - 67| 0| let mut countdown = 2; - 68| 0| if !is_true { - 69| 0| countdown = 20; - 70| 0| } - 71| 0|} - 72| | - 73| |#[inline(always)] - 74| 0|fn unused_private_function() { - 75| 0| let is_true = std::env::args().len() == 1; - 76| 0| let mut countdown = 2; - 77| 0| if !is_true { - 78| 0| countdown = 20; - 79| 0| } - 80| 0|} - 81| | - 82| 2|fn use_this_lib_crate() { - 83| 2| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); - 84| 2| used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - 85| 2| "used from library used_crate.rs", - 86| 2| ); - 87| 2| let some_vec = vec![5, 6, 7, 8]; - 88| 2| used_only_from_this_lib_crate_generic_function(some_vec); - 89| 2| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); - 90| 2|} + LL| | + LL| |#[inline(always)] + LL| 0|pub fn unused_generic_function(arg: T) { + LL| 0| println!("unused_generic_function with {:?}", arg); + LL| 0|} + LL| | + LL| |#[inline(always)] + LL| 0|pub fn unused_function() { + LL| 0| let is_true = std::env::args().len() == 1; + LL| 0| let mut countdown = 2; + LL| 0| if !is_true { + LL| 0| countdown = 20; + LL| 0| } + LL| 0|} + LL| | + LL| |#[inline(always)] + LL| 0|fn unused_private_function() { + LL| 0| let is_true = std::env::args().len() == 1; + LL| 0| let mut countdown = 2; + LL| 0| if !is_true { + LL| 0| countdown = 20; + LL| 0| } + LL| 0|} + LL| | + LL| 2|fn use_this_lib_crate() { + LL| 2| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); + LL| 2| used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + LL| 2| "used from library used_crate.rs", + LL| 2| ); + LL| 2| let some_vec = vec![5, 6, 7, 8]; + LL| 2| used_only_from_this_lib_crate_generic_function(some_vec); + LL| 2| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); + LL| 2|} $DIR/uses_inline_crate.rs: - 1| |// FIXME #110395 - 2| |// ignore-linux - 3| | - 4| |// Validates coverage now works with optimizations - 5| |// compile-flags: -C opt-level=3 - 6| | - 7| |#![allow(unused_assignments, unused_variables)] - 8| | - 9| |// aux-build:used_inline_crate.rs - 10| |extern crate used_inline_crate; - 11| | - 12| 1|fn main() { - 13| 1| used_inline_crate::used_function(); - 14| 1| used_inline_crate::used_inline_function(); - 15| 1| let some_vec = vec![1, 2, 3, 4]; - 16| 1| used_inline_crate::used_only_from_bin_crate_generic_function(&some_vec); - 17| 1| used_inline_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); - 18| 1| used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); - 19| 1| used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - 20| 1| "interesting?", - 21| 1| ); - 22| 1|} + LL| |// This test was failing on Linux for a while due to #110393 somehow making + LL| |// the unused functions not instrumented, but it seems to be fine now. + LL| | + LL| |// Validates coverage now works with optimizations + LL| |// compile-flags: -C opt-level=3 + LL| | + LL| |#![allow(unused_assignments, unused_variables)] + LL| | + LL| |// aux-build:used_inline_crate.rs + LL| |extern crate used_inline_crate; + LL| | + LL| 1|fn main() { + LL| 1| used_inline_crate::used_function(); + LL| 1| used_inline_crate::used_inline_function(); + LL| 1| let some_vec = vec![1, 2, 3, 4]; + LL| 1| used_inline_crate::used_only_from_bin_crate_generic_function(&some_vec); + LL| 1| used_inline_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); + LL| 1| used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); + LL| 1| used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + LL| 1| "interesting?", + LL| 1| ); + LL| 1|} diff --git a/tests/run-coverage/uses_inline_crate.rs b/tests/run-coverage/uses_inline_crate.rs index 4bd66d2f8..d7b4c3c05 100644 --- a/tests/run-coverage/uses_inline_crate.rs +++ b/tests/run-coverage/uses_inline_crate.rs @@ -1,5 +1,5 @@ -// FIXME #110395 -// ignore-linux +// This test was failing on Linux for a while due to #110393 somehow making +// the unused functions not instrumented, but it seems to be fine now. // Validates coverage now works with optimizations // compile-flags: -C opt-level=3 diff --git a/tests/run-coverage/while.coverage b/tests/run-coverage/while.coverage index efa7d083f..c9d497651 100644 --- a/tests/run-coverage/while.coverage +++ b/tests/run-coverage/while.coverage @@ -1,6 +1,6 @@ - 1| 1|fn main() { - 2| 1| let num = 9; - 3| 1| while num >= 10 { - 4| 0| } - 5| 1|} + LL| 1|fn main() { + LL| 1| let num = 9; + LL| 1| while num >= 10 { + LL| 0| } + LL| 1|} diff --git a/tests/run-coverage/while_early_ret.coverage b/tests/run-coverage/while_early_ret.coverage index 2ce94e013..97808447a 100644 --- a/tests/run-coverage/while_early_ret.coverage +++ b/tests/run-coverage/while_early_ret.coverage @@ -1,43 +1,43 @@ - 1| |#![allow(unused_assignments)] - 2| |// failure-status: 1 - 3| | - 4| 1|fn main() -> Result<(),u8> { - 5| 1| let mut countdown = 10; - 6| | while - 7| 7| countdown - 8| 7| > - 9| 7| 0 - 10| | { - 11| | if - 12| 7| countdown - 13| 7| < - 14| 7| 5 - 15| | { - 16| | return - 17| | if - 18| 1| countdown - 19| 1| > - 20| 1| 8 - 21| | { - 22| 0| Ok(()) - 23| | } - 24| | else - 25| | { - 26| 1| Err(1) - 27| | } - 28| | ; - 29| 6| } - 30| 6| countdown - 31| 6| -= - 32| 6| 1 - 33| | ; - 34| | } - 35| 0| Ok(()) - 36| 1|} - 37| | - 38| |// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and - 39| |// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux - 40| |// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program - 41| |// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical - 42| |// to the coverage test for early returns, but this is a limitation that should be fixed. + LL| |#![allow(unused_assignments)] + LL| |// failure-status: 1 + LL| | + LL| 1|fn main() -> Result<(),u8> { + LL| 1| let mut countdown = 10; + LL| | while + LL| 7| countdown + LL| 7| > + LL| 7| 0 + LL| | { + LL| | if + LL| 7| countdown + LL| 7| < + LL| 7| 5 + LL| | { + LL| | return + LL| | if + LL| 1| countdown + LL| 1| > + LL| 1| 8 + LL| | { + LL| 0| Ok(()) + LL| | } + LL| | else + LL| | { + LL| 1| Err(1) + LL| | } + LL| | ; + LL| 6| } + LL| 6| countdown + LL| 6| -= + LL| 6| 1 + LL| | ; + LL| | } + LL| 0| Ok(()) + LL| 1|} + LL| | + LL| |// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and + LL| |// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux + LL| |// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program + LL| |// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical + LL| |// to the coverage test for early returns, but this is a limitation that should be fixed. diff --git a/tests/run-coverage/yield.coverage b/tests/run-coverage/yield.coverage index 6e2f23ee7..383dd9915 100644 --- a/tests/run-coverage/yield.coverage +++ b/tests/run-coverage/yield.coverage @@ -1,38 +1,38 @@ - 1| |#![feature(generators, generator_trait)] - 2| |#![allow(unused_assignments)] - 3| | - 4| |use std::ops::{Generator, GeneratorState}; - 5| |use std::pin::Pin; - 6| | - 7| 1|fn main() { - 8| 1| let mut generator = || { - 9| 1| yield 1; - 10| 1| return "foo" - 11| 1| }; - 12| | - 13| 1| match Pin::new(&mut generator).resume(()) { - 14| 1| GeneratorState::Yielded(1) => {} - 15| 0| _ => panic!("unexpected value from resume"), - 16| | } - 17| 1| match Pin::new(&mut generator).resume(()) { - 18| 1| GeneratorState::Complete("foo") => {} - 19| 0| _ => panic!("unexpected value from resume"), - 20| | } - 21| | - 22| 1| let mut generator = || { - 23| 1| yield 1; - 24| 1| yield 2; - 25| 0| yield 3; - 26| 0| return "foo" - 27| 0| }; - 28| | - 29| 1| match Pin::new(&mut generator).resume(()) { - 30| 1| GeneratorState::Yielded(1) => {} - 31| 0| _ => panic!("unexpected value from resume"), - 32| | } - 33| 1| match Pin::new(&mut generator).resume(()) { - 34| 1| GeneratorState::Yielded(2) => {} - 35| 0| _ => panic!("unexpected value from resume"), - 36| | } - 37| 1|} + LL| |#![feature(generators, generator_trait)] + LL| |#![allow(unused_assignments)] + LL| | + LL| |use std::ops::{Generator, GeneratorState}; + LL| |use std::pin::Pin; + LL| | + LL| 1|fn main() { + LL| 1| let mut generator = || { + LL| 1| yield 1; + LL| 1| return "foo" + LL| 1| }; + LL| | + LL| 1| match Pin::new(&mut generator).resume(()) { + LL| 1| GeneratorState::Yielded(1) => {} + LL| 0| _ => panic!("unexpected value from resume"), + LL| | } + LL| 1| match Pin::new(&mut generator).resume(()) { + LL| 1| GeneratorState::Complete("foo") => {} + LL| 0| _ => panic!("unexpected value from resume"), + LL| | } + LL| | + LL| 1| let mut generator = || { + LL| 1| yield 1; + LL| 1| yield 2; + LL| 0| yield 3; + LL| 0| return "foo" + LL| 0| }; + LL| | + LL| 1| match Pin::new(&mut generator).resume(()) { + LL| 1| GeneratorState::Yielded(1) => {} + LL| 0| _ => panic!("unexpected value from resume"), + LL| | } + LL| 1| match Pin::new(&mut generator).resume(()) { + LL| 1| GeneratorState::Yielded(2) => {} + LL| 0| _ => panic!("unexpected value from resume"), + LL| | } + LL| 1|} diff --git a/tests/run-make-fulldeps/issue-19371/foo.rs b/tests/run-make-fulldeps/issue-19371/foo.rs index 9cca62000..681326387 100644 --- a/tests/run-make-fulldeps/issue-19371/foo.rs +++ b/tests/run-make-fulldeps/issue-19371/foo.rs @@ -52,6 +52,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) { input, output_file: Some(OutFileName::Real(output)), output_dir: None, + ice_file: None, file_loader: None, locale_resources: &[], lint_caps: Default::default(), @@ -68,6 +69,6 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) { let ongoing_codegen = queries.ongoing_codegen()?; queries.linker(ongoing_codegen) }); - linker.unwrap().link(); + linker.unwrap().link().unwrap(); }); } diff --git a/tests/run-make/comment-section/Makefile b/tests/run-make/comment-section/Makefile new file mode 100644 index 000000000..9f810063c --- /dev/null +++ b/tests/run-make/comment-section/Makefile @@ -0,0 +1,15 @@ +include ../tools.mk + +# only-linux + +all: + echo 'fn main(){}' | $(RUSTC) - --emit=link,obj -Csave-temps --target=$(TARGET) + + # Check linked output has a `.comment` section with the expected content. + readelf -p '.comment' $(TMPDIR)/rust_out | $(CGREP) -F 'rustc version 1.' + + # Check all object files (including temporary outputs) have a `.comment` + # section with the expected content. + set -e; for f in $(TMPDIR)/*.o; do \ + readelf -p '.comment' $$f | $(CGREP) -F 'rustc version 1.'; \ + done diff --git a/tests/run-make/coverage-llvmir/filecheck.testprog.txt b/tests/run-make/coverage-llvmir/filecheck.testprog.txt index b3a8808df..9d63fabd7 100644 --- a/tests/run-make/coverage-llvmir/filecheck.testprog.txt +++ b/tests/run-make/coverage-llvmir/filecheck.testprog.txt @@ -39,10 +39,10 @@ CHECK-NOT: [[DEFINE_INTERNAL]] CHECK: atomicrmw add ptr CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, -CHECK: declare void @llvm.instrprof.increment({{i8\*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] +CHECK: declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] WINDOWS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() #[[LLVM_PROFILE_RUNTIME_USER_ATTR:[0-9]+]] comdat { -WINDOWS-NEXT: %1 = load i32, {{i32\*|ptr}} @__llvm_profile_runtime +WINDOWS-NEXT: %1 = load i32, ptr @__llvm_profile_runtime WINDOWS-NEXT: ret i32 %1 WINDOWS-NEXT: } diff --git a/tests/run-make/doctests-keep-binaries/Makefile b/tests/run-make/doctests-keep-binaries/Makefile index 6254e93d3..2c647851a 100644 --- a/tests/run-make/doctests-keep-binaries/Makefile +++ b/tests/run-make/doctests-keep-binaries/Makefile @@ -3,7 +3,9 @@ include ../tools.mk # Check that valid binaries are persisted by running them, regardless of whether the --run or --no-run option is used. -all: run no_run +MY_SRC_DIR := ${CURDIR} + +all: run no_run test_run_directory run: mkdir -p $(TMPDIR)/doctests @@ -20,3 +22,12 @@ no_run: $(TMPDIR)/doctests/t_rs_2_0/rust_out $(TMPDIR)/doctests/t_rs_8_0/rust_out rm -rf $(TMPDIR)/doctests + +# Behavior with --test-run-directory with relative paths. +test_run_directory: + mkdir -p $(TMPDIR)/doctests + mkdir -p $(TMPDIR)/rundir + $(RUSTC) --crate-type rlib t.rs + ( cd $(TMPDIR); \ + $(RUSTDOC) -Zunstable-options --test --persist-doctests doctests --test-run-directory rundir --extern t=libt.rlib $(MY_SRC_DIR)/t.rs ) + rm -rf $(TMPDIR)/doctests $(TMPDIR)/rundir diff --git a/tests/run-make/doctests-runtool/Makefile b/tests/run-make/doctests-runtool/Makefile new file mode 100644 index 000000000..7d5df1e30 --- /dev/null +++ b/tests/run-make/doctests-runtool/Makefile @@ -0,0 +1,20 @@ +# ignore-cross-compile +include ../tools.mk + +# Tests behavior of rustdoc --runtool + +MY_SRC_DIR := ${CURDIR} + +all: with_test_run_directory + +# Behavior with --runtool with relative paths and --test-run-directory. +with_test_run_directory: + mkdir -p $(TMPDIR)/rundir + mkdir -p $(TMPDIR)/runtool + $(RUSTC) --crate-type rlib t.rs + $(RUSTC) runtool.rs -o $(TMPDIR)/runtool/runtool + ( cd $(TMPDIR); \ + $(RUSTDOC) -Zunstable-options --test --test-run-directory rundir \ + --runtool runtool/runtool --extern t=libt.rlib $(MY_SRC_DIR)/t.rs \ + ) + rm -rf $(TMPDIR)/rundir $(TMPDIR)/runtool diff --git a/tests/run-make/doctests-runtool/runtool.rs b/tests/run-make/doctests-runtool/runtool.rs new file mode 100644 index 000000000..f5e3afdf2 --- /dev/null +++ b/tests/run-make/doctests-runtool/runtool.rs @@ -0,0 +1,3 @@ +fn main() { + eprintln!("{:?}", std::env::args().collect::>()); +} diff --git a/tests/run-make/doctests-runtool/t.rs b/tests/run-make/doctests-runtool/t.rs new file mode 100644 index 000000000..c38cf0a0b --- /dev/null +++ b/tests/run-make/doctests-runtool/t.rs @@ -0,0 +1,11 @@ +/// Fungle the foople. +/// ``` +/// t::foople(); +/// ``` +pub fn foople() {} + +/// Flomble the florp +/// ``` +/// t::florp(); +/// ``` +pub fn florp() {} diff --git a/tests/run-make/dump-ice-to-disk/Makefile b/tests/run-make/dump-ice-to-disk/Makefile new file mode 100644 index 000000000..23006fc09 --- /dev/null +++ b/tests/run-make/dump-ice-to-disk/Makefile @@ -0,0 +1,10 @@ +include ../tools.mk + +# ignore-windows + +export RUSTC := $(RUSTC_ORIGINAL) +export LD_LIBRARY_PATH := $(HOST_RPATH_DIR) +export TMPDIR := $(TMPDIR) + +all: + bash check.sh diff --git a/tests/run-make/dump-ice-to-disk/check.sh b/tests/run-make/dump-ice-to-disk/check.sh new file mode 100644 index 000000000..ab6f9ab60 --- /dev/null +++ b/tests/run-make/dump-ice-to-disk/check.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# Default nightly behavior (write ICE to current directory) +# FIXME(estebank): these are failing on CI, but passing locally. +# $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default.log 2>&1 +# default=$(cat ./rustc-ice-*.txt | wc -l) +# rm ./rustc-ice-*.txt + +# Explicit directory set +export RUSTC_ICE=$TMPDIR +$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1 +default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) +content=$(cat $TMPDIR/rustc-ice-*.txt) +rm $TMPDIR/rustc-ice-*.txt +RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1 +short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) +rm $TMPDIR/rustc-ice-*.txt +RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-full.log 2>&1 +full=$(cat $TMPDIR/rustc-ice-*.txt | wc -l) +rm $TMPDIR/rustc-ice-*.txt + +# Explicitly disabling ICE dump +export RUSTC_ICE=0 +$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1 +should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt 2>/dev/null | wc -l) +should_be_empty_dot=$(ls -l ./rustc-ice-*.txt 2>/dev/null | wc -l) + +echo "#### ICE Dump content:" +echo $content +echo "#### default length:" +echo $default +echo "#### short length:" +echo $short +echo "#### default_set length:" +echo $default_set +echo "#### full length:" +echo $full +echo "#### should_be_empty_dot length:" +echo $should_be_empty_dot +echo "#### should_be_empty_tmp length:" +echo $should_be_empty_tmp + +## Verify that a the ICE dump file is created in the appropriate directories, that +## their lengths are the same regardless of other backtrace configuration options, +## that the file is not created when asked to (RUSTC_ICE=0) and that the file +## contains at least part of the expected content. +if [ $short -eq $default_set ] && + #[ $default -eq $short ] && + [ $default_set -eq $full ] && + [[ $content == *"thread 'rustc' panicked at "* ]] && + [[ $content == *"stack backtrace:"* ]] && + #[ $default -gt 0 ] && + [ $should_be_empty_dot -eq 0 ] && + [ $should_be_empty_tmp -eq 0 ]; then + exit 0 +else + exit 1 +fi diff --git a/tests/run-make/dump-ice-to-disk/src/lib.rs b/tests/run-make/dump-ice-to-disk/src/lib.rs new file mode 100644 index 000000000..b23b7f830 --- /dev/null +++ b/tests/run-make/dump-ice-to-disk/src/lib.rs @@ -0,0 +1,7 @@ +fn func(s: &str) { + println!("{}", s); +} + +fn main() { + func(1); +} diff --git a/tests/run-make/exit-code/Makefile b/tests/run-make/exit-code/Makefile index 6458b7168..155e5cd11 100644 --- a/tests/run-make/exit-code/Makefile +++ b/tests/run-make/exit-code/Makefile @@ -5,7 +5,7 @@ all: $(RUSTC) success.rs; [ $$? -eq 0 ] $(RUSTC) --invalid-arg-foo; [ $$? -eq 1 ] $(RUSTC) compile-error.rs; [ $$? -eq 1 ] - $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ] + RUSTC_ICE=0 $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ] $(RUSTDOC) -o $(TMPDIR)/exit-code success.rs; [ $$? -eq 0 ] $(RUSTDOC) --invalid-arg-foo; [ $$? -eq 1 ] $(RUSTDOC) compile-error.rs; [ $$? -eq 1 ] diff --git a/tests/run-make/extern-flag-pathless/Makefile b/tests/run-make/extern-flag-pathless/Makefile index 701bfcd28..36b374e0d 100644 --- a/tests/run-make/extern-flag-pathless/Makefile +++ b/tests/run-make/extern-flag-pathless/Makefile @@ -3,17 +3,32 @@ include ../tools.mk # Test mixing pathless --extern with paths. +# Test for static linking by checking that the binary runs if the dylib +# is removed and test for dynamic linking by checking that the binary +# fails to run if the dylib is removed. + all: - $(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib - $(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic + $(RUSTC) bar.rs --crate-type=rlib --crate-type=dylib -Cprefer-dynamic + # rlib preferred over dylib $(RUSTC) foo.rs --extern bar - $(call RUN,foo) | $(CGREP) 'static' + mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp + $(call RUN,foo) + mv $(TMPDIR)/bar.tmp $(call DYLIB,bar) + $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar - $(call RUN,foo) | $(CGREP) 'static' + mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp + $(call RUN,foo) + mv $(TMPDIR)/bar.tmp $(call DYLIB,bar) + # explicit --extern overrides pathless $(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar - $(call RUN,foo) | $(CGREP) 'dynamic' + mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp + $(call FAIL,foo) + mv $(TMPDIR)/bar.tmp $(call DYLIB,bar) + # prefer-dynamic does what it says $(RUSTC) foo.rs --extern bar -C prefer-dynamic - $(call RUN,foo) | $(CGREP) 'dynamic' + mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp + $(call FAIL,foo) + mv $(TMPDIR)/bar.tmp $(call DYLIB,bar) diff --git a/tests/run-make/extern-flag-pathless/bar-dynamic.rs b/tests/run-make/extern-flag-pathless/bar-dynamic.rs deleted file mode 100644 index e2d68d517..000000000 --- a/tests/run-make/extern-flag-pathless/bar-dynamic.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn f() { - println!("dynamic"); -} diff --git a/tests/run-make/extern-flag-pathless/bar-static.rs b/tests/run-make/extern-flag-pathless/bar-static.rs deleted file mode 100644 index 240d8bde4..000000000 --- a/tests/run-make/extern-flag-pathless/bar-static.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn f() { - println!("static"); -} diff --git a/tests/run-make/extern-flag-pathless/bar.rs b/tests/run-make/extern-flag-pathless/bar.rs new file mode 100644 index 000000000..cdc6c27d8 --- /dev/null +++ b/tests/run-make/extern-flag-pathless/bar.rs @@ -0,0 +1 @@ +pub fn f() {} diff --git a/tests/run-make/extern-fn-explicit-align/Makefile b/tests/run-make/extern-fn-explicit-align/Makefile new file mode 100644 index 000000000..3cbbf3839 --- /dev/null +++ b/tests/run-make/extern-fn-explicit-align/Makefile @@ -0,0 +1,6 @@ +# ignore-cross-compile +include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-explicit-align/test.c b/tests/run-make/extern-fn-explicit-align/test.c new file mode 100644 index 000000000..a3db3442a --- /dev/null +++ b/tests/run-make/extern-fn-explicit-align/test.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include + +struct BoolAndU32 +{ + bool a; + uint32_t b; +}; + +#ifdef _MSC_VER +__declspec(align(16)) +struct TwoU64s +{ + uint64_t a; + uint64_t b; +}; +#else +struct __attribute__((aligned(16))) TwoU64s +{ + uint64_t a; + uint64_t b; +}; +#endif + +struct WrappedU64s +{ + struct TwoU64s a; +}; + +#ifdef _MSC_VER +__declspec(align(1)) +struct LowerAlign +{ + uint64_t a; + uint64_t b; +}; +#else +struct __attribute__((aligned(1))) LowerAlign +{ + uint64_t a; + uint64_t b; +}; +#endif + +#pragma pack(push, 1) +struct Packed +{ + uint64_t a; + uint64_t b; +}; +#pragma pack(pop) + +int32_t many_args( + void *a, + void *b, + const char *c, + uint64_t d, + bool e, + struct BoolAndU32 f, + void *g, + struct TwoU64s h, + void *i, + struct WrappedU64s j, + void *k, + struct LowerAlign l, + void *m, + struct Packed n, + const char *o) +{ + assert(!a); + assert(!b); + assert(!c); + assert(d == 42); + assert(e); + assert(f.a); + assert(f.b == 1337); + assert(!g); + assert(h.a == 1); + assert(h.b == 2); + assert(!i); + assert(j.a.a == 3); + assert(j.a.b == 4); + assert(!k); + assert(l.a == 5); + assert(l.b == 6); + assert(!m); + assert(n.a == 7); + assert(n.b == 8); + assert(strcmp(o, "Hello world") == 0); + return 0; +} diff --git a/tests/run-make/extern-fn-explicit-align/test.rs b/tests/run-make/extern-fn-explicit-align/test.rs new file mode 100644 index 000000000..846622de3 --- /dev/null +++ b/tests/run-make/extern-fn-explicit-align/test.rs @@ -0,0 +1,89 @@ +// Issue #80127: Passing structs via FFI should work with explicit alignment. + +use std::ffi::{CStr, c_char}; +use std::ptr::null_mut; + +#[repr(C)] +pub struct BoolAndU32 { + pub a: bool, + pub b: u32, +} + +#[repr(C)] +#[repr(align(16))] +pub struct TwoU64s { + pub a: u64, + pub b: u64, +} + +#[repr(C)] +pub struct WrappedU64s { + pub a: TwoU64s +} + +#[repr(C)] +// Even though requesting align 1 can never change the alignment, it still affects the ABI +// on some platforms like i686-windows. +#[repr(align(1))] +pub struct LowerAlign { + pub a: u64, + pub b: u64, +} + +#[repr(C)] +#[repr(packed)] +pub struct Packed { + pub a: u64, + pub b: u64, +} + +#[link(name = "test", kind = "static")] +extern "C" { + fn many_args( + a: *mut (), + b: *mut (), + c: *const c_char, + d: u64, + e: bool, + f: BoolAndU32, + g: *mut (), + h: TwoU64s, + i: *mut (), + j: WrappedU64s, + k: *mut (), + l: LowerAlign, + m: *mut (), + n: Packed, + o: *const c_char, + ) -> i32; +} + +const STRING: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Hello world\0") }; + +fn main() { + let bool_and_u32 = BoolAndU32 { a: true, b: 1337 }; + let two_u64s = TwoU64s { a: 1, b: 2 }; + let wrapped = WrappedU64s { a: TwoU64s { a: 3, b: 4 } }; + let lower = LowerAlign { a: 5, b: 6 }; + let packed = Packed { a: 7, b: 8 }; + let string = STRING; + unsafe { + many_args( + null_mut(), + null_mut(), + null_mut(), + 42, + true, + bool_and_u32, + null_mut(), + two_u64s, + null_mut(), + wrapped, + null_mut(), + lower, + null_mut(), + packed, + string.as_ptr(), + ); + } +} diff --git a/tests/run-make/extern-fn-struct-passing-abi/test.c b/tests/run-make/extern-fn-struct-passing-abi/test.c index 136b07129..2cff776d8 100644 --- a/tests/run-make/extern-fn-struct-passing-abi/test.c +++ b/tests/run-make/extern-fn-struct-passing-abi/test.c @@ -28,6 +28,14 @@ struct Huge { int32_t e; }; +struct Huge64 { + int64_t a; + int64_t b; + int64_t c; + int64_t d; + int64_t e; +}; + struct FloatPoint { double x; double y; @@ -152,6 +160,21 @@ void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c, assert(g.d == 420); } +// System V x86_64 ABI: +// a, b, d, e, f should be byval pointer (on the stack) +// g passed via register (fixes #41375) +// +// i686-windows ABI: +// a, b, d, e, f, g should be byval pointer +void byval_rect_with_many_huge64(struct Huge64 a, struct Huge64 b, struct Huge64 c, + struct Huge64 d, struct Huge64 e, struct Huge64 f, + struct Rect g) { + assert(g.a == 1234); + assert(g.b == 4567); + assert(g.c == 7890); + assert(g.d == 4209); +} + // System V x86_64 & Win64 ABI: // a, b should be in registers // s should be split across 2 integer registers @@ -279,6 +302,19 @@ struct Huge huge_struct(struct Huge s) { return s; } +// System V x86_64 & i686-windows ABI: +// s should be byval pointer +// return should in a hidden sret pointer +struct Huge64 huge64_struct(struct Huge64 s) { + assert(s.a == 1234); + assert(s.b == 1335); + assert(s.c == 1436); + assert(s.d == 1537); + assert(s.e == 1638); + + return s; +} + // System V x86_64 ABI: // p should be in registers // return should be in registers diff --git a/tests/run-make/extern-fn-struct-passing-abi/test.rs b/tests/run-make/extern-fn-struct-passing-abi/test.rs index afe0f52ef..99e079f98 100644 --- a/tests/run-make/extern-fn-struct-passing-abi/test.rs +++ b/tests/run-make/extern-fn-struct-passing-abi/test.rs @@ -36,6 +36,16 @@ struct Huge { e: i32, } +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct Huge64 { + a: i64, + b: i64, + c: i64, + d: i64, + e: i64, +} + #[derive(Clone, Copy, Debug, PartialEq)] #[repr(C)] struct FloatPoint { @@ -79,6 +89,12 @@ extern "C" { fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect); + fn byval_rect_with_many_huge64( + a: Huge64, b: Huge64, c: Huge64, + d: Huge64, e: Huge64, f: Huge64, + g: Rect, + ); + fn split_rect(a: i32, b: i32, s: Rect); fn split_rect_floats(a: f32, b: f32, s: FloatRect); @@ -95,6 +111,8 @@ extern "C" { fn huge_struct(s: Huge) -> Huge; + fn huge64_struct(s: Huge64) -> Huge64; + fn float_point(p: FloatPoint) -> FloatPoint; fn float_one(f: FloatOne) -> FloatOne; @@ -107,6 +125,7 @@ fn main() { let t = BiggerRect { s: s, a: 27834, b: 7657 }; let u = FloatRect { a: 3489, b: 3490, c: 8. }; let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 }; + let w = Huge64 { a: 1234, b: 1335, c: 1436, d: 1537, e: 1638 }; let p = FloatPoint { x: 5., y: -3. }; let f1 = FloatOne { x: 7. }; let i = IntOdd { a: 1, b: 2, c: 3 }; @@ -117,12 +136,14 @@ fn main() { byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u); byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s); byval_rect_with_many_huge(v, v, v, v, v, v, Rect { a: 123, b: 456, c: 789, d: 420 }); + byval_rect_with_many_huge64(w, w, w, w, w, w, Rect { a: 1234, b: 4567, c: 7890, d: 4209 }); split_rect(1, 2, s); split_rect_floats(1., 2., u); split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s); split_and_byval_rect(1, 2, 3, s, s); split_rect(1, 2, s); assert_eq!(huge_struct(v), v); + assert_eq!(huge64_struct(w), w); assert_eq!(split_ret_byval_struct(1, 2, s), s); assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t); assert_eq!(sret_split_struct(1, 2, s), t); diff --git a/tests/run-make/libtest-json/output-default.json b/tests/run-make/libtest-json/output-default.json index ad22b66ed..01710f59e 100644 --- a/tests/run-make/libtest-json/output-default.json +++ b/tests/run-make/libtest-json/output-default.json @@ -2,7 +2,7 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok" } { "type": "test", "event": "started", "name": "d" } diff --git a/tests/run-make/libtest-json/output-stdout-success.json b/tests/run-make/libtest-json/output-stdout-success.json index ec98172eb..878eb6c7c 100644 --- a/tests/run-make/libtest-json/output-stdout-success.json +++ b/tests/run-make/libtest-json/output-stdout-success.json @@ -2,9 +2,9 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } -{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at 'assertion failed: false', f.rs:15:5\n" } +{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" } { "type": "test", "event": "started", "name": "d" } { "type": "test", "name": "d", "event": "ignored", "message": "msg" } { "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME } diff --git a/tests/run-make/libtest-junit/output-default.xml b/tests/run-make/libtest-junit/output-default.xml index d59e07b8a..58a9a2874 100644 --- a/tests/run-make/libtest-junit/output-default.xml +++ b/tests/run-make/libtest-junit/output-default.xml @@ -1 +1 @@ - + diff --git a/tests/run-make/libtest-junit/output-stdout-success.xml b/tests/run-make/libtest-junit/output-stdout-success.xml index 0c300611e..723816a4a 100644 --- a/tests/run-make/libtest-junit/output-stdout-success.xml +++ b/tests/run-make/libtest-junit/output-stdout-success.xml @@ -1 +1 @@ - + diff --git a/tests/run-make/llvm-ident/Makefile b/tests/run-make/llvm-ident/Makefile new file mode 100644 index 000000000..e583e6018 --- /dev/null +++ b/tests/run-make/llvm-ident/Makefile @@ -0,0 +1,19 @@ +include ../tools.mk + +# only-linux + +all: + # `-Ccodegen-units=16 -Copt-level=2` is used here to trigger thin LTO + # across codegen units to test deduplication of the named metadata + # (see `LLVMRustPrepareThinLTOImport` for details). + echo 'fn main(){}' | $(RUSTC) - --emit=link,obj -Csave-temps -Ccodegen-units=16 -Copt-level=2 --target=$(TARGET) + + # `llvm-dis` is used here since `--emit=llvm-ir` does not emit LLVM IR + # for temporary outputs. + "$(LLVM_BIN_DIR)"/llvm-dis $(TMPDIR)/*.bc + + # Check LLVM IR files (including temporary outputs) have `!llvm.ident` + # named metadata, reusing the related codegen test. + set -e; for f in $(TMPDIR)/*.ll; do \ + $(LLVM_FILECHECK) --input-file $$f ../../codegen/llvm-ident.rs; \ + done diff --git a/tests/run-make/mixing-libs/Makefile b/tests/run-make/mixing-libs/Makefile index e8262b284..459db0dfd 100644 --- a/tests/run-make/mixing-libs/Makefile +++ b/tests/run-make/mixing-libs/Makefile @@ -2,9 +2,7 @@ include ../tools.mk all: - $(RUSTC) rlib.rs - $(RUSTC) dylib.rs - $(RUSTC) rlib.rs --crate-type=dylib - $(RUSTC) dylib.rs - $(call REMOVE_DYLIBS,rlib) + $(RUSTC) rlib.rs --crate-type=rlib --crate-type=dylib + $(RUSTC) dylib.rs # no -Cprefer-dynamic so statically linking librlib.rlib + $(call REMOVE_DYLIBS,rlib) # remove librlib.so to test that prog.rs doesn't get confused about the removed dylib version of librlib $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/tests/run-make/no-builtins-attribute/Makefile b/tests/run-make/no-builtins-attribute/Makefile new file mode 100644 index 000000000..0ce95faca --- /dev/null +++ b/tests/run-make/no-builtins-attribute/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +# We want to check if `no-builtins` is also added to the function declarations in the used crate. + +all: + $(RUSTC) no_builtins.rs --emit=link + $(RUSTC) main.rs --emit=llvm-ir + + cat "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck.main.txt diff --git a/tests/run-make/no-builtins-attribute/filecheck.main.txt b/tests/run-make/no-builtins-attribute/filecheck.main.txt new file mode 100644 index 000000000..ecd650bdc --- /dev/null +++ b/tests/run-make/no-builtins-attribute/filecheck.main.txt @@ -0,0 +1,5 @@ +CHECK: declare void @foo() +CHECK-SAME: #[[ATTR_3:[0-9]+]] + +CHECK: attributes #[[ATTR_3]] +CHECK-SAME: no-builtins diff --git a/tests/run-make/no-builtins-attribute/main.rs b/tests/run-make/no-builtins-attribute/main.rs new file mode 100644 index 000000000..77754b37e --- /dev/null +++ b/tests/run-make/no-builtins-attribute/main.rs @@ -0,0 +1,10 @@ +extern crate no_builtins; + +#[no_mangle] +fn call_foo() { + no_builtins::foo(); +} + +fn main() { + call_foo(); +} diff --git a/tests/run-make/no-builtins-attribute/no_builtins.rs b/tests/run-make/no-builtins-attribute/no_builtins.rs new file mode 100644 index 000000000..8ca862d2f --- /dev/null +++ b/tests/run-make/no-builtins-attribute/no_builtins.rs @@ -0,0 +1,5 @@ +#![crate_type = "lib"] +#![no_builtins] + +#[no_mangle] +pub fn foo() {} diff --git a/tests/run-make/no-cdylib-as-rdylib/Makefile b/tests/run-make/no-cdylib-as-rdylib/Makefile new file mode 100644 index 000000000..4d2be0aea --- /dev/null +++ b/tests/run-make/no-cdylib-as-rdylib/Makefile @@ -0,0 +1,16 @@ +# ignore-cross-compile +include ../tools.mk + +# Test that rustc will not attempt to link against a cdylib as if +# it is a rust dylib when an rlib for the same crate is available. +# Previously rustc didn't actually check if any further formats of +# a crate which has been loaded are of the same version and if +# they are actually valid. This caused a cdylib to be interpreted +# as rust dylib as soon as the corresponding rlib was loaded. As +# cdylibs don't export any rust symbols, linking would fail if +# rustc decides to link against the cdylib rather than the rlib. + +all: + $(RUSTC) bar.rs --crate-type=rlib --crate-type=cdylib + $(RUSTC) foo.rs -C prefer-dynamic + $(call RUN,foo) diff --git a/tests/run-make/no-cdylib-as-rdylib/bar.rs b/tests/run-make/no-cdylib-as-rdylib/bar.rs new file mode 100644 index 000000000..c5c0bc606 --- /dev/null +++ b/tests/run-make/no-cdylib-as-rdylib/bar.rs @@ -0,0 +1 @@ +pub fn bar() {} diff --git a/tests/run-make/no-cdylib-as-rdylib/foo.rs b/tests/run-make/no-cdylib-as-rdylib/foo.rs new file mode 100644 index 000000000..8d68535e3 --- /dev/null +++ b/tests/run-make/no-cdylib-as-rdylib/foo.rs @@ -0,0 +1,5 @@ +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/tests/run-make/optimization-remarks-dir-pgo/Makefile b/tests/run-make/optimization-remarks-dir-pgo/Makefile new file mode 100644 index 000000000..3bc3d7d14 --- /dev/null +++ b/tests/run-make/optimization-remarks-dir-pgo/Makefile @@ -0,0 +1,21 @@ +# needs-profiler-support +# ignore-windows-gnu +# ignore-cross-compile + +# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works +# properly. Since we only have GCC on the CI ignore the test for now. + +include ../tools.mk + +PROFILE_DIR=$(TMPDIR)/profiles + +check_hotness: + $(RUSTC) -Cprofile-generate="$(TMPDIR)"/profdata -O foo.rs -o$(TMPDIR)/foo + $(TMPDIR)/foo + "$(LLVM_BIN_DIR)"/llvm-profdata merge \ + -o "$(TMPDIR)"/merged.profdata \ + "$(TMPDIR)"/profdata/*.profraw + $(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata -O foo.rs -Cremark=all -Zremark-dir=$(PROFILE_DIR) + + # Check that PGO hotness is included in the remark files + cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "Hotness" diff --git a/tests/run-make/optimization-remarks-dir-pgo/foo.rs b/tests/run-make/optimization-remarks-dir-pgo/foo.rs new file mode 100644 index 000000000..f7ca18263 --- /dev/null +++ b/tests/run-make/optimization-remarks-dir-pgo/foo.rs @@ -0,0 +1,6 @@ +#[inline(never)] +pub fn bar() {} + +fn main() { + bar(); +} diff --git a/tests/run-make/panic-abort-eh_frame/Makefile b/tests/run-make/panic-abort-eh_frame/Makefile index 1cb7bf575..7020455b7 100644 --- a/tests/run-make/panic-abort-eh_frame/Makefile +++ b/tests/run-make/panic-abort-eh_frame/Makefile @@ -6,5 +6,5 @@ include ../tools.mk all: - $(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort + $(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort --edition 2021 -Z validate-mir objdump --dwarf=frames $(TMPDIR)/foo.o | $(CGREP) -v 'DW_CFA' diff --git a/tests/run-make/panic-abort-eh_frame/foo.rs b/tests/run-make/panic-abort-eh_frame/foo.rs index e18535294..e2274d469 100644 --- a/tests/run-make/panic-abort-eh_frame/foo.rs +++ b/tests/run-make/panic-abort-eh_frame/foo.rs @@ -1,5 +1,13 @@ #![no_std] +use core::future::Future; + +pub struct NeedsDrop; + +impl Drop for NeedsDrop { + fn drop(&mut self) {} +} + #[panic_handler] fn handler(_: &core::panic::PanicInfo<'_>) -> ! { loop {} @@ -8,3 +16,19 @@ fn handler(_: &core::panic::PanicInfo<'_>) -> ! { pub unsafe fn oops(x: *const u32) -> u32 { *x } + +pub async fn foo(_: NeedsDrop) { + async fn bar() {} + bar().await; +} + +pub fn poll_foo(x: &mut core::task::Context<'_>) { + let _g = NeedsDrop; + let mut p = core::pin::pin!(foo(NeedsDrop)); + let _ = p.as_mut().poll(x); + let _ = p.as_mut().poll(x); +} + +pub fn drop_foo() { + drop(foo(NeedsDrop)); +} diff --git a/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt b/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt index e19c78350..2b058faaf 100644 --- a/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt +++ b/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt @@ -2,7 +2,7 @@ CHECK: define void @call_a_bunch_of_functions({{.*}} { # Make sure that indirect call promotion inserted a check against the most # frequently called function. -CHECK: %{{.*}} = icmp eq {{void \(\)\*|ptr}} %{{.*}}, @function_called_always +CHECK: %{{.*}} = icmp eq ptr %{{.*}}, @function_called_always # Check that the call to `function_called_always` was inlined, so that we # directly call `opaque_f1` from the upstream crate. @@ -12,5 +12,5 @@ CHECK: call void @opaque_f1() # Same checks as above, repeated for the trait object case CHECK: define void @call_a_bunch_of_trait_methods({{.*}} -CHECK: %{{.*}} = icmp eq {{void \(\{\}\*\)\*|ptr}} %{{.*}}, {{.*}}@foo +CHECK: %{{.*}} = icmp eq ptr %{{.*}}, {{.*}}@foo CHECK: tail call void @opaque_f2() diff --git a/tests/run-make/pretty-print-with-dep-file/Makefile b/tests/run-make/pretty-print-with-dep-file/Makefile new file mode 100644 index 000000000..fa8089eb6 --- /dev/null +++ b/tests/run-make/pretty-print-with-dep-file/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +all: + $(RUSTC) --emit=dep-info -Zunpretty=expanded with-dep.rs + $(CGREP) "with-dep.rs" < $(TMPDIR)/with-dep.d + -rm $(TMPDIR)/with-dep.d + + $(RUSTC) --emit=dep-info -Zunpretty=normal with-dep.rs + ! test -f $(TMPDIR)/with-dep.d diff --git a/tests/run-make/pretty-print-with-dep-file/with-dep.rs b/tests/run-make/pretty-print-with-dep-file/with-dep.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/tests/run-make/pretty-print-with-dep-file/with-dep.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/print-cfg/Makefile b/tests/run-make/print-cfg/Makefile index 126f5768c..654c303b3 100644 --- a/tests/run-make/print-cfg/Makefile +++ b/tests/run-make/print-cfg/Makefile @@ -2,7 +2,7 @@ include ../tools.mk -all: default +all: default output_to_file $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64 $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc @@ -11,6 +11,23 @@ all: default $(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) target_abi= $(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) eabihf +output_to_file: + # Backend-independent, printed by rustc_driver_impl/src/lib.rs + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt -Z unstable-options + $(CGREP) windows < $(TMPDIR)/cfg.txt + + # Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs + $(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt -Z unstable-options + $(CGREP) dynamic-no-pic < $(TMPDIR)/relocation-models.txt + + # Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs + $(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt -Z unstable-options + $(CGREP) reference-types < $(TMPDIR)/target-features.txt + + # Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp + $(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt -Z unstable-options + $(CGREP) generic < $(TMPDIR)/target-cpus.txt + ifdef IS_WINDOWS default: $(RUSTC) --print cfg | $(CGREP) windows diff --git a/tests/run-make/print-native-static-libs/Makefile b/tests/run-make/print-native-static-libs/Makefile index 98e72d769..a16c8b0f2 100644 --- a/tests/run-make/print-native-static-libs/Makefile +++ b/tests/run-make/print-native-static-libs/Makefile @@ -5,7 +5,7 @@ include ../tools.mk all: $(RUSTC) --crate-type rlib -lbar_cli bar.rs - $(RUSTC) foo.rs -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \ + $(RUSTC) foo.rs -lfoo_cli -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \ | grep 'note: native-static-libs: ' \ | sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt @@ -13,3 +13,7 @@ all: cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs cat $(TMPDIR)/libs.txt | grep -F "bar_cli" cat $(TMPDIR)/libs.txt | grep -F "foo_cli" + + # make sure that foo_cli and glib-2.0 are not consecutively present + cat $(TMPDIR)/libs.txt | grep -Fv "foo_cli -lfoo_cli" + cat $(TMPDIR)/libs.txt | grep -Fv "glib-2.0 -lglib-2.0" diff --git a/tests/run-make/print-native-static-libs/bar.rs b/tests/run-make/print-native-static-libs/bar.rs index a563bbc2a..cd9c1c453 100644 --- a/tests/run-make/print-native-static-libs/bar.rs +++ b/tests/run-make/print-native-static-libs/bar.rs @@ -3,6 +3,7 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 { // Obviously makes no sense but... unsafe { g_free(std::ptr::null_mut()); + g_free2(std::ptr::null_mut()); } left + right } @@ -11,3 +12,8 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 { extern "C" { fn g_free(p: *mut ()); } + +#[link(name = "glib-2.0")] +extern "C" { + fn g_free2(p: *mut ()); +} diff --git a/tests/run-make/rmeta-preferred/Makefile b/tests/run-make/rmeta-preferred/Makefile new file mode 100644 index 000000000..3bf12cced --- /dev/null +++ b/tests/run-make/rmeta-preferred/Makefile @@ -0,0 +1,16 @@ +# ignore-cross-compile +include ../tools.mk + +# Test that using rlibs and rmeta dep crates work together. Specifically, that +# there can be both an rmeta and an rlib file and rustc will prefer the rmeta +# file. +# +# This behavior is simply making sure this doesn't accidentally change; in this +# case we want to make sure that the rlib isn't being used as that would cause +# bugs in -Zbinary-dep-depinfo (see #68298). + +all: + $(RUSTC) rmeta_aux.rs --crate-type=rlib --emit link,metadata + $(RUSTC) lib.rs --crate-type=rlib --emit dep-info -Zbinary-dep-depinfo + $(CGREP) "librmeta_aux.rmeta" < $(TMPDIR)/lib.d + $(CGREP) -v "librmeta_aux.rlib" < $(TMPDIR)/lib.d diff --git a/tests/run-make/rmeta-preferred/lib.rs b/tests/run-make/rmeta-preferred/lib.rs new file mode 100644 index 000000000..d0b81a062 --- /dev/null +++ b/tests/run-make/rmeta-preferred/lib.rs @@ -0,0 +1,14 @@ +// Test that using rlibs and rmeta dep crates work together. Specifically, that +// there can be both an rmeta and an rlib file and rustc will prefer the rmeta +// file. +// +// This behavior is simply making sure this doesn't accidentally change; in this +// case we want to make sure that the rlib isn't being used as that would cause +// bugs in -Zbinary-dep-depinfo (see #68298). + +extern crate rmeta_aux; +use rmeta_aux::Foo; + +pub fn foo() { + let _ = Foo { field: 42 }; +} diff --git a/tests/run-make/rmeta-preferred/rmeta_aux.rs b/tests/run-make/rmeta-preferred/rmeta_aux.rs new file mode 100644 index 000000000..3f7a12b50 --- /dev/null +++ b/tests/run-make/rmeta-preferred/rmeta_aux.rs @@ -0,0 +1,3 @@ +pub struct Foo { + pub field: i32, +} diff --git a/tests/run-make/short-ice/Makefile b/tests/run-make/short-ice/Makefile index 4f33d5902..23006fc09 100644 --- a/tests/run-make/short-ice/Makefile +++ b/tests/run-make/short-ice/Makefile @@ -3,6 +3,7 @@ include ../tools.mk # ignore-windows export RUSTC := $(RUSTC_ORIGINAL) +export LD_LIBRARY_PATH := $(HOST_RPATH_DIR) export TMPDIR := $(TMPDIR) all: diff --git a/tests/run-make/short-ice/check.sh b/tests/run-make/short-ice/check.sh index 96cd8fe86..56babd214 100644 --- a/tests/run-make/short-ice/check.sh +++ b/tests/run-make/short-ice/check.sh @@ -1,5 +1,5 @@ #!/bin/sh - +export RUSTC_ICE=0 RUST_BACKTRACE=1 $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-1.log 2>&1 RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-2.log 2>&1 @@ -28,8 +28,8 @@ echo "rustc_query_count_full: $rustc_query_count_full" ## and marks are in pairs. if [ $short -lt $full ] && [ $begin_count -eq $end_count ] && - [ $(($rustc_query_count + 10)) -lt $rustc_query_count_full ] && - [ $rustc_query_count_full -gt 10 ]; then + [ $(($rustc_query_count + 5)) -lt $rustc_query_count_full ] && + [ $rustc_query_count_full -gt 5 ]; then exit 0 else exit 1 diff --git a/tests/run-make/tools.mk b/tests/run-make/tools.mk index ea06b620c..6121a91e9 100644 --- a/tests/run-make/tools.mk +++ b/tests/run-make/tools.mk @@ -8,7 +8,7 @@ TARGET_RPATH_ENV = \ RUSTC_ORIGINAL := $(RUSTC) BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)' BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)' -RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) +RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) -Ainternal_features RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR) ifdef RUSTC_LINKER RUSTC := $(RUSTC) -Clinker='$(RUSTC_LINKER)' diff --git a/tests/run-make/unknown-mod-stdin/Makefile b/tests/run-make/unknown-mod-stdin/Makefile new file mode 100644 index 000000000..c19317653 --- /dev/null +++ b/tests/run-make/unknown-mod-stdin/Makefile @@ -0,0 +1,15 @@ +# ignore-windows + +include ../tools.mk + +all: + echo 'mod unknown;' | $(RUSTC) --crate-type rlib - >$(TMPDIR)/unknown-mod.stdout 2>$(TMPDIR)/unknown-mod.stderr || echo "failed successfully" + +# Bless like this: RUSTC_BLESS_TEST=1 ./x.py test tests/run-make/unknown-mod-stdin +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/unknown-mod.stdout unknown-mod.stdout + cp "$(TMPDIR)"/unknown-mod.stderr unknown-mod.stderr +else + $(DIFF) unknown-mod.stdout "$(TMPDIR)"/unknown-mod.stdout + $(DIFF) unknown-mod.stderr "$(TMPDIR)"/unknown-mod.stderr +endif diff --git a/tests/run-make/unknown-mod-stdin/unknown-mod.stderr b/tests/run-make/unknown-mod-stdin/unknown-mod.stderr new file mode 100644 index 000000000..d7258fe4f --- /dev/null +++ b/tests/run-make/unknown-mod-stdin/unknown-mod.stderr @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `unknown` + --> :1:1 + | +1 | mod unknown; + | ^^^^^^^^^^^^ + | + = help: to create the module `unknown`, create file "unknown.rs" or "unknown/mod.rs" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff --git a/tests/run-make/unknown-mod-stdin/unknown-mod.stdout b/tests/run-make/unknown-mod-stdin/unknown-mod.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/tests/run-make/wasm-exceptions-nostd/Makefile b/tests/run-make/wasm-exceptions-nostd/Makefile new file mode 100644 index 000000000..34755ec14 --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/Makefile @@ -0,0 +1,12 @@ +include ../tools.mk + +# only-wasm32-bare + +# Add a few command line args to make exceptions work +RUSTC := $(RUSTC) -C llvm-args=-wasm-enable-eh +RUSTC := $(RUSTC) -C target-feature=+exception-handling +RUSTC := $(RUSTC) -C panic=unwind + +all: + $(RUSTC) src/lib.rs --target wasm32-unknown-unknown + $(NODE) verify.mjs $(TMPDIR)/lib.wasm diff --git a/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs b/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs new file mode 100644 index 000000000..572d25330 --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs @@ -0,0 +1,67 @@ +use core::alloc::{GlobalAlloc, Layout}; +use core::cell::UnsafeCell; + +#[global_allocator] +static ALLOCATOR: ArenaAllocator = ArenaAllocator::new(); + +/// Very simple allocator which never deallocates memory +/// +/// Based on the example from +/// https://doc.rust-lang.org/stable/std/alloc/trait.GlobalAlloc.html +pub struct ArenaAllocator { + arena: UnsafeCell, +} + +impl ArenaAllocator { + pub const fn new() -> Self { + Self { + arena: UnsafeCell::new(Arena::new()), + } + } +} + +/// Safe because we are singlethreaded +unsafe impl Sync for ArenaAllocator {} + +unsafe impl GlobalAlloc for ArenaAllocator { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + let arena = &mut *self.arena.get(); + arena.alloc(layout) + } + + unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} +} + +const ARENA_SIZE: usize = 64 * 1024; // more than enough + +#[repr(C, align(4096))] +struct Arena { + buf: [u8; ARENA_SIZE], // aligned at 4096 + allocated: usize, +} + +impl Arena { + pub const fn new() -> Self { + Self { + buf: [0x55; ARENA_SIZE], + allocated: 0, + } + } + + pub unsafe fn alloc(&mut self, layout: Layout) -> *mut u8 { + if layout.align() > 4096 || layout.size() > ARENA_SIZE { + return core::ptr::null_mut(); + } + + let align_minus_one = layout.align() - 1; + let start = (self.allocated + align_minus_one) & !align_minus_one; // round up + let new_cursor = start + layout.size(); + + if new_cursor >= ARENA_SIZE { + return core::ptr::null_mut(); + } + + self.allocated = new_cursor; + self.buf.as_mut_ptr().add(start) + } +} diff --git a/tests/run-make/wasm-exceptions-nostd/src/lib.rs b/tests/run-make/wasm-exceptions-nostd/src/lib.rs new file mode 100644 index 000000000..7049d2fd9 --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/src/lib.rs @@ -0,0 +1,60 @@ +#![no_std] +#![crate_type = "cdylib"] + +// Allow a few unstable features because we create a panic +// runtime for native wasm exceptions from scratch + +#![feature(core_intrinsics)] +#![feature(lang_items)] +#![feature(link_llvm_intrinsics)] +#![feature(panic_info_message)] + +extern crate alloc; + +/// This module allows us to use `Box`, `String`, ... even in no-std +mod arena_alloc; + +/// This module allows logging text, even in no-std +mod logging; + +/// This module allows exceptions, even in no-std +#[cfg(target_arch = "wasm32")] +mod panicking; + +use alloc::boxed::Box; +use alloc::string::String; + +struct LogOnDrop; + +impl Drop for LogOnDrop { + fn drop(&mut self) { + logging::log_str("Dropped"); + } +} + +#[allow(unreachable_code)] +#[allow(unconditional_panic)] +#[no_mangle] +pub extern "C" fn start() -> usize { + let data = 0x1234usize as *mut u8; // Something to recognize + + unsafe { + core::intrinsics::r#try(|data: *mut u8| { + let _log_on_drop = LogOnDrop; + + logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data)); + let x = [12]; + let _ = x[4]; // should panic + + logging::log_str("This line should not be visible! :("); + }, data, |data, exception| { + let exception = *Box::from_raw(exception as *mut String); + logging::log_str("Caught something!"); + logging::log_str(&alloc::format!(" data : {:?}", data)); + logging::log_str(&alloc::format!(" exception: {:?}", exception)); + }); + } + + logging::log_str("This program terminates correctly."); + 0 +} diff --git a/tests/run-make/wasm-exceptions-nostd/src/logging.rs b/tests/run-make/wasm-exceptions-nostd/src/logging.rs new file mode 100644 index 000000000..569d03ec8 --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/src/logging.rs @@ -0,0 +1,9 @@ +extern "C" { + fn __log_utf8(ptr: *const u8, size: usize); +} + +pub fn log_str(text: &str) { + unsafe { + __log_utf8(text.as_ptr(), text.len()); + } +} diff --git a/tests/run-make/wasm-exceptions-nostd/src/panicking.rs b/tests/run-make/wasm-exceptions-nostd/src/panicking.rs new file mode 100644 index 000000000..4a8923fd4 --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/src/panicking.rs @@ -0,0 +1,29 @@ +#[lang = "eh_personality"] +fn eh_personality() {} + +mod internal { + extern "C" { + #[link_name = "llvm.wasm.throw"] + pub fn wasm_throw(tag: i32, ptr: *mut u8) -> !; + } +} + +unsafe fn wasm_throw(ptr: *mut u8) -> ! { + internal::wasm_throw(0, ptr); +} + +#[panic_handler] +fn panic_handler(info: &core::panic::PanicInfo<'_>) -> ! { + use alloc::boxed::Box; + use alloc::string::ToString; + + let msg = info + .message() + .map(|msg| msg.to_string()) + .unwrap_or("(no message)".to_string()); + let exception = Box::new(msg.to_string()); + unsafe { + let exception_raw = Box::into_raw(exception); + wasm_throw(exception_raw as *mut u8); + } +} diff --git a/tests/run-make/wasm-exceptions-nostd/verify.mjs b/tests/run-make/wasm-exceptions-nostd/verify.mjs new file mode 100644 index 000000000..e6c44d89d --- /dev/null +++ b/tests/run-make/wasm-exceptions-nostd/verify.mjs @@ -0,0 +1,75 @@ +import fs from 'fs'; + +const dec = new TextDecoder("utf-8"); + +if (process.argv.length != 3) { + console.log("Usage: node verify.mjs "); + process.exit(0); +} + +const wasmfile = process.argv[2]; +if (!fs.existsSync(wasmfile)) { + console.log("Error: File not found:", wasmfile); + process.exit(1); +} + +const wasmBuffer = fs.readFileSync(wasmfile); + +async function main() { + + let memory = new ArrayBuffer(0) // will be changed after instantiate + + const captured_output = []; + + const imports = { + env: { + __log_utf8: (ptr, size) => { + const str = dec.decode(new DataView(memory, ptr, size)); + captured_output.push(str); + console.log(str); + } + } + }; + + const wasmModule = await WebAssembly.instantiate(wasmBuffer, imports); + memory = wasmModule.instance.exports.memory.buffer; + + const start = wasmModule.instance.exports.start; + const return_code = start(); + + console.log("Return-Code:", return_code); + + if (return_code !== 0) { + console.error("Expected return code 0"); + process.exit(return_code); + } + + const expected_output = [ + '`r#try` called with ptr 0x1234', + 'Dropped', + 'Caught something!', + ' data : 0x1234', + ' exception: "index out of bounds: the len is 1 but the index is 4"', + 'This program terminates correctly.', + ]; + + assert_equal(captured_output, expected_output); +} + +function assert_equal(captured_output, expected_output) { + if (captured_output.length != expected_output.length) { + console.error("Unexpected number of output lines. Got", captured_output.length, "but expected", expected_output.length); + process.exit(1); // exit with error + } + + for (let idx = 0; idx < expected_output.length; ++idx) { + if (captured_output[idx] !== expected_output[idx]) { + console.error("Unexpected output"); + console.error("[got] ", captured_output[idx]); + console.error("[expected]", expected_output[idx]); + process.exit(2); // exit with error + } + } +} + +await main(); \ No newline at end of file diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml index e9b772969..30b83f0da 100644 --- a/tests/rustdoc-gui/anchors.goml +++ b/tests/rustdoc-gui/anchors.goml @@ -17,34 +17,34 @@ define-function: ( assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|}) assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|}) assert-css: ( - ".rightside .srclink", + ".rightside a.src", {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, ALL, ) compare-elements-css: ( - ".rightside .srclink", - ".rightside.srclink", + ".rightside a.src", + "a.rightside.src", ["color", "text-decoration"], ) compare-elements-css: ( - ".main-heading .srclink", - ".rightside.srclink", + ".main-heading a.src", + "a.rightside.src", ["color", "text-decoration"], ) - move-cursor-to: ".main-heading .srclink" + move-cursor-to: ".main-heading a.src" assert-css: ( - ".main-heading .srclink", + ".main-heading a.src", {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, ) - move-cursor-to: ".impl-items .rightside .srclink" + move-cursor-to: ".impl-items .rightside a.src" assert-css: ( - ".impl-items .rightside .srclink", + ".impl-items .rightside a.src", {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, ) - move-cursor-to: ".impl-items .rightside.srclink" + move-cursor-to: ".impl-items a.rightside.src" assert-css: ( - ".impl-items .rightside.srclink", + ".impl-items a.rightside.src", {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, ) diff --git a/tests/rustdoc-gui/basic-code.goml b/tests/rustdoc-gui/basic-code.goml index e372f7119..22ac53161 100644 --- a/tests/rustdoc-gui/basic-code.goml +++ b/tests/rustdoc-gui/basic-code.goml @@ -1,6 +1,6 @@ // Small test to ensure the "src-line-numbers" element is only present once on // the page. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -click: ".srclink" +click: "a.src" wait-for: ".src-line-numbers" assert-count: (".src-line-numbers", 1) diff --git a/tests/rustdoc-gui/code-sidebar-toggle.goml b/tests/rustdoc-gui/code-sidebar-toggle.goml index 28c3712f3..d1efa45dc 100644 --- a/tests/rustdoc-gui/code-sidebar-toggle.goml +++ b/tests/rustdoc-gui/code-sidebar-toggle.goml @@ -1,7 +1,7 @@ // This test checks that the source code pages sidebar toggle is working as expected. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -click: ".srclink" +click: "a.src" wait-for: "#src-sidebar-toggle" click: "#src-sidebar-toggle" expect-failure: true -assert-css: ("#source-sidebar", { "left": "-300px" }) +assert-css: ("#src-sidebar", { "left": "-300px" }) diff --git a/tests/rustdoc-gui/headings.goml b/tests/rustdoc-gui/headings.goml index 089e2203a..102b699b1 100644 --- a/tests/rustdoc-gui/headings.goml +++ b/tests/rustdoc-gui/headings.goml @@ -194,27 +194,27 @@ call-function: ( "check-colors", { "theme": "ayu", - "heading_color": "rgb(255, 255, 255)", - "small_heading_color": "rgb(197, 197, 197)", - "heading_border_color": "rgb(92, 103, 115)", + "heading_color": "#fff", + "small_heading_color": "#c5c5c5", + "heading_border_color": "#5c6773", }, ) call-function: ( "check-colors", { "theme": "dark", - "heading_color": "rgb(221, 221, 221)", - "small_heading_color": "rgb(221, 221, 221)", - "heading_border_color": "rgb(210, 210, 210)", + "heading_color": "#ddd", + "small_heading_color": "#ddd", + "heading_border_color": "#d2d2d2", }, ) call-function: ( "check-colors", { "theme": "light", - "heading_color": "rgb(0, 0, 0)", - "small_heading_color": "rgb(0, 0, 0)", - "heading_border_color": "rgb(221, 221, 221)", + "heading_color": "black", + "small_heading_color": "black", + "heading_border_color": "#ddd", }, ) @@ -224,7 +224,7 @@ define-function: ( block { set-local-storage: {"rustdoc-theme": |theme|} reload: - assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) + assert-css: (".since", {"color": "#808080"}, ALL) }, ) diff --git a/tests/rustdoc-gui/item-decl-colors.goml b/tests/rustdoc-gui/item-decl-colors.goml index 5732dd8ee..a77784273 100644 --- a/tests/rustdoc-gui/item-decl-colors.goml +++ b/tests/rustdoc-gui/item-decl-colors.goml @@ -20,6 +20,7 @@ define-function: ( block { go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html" show-text: true + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL) @@ -40,41 +41,41 @@ call-function: ( "check-colors", { "theme": "ayu", - "attr_color": "rgb(153, 153, 153)", - "trait_color": "rgb(57, 175, 215)", - "struct_color": "rgb(255, 160, 165)", - "enum_color": "rgb(255, 160, 165)", - "primitive_color": "rgb(255, 160, 165)", - "constant_color": "rgb(57, 175, 215)", - "fn_color": "rgb(253, 214, 135)", - "assoc_type_color": "rgb(57, 175, 215)", + "attr_color": "#999", + "trait_color": "#39afd7", + "struct_color": "#ffa0a5", + "enum_color": "#ffa0a5", + "primitive_color": "#ffa0a5", + "constant_color": "#39afd7", + "fn_color": "#fdd687", + "assoc_type_color": "#39afd7", }, ) call-function: ( "check-colors", { "theme": "dark", - "attr_color": "rgb(153, 153, 153)", - "trait_color": "rgb(183, 140, 242)", - "struct_color": "rgb(45, 191, 184)", - "enum_color": "rgb(45, 191, 184)", - "primitive_color": "rgb(45, 191, 184)", - "constant_color": "rgb(210, 153, 29)", - "fn_color": "rgb(43, 171, 99)", - "assoc_type_color": "rgb(210, 153, 29)", + "attr_color": "#999", + "trait_color": "#b78cf2", + "struct_color": "#2dbfb8", + "enum_color": "#2dbfb8", + "primitive_color": "#2dbfb8", + "constant_color": "#d2991d", + "fn_color": "#2bab63", + "assoc_type_color": "#d2991d", }, ) call-function: ( "check-colors", { "theme": "light", - "attr_color": "rgb(153, 153, 153)", - "trait_color": "rgb(110, 79, 201)", - "struct_color": "rgb(173, 55, 138)", - "enum_color": "rgb(173, 55, 138)", - "primitive_color": "rgb(173, 55, 138)", - "constant_color": "rgb(56, 115, 173)", - "fn_color": "rgb(173, 124, 55)", - "assoc_type_color": "rgb(56, 115, 173)", + "attr_color": "#999", + "trait_color": "#6e4fc9", + "struct_color": "#ad378a", + "enum_color": "#ad378a", + "primitive_color": "#ad378a", + "constant_color": "#3873ad", + "fn_color": "#ad7c37", + "assoc_type_color": "#3873ad", }, ) diff --git a/tests/rustdoc-gui/jump-to-def-background.goml b/tests/rustdoc-gui/jump-to-def-background.goml index 6adc36b0e..fa7ed3586 100644 --- a/tests/rustdoc-gui/jump-to-def-background.goml +++ b/tests/rustdoc-gui/jump-to-def-background.goml @@ -1,4 +1,4 @@ -// We check the background color on the jump to definition links in the source code page. +// We check the background color on the jump to definition links in the src code page. go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" define-function: ( @@ -10,7 +10,7 @@ define-function: ( // We reload the page so the local storage settings are being used. reload: assert-css: ( - "body.source .example-wrap pre.rust a", + "body.src .example-wrap pre.rust a", {"background-color": |background_color|}, ALL, ) diff --git a/tests/rustdoc-gui/label-next-to-symbol.goml b/tests/rustdoc-gui/label-next-to-symbol.goml index eb603d6c6..d23f9114d 100644 --- a/tests/rustdoc-gui/label-next-to-symbol.goml +++ b/tests/rustdoc-gui/label-next-to-symbol.goml @@ -10,11 +10,11 @@ assert: (".stab.portability") // make sure that deprecated and portability have the right colors assert-css: ( ".item-table .item-name .stab.deprecated", - { "background-color": "rgb(255, 245, 214)" }, + { "background-color": "#fff5d6" }, ) assert-css: ( ".item-table .item-name .stab.portability", - { "background-color": "rgb(255, 245, 214)" }, + { "background-color": "#fff5d6" }, ) // table like view diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml index 2ee4bce10..0789d785f 100644 --- a/tests/rustdoc-gui/links-color.goml +++ b/tests/rustdoc-gui/links-color.goml @@ -46,53 +46,53 @@ call-function: ( "check-colors", { "theme": "ayu", - "mod": "rgb(57, 175, 215)", - "macro": "rgb(163, 122, 204)", - "struct": "rgb(255, 160, 165)", - "enum": "rgb(255, 160, 165)", - "trait": "rgb(57, 175, 215)", - "fn": "rgb(253, 214, 135)", - "type": "rgb(255, 160, 165)", - "union": "rgb(255, 160, 165)", - "keyword": "rgb(57, 175, 215)", - "sidebar": "rgb(83, 177, 219)", - "sidebar_current": "rgb(255, 180, 76)", - "sidebar_current_background": "rgba(0, 0, 0, 0)", + "mod": "#39afd7", + "macro": "#a37acc", + "struct": "#ffa0a5", + "enum": "#ffa0a5", + "trait": "#39afd7", + "fn": "#fdd687", + "type": "#ffa0a5", + "union": "#ffa0a5", + "keyword": "#39afd7", + "sidebar": "#53b1db", + "sidebar_current": "#ffb44c", + "sidebar_current_background": "transparent", }, ) call-function: ( "check-colors", { "theme": "dark", - "mod": "rgb(210, 153, 29)", - "macro": "rgb(9, 189, 0)", - "struct": "rgb(45, 191, 184)", - "enum": "rgb(45, 191, 184)", - "trait": "rgb(183, 140, 242)", - "fn": "rgb(43, 171, 99)", - "type": "rgb(45, 191, 184)", - "union": "rgb(45, 191, 184)", - "keyword": "rgb(210, 153, 29)", - "sidebar": "rgb(253, 191, 53)", - "sidebar_current": "rgb(253, 191, 53)", - "sidebar_current_background": "rgb(68, 68, 68)", + "mod": "#d2991d", + "macro": "#09bd00", + "struct": "#2dbfb8", + "enum": "#2dbfb8", + "trait": "#b78cf2", + "fn": "#2bab63", + "type": "#2dbfb8", + "union": "#2dbfb8", + "keyword": "#d2991d", + "sidebar": "#fdbf35", + "sidebar_current": "#fdbf35", + "sidebar_current_background": "#444", }, ) call-function: ( "check-colors", { "theme": "light", - "mod": "rgb(56, 115, 173)", - "macro": "rgb(6, 128, 0)", - "struct": "rgb(173, 55, 138)", - "enum": "rgb(173, 55, 138)", - "trait": "rgb(110, 79, 201)", - "fn": "rgb(173, 124, 55)", - "type": "rgb(173, 55, 138)", - "union": "rgb(173, 55, 138)", - "keyword": "rgb(56, 115, 173)", - "sidebar": "rgb(53, 109, 164)", - "sidebar_current": "rgb(53, 109, 164)", - "sidebar_current_background": "rgb(255, 255, 255)", + "mod": "#3873ad", + "macro": "#068000", + "struct": "#ad378a", + "enum": "#ad378a", + "trait": "#6e4fc9", + "fn": "#ad7c37", + "type": "#ad378a", + "union": "#ad378a", + "keyword": "#3873ad", + "sidebar": "#356da4", + "sidebar_current": "#356da4", + "sidebar_current_background": "#fff", }, ) diff --git a/tests/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml index 4bdf31ecb..404e57403 100644 --- a/tests/rustdoc-gui/pocket-menu.goml +++ b/tests/rustdoc-gui/pocket-menu.goml @@ -29,52 +29,39 @@ click: "#help-button" assert-css: ("#help-button .popover", {"display": "none"}) assert-css: ("#settings-menu .popover", {"display": "none"}) -// We check the borders color now: - -// Ayu theme -set-local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -click: "#help-button" -assert-css: ( - "#help-button .popover", - {"display": "block", "border-color": "rgb(92, 103, 115)"}, -) -compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) -compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) - -// Dark theme -set-local-storage: { - "rustdoc-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: +define-function: ( + "check-popover-colors", + (theme, border_color), + block { + set-local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: -click: "#help-button" -assert-css: ( - "#help-button .popover", - {"display": "block", "border-color": "rgb(224, 224, 224)"}, + click: "#help-button" + assert-css: ( + "#help-button .popover", + {"display": "block", "border-color": |border_color|}, + ) + compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) + compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) + } ) -compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) -compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) - -// Light theme -set-local-storage: { - "rustdoc-theme": "light", - "rustdoc-use-system-theme": "false", -} -reload: -click: "#help-button" -assert-css: ( - "#help-button .popover", - {"display": "block", "border-color": "rgb(224, 224, 224)"}, -) -compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) -compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) +// We check the borders color now: +call-function: ("check-popover-colors", { + "theme": "ayu", + "border_color": "#5c6773", +}) +call-function: ("check-popover-colors", { + "theme": "dark", + "border_color": "#e0e0e0", +}) +call-function: ("check-popover-colors", { + "theme": "light", + "border_color": "#e0e0e0", +}) // Opening the mobile sidebar should close the settings popover. set-window-size: (650, 600) diff --git a/tests/rustdoc-gui/run-on-hover.goml b/tests/rustdoc-gui/run-on-hover.goml index b5fc49eac..1f87febce 100644 --- a/tests/rustdoc-gui/run-on-hover.goml +++ b/tests/rustdoc-gui/run-on-hover.goml @@ -33,22 +33,22 @@ define-function: ( call-function: ("check-run-button", { "theme": "ayu", - "color": "rgb(120, 135, 151)", + "color": "#788797", "background": "rgba(57, 175, 215, 0.09)", - "hover_color": "rgb(197, 197, 197)", + "hover_color": "#c5c5c5", "hover_background": "rgba(57, 175, 215, 0.37)", }) call-function: ("check-run-button", { "theme": "dark", - "color": "rgb(222, 222, 222)", + "color": "#dedede", "background": "rgba(78, 139, 202, 0.2)", - "hover_color": "rgb(222, 222, 222)", + "hover_color": "#dedede", "hover_background": "rgb(78, 139, 202)", }) call-function: ("check-run-button", { "theme": "light", - "color": "rgb(245, 245, 245)", + "color": "#f5f5f5", "background": "rgba(78, 139, 202, 0.2)", - "hover_color": "rgb(245, 245, 245)", + "hover_color": "#f5f5f5", "hover_background": "rgb(78, 139, 202)", }) diff --git a/tests/rustdoc-gui/rust-logo.goml b/tests/rustdoc-gui/rust-logo.goml index 640ed152b..cd453aea2 100644 --- a/tests/rustdoc-gui/rust-logo.goml +++ b/tests/rustdoc-gui/rust-logo.goml @@ -33,20 +33,20 @@ call-function: ( "check-logo", { "theme": "ayu", - "filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) " + - "drop-shadow(rgb(255, 255, 255) 0px 1px 0px) " + - "drop-shadow(rgb(255, 255, 255) -1px 0px 0px) " + - "drop-shadow(rgb(255, 255, 255) 0px -1px 0px)", + "filter": "drop-shadow(#fff 1px 0px 0px) " + + "drop-shadow(#fff 0px 1px 0px) " + + "drop-shadow(#fff -1px 0px 0px) " + + "drop-shadow(#fff 0px -1px 0px)", }, ) call-function: ( "check-logo", { "theme": "dark", - "filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) " + - "drop-shadow(rgb(255, 255, 255) 0px 1px 0px) " + - "drop-shadow(rgb(255, 255, 255) -1px 0px 0px) " + - "drop-shadow(rgb(255, 255, 255) 0px -1px 0px)", + "filter": "drop-shadow(#fff 1px 0px 0px) " + + "drop-shadow(#fff 0px 1px 0px) " + + "drop-shadow(#fff -1px 0px 0px) " + + "drop-shadow(#fff 0px -1px 0px)", }, ) call-function: ( diff --git a/tests/rustdoc-gui/scrape-examples-toggle.goml b/tests/rustdoc-gui/scrape-examples-toggle.goml index 9cec6d2bb..f742b3186 100644 --- a/tests/rustdoc-gui/scrape-examples-toggle.goml +++ b/tests/rustdoc-gui/scrape-examples-toggle.goml @@ -28,18 +28,18 @@ define-function: ( call-function: ("check-color", { "theme": "ayu", - "toggle_line_color": "rgb(153, 153, 153)", - "toggle_line_hover_color": "rgb(197, 197, 197)", + "toggle_line_color": "#999", + "toggle_line_hover_color": "#c5c5c5", }) call-function: ("check-color", { "theme": "dark", - "toggle_line_color": "rgb(153, 153, 153)", - "toggle_line_hover_color": "rgb(197, 197, 197)", + "toggle_line_color": "#999", + "toggle_line_hover_color": "#c5c5c5", }) call-function: ("check-color", { "theme": "light", - "toggle_line_color": "rgb(204, 204, 204)", - "toggle_line_hover_color": "rgb(153, 153, 153)", + "toggle_line_color": "#ccc", + "toggle_line_hover_color": "#999", }) // Toggling all docs will close additional examples diff --git a/tests/rustdoc-gui/search-error.goml b/tests/rustdoc-gui/search-error.goml index d21905e90..70aeda176 100644 --- a/tests/rustdoc-gui/search-error.goml +++ b/tests/rustdoc-gui/search-error.goml @@ -20,20 +20,20 @@ call-function: ( "check-colors", { "theme": "ayu", - "error_background": "rgb(79, 76, 76)", + "error_background": "#4f4c4c", }, ) call-function: ( "check-colors", { "theme": "dark", - "error_background": "rgb(72, 72, 72)", + "error_background": "#484848", }, ) call-function: ( "check-colors", { "theme": "light", - "error_background": "rgb(208, 204, 204)", + "error_background": "#d0cccc", }, ) diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index 83c698090..a4e223648 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -2,262 +2,138 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true -// Ayu theme -set-local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - "color": "rgb(255, 255, 255)", - }, -) -focus: ".search-input" -// Nothing should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - "color": "rgb(255, 255, 255)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(197, 197, 197)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(255, 255, 255)", - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(197, 197, 197)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(255, 255, 255)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(20, 25, 32)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(57, 175, 215)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(197, 197, 197)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(197, 197, 197)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(20, 25, 32)", - }, -) - -// Dark theme -set-local-storage: { - "rustdoc-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - }, -) -focus: ".search-input" -// Only "border-color" should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(0, 141, 253)", - "background-color": "rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(221, 221, 221)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(221, 221, 221)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(255, 185, 0)", - "background-color": "rgb(240, 240, 240)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(210, 153, 29)", +define-function: ( + "check-search-colors", + ( + theme, border, background, search_input_color, search_input_border_focus, + menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color, + ), + block { + set-local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: + assert-css: ( + ".search-input", + { + "border-color": |border|, + "background-color": |background|, + "color": |search_input_color|, + }, + ) + // Focus on search input. + focus: ".search-input" + assert-css: ( + ".search-input", + { + "border-color": |search_input_border_focus|, + "background-color": |background|, + "color": |search_input_color|, + }, + ) + assert-css: ( + "#help-button", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#help-button > a", + { + "color": |menu_button_a_color|, + "border-color": |border|, + "background-color": |background|, + }, + ) + // Hover help button. + move-cursor-to: "#help-button" + assert-css: ( + "#help-button:hover", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#help-button > a", + { + "color": |menu_button_a_color|, + "border-color": |menu_button_a_border_hover|, + "background-color": |background|, + }, + ) + // Link color inside + click: "#help-button" + assert-css: ( + "#help a", + { + "color": |menu_a_color|, + }, + ) + assert-css: ( + "#settings-menu", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#settings-menu > a", + { + "color": |menu_button_a_color|, + "border-color": |border|, + "background-color": |background|, + }, + ) + // Hover settings menu. + move-cursor-to: "#settings-menu" + assert-css: ( + "#settings-menu:hover", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#settings-menu:hover > a", + { + "color": |menu_button_a_color|, + "border-color": |menu_button_a_border_hover|, + "background-color": |background|, + }, + ) }, ) -assert-css: ( - "#settings-menu", - {"border-color": "rgb(221, 221, 221)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(221, 221, 221)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(255, 185, 0)", - "background-color": "rgb(240, 240, 240)", - }, -) - -// Light theme -set-local-storage: { - "rustdoc-theme": "light", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - }, -) -focus: ".search-input" -// Nothing should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(102, 175, 233)", - "background-color": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(0, 0, 0)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(0, 0, 0)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(113, 113, 113)", - "background-color": "rgb(255, 255, 255)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(56, 115, 173)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(0, 0, 0)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(0, 0, 0)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(113, 113, 113)", - "background-color": "rgb(255, 255, 255)", - }, +call-function: ( + "check-search-colors", + { + "theme": "ayu", + "border": "#5c6773", + "background": "#141920", + "search_input_color": "#fff", + "search_input_border_focus": "#5c6773", + "menu_button_border": "#c5c5c5", + "menu_button_a_color": "#fff", + "menu_button_a_border_hover": "#e0e0e0", + "menu_a_color": "#39afd7", + } +) +call-function: ( + "check-search-colors", + { + "theme": "dark", + "border": "#e0e0e0", + "background": "#f0f0f0", + "search_input_color": "#111", + "search_input_border_focus": "#008dfd", + "menu_button_border": "#ddd", + "menu_button_a_color": "#000", + "menu_button_a_border_hover": "#ffb900", + "menu_a_color": "#d2991d", + } +) +call-function: ( + "check-search-colors", + { + "theme": "light", + "border": "#e0e0e0", + "background": "#fff", + "search_input_color": "#000", + "search_input_border_focus": "#66afe9", + "menu_button_border": "#000", + "menu_button_a_color": "#000", + "menu_button_a_border_hover": "#717171", + "menu_a_color": "#3873ad", + } ) diff --git a/tests/rustdoc-gui/search-reexport.goml b/tests/rustdoc-gui/search-reexport.goml index 6ea6d53e2..b9d2c8f15 100644 --- a/tests/rustdoc-gui/search-reexport.goml +++ b/tests/rustdoc-gui/search-reexport.goml @@ -26,7 +26,7 @@ write: (".search-input", "AliasForTheStdReexport") wait-for: "//a[@class='result-import']" assert-text: ( "a.result-import .result-name", - "AliasForTheStdReexport - see re-export test_docs::TheStdReexport", + "re-export AliasForTheStdReexport - see test_docs::TheStdReexport", ) // Same thing again, we click on it to ensure the background is once again set as expected. click: "//a[@class='result-import']" diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index 7a7785fd9..f9f81c5ba 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -368,8 +368,8 @@ define-function: ( // Waiting for the search results to appear... wait-for: "#search-tabs" // Checking that the colors for the alias element are the ones expected. - assert-css: (".result-name > .alias", {"color": |alias|}) - assert-css: (".result-name > .alias > .grey", {"color": |grey|}) + assert-css: (".result-name .path .alias", {"color": |alias|}) + assert-css: (".result-name .path .alias > .grey", {"color": |grey|}) // Leave the search results to prevent reloading with an already filled search input. press-key: "Escape" }, diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml index 2223598f0..7bbde3ec2 100644 --- a/tests/rustdoc-gui/search-tab.goml +++ b/tests/rustdoc-gui/search-tab.goml @@ -40,37 +40,37 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "background": "rgba(0, 0, 0, 0)", - "background_selected": "rgb(20, 25, 32)", - "background_hover": "rgba(0, 0, 0, 0)", - "border_bottom": "0px none rgb(197, 197, 197)", - "border_bottom_selected": "1px solid rgb(255, 180, 76)", + "background": "transparent", + "background_selected": "#141920", + "background_hover": "transparent", + "border_bottom": "0px none #c5c5c5", + "border_bottom_selected": "1px solid #ffb44c", "border_bottom_hover": "1px solid rgba(242, 151, 24, 0.3)", - "border_top": "0px none rgb(197, 197, 197)", - "border_top_selected": "0px none rgb(197, 197, 197)", - "border_top_hover": "0px none rgb(197, 197, 197)", + "border_top": "0px none #c5c5c5", + "border_top_selected": "0px none #c5c5c5", + "border_top_hover": "0px none #c5c5c5", }) call-function: ("check-colors", { "theme": "dark", - "background": "rgb(37, 37, 37)", - "background_selected": "rgb(53, 53, 53)", - "background_hover": "rgb(53, 53, 53)", - "border_bottom": "0px none rgb(221, 221, 221)", - "border_bottom_selected": "0px none rgb(221, 221, 221)", - "border_bottom_hover": "0px none rgb(221, 221, 221)", - "border_top": "2px solid rgb(37, 37, 37)", - "border_top_selected": "2px solid rgb(0, 137, 255)", - "border_top_hover": "2px solid rgb(0, 137, 255)", + "background": "#252525", + "background_selected": "#353535", + "background_hover": "#353535", + "border_bottom": "0px none #ddd", + "border_bottom_selected": "0px none #ddd", + "border_bottom_hover": "0px none #ddd", + "border_top": "2px solid #252525", + "border_top_selected": "2px solid #0089ff", + "border_top_hover": "2px solid #0089ff", }) call-function: ("check-colors", { "theme": "light", - "background": "rgb(230, 230, 230)", - "background_selected": "rgb(255, 255, 255)", - "background_hover": "rgb(255, 255, 255)", - "border_bottom": "0px none rgb(0, 0, 0)", - "border_bottom_selected": "0px none rgb(0, 0, 0)", - "border_bottom_hover": "0px none rgb(0, 0, 0)", - "border_top": "2px solid rgb(230, 230, 230)", - "border_top_selected": "2px solid rgb(0, 137, 255)", - "border_top_hover": "2px solid rgb(0, 137, 255)", + "background": "#e6e6e6", + "background_selected": "#fff", + "background_hover": "#fff", + "border_bottom": "0px none #000", + "border_bottom_selected": "0px none #000", + "border_bottom_hover": "0px none #000", + "border_top": "2px solid #e6e6e6", + "border_top_selected": "2px solid #0089ff", + "border_top_hover": "2px solid #0089ff", }) diff --git a/tests/rustdoc-gui/sidebar-links-color.goml b/tests/rustdoc-gui/sidebar-links-color.goml index cec1a7999..079d582a5 100644 --- a/tests/rustdoc-gui/sidebar-links-color.goml +++ b/tests/rustdoc-gui/sidebar-links-color.goml @@ -92,80 +92,80 @@ call-function: ( "check-colors", { "theme": "ayu", - "struct": "rgb(83, 177, 219)", - "struct_hover": "rgb(255, 180, 76)", - "struct_hover_background": "rgba(0, 0, 0, 0)", - "enum": "rgb(83, 177, 219)", - "enum_hover": "rgb(255, 180, 76)", - "enum_hover_background": "rgba(0, 0, 0, 0)", - "union": "rgb(83, 177, 219)", - "union_hover": "rgb(255, 180, 76)", - "union_hover_background": "rgba(0, 0, 0, 0)", - "trait": "rgb(83, 177, 219)", - "trait_hover": "rgb(255, 180, 76)", - "trait_hover_background": "rgba(0, 0, 0, 0)", - "fn": "rgb(83, 177, 219)", - "fn_hover": "rgb(255, 180, 76)", - "fn_hover_background": "rgba(0, 0, 0, 0)", - "type": "rgb(83, 177, 219)", - "type_hover": "rgb(255, 180, 76)", - "type_hover_background": "rgba(0, 0, 0, 0)", - "keyword": "rgb(83, 177, 219)", - "keyword_hover": "rgb(255, 180, 76)", - "keyword_hover_background": "rgba(0, 0, 0, 0)", + "struct": "#53b1db", + "struct_hover": "#ffb44c", + "struct_hover_background": "transparent", + "enum": "#53b1db", + "enum_hover": "#ffb44c", + "enum_hover_background": "transparent", + "union": "#53b1db", + "union_hover": "#ffb44c", + "union_hover_background": "transparent", + "trait": "#53b1db", + "trait_hover": "#ffb44c", + "trait_hover_background": "transparent", + "fn": "#53b1db", + "fn_hover": "#ffb44c", + "fn_hover_background": "transparent", + "type": "#53b1db", + "type_hover": "#ffb44c", + "type_hover_background": "transparent", + "keyword": "#53b1db", + "keyword_hover": "#ffb44c", + "keyword_hover_background": "transparent", } ) call-function: ( "check-colors", { "theme": "dark", - "struct": "rgb(253, 191, 53)", - "struct_hover": "rgb(253, 191, 53)", - "struct_hover_background": "rgb(68, 68, 68)", - "enum": "rgb(253, 191, 53)", - "enum_hover": "rgb(253, 191, 53)", - "enum_hover_background": "rgb(68, 68, 68)", - "union": "rgb(253, 191, 53)", - "union_hover": "rgb(253, 191, 53)", - "union_hover_background": "rgb(68, 68, 68)", - "trait": "rgb(253, 191, 53)", - "trait_hover": "rgb(253, 191, 53)", - "trait_hover_background": "rgb(68, 68, 68)", - "fn": "rgb(253, 191, 53)", - "fn_hover": "rgb(253, 191, 53)", - "fn_hover_background": "rgb(68, 68, 68)", - "type": "rgb(253, 191, 53)", - "type_hover": "rgb(253, 191, 53)", - "type_hover_background": "rgb(68, 68, 68)", - "keyword": "rgb(253, 191, 53)", - "keyword_hover": "rgb(253, 191, 53)", - "keyword_hover_background": "rgb(68, 68, 68)", + "struct": "#fdbf35", + "struct_hover": "#fdbf35", + "struct_hover_background": "#444", + "enum": "#fdbf35", + "enum_hover": "#fdbf35", + "enum_hover_background": "#444", + "union": "#fdbf35", + "union_hover": "#fdbf35", + "union_hover_background": "#444", + "trait": "#fdbf35", + "trait_hover": "#fdbf35", + "trait_hover_background": "#444", + "fn": "#fdbf35", + "fn_hover": "#fdbf35", + "fn_hover_background": "#444", + "type": "#fdbf35", + "type_hover": "#fdbf35", + "type_hover_background": "#444", + "keyword": "#fdbf35", + "keyword_hover": "#fdbf35", + "keyword_hover_background": "#444", } ) call-function: ( "check-colors", { "theme": "light", - "struct": "rgb(53, 109, 164)", - "struct_hover": "rgb(53, 109, 164)", - "struct_hover_background": "rgb(255, 255, 255)", - "enum": "rgb(53, 109, 164)", - "enum_hover": "rgb(53, 109, 164)", - "enum_hover_background": "rgb(255, 255, 255)", - "union": "rgb(53, 109, 164)", - "union_hover": "rgb(53, 109, 164)", - "union_hover_background": "rgb(255, 255, 255)", - "trait": "rgb(53, 109, 164)", - "trait_hover": "rgb(53, 109, 164)", - "trait_hover_background": "rgb(255, 255, 255)", - "fn": "rgb(53, 109, 164)", - "fn_hover": "rgb(53, 109, 164)", - "fn_hover_background": "rgb(255, 255, 255)", - "type": "rgb(53, 109, 164)", - "type_hover": "rgb(53, 109, 164)", - "type_hover_background": "rgb(255, 255, 255)", - "keyword": "rgb(53, 109, 164)", - "keyword_hover": "rgb(53, 109, 164)", - "keyword_hover_background": "rgb(255, 255, 255)", + "struct": "#356da4", + "struct_hover": "#356da4", + "struct_hover_background": "#fff", + "enum": "#356da4", + "enum_hover": "#356da4", + "enum_hover_background": "#fff", + "union": "#356da4", + "union_hover": "#356da4", + "union_hover_background": "#fff", + "trait": "#356da4", + "trait_hover": "#356da4", + "trait_hover_background": "#fff", + "fn": "#356da4", + "fn_hover": "#356da4", + "fn_hover_background": "#fff", + "type": "#356da4", + "type_hover": "#356da4", + "type_hover_background": "#fff", + "keyword": "#356da4", + "keyword_hover": "#356da4", + "keyword_hover_background": "#fff", } ) diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml index 0c680bcc9..88546ed25 100644 --- a/tests/rustdoc-gui/sidebar-source-code-display.goml +++ b/tests/rustdoc-gui/sidebar-source-code-display.goml @@ -40,7 +40,7 @@ define-function: ( reload: wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) assert-css: ( - "#source-sidebar details[open] > .files a.selected", + "#src-sidebar details[open] > .files a.selected", {"color": |color_hover|, "background-color": |background|}, ) @@ -62,58 +62,58 @@ define-function: ( // Without hover or focus. assert-css: ( - "#source-sidebar details[open] > .files a:not(.selected)", + "#src-sidebar details[open] > .files a:not(.selected)", {"color": |color|, "background-color": |background_toggle|}, ) // With focus. - focus: "#source-sidebar details[open] > .files a:not(.selected)" + focus: "#src-sidebar details[open] > .files a:not(.selected)" wait-for-css: ( - "#source-sidebar details[open] > .files a:not(.selected):focus", + "#src-sidebar details[open] > .files a:not(.selected):focus", {"color": |color_hover|, "background-color": |background_hover|}, ) focus: ".search-input" // With hover. - move-cursor-to: "#source-sidebar details[open] > .files a:not(.selected)" + move-cursor-to: "#src-sidebar details[open] > .files a:not(.selected)" assert-css: ( - "#source-sidebar details[open] > .files a:not(.selected):hover", + "#src-sidebar details[open] > .files a:not(.selected):hover", {"color": |color_hover|, "background-color": |background_hover|}, ) // Without hover or focus. assert-css: ( - "#source-sidebar .dir-entry summary", + "#src-sidebar .dir-entry summary", {"color": |color|, "background-color": |background_toggle|}, ) // With focus. - focus: "#source-sidebar .dir-entry summary" + focus: "#src-sidebar .dir-entry summary" wait-for-css: ( - "#source-sidebar .dir-entry summary:focus", + "#src-sidebar .dir-entry summary:focus", {"color": |color_hover|, "background-color": |background_hover|}, ) focus: ".search-input" // With hover. - move-cursor-to: "#source-sidebar .dir-entry summary" + move-cursor-to: "#src-sidebar .dir-entry summary" assert-css: ( - "#source-sidebar .dir-entry summary:hover", + "#src-sidebar .dir-entry summary:hover", {"color": |color_hover|, "background-color": |background_hover|}, ) // Without hover or focus. assert-css: ( - "#source-sidebar details[open] > .folders > details > summary", + "#src-sidebar details[open] > .folders > details > summary", {"color": |color|, "background-color": |background_toggle|}, ) // With focus. - focus: "#source-sidebar details[open] > .folders > details > summary" + focus: "#src-sidebar details[open] > .folders > details > summary" wait-for-css: ( - "#source-sidebar details[open] > .folders > details > summary:focus", + "#src-sidebar details[open] > .folders > details > summary:focus", {"color": |color_hover|, "background-color": |background_hover|}, ) focus: ".search-input" // With hover. - move-cursor-to: "#source-sidebar details[open] > .folders > details > summary" + move-cursor-to: "#src-sidebar details[open] > .folders > details > summary" assert-css: ( - "#source-sidebar details[open] > .folders > details > summary:hover", + "#src-sidebar details[open] > .folders > details > summary:hover", {"color": |color_hover|, "background-color": |background_hover|}, ) }, @@ -141,7 +141,7 @@ call-function: ("check-colors", { "theme": "ayu", "color": "#c5c5c5", "color_hover": "#ffb44c", - "background": "rgb(20, 25, 31)", + "background": "#14191f", "background_hover": "#14191f", "background_toggle": "rgba(0, 0, 0, 0)", "background_toggle_hover": "rgba(70, 70, 70, 0.33)", @@ -190,16 +190,16 @@ assert-window-property: {"pageYOffset": "2542"} // make it the current selection. set-window-size: (500, 700) click: "#src-sidebar-toggle" -wait-for-css: ("#source-sidebar", {"visibility": "visible"}) +wait-for-css: ("#src-sidebar", {"visibility": "visible"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} click: ".sidebar a.selected" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" -wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) +wait-for-css: ("#src-sidebar", {"visibility": "hidden"}) assert-local-storage: {"rustdoc-source-sidebar-show": "false"} // Resize back to desktop size, to check that the sidebar doesn't spontaneously open. set-window-size: (1000, 1000) -wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) +wait-for-css: ("#src-sidebar", {"visibility": "hidden"}) assert-local-storage: {"rustdoc-source-sidebar-show": "false"} click: "#src-sidebar-toggle" -wait-for-css: ("#source-sidebar", {"visibility": "visible"}) +wait-for-css: ("#src-sidebar", {"visibility": "visible"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 2cb888178..69c589741 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -14,7 +14,7 @@ define-function: ( } reload: // Checking results colors. - assert-css: (".source .sidebar", { + assert-css: (".src .sidebar", { "color": |color|, "background-color": |background_color| }, ALL) @@ -53,8 +53,8 @@ assert-css: ("nav.sidebar", {"width": "50px"}) // We now click on the button to expand the sidebar. click: (10, 10) // We wait for the sidebar to be expanded. -wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) -assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) +wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"}) +assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) // We collapse the sidebar. click: (10, 10) // We ensure that the class has been removed. @@ -66,24 +66,24 @@ go-to: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html" // First we expand the sidebar again. click: (10, 10) // We wait for the sidebar to be expanded. -wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) +wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"}) assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']" assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']" assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9) +assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 9) // We now switch to mobile mode. set-window-size: (600, 600) -wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"}) +wait-for-css: (".src-sidebar-expanded nav.sidebar", {"left": "0px"}) // We collapse the sidebar. click: (10, 10) // We check that the sidebar has been moved off-screen. assert-css: ("nav.sidebar", {"left": "-1000px"}) // We ensure that the class has been removed. -assert-false: ".source-sidebar-expanded" +assert-false: ".src-sidebar-expanded" assert: "nav.sidebar" // Check that the topbar is not visible diff --git a/tests/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml index 67f1497e7..0e4913caf 100644 --- a/tests/rustdoc-gui/source-anchor-scroll.goml +++ b/tests/rustdoc-gui/source-anchor-scroll.goml @@ -7,11 +7,11 @@ set-window-size: (600, 800) // We check that the scroll is at the top first. assert-property: ("html", {"scrollTop": "0"}) -click: '//a[text() = "barbar"]' +click: '//a[text() = "barbar" and @href="#5-7"]' assert-property: ("html", {"scrollTop": "149"}) -click: '//a[text() = "bar"]' +click: '//a[text() = "bar" and @href="#28-36"]' assert-property: ("html", {"scrollTop": "180"}) -click: '//a[text() = "sub_fn"]' +click: '//a[text() = "sub_fn" and @href="#2-4"]' assert-property: ("html", {"scrollTop": "77"}) // We now check that clicking on lines doesn't change the scroll diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index f8f73398d..f19e3ce80 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -98,26 +98,26 @@ assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) // First we "open" it. click: "#src-sidebar-toggle" -assert: ".source-sidebar-expanded" +assert: ".src-sidebar-expanded" // We check that the first entry of the sidebar is collapsed -assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) -assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css") +assert-property: ("#src-sidebar details:first-of-type", {"open": "false"}) +assert-text: ("#src-sidebar details:first-of-type > summary", "extend_css") // We now click on it. -click: "#source-sidebar details:first-of-type > summary" -assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) +click: "#src-sidebar details:first-of-type > summary" +assert-property: ("#src-sidebar details:first-of-type", {"open": "true"}) // And now we collapse it again. -click: "#source-sidebar details:first-of-type > summary" -assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) +click: "#src-sidebar details:first-of-type > summary" +assert-property: ("#src-sidebar details:first-of-type", {"open": "false"}) // And open it again, since it'll be the reference we use to check positions. -click: "#source-sidebar details:first-of-type > summary" -assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) +click: "#src-sidebar details:first-of-type > summary" +assert-property: ("#src-sidebar details:first-of-type", {"open": "true"}) // Check the sidebar directory entries have a marker and spacing (desktop). store-property: ( - "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", + "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a", {"offsetHeight": link_height}, ) define-function: ( @@ -125,28 +125,28 @@ define-function: ( (x, y), block { assert: "details:first-of-type.dir-entry[open] > summary::marker" - assert-css: ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"}) + assert-css: ("#src-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"}) // This check ensures that the summary is only one line. assert-property: ( - "#source-sidebar > details:first-of-type.dir-entry[open] > summary", + "#src-sidebar > details:first-of-type.dir-entry[open] > summary", {"offsetHeight": |link_height|} ) assert-position: ( - "#source-sidebar > details:first-of-type.dir-entry[open] > summary", + "#src-sidebar > details:first-of-type.dir-entry[open] > summary", {"x": |x|, "y": |y|} ) assert-property: ( - "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", + "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a", {"offsetHeight": |link_height|} ) assert-position: ( - "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", + "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a", // left margin {"x": |x| + 27, "y": |y| + |link_height|} ) } ) -store-property: ("#source-sidebar > .title", { +store-property: ("#src-sidebar > .title", { "offsetHeight": source_sidebar_title_height, "offsetTop": source_sidebar_title_y, }) @@ -175,7 +175,7 @@ assert-property: ("#main-content", {"offsetTop": 76}) // 21 = 76 - 34 - 21 // Check the sidebar directory entries have a marker and spacing (tablet). -store-property: ("#source-sidebar > .title", { +store-property: ("#src-sidebar > .title", { "offsetHeight": source_sidebar_title_height, "offsetTop": source_sidebar_title_y, }) @@ -189,7 +189,7 @@ set-window-size: (450, 700) assert-css: ("nav.sub", {"flex-direction": "column"}) // Check the sidebar directory entries have a marker and spacing (phone). -store-property: ("#source-sidebar > .title", { +store-property: ("#src-sidebar > .title", { "offsetHeight": source_sidebar_title_height, "offsetTop": source_sidebar_title_y, }) diff --git a/tests/rustdoc-gui/src-font-size.goml b/tests/rustdoc-gui/src-font-size.goml index ff30bcdf2..f23387d73 100644 --- a/tests/rustdoc-gui/src-font-size.goml +++ b/tests/rustdoc-gui/src-font-size.goml @@ -4,13 +4,13 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" show-text: true // Check the impl headers. -assert-css: (".impl .srclink", {"font-size": "16px", "font-weight": 400}, ALL) +assert-css: (".impl a.src", {"font-size": "16px", "font-weight": 400}, ALL) assert-css: (".impl .code-header", {"font-size": "18px", "font-weight": 600}, ALL) // Check the impl items. -assert-css: (".impl-items .srclink", {"font-size": "16px", "font-weight": 400}, ALL) +assert-css: (".impl-items a.src", {"font-size": "16px", "font-weight": 400}, ALL) assert-css: (".impl-items .code-header", {"font-size": "16px", "font-weight": 600}, ALL) // Check that we can click on source link store-document-property: {"URL": url} -click: ".impl-items .srclink" +click: ".impl-items a.src" assert-document-property-false: {"URL": |url|} diff --git a/tests/rustdoc-gui/src/staged_api/lib.rs b/tests/rustdoc-gui/src/staged_api/lib.rs index 5934593a8..0c914470e 100644 --- a/tests/rustdoc-gui/src/staged_api/lib.rs +++ b/tests/rustdoc-gui/src/staged_api/lib.rs @@ -1,4 +1,5 @@ #![feature(staged_api)] +#![allow(internal_features)] #![stable(feature = "some_feature", since = "1.3.5")] #[stable(feature = "some_feature", since = "1.3.5")] diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index ecf3a7cc1..49484ee08 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -3,6 +3,7 @@ #![doc(html_playground_url="https://play.rust-lang.org/")] #![crate_name = "test_docs"] +#![allow(internal_features)] #![feature(rustdoc_internals)] #![feature(doc_cfg)] #![feature(associated_type_defaults)] diff --git a/tests/rustdoc-gui/unsafe-fn.goml b/tests/rustdoc-gui/unsafe-fn.goml index 51007b653..8d26f15f3 100644 --- a/tests/rustdoc-gui/unsafe-fn.goml +++ b/tests/rustdoc-gui/unsafe-fn.goml @@ -23,6 +23,6 @@ define-function: ( }, ) -call-function: ("sup-check", ("dark", "rgb(221, 221, 221)")) -call-function: ("sup-check", ("ayu", "rgb(197, 197, 197)")) -call-function: ("sup-check", ("light", "rgb(0, 0, 0)")) +call-function: ("sup-check", ("ayu", "#c5c5c5")) +call-function: ("sup-check", ("dark", "#ddd")) +call-function: ("sup-check", ("light", "black")) diff --git a/tests/rustdoc-json/enums/field_order.rs b/tests/rustdoc-json/enums/field_order.rs new file mode 100644 index 000000000..e89add9cb --- /dev/null +++ b/tests/rustdoc-json/enums/field_order.rs @@ -0,0 +1,40 @@ +// Check that the order of fields is preserved. + +pub enum Whatever { + Foo { + // Important: random prefixes are used here to ensure that + // sorting fields by name would cause this test to fail. + ews_0: i32, + dik_1: i32, + hsk_2: i32, + djt_3: i32, + jnr_4: i32, + dfs_5: i32, + bja_6: i32, + lyc_7: i32, + yqd_8: i32, + vll_9: i32, + }, +} + +// @set 0 = '$.index[*][?(@.name == "ews_0")].id' +// @set 1 = '$.index[*][?(@.name == "dik_1")].id' +// @set 2 = '$.index[*][?(@.name == "hsk_2")].id' +// @set 3 = '$.index[*][?(@.name == "djt_3")].id' +// @set 4 = '$.index[*][?(@.name == "jnr_4")].id' +// @set 5 = '$.index[*][?(@.name == "dfs_5")].id' +// @set 6 = '$.index[*][?(@.name == "bja_6")].id' +// @set 7 = '$.index[*][?(@.name == "lyc_7")].id' +// @set 8 = '$.index[*][?(@.name == "yqd_8")].id' +// @set 9 = '$.index[*][?(@.name == "vll_9")].id' + +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[0]' $0 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[1]' $1 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[2]' $2 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[3]' $3 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[4]' $4 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[5]' $5 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[6]' $6 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[7]' $7 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[8]' $8 +// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[9]' $9 diff --git a/tests/rustdoc-json/enums/variant_order.rs b/tests/rustdoc-json/enums/variant_order.rs new file mode 100644 index 000000000..17ca96213 --- /dev/null +++ b/tests/rustdoc-json/enums/variant_order.rs @@ -0,0 +1,38 @@ +// Check that the order of variants is preserved. + +pub enum Foo { + // Important: random prefixes are used here to ensure that + // sorting fields by name would cause this test to fail. + Ews0, + Dik1, + Hsk2, + Djt3, + Jnr4, + Dfs5, + Bja6, + Lyc7, + Yqd8, + Vll9, +} + +// @set 0 = '$.index[*][?(@.name == "Ews0")].id' +// @set 1 = '$.index[*][?(@.name == "Dik1")].id' +// @set 2 = '$.index[*][?(@.name == "Hsk2")].id' +// @set 3 = '$.index[*][?(@.name == "Djt3")].id' +// @set 4 = '$.index[*][?(@.name == "Jnr4")].id' +// @set 5 = '$.index[*][?(@.name == "Dfs5")].id' +// @set 6 = '$.index[*][?(@.name == "Bja6")].id' +// @set 7 = '$.index[*][?(@.name == "Lyc7")].id' +// @set 8 = '$.index[*][?(@.name == "Yqd8")].id' +// @set 9 = '$.index[*][?(@.name == "Vll9")].id' + +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[0]' $0 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[1]' $1 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[2]' $2 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[3]' $3 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[4]' $4 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[5]' $5 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[6]' $6 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[7]' $7 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[8]' $8 +// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[9]' $9 diff --git a/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs new file mode 100644 index 000000000..d2ac316d4 --- /dev/null +++ b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs @@ -0,0 +1,15 @@ +#![feature(no_core)] +#![no_core] + +// @count "$.index[*][?(@.inner.impl)]" 1 +// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]" +// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]" +// @has "$.index[*][?(@.name=='PubTrait')]" +pub trait PubTrait {} + +#[doc(hidden)] +pub struct HiddenPubStruct; +pub struct NotHiddenPubStruct; + +impl PubTrait for HiddenPubStruct {} +impl PubTrait for NotHiddenPubStruct {} diff --git a/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs new file mode 100644 index 000000000..fcd27ca4b --- /dev/null +++ b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs @@ -0,0 +1,14 @@ +// compile-flags: --document-hidden-items + +#![feature(no_core)] +#![no_core] + +// @has "$.index[*][?(@.name == 'HiddenPubStruct')]" +// @has "$.index[*][?(@.inner.impl)]" +// @has "$.index[*][?(@.name=='PubTrait')]" +pub trait PubTrait {} + +#[doc(hidden)] +pub struct HiddenPubStruct; + +impl PubTrait for HiddenPubStruct {} diff --git a/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs new file mode 100644 index 000000000..141c54a57 --- /dev/null +++ b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs @@ -0,0 +1,21 @@ +#![feature(no_core)] +#![no_core] + +// @count "$.index[*][?(@.inner.impl)]" 1 +// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]" +// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]" +// @has "$.index[*][?(@.name=='PubTrait')]" +pub trait PubTrait {} + +#[doc(hidden)] +pub mod hidden { + pub struct HiddenPubStruct; + + impl crate::PubTrait for HiddenPubStruct {} +} + +pub mod not_hidden { + pub struct NotHiddenPubStruct; + + impl crate::PubTrait for NotHiddenPubStruct {} +} diff --git a/tests/rustdoc-json/structs/field_order.rs b/tests/rustdoc-json/structs/field_order.rs new file mode 100644 index 000000000..a8c18323d --- /dev/null +++ b/tests/rustdoc-json/structs/field_order.rs @@ -0,0 +1,38 @@ +// Check that the order of fields is preserved. + +pub struct Foo { + // Important: random prefixes are used here to ensure that + // sorting fields by name would cause this test to fail. + pub ews_0: i32, + pub dik_1: i32, + pub hsk_2: i32, + pub djt_3: i32, + pub jnr_4: i32, + pub dfs_5: i32, + pub bja_6: i32, + pub lyc_7: i32, + pub yqd_8: i32, + pub vll_9: i32, +} + +// @set 0 = '$.index[*][?(@.name == "ews_0")].id' +// @set 1 = '$.index[*][?(@.name == "dik_1")].id' +// @set 2 = '$.index[*][?(@.name == "hsk_2")].id' +// @set 3 = '$.index[*][?(@.name == "djt_3")].id' +// @set 4 = '$.index[*][?(@.name == "jnr_4")].id' +// @set 5 = '$.index[*][?(@.name == "dfs_5")].id' +// @set 6 = '$.index[*][?(@.name == "bja_6")].id' +// @set 7 = '$.index[*][?(@.name == "lyc_7")].id' +// @set 8 = '$.index[*][?(@.name == "yqd_8")].id' +// @set 9 = '$.index[*][?(@.name == "vll_9")].id' + +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[0]' $0 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[1]' $1 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[2]' $2 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[3]' $3 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[4]' $4 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[5]' $5 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[6]' $6 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[7]' $7 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[8]' $8 +// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[9]' $9 diff --git a/tests/rustdoc-json/traits/private_supertrait.rs b/tests/rustdoc-json/traits/private_supertrait.rs new file mode 100644 index 000000000..49238e5e8 --- /dev/null +++ b/tests/rustdoc-json/traits/private_supertrait.rs @@ -0,0 +1,15 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + + +// @!has "$.index[*][?(@.name == 'sealed')]" +mod sealed { + // @set sealed_id = "$.index[*][?(@.name=='Sealed')].id" + pub trait Sealed {} +} + +// @count "$.index[*][?(@.name=='Trait')].inner.trait.bounds[*]" 1 +// @is "$.index[*][?(@.name=='Trait')].inner.trait.bounds[0].trait_bound.trait.id" $sealed_id +pub trait Trait: sealed::Sealed {} diff --git a/tests/rustdoc-json/type/inherent_associated_type_bound.rs b/tests/rustdoc-json/type/inherent_associated_type_bound.rs index 2e9b13d0c..8e39f4718 100644 --- a/tests/rustdoc-json/type/inherent_associated_type_bound.rs +++ b/tests/rustdoc-json/type/inherent_associated_type_bound.rs @@ -5,14 +5,15 @@ // @set Carrier = '$.index[*][?(@.name=="Carrier")].id' pub struct Carrier<'a>(&'a ()); -// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.generic_params[*].name' \""'b"\" -// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier -// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\" -// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"' -// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.trait' null -// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"' - -pub type User = for<'b> fn(Carrier<'b>::Focus); +// @count "$.index[*][?(@.name=='user')].inner.function.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='user')].inner.function.decl.inputs[0][0]" '"_"' +// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.generic_params[*].name' \""'b"\" +// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier +// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\" +// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"' +// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.trait' null +// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"' +pub fn user(_: for<'b> fn(Carrier<'b>::Focus)) {} impl<'a> Carrier<'a> { pub type Focus = &'a mut T; diff --git a/tests/rustdoc-json/type/inherent_associated_type_projections.rs b/tests/rustdoc-json/type/inherent_associated_type_projections.rs index 942e323ef..d12e5f4a7 100644 --- a/tests/rustdoc-json/type/inherent_associated_type_projections.rs +++ b/tests/rustdoc-json/type/inherent_associated_type_projections.rs @@ -5,11 +5,13 @@ // @set Parametrized = '$.index[*][?(@.name=="Parametrized")].id' pub struct Parametrized(T); -// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.id' $Parametrized -// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\" -// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.name' '"Proj"' -// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.trait' null -pub type Test = Parametrized::Proj; +// @count "$.index[*][?(@.name=='test')].inner.function.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='test')].inner.function.decl.inputs[0][0]" '"_"' +// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Parametrized +// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\" +// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.name' '"Proj"' +// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.trait' null +pub fn test(_: Parametrized::Proj) {} /// param_bool impl Parametrized { diff --git a/tests/rustdoc-json/unions/field_order.rs b/tests/rustdoc-json/unions/field_order.rs new file mode 100644 index 000000000..8a40bda03 --- /dev/null +++ b/tests/rustdoc-json/unions/field_order.rs @@ -0,0 +1,38 @@ +// Check that the order of fields is preserved. + +pub union Foo { + // Important: random prefixes are used here to ensure that + // sorting fields by name would cause this test to fail. + pub ews_0: i32, + pub dik_1: i32, + pub hsk_2: i32, + pub djt_3: i32, + pub jnr_4: i32, + pub dfs_5: i32, + pub bja_6: i32, + pub lyc_7: i32, + pub yqd_8: i32, + pub vll_9: i32, +} + +// @set 0 = '$.index[*][?(@.name == "ews_0")].id' +// @set 1 = '$.index[*][?(@.name == "dik_1")].id' +// @set 2 = '$.index[*][?(@.name == "hsk_2")].id' +// @set 3 = '$.index[*][?(@.name == "djt_3")].id' +// @set 4 = '$.index[*][?(@.name == "jnr_4")].id' +// @set 5 = '$.index[*][?(@.name == "dfs_5")].id' +// @set 6 = '$.index[*][?(@.name == "bja_6")].id' +// @set 7 = '$.index[*][?(@.name == "lyc_7")].id' +// @set 8 = '$.index[*][?(@.name == "yqd_8")].id' +// @set 9 = '$.index[*][?(@.name == "vll_9")].id' + +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[0]' $0 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[1]' $1 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[2]' $2 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[3]' $3 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[4]' $4 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[5]' $5 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[6]' $6 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[7]' $7 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[8]' $8 +// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[9]' $9 diff --git a/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout index 6c147054d..f4bfb94e9 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout @@ -26,7 +26,8 @@ stdout 2 stderr: stderr 1 stderr 2 -thread 'main' panicked at 'oh no', $DIR/failed-doctest-output-windows.rs:7:1 +thread 'main' panicked at $DIR/failed-doctest-output-windows.rs:7:1: +oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc-ui/doctest/failed-doctest-output.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout index 630198a56..840c9c508 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-output.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout @@ -26,7 +26,8 @@ stdout 2 stderr: stderr 1 stderr 2 -thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1 +thread 'main' panicked at $DIR/failed-doctest-output.rs:7:1: +oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc-ui/ice-bug-report-url.rs b/tests/rustdoc-ui/ice-bug-report-url.rs index 8ede91cf8..a3fa819ab 100644 --- a/tests/rustdoc-ui/ice-bug-report-url.rs +++ b/tests/rustdoc-ui/ice-bug-report-url.rs @@ -1,11 +1,12 @@ // compile-flags: -Ztreat-err-as-bug +// rustc-env:RUSTC_ICE=0 // failure-status: 101 // error-pattern: aborting due to // error-pattern: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*" -> "note: rustc {version} running on {platform}" -// normalize-stderr-test "thread.*panicked at .*, compiler.*" -> "thread panicked at 'aborting due to `-Z treat-err-as-bug`'" +// normalize-stderr-test "thread.*panicked at compiler.*" -> "" // normalize-stderr-test " +\d{1,}: .*\n" -> "" // normalize-stderr-test " + at .*\n" -> "" // normalize-stderr-test ".*note: Some details are omitted.*\n" -> "" diff --git a/tests/rustdoc-ui/ice-bug-report-url.stderr b/tests/rustdoc-ui/ice-bug-report-url.stderr index 98c08b9a8..869fcd20f 100644 --- a/tests/rustdoc-ui/ice-bug-report-url.stderr +++ b/tests/rustdoc-ui/ice-bug-report-url.stderr @@ -1,10 +1,11 @@ error: expected one of `->`, `where`, or `{`, found `` - --> $DIR/ice-bug-report-url.rs:13:10 + --> $DIR/ice-bug-report-url.rs:14:10 | LL | fn wrong() | ^ expected one of `->`, `where`, or `{` -thread panicked at 'aborting due to `-Z treat-err-as-bug`' + +aborting due to `-Z treat-err-as-bug=1` stack backtrace: error: the compiler unexpectedly panicked. this is a bug. diff --git a/tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.rs b/tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.rs new file mode 100644 index 000000000..f3f044f61 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.rs @@ -0,0 +1,16 @@ +// Test that we don't ICE with broken links that don't show up in the docs. + +// check-pass +// edition: 2021 + +/// [1] +//~^ WARN unresolved link to `1` +//~| WARN unresolved link to `1` +pub use {std, core}; + +/// [2] +pub use {}; + +/// [3] +//~^ WARN unresolved link to `3` +pub extern crate alloc; diff --git a/tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.stderr b/tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.stderr new file mode 100644 index 000000000..83e0d3962 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.stderr @@ -0,0 +1,27 @@ +warning: unresolved link to `3` + --> $DIR/broken-link-in-unused-doc-string.rs:14:6 + | +LL | /// [3] + | ^ no item named `3` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default + +warning: unresolved link to `1` + --> $DIR/broken-link-in-unused-doc-string.rs:6:6 + | +LL | /// [1] + | ^ no item named `1` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `1` + --> $DIR/broken-link-in-unused-doc-string.rs:6:6 + | +LL | /// [1] + | ^ no item named `1` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: 3 warnings emitted + diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr index 79e1b7531..9aeb3389e 100644 --- a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr @@ -19,6 +19,7 @@ LL | | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { LL | | assert!(bar(&meh) == bar(&muh)); LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/rustdoc-ui/lints/inline-doc-link.rs b/tests/rustdoc-ui/lints/inline-doc-link.rs new file mode 100644 index 000000000..596f89be3 --- /dev/null +++ b/tests/rustdoc-ui/lints/inline-doc-link.rs @@ -0,0 +1,13 @@ +// Regression test for + +// check-pass +#![deny(rustdoc::redundant_explicit_links)] + +mod m { + pub enum ValueEnum {} +} +mod m2 { + /// [`ValueEnum`] + pub use crate::m::ValueEnum; +} +pub use m2::ValueEnum; diff --git a/tests/rustdoc-ui/lints/invalid-doc-attr.rs b/tests/rustdoc-ui/lints/invalid-doc-attr.rs index c231e43b3..16b12cca5 100644 --- a/tests/rustdoc-ui/lints/invalid-doc-attr.rs +++ b/tests/rustdoc-ui/lints/invalid-doc-attr.rs @@ -1,5 +1,10 @@ #![crate_type = "lib"] #![deny(warnings)] +#![feature(doc_masked)] + +#![doc(masked)] +//~^ ERROR this attribute can only be applied to an `extern crate` item +//~| WARN is being phased out #[doc(test(no_crate_inject))] //~^ ERROR can only be applied at the crate level @@ -30,3 +35,13 @@ pub mod bar { //~^^ ERROR conflicting doc inlining attributes //~| HELP remove one of the conflicting attributes pub use bar::baz; + +#[doc(masked)] +//~^ ERROR this attribute can only be applied to an `extern crate` item +//~| WARN is being phased out +pub struct Masked; + +#[doc(masked)] +//~^ ERROR this attribute cannot be applied to an `extern crate self` item +//~| WARN is being phased out +pub extern crate self as reexport; diff --git a/tests/rustdoc-ui/lints/invalid-doc-attr.stderr b/tests/rustdoc-ui/lints/invalid-doc-attr.stderr index b23b8ded8..82ea33e1d 100644 --- a/tests/rustdoc-ui/lints/invalid-doc-attr.stderr +++ b/tests/rustdoc-ui/lints/invalid-doc-attr.stderr @@ -1,5 +1,5 @@ error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:4:7 + --> $DIR/invalid-doc-attr.rs:9:7 | LL | #[doc(test(no_crate_inject))] | ^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | #![doc(test(no_crate_inject))] | + error: this attribute can only be applied to a `use` item - --> $DIR/invalid-doc-attr.rs:9:7 + --> $DIR/invalid-doc-attr.rs:14:7 | LL | #[doc(inline)] | ^^^^^^ only applicable on `use` items @@ -32,7 +32,7 @@ LL | pub fn foo() {} = note: read for more information error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:15:12 + --> $DIR/invalid-doc-attr.rs:20:12 | LL | #![doc(test(no_crate_inject))] | ^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | #![doc(test(no_crate_inject))] = note: read for more information error: conflicting doc inlining attributes - --> $DIR/invalid-doc-attr.rs:28:7 + --> $DIR/invalid-doc-attr.rs:33:7 | LL | #[doc(inline)] | ^^^^^^ this attribute... @@ -51,8 +51,43 @@ LL | #[doc(no_inline)] | = help: remove one of the conflicting attributes +error: this attribute can only be applied to an `extern crate` item + --> $DIR/invalid-doc-attr.rs:39:7 + | +LL | #[doc(masked)] + | ^^^^^^ only applicable on `extern crate` items +... +LL | pub struct Masked; + | ----------------- not an `extern crate` item + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 + = note: read for more information + +error: this attribute cannot be applied to an `extern crate self` item + --> $DIR/invalid-doc-attr.rs:44:7 + | +LL | #[doc(masked)] + | ^^^^^^ not applicable on `extern crate self` items +... +LL | pub extern crate self as reexport; + | --------------------------------- `extern crate self` defined here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 + +error: this attribute can only be applied to an `extern crate` item + --> $DIR/invalid-doc-attr.rs:5:8 + | +LL | #![doc(masked)] + | ^^^^^^ only applicable on `extern crate` items + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 + = note: read for more information + error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:19:11 + --> $DIR/invalid-doc-attr.rs:24:11 | LL | #[doc(test(no_crate_inject))] | ^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +97,7 @@ LL | #[doc(test(no_crate_inject))] = note: read for more information error: this attribute can only be applied to a `use` item - --> $DIR/invalid-doc-attr.rs:22:11 + --> $DIR/invalid-doc-attr.rs:27:11 | LL | #[doc(inline)] | ^^^^^^ only applicable on `use` items @@ -74,5 +109,5 @@ LL | pub fn baz() {} = note: for more information, see issue #82730 = note: read for more information -error: aborting due to 6 previous errors +error: aborting due to 9 previous errors diff --git a/tests/rustdoc-ui/lints/no-redundancy.rs b/tests/rustdoc-ui/lints/no-redundancy.rs new file mode 100644 index 000000000..e3358728b --- /dev/null +++ b/tests/rustdoc-ui/lints/no-redundancy.rs @@ -0,0 +1,7 @@ +// check-pass + +#![deny(rustdoc::redundant_explicit_links)] + +/// [Vec][std::vec::Vec#examples] should not warn, because it's not actually redundant! +/// [This is just an `Option`][std::option::Option] has different display content to actual link! +pub fn func() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs new file mode 100644 index 000000000..fecefb7b2 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs @@ -0,0 +1,18 @@ +// check-pass + +/// [`…foo`] [`…bar`] [`Err`] +pub struct Broken {} + +/// [`…`] [`…`] [`Err`] +pub struct Broken2 {} + +/// [`…`][…] [`…`][…] [`Err`] +pub struct Broken3 {} + +/// […………………………][Broken3] +pub struct Broken4 {} + +/// [Broken3][…………………………] +pub struct Broken5 {} + +pub struct Err; diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links.fixed b/tests/rustdoc-ui/lints/redundant_explicit_links.fixed new file mode 100644 index 000000000..900234e31 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links.fixed @@ -0,0 +1,158 @@ +// run-rustfix + +#![deny(rustdoc::redundant_explicit_links)] + +pub fn dummy_target() {} + +/// [dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`] +//~^ ERROR redundant explicit link target +/// +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`] TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_inline() {} + +/// [`Vec`](Vec) +/// [`Vec`](std::vec::Vec) +pub fn should_not_warn_inline() {} + +/// [dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`] +//~^ ERROR redundant explicit link target +/// +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`] TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_reference_unknown() {} + +/// [`Vec`][Vec] +/// [`Vec`][std::vec::Vec] +pub fn should_not_warn_reference_unknown() {} + +/// [dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`] +//~^ ERROR redundant explicit link target +/// +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`] TEXT +//~^ ERROR redundant explicit link target +/// +/// [dummy_target]: dummy_target +/// [Vec]: Vec +/// [std::vec::Vec]: Vec +/// [usize]: usize +/// [std::primitive::usize]: usize +pub fn should_warn_reference() {} + +/// [`Vec`]: Vec +/// [`Vec`]: std::vec::Vec +pub fn should_not_warn_reference() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links.rs b/tests/rustdoc-ui/lints/redundant_explicit_links.rs new file mode 100644 index 000000000..13feb85e0 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links.rs @@ -0,0 +1,158 @@ +// run-rustfix + +#![deny(rustdoc::redundant_explicit_links)] + +pub fn dummy_target() {} + +/// [dummy_target](dummy_target) +//~^ ERROR redundant explicit link target +/// [`dummy_target`](dummy_target) +//~^ ERROR redundant explicit link target +/// +/// [Vec](Vec) +//~^ ERROR redundant explicit link target +/// [`Vec`](Vec) +//~^ ERROR redundant explicit link target +/// [Vec](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// [`Vec`](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// [std::vec::Vec](Vec) +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`](Vec) +//~^ ERROR redundant explicit link target +/// [std::vec::Vec](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// +/// [usize](usize) +//~^ ERROR redundant explicit link target +/// [`usize`](usize) +//~^ ERROR redundant explicit link target +/// [usize](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// [`usize`](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// [std::primitive::usize](usize) +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`](usize) +//~^ ERROR redundant explicit link target +/// [std::primitive::usize](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// +/// [dummy_target](dummy_target) TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`](dummy_target) TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_inline() {} + +/// [`Vec`](Vec) +/// [`Vec`](std::vec::Vec) +pub fn should_not_warn_inline() {} + +/// [dummy_target][dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] +//~^ ERROR redundant explicit link target +/// +/// [Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// +/// [usize][usize] +//~^ ERROR redundant explicit link target +/// [`usize`][usize] +//~^ ERROR redundant explicit link target +/// [usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target][dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_reference_unknown() {} + +/// [`Vec`][Vec] +/// [`Vec`][std::vec::Vec] +pub fn should_not_warn_reference_unknown() {} + +/// [dummy_target][dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] +//~^ ERROR redundant explicit link target +/// +/// [Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// +/// [usize][usize] +//~^ ERROR redundant explicit link target +/// [`usize`][usize] +//~^ ERROR redundant explicit link target +/// [usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target][dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// +/// [dummy_target]: dummy_target +/// [Vec]: Vec +/// [std::vec::Vec]: Vec +/// [usize]: usize +/// [std::primitive::usize]: usize +pub fn should_warn_reference() {} + +/// [`Vec`]: Vec +/// [`Vec`]: std::vec::Vec +pub fn should_not_warn_reference() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links.stderr b/tests/rustdoc-ui/lints/redundant_explicit_links.stderr new file mode 100644 index 000000000..34ec9be66 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links.stderr @@ -0,0 +1,1007 @@ +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:7:20 + | +LL | /// [dummy_target](dummy_target) + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +note: the lint level is defined here + --> $DIR/redundant_explicit_links.rs:3:9 + | +LL | #![deny(rustdoc::redundant_explicit_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: remove explicit link target + | +LL | /// [dummy_target] + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:9:22 + | +LL | /// [`dummy_target`](dummy_target) + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:12:11 + | +LL | /// [Vec](Vec) + | --- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:14:13 + | +LL | /// [`Vec`](Vec) + | ----- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:16:11 + | +LL | /// [Vec](std::vec::Vec) + | --- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:18:13 + | +LL | /// [`Vec`](std::vec::Vec) + | ----- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:20:21 + | +LL | /// [std::vec::Vec](Vec) + | ------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:22:23 + | +LL | /// [`std::vec::Vec`](Vec) + | --------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:24:21 + | +LL | /// [std::vec::Vec](std::vec::Vec) + | ------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:26:23 + | +LL | /// [`std::vec::Vec`](std::vec::Vec) + | --------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:29:13 + | +LL | /// [usize](usize) + | ----- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:31:15 + | +LL | /// [`usize`](usize) + | ------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:33:13 + | +LL | /// [usize](std::primitive::usize) + | ----- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:35:15 + | +LL | /// [`usize`](std::primitive::usize) + | ------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:37:29 + | +LL | /// [std::primitive::usize](usize) + | --------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:39:31 + | +LL | /// [`std::primitive::usize`](usize) + | ----------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:41:29 + | +LL | /// [std::primitive::usize](std::primitive::usize) + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:43:31 + | +LL | /// [`std::primitive::usize`](std::primitive::usize) + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:46:20 + | +LL | /// [dummy_target](dummy_target) TEXT + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] TEXT + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:48:22 + | +LL | /// [`dummy_target`](dummy_target) TEXT + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] TEXT + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:56:20 + | +LL | /// [dummy_target][dummy_target] + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:58:22 + | +LL | /// [`dummy_target`][dummy_target] + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:61:11 + | +LL | /// [Vec][Vec] + | --- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:63:13 + | +LL | /// [`Vec`][Vec] + | ----- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:65:11 + | +LL | /// [Vec][std::vec::Vec] + | --- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:67:13 + | +LL | /// [`Vec`][std::vec::Vec] + | ----- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:69:21 + | +LL | /// [std::vec::Vec][Vec] + | ------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:71:23 + | +LL | /// [`std::vec::Vec`][Vec] + | --------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:73:21 + | +LL | /// [std::vec::Vec][std::vec::Vec] + | ------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:75:23 + | +LL | /// [`std::vec::Vec`][std::vec::Vec] + | --------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:78:13 + | +LL | /// [usize][usize] + | ----- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:80:15 + | +LL | /// [`usize`][usize] + | ------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:82:13 + | +LL | /// [usize][std::primitive::usize] + | ----- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:84:15 + | +LL | /// [`usize`][std::primitive::usize] + | ------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:86:29 + | +LL | /// [std::primitive::usize][usize] + | --------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:88:31 + | +LL | /// [`std::primitive::usize`][usize] + | ----------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:90:29 + | +LL | /// [std::primitive::usize][std::primitive::usize] + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:92:31 + | +LL | /// [`std::primitive::usize`][std::primitive::usize] + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:95:20 + | +LL | /// [dummy_target][dummy_target] TEXT + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] TEXT + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:97:22 + | +LL | /// [`dummy_target`][dummy_target] TEXT + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] TEXT + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:105:20 + | +LL | /// [dummy_target][dummy_target] + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:107:22 + | +LL | /// [`dummy_target`][dummy_target] + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:110:11 + | +LL | /// [Vec][Vec] + | --- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:112:13 + | +LL | /// [`Vec`][Vec] + | ----- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:114:11 + | +LL | /// [Vec][std::vec::Vec] + | --- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:116:13 + | +LL | /// [`Vec`][std::vec::Vec] + | ----- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:118:21 + | +LL | /// [std::vec::Vec][Vec] + | ------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:120:23 + | +LL | /// [`std::vec::Vec`][Vec] + | --------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:122:21 + | +LL | /// [std::vec::Vec][std::vec::Vec] + | ------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:124:23 + | +LL | /// [`std::vec::Vec`][std::vec::Vec] + | --------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:127:13 + | +LL | /// [usize][usize] + | ----- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:129:15 + | +LL | /// [`usize`][usize] + | ------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:131:13 + | +LL | /// [usize][std::primitive::usize] + | ----- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:133:15 + | +LL | /// [`usize`][std::primitive::usize] + | ------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:135:29 + | +LL | /// [std::primitive::usize][usize] + | --------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:137:31 + | +LL | /// [`std::primitive::usize`][usize] + | ----------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:139:29 + | +LL | /// [std::primitive::usize][std::primitive::usize] + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:141:31 + | +LL | /// [`std::primitive::usize`][std::primitive::usize] + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:144:20 + | +LL | /// [dummy_target][dummy_target] TEXT + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] TEXT + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:146:22 + | +LL | /// [`dummy_target`][dummy_target] TEXT + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] TEXT + | ~~~~~~~~~~~~~~~~ + +error: aborting due to 60 previous errors + diff --git a/tests/rustdoc-ui/unescaped_backticks.rs b/tests/rustdoc-ui/unescaped_backticks.rs index e99cd1f3d..e960e9f59 100644 --- a/tests/rustdoc-ui/unescaped_backticks.rs +++ b/tests/rustdoc-ui/unescaped_backticks.rs @@ -1,6 +1,7 @@ #![deny(rustdoc::unescaped_backticks)] #![allow(rustdoc::broken_intra_doc_links)] #![allow(rustdoc::invalid_html_tags)] +#![allow(rustdoc::redundant_explicit_links)] /// pub fn empty() {} diff --git a/tests/rustdoc-ui/unescaped_backticks.stderr b/tests/rustdoc-ui/unescaped_backticks.stderr index bf1f18889..83822f778 100644 --- a/tests/rustdoc-ui/unescaped_backticks.stderr +++ b/tests/rustdoc-ui/unescaped_backticks.stderr @@ -1,5 +1,5 @@ error: unescaped backtick - --> $DIR/unescaped_backticks.rs:186:70 + --> $DIR/unescaped_backticks.rs:187:70 | LL | /// if you want your MIR to be modified by the full MIR pipeline, or `#![custom_mir(dialect = | ^ @@ -19,7 +19,7 @@ LL | /// if you want your MIR to be modified by the full MIR pipeline, or \`#![c | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:231:13 + --> $DIR/unescaped_backticks.rs:232:13 | LL | //! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")] | ^ @@ -34,7 +34,7 @@ LL | //! \`#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kin | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:236:13 + --> $DIR/unescaped_backticks.rs:237:13 | LL | /// `cfg=... | ^ @@ -49,7 +49,7 @@ LL | /// \`cfg=... | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:240:42 + --> $DIR/unescaped_backticks.rs:241:42 | LL | /// `cfg=... and not `#[cfg_attr]` | ^ @@ -64,7 +64,7 @@ LL | /// `cfg=... and not `#[cfg_attr]\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:192:91 + --> $DIR/unescaped_backticks.rs:193:91 | LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to | ^ @@ -79,7 +79,7 @@ LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:201:34 + --> $DIR/unescaped_backticks.rs:202:34 | LL | /// in `nt_to_tokenstream` | ^ @@ -94,7 +94,7 @@ LL | /// in `nt_to_tokenstream\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:207:62 + --> $DIR/unescaped_backticks.rs:208:62 | LL | /// that `Option` only takes up 4 bytes, because `newtype_index! reserves | ^ @@ -109,7 +109,7 @@ LL | /// that `Option` only takes up 4 bytes, because \`newtype_inde | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:215:52 + --> $DIR/unescaped_backticks.rs:216:52 | LL | /// also avoids the need to import `OpenOptions`. | ^ @@ -124,7 +124,7 @@ LL | /// also avoids the need to import `OpenOptions\`. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:220:46 + --> $DIR/unescaped_backticks.rs:221:46 | LL | /// `HybridBitSet`. Has no effect if `row` does not exist. | ^ @@ -139,7 +139,7 @@ LL | /// `HybridBitSet`. Has no effect if `row\` does not exist. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:246:12 + --> $DIR/unescaped_backticks.rs:247:12 | LL | /// RWU`s can get very large, so it uses a more compact representation. | ^ @@ -154,7 +154,7 @@ LL | /// RWU\`s can get very large, so it uses a more compact representation | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:253:15 + --> $DIR/unescaped_backticks.rs:254:15 | LL | /// in `U2`. | ^ @@ -169,7 +169,7 @@ LL | /// in `U2\`. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:270:42 + --> $DIR/unescaped_backticks.rs:271:42 | LL | /// because it contains `[type error]`. Yuck! (See issue #29857 for | ^ @@ -184,7 +184,7 @@ LL | /// because it contains `[type error]\`. Yuck! (See issue #29857 for | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:280:53 + --> $DIR/unescaped_backticks.rs:281:53 | LL | /// well as the second instance of `A: AutoTrait`) to suppress | ^ @@ -199,7 +199,7 @@ LL | /// well as the second instance of `A: AutoTrait\`) to suppress | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:290:40 + --> $DIR/unescaped_backticks.rs:291:40 | LL | /// `'a` with `'b` and not `'static`. But it will have to do for | ^ @@ -211,7 +211,7 @@ LL | /// `'a` with `'b` and not `'static\`. But it will have to do for | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:299:54 + --> $DIR/unescaped_backticks.rs:300:54 | LL | /// `None`. Otherwise, it will return `Some(Dispatch)`. | ^ @@ -226,7 +226,7 @@ LL | /// `None`. Otherwise, it will return `Some(Dispatch)\`. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:303:13 + --> $DIR/unescaped_backticks.rs:304:13 | LL | /// or `None` if it isn't. | ^ @@ -238,7 +238,7 @@ LL | /// or `None\` if it isn't. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:307:14 + --> $DIR/unescaped_backticks.rs:308:14 | LL | /// `on_event` should be called. | ^ @@ -253,7 +253,7 @@ LL | /// `on_event\` should be called. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:312:29 + --> $DIR/unescaped_backticks.rs:313:29 | LL | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max | ^ @@ -268,7 +268,7 @@ LL | /// [`rebuild_interest_cache\`][rebuild] is called after the value of the m | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -287,7 +287,7 @@ LL | | /// level changes. to this: `None`. Otherwise, it will return `Some(Dispatch)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -304,7 +304,7 @@ LL | | /// level changes. to this: or `None\` if it isn't. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -323,7 +323,7 @@ LL | | /// level changes. to this: `on_event\` should be called. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -342,7 +342,7 @@ LL | | /// level changes. to this: [`rebuild_interest_cache\`][rebuild] is called after the value of the max error: unescaped backtick - --> $DIR/unescaped_backticks.rs:348:56 + --> $DIR/unescaped_backticks.rs:349:56 | LL | /// instead and use [`CloneCounterObserver::counter`] to increment. | ^ @@ -354,7 +354,7 @@ LL | /// instead and use [`CloneCounterObserver::counter\`] to increment. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:11:5 + --> $DIR/unescaped_backticks.rs:12:5 | LL | /// ` | ^ @@ -366,7 +366,7 @@ LL | /// \` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:18:7 + --> $DIR/unescaped_backticks.rs:19:7 | LL | /// \` | ^ @@ -381,7 +381,7 @@ LL | /// \\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:25:6 + --> $DIR/unescaped_backticks.rs:26:6 | LL | /// [`link1] | ^ @@ -396,7 +396,7 @@ LL | /// [\`link1] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:29:11 + --> $DIR/unescaped_backticks.rs:30:11 | LL | /// [link2`] | ^ @@ -411,7 +411,7 @@ LL | /// [link2\`] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:33:6 + --> $DIR/unescaped_backticks.rs:34:6 | LL | /// [`link_long](link_long) | ^ @@ -426,7 +426,7 @@ LL | /// [\`link_long](link_long) | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:37:6 + --> $DIR/unescaped_backticks.rs:38:6 | LL | /// [`broken-link] | ^ @@ -441,7 +441,7 @@ LL | /// [\`broken-link] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:44:8 + --> $DIR/unescaped_backticks.rs:45:8 | LL | /// | ^ @@ -456,7 +456,7 @@ LL | /// | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:54:6 + --> $DIR/unescaped_backticks.rs:55:6 | LL | /// 🦀`🦀 | ^ @@ -475,7 +475,7 @@ LL | /// 🦀\`🦀 | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:58:5 + --> $DIR/unescaped_backticks.rs:59:5 | LL | /// `foo( | ^ @@ -490,7 +490,7 @@ LL | /// \`foo( | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:64:14 + --> $DIR/unescaped_backticks.rs:65:14 | LL | /// `foo `bar` | ^ @@ -505,7 +505,7 @@ LL | /// `foo `bar\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:70:5 + --> $DIR/unescaped_backticks.rs:71:5 | LL | /// `foo( | ^ @@ -520,7 +520,7 @@ LL | /// \`foo( | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:75:83 + --> $DIR/unescaped_backticks.rs:76:83 | LL | /// Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`. | ^ @@ -535,7 +535,7 @@ LL | /// Addition is commutative, which means that add(a, b)` is the same as `ad | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:79:51 + --> $DIR/unescaped_backticks.rs:80:51 | LL | /// or even to add a number `n` to 42 (`add(42, b)`)! | ^ @@ -550,7 +550,7 @@ LL | /// or even to add a number `n` to 42 (`add(42, b)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:83:83 + --> $DIR/unescaped_backticks.rs:84:83 | LL | /// Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`. | ^ @@ -565,7 +565,7 @@ LL | /// Addition is commutative, which means that `add(a, b) is the same as `ad | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:87:51 + --> $DIR/unescaped_backticks.rs:88:51 | LL | /// or even to add a number `n` to 42 (`add(42, n)`)! | ^ @@ -580,7 +580,7 @@ LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:91:83 + --> $DIR/unescaped_backticks.rs:92:83 | LL | /// Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`. | ^ @@ -595,7 +595,7 @@ LL | /// Addition is commutative, which means that `add(a, b)` is the same as ad | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:95:50 + --> $DIR/unescaped_backticks.rs:96:50 | LL | /// or even to add a number `n` to 42 (add(42, n)`)! | ^ @@ -610,7 +610,7 @@ LL | /// or even to add a number `n` to 42 (add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:99:74 + --> $DIR/unescaped_backticks.rs:100:74 | LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a). | ^ @@ -625,7 +625,7 @@ LL | /// Addition is commutative, which means that `add(a, b)` is the same as \` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:103:51 + --> $DIR/unescaped_backticks.rs:104:51 | LL | /// or even to add a number `n` to 42 (`add(42, n)`)! | ^ @@ -640,7 +640,7 @@ LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:107:1 + --> $DIR/unescaped_backticks.rs:108:1 | LL | #[doc = "`"] | ^^^^^^^^^^^^ @@ -651,7 +651,7 @@ LL | #[doc = "`"] to this: \` error: unescaped backtick - --> $DIR/unescaped_backticks.rs:114:1 + --> $DIR/unescaped_backticks.rs:115:1 | LL | #[doc = concat!("\\", "`")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -664,7 +664,7 @@ LL | #[doc = concat!("\\", "`")] to this: \\` error: unescaped backtick - --> $DIR/unescaped_backticks.rs:118:1 + --> $DIR/unescaped_backticks.rs:119:1 | LL | #[doc = "Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -677,7 +677,7 @@ LL | #[doc = "Addition is commutative, which means that add(a, b)` is the same a to this: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:122:1 + --> $DIR/unescaped_backticks.rs:123:1 | LL | #[doc = "Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -690,7 +690,7 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b) is the same a to this: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:126:1 + --> $DIR/unescaped_backticks.rs:127:1 | LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -703,7 +703,7 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same to this: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:130:1 + --> $DIR/unescaped_backticks.rs:131:1 | LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -716,7 +716,7 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same to this: Addition is commutative, which means that `add(a, b)` is the same as \`add(b, a). error: unescaped backtick - --> $DIR/unescaped_backticks.rs:135:5 + --> $DIR/unescaped_backticks.rs:136:5 | LL | /// `foo | ^ @@ -731,7 +731,7 @@ LL | /// \`foo | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:139:7 + --> $DIR/unescaped_backticks.rs:140:7 | LL | /// # `(heading | ^ @@ -746,7 +746,7 @@ LL | /// # \`(heading | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:141:17 + --> $DIR/unescaped_backticks.rs:142:17 | LL | /// ## heading2)` | ^ @@ -761,7 +761,7 @@ LL | /// ## heading2)\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:144:11 + --> $DIR/unescaped_backticks.rs:145:11 | LL | /// multi `( | ^ @@ -776,7 +776,7 @@ LL | /// multi \`( | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:150:10 + --> $DIR/unescaped_backticks.rs:151:10 | LL | /// para)`(graph | ^ @@ -795,7 +795,7 @@ LL | /// para)\`(graph | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:153:10 + --> $DIR/unescaped_backticks.rs:154:10 | LL | /// para)`(graph2 | ^ @@ -814,7 +814,7 @@ LL | /// para)\`(graph2 | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:156:12 + --> $DIR/unescaped_backticks.rs:157:12 | LL | /// 1. foo)` | ^ @@ -829,7 +829,7 @@ LL | /// 1. foo)\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:158:8 + --> $DIR/unescaped_backticks.rs:159:8 | LL | /// 2. `(bar | ^ @@ -844,7 +844,7 @@ LL | /// 2. \`(bar | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:160:11 + --> $DIR/unescaped_backticks.rs:161:11 | LL | /// * baz)` | ^ @@ -859,7 +859,7 @@ LL | /// * baz)\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:162:7 + --> $DIR/unescaped_backticks.rs:163:7 | LL | /// * `(quux | ^ @@ -874,7 +874,7 @@ LL | /// * \`(quux | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:165:5 + --> $DIR/unescaped_backticks.rs:166:5 | LL | /// `#![this_is_actually_an_image(and(not), an = "attribute")] | ^ @@ -889,7 +889,7 @@ LL | /// \`#![this_is_actually_an_image(and(not), an = "attribute")] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:168:62 + --> $DIR/unescaped_backticks.rs:169:62 | LL | /// #![this_is_actually_an_image(and(not), an = "attribute")]` | ^ @@ -904,7 +904,7 @@ LL | /// #![this_is_actually_an_image(and(not), an = "attribute")]\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:173:7 + --> $DIR/unescaped_backticks.rs:174:7 | LL | /// | `table( | )head` | | ^ @@ -919,7 +919,7 @@ LL | /// | \`table( | )head` | | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:173:22 + --> $DIR/unescaped_backticks.rs:174:22 | LL | /// | `table( | )head` | | ^ @@ -934,7 +934,7 @@ LL | /// | `table( | )head\` | | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:177:12 + --> $DIR/unescaped_backticks.rs:178:12 | LL | /// | table`( | )`body | | ^ @@ -949,7 +949,7 @@ LL | /// | table\`( | )`body | | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:177:18 + --> $DIR/unescaped_backticks.rs:178:18 | LL | /// | table`( | )`body | | ^ diff --git a/tests/rustdoc/alias-reexport.rs b/tests/rustdoc/alias-reexport.rs index a2a8e651c..4003ecec2 100644 --- a/tests/rustdoc/alias-reexport.rs +++ b/tests/rustdoc/alias-reexport.rs @@ -3,6 +3,7 @@ #![crate_name = "foo"] #![feature(lazy_type_alias)] +#![allow(incomplete_features)] extern crate alias_reexport2; diff --git a/tests/rustdoc/alias-reexport2.rs b/tests/rustdoc/alias-reexport2.rs index 85d3cdad9..5f6357ad1 100644 --- a/tests/rustdoc/alias-reexport2.rs +++ b/tests/rustdoc/alias-reexport2.rs @@ -3,6 +3,7 @@ #![crate_name = "foo"] #![feature(lazy_type_alias)] +#![allow(incomplete_features)] extern crate alias_reexport; diff --git a/tests/rustdoc/anchors.no_const_anchor.html b/tests/rustdoc/anchors.no_const_anchor.html index a8587829d..06673d874 100644 --- a/tests/rustdoc/anchors.no_const_anchor.html +++ b/tests/rustdoc/anchors.no_const_anchor.html @@ -1 +1 @@ -
source

const YOLO: u32

\ No newline at end of file +
source

const YOLO: u32

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_const_anchor2.html b/tests/rustdoc/anchors.no_const_anchor2.html index 4c5e45fea..73c3d0a80 100644 --- a/tests/rustdoc/anchors.no_const_anchor2.html +++ b/tests/rustdoc/anchors.no_const_anchor2.html @@ -1 +1 @@ -
source

pub const X: i32 = 0i32

\ No newline at end of file +
source

pub const X: i32 = 0i32

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_method_anchor.html b/tests/rustdoc/anchors.no_method_anchor.html index 44957a5b7..e8b61caa1 100644 --- a/tests/rustdoc/anchors.no_method_anchor.html +++ b/tests/rustdoc/anchors.no_method_anchor.html @@ -1 +1 @@ -
source

pub fn new() -> Self

\ No newline at end of file +
source

pub fn new() -> Self

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_trait_method_anchor.html b/tests/rustdoc/anchors.no_trait_method_anchor.html index 75c2caf87..abdb17c27 100644 --- a/tests/rustdoc/anchors.no_trait_method_anchor.html +++ b/tests/rustdoc/anchors.no_trait_method_anchor.html @@ -1 +1 @@ -
source

fn bar()

\ No newline at end of file +
source

fn bar()

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_tymethod_anchor.html b/tests/rustdoc/anchors.no_tymethod_anchor.html index 38575eadf..23f4277c5 100644 --- a/tests/rustdoc/anchors.no_tymethod_anchor.html +++ b/tests/rustdoc/anchors.no_tymethod_anchor.html @@ -1 +1 @@ -
source

fn foo()

\ No newline at end of file +
source

fn foo()

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_type_anchor.html b/tests/rustdoc/anchors.no_type_anchor.html index dd65d98fe..62b929550 100644 --- a/tests/rustdoc/anchors.no_type_anchor.html +++ b/tests/rustdoc/anchors.no_type_anchor.html @@ -1 +1 @@ -
source

type T

\ No newline at end of file +
source

type T

\ No newline at end of file diff --git a/tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs new file mode 100644 index 000000000..a1a716f5a --- /dev/null +++ b/tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs @@ -0,0 +1,3 @@ +#![crate_name = "colors"] + +pub struct Color; diff --git a/tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs b/tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs new file mode 100644 index 000000000..eacec957a --- /dev/null +++ b/tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs @@ -0,0 +1 @@ +pub struct Ident; diff --git a/tests/rustdoc/check-source-code-urls-to-def.rs b/tests/rustdoc/check-source-code-urls-to-def.rs index 41b9d41fa..b803c7e9e 100644 --- a/tests/rustdoc/check-source-code-urls-to-def.rs +++ b/tests/rustdoc/check-source-code-urls-to-def.rs @@ -14,10 +14,10 @@ extern crate source_code; #[path = "auxiliary/source-code-bar.rs"] pub mod bar; -// @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5"]' 4 +// @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4 use bar::Bar; -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13"]' 'self' -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait' +// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self' +// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' use bar::sub::{self, Trait}; pub struct Foo; @@ -32,7 +32,8 @@ fn babar() {} // @has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html' // @has - '//pre[@class="rust"]//a/@href' '/primitive.str.html' // @count - '//pre[@class="rust"]//a[@href="#23"]' 5 -// @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode' +// @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \ +// 'source_code::SourceCode' pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { let x = 12; let y: Foo = Foo; @@ -42,15 +43,15 @@ pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::Sour y.hello(); } -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait' -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait' +// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait' +// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' pub fn foo2(t: &T, v: &V, b: bool) {} pub trait AnotherTrait {} pub trait WhyNot {} -// @has - '//pre[@class="rust"]//a[@href="#49"]' 'AnotherTrait' -// @has - '//pre[@class="rust"]//a[@href="#50"]' 'WhyNot' +// @has - '//pre[@class="rust"]//a[@href="#50"]' 'AnotherTrait' +// @has - '//pre[@class="rust"]//a[@href="#51"]' 'WhyNot' pub fn foo3(t: &T, v: &V) where T: AnotherTrait, @@ -59,7 +60,7 @@ where pub trait AnotherTrait2 {} -// @has - '//pre[@class="rust"]//a[@href="#60"]' 'AnotherTrait2' +// @has - '//pre[@class="rust"]//a[@href="#61"]' 'AnotherTrait2' pub fn foo4() { let x: Vec = Vec::new(); } diff --git a/tests/rustdoc/default-trait-method.rs b/tests/rustdoc/default-trait-method.rs index 6d0e339c4..c89506781 100644 --- a/tests/rustdoc/default-trait-method.rs +++ b/tests/rustdoc/default-trait-method.rs @@ -1,26 +1,45 @@ #![feature(min_specialization)] // @has default_trait_method/trait.Item.html -// @has - '//*[@id="tymethod.foo"]' 'fn foo()' -// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()' -// @has - '//*[@id="tymethod.bar"]' 'fn bar()' -// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()' -// @has - '//*[@id="method.baz"]' 'fn baz()' -// @!has - '//*[@id="method.baz"]' 'default fn baz()' pub trait Item { + // @has - '//*[@id="tymethod.foo"]' 'fn foo()' + // @!has - '//*[@id="tymethod.foo"]' 'default fn foo()' fn foo(); + + // @has - '//*[@id="tymethod.bar"]' 'fn bar()' + // @!has - '//*[@id="tymethod.bar"]' 'default fn bar()' fn bar(); - fn baz() {} + + // @has - '//*[@id="tymethod.baz"]' 'unsafe fn baz()' + // @!has - '//*[@id="tymethod.baz"]' 'default unsafe fn baz()' + unsafe fn baz(); + + // @has - '//*[@id="tymethod.quux"]' 'unsafe fn quux()' + // @!has - '//*[@id="tymethod.quux"]' 'default unsafe fn quux()' + unsafe fn quux(); + + // @has - '//*[@id="method.xyzzy"]' 'fn xyzzy()' + // @!has - '//*[@id="method.xyzzy"]' 'default fn xyzzy()' + fn xyzzy() {} } // @has default_trait_method/struct.Foo.html -// @has - '//*[@id="method.foo"]' 'default fn foo()' -// @has - '//*[@id="method.bar"]' 'fn bar()' -// @!has - '//*[@id="method.bar"]' 'default fn bar()' -// @has - '//*[@id="method.baz"]' 'fn baz()' -// @!has - '//*[@id="method.baz"]' 'default fn baz()' pub struct Foo; impl Item for Foo { + // @has - '//*[@id="method.foo"]' 'default fn foo()' default fn foo() {} + + // @has - '//*[@id="method.bar"]' 'fn bar()' + // @!has - '//*[@id="method.bar"]' 'default fn bar()' fn bar() {} + + // @has - '//*[@id="method.baz"]' 'default unsafe fn baz()' + default unsafe fn baz() {} + + // @has - '//*[@id="method.quux"]' 'unsafe fn quux()' + // @!has - '//*[@id="method.quux"]' 'default unsafe fn quux()' + unsafe fn quux() {} + + // @has - '//*[@id="method.xyzzy"]' 'fn xyzzy()' + // @!has - '//*[@id="method.xyzzy"]' 'default fn xyzzy()' } diff --git a/tests/rustdoc/description.rs b/tests/rustdoc/description.rs index 43cd59ebd..aabbb4c4c 100644 --- a/tests/rustdoc/description.rs +++ b/tests/rustdoc/description.rs @@ -1,4 +1,5 @@ #![crate_name = "foo"] +#![allow(rustdoc::redundant_explicit_links)] //! # Description test crate //! //! This is the contents of the test crate docstring. diff --git a/tests/rustdoc/display-hidden-items.rs b/tests/rustdoc/display-hidden-items.rs new file mode 100644 index 000000000..d97d5b4a9 --- /dev/null +++ b/tests/rustdoc/display-hidden-items.rs @@ -0,0 +1,71 @@ +// Test to ensure that the `--document-hidden-items` option is working as expected. +// compile-flags: -Z unstable-options --document-hidden-items +// ignore-tidy-linelength + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// @has - '//*[@id="reexport.hidden_reexport"]/code' 'pub use hidden::inside_hidden as hidden_reexport;' +#[doc(hidden)] +pub use hidden::inside_hidden as hidden_reexport; + +// @has - '//*[@class="item-name"]/a[@class="trait"]' 'TraitHidden' +// @has 'foo/trait.TraitHidden.html' +#[doc(hidden)] +pub trait TraitHidden {} + +// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="trait"]' 'Trait' +pub trait Trait { + // @has 'foo/trait.Trait.html' + // @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' 'const BAR: u32 = 0u32' + #[doc(hidden)] + const BAR: u32 = 0; + + // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()' + #[doc(hidden)] + fn foo() {} +} + +// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="struct"]' 'Struct' +// @has 'foo/struct.Struct.html' +pub struct Struct { + // @has - '//*[@id="structfield.a"]/code' 'a: u32' + #[doc(hidden)] + pub a: u32, +} + +impl Struct { + // @has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> Self' + #[doc(hidden)] + pub fn new() -> Self { Self { a: 0 } } +} + +impl Trait for Struct { + // @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' 'const BAR: u32 = 0u32' + // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()' +} +// @has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct' +impl TraitHidden for Struct {} + +// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'HiddenEnum' +// @has 'foo/enum.HiddenEnum.html' +#[doc(hidden)] +pub enum HiddenEnum { + A, +} + +// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'Enum' +pub enum Enum { + // @has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A' + #[doc(hidden)] + A, +} + +// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="mod"]' 'hidden' +#[doc(hidden)] +pub mod hidden { + // @has 'foo/hidden/index.html' + // @has - '//*[@class="item-name"]/a[@class="fn"]' 'inside_hidden' + // @has 'foo/hidden/fn.inside_hidden.html' + pub fn inside_hidden() {} +} diff --git a/tests/rustdoc/ensure-src-link.rs b/tests/rustdoc/ensure-src-link.rs index c65387080..f99c4c4d9 100644 --- a/tests/rustdoc/ensure-src-link.rs +++ b/tests/rustdoc/ensure-src-link.rs @@ -2,5 +2,5 @@ // This test ensures that the [src] link is present on traits items. -// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="srclink rightside"]' "source" +// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src rightside"]' "source" pub use std::iter::Iterator; diff --git a/tests/rustdoc/extern-impl-trait.rs b/tests/rustdoc/extern-impl-trait.rs index 8ab026afd..4d8672305 100644 --- a/tests/rustdoc/extern-impl-trait.rs +++ b/tests/rustdoc/extern-impl-trait.rs @@ -7,5 +7,5 @@ extern crate extern_impl_trait; // @has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo + 'a" pub use extern_impl_trait::X; -// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl ?Sized + Foo + 'a" +// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo + ?Sized + 'a" pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/generic-const-items.rs b/tests/rustdoc/generic-const-items.rs new file mode 100644 index 000000000..e2c6a027a --- /dev/null +++ b/tests/rustdoc/generic-const-items.rs @@ -0,0 +1,38 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// @has 'generic_const_items/constant.K.html' +// @has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From;" +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From; + +// @has generic_const_items/trait.Trait.html +pub trait Trait { + // @has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a T \ + // where \ + // T: 'a + Eq" + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +// @has generic_const_items/struct.Implementor.html +// @has - '//h3[@class="code-header"]' 'impl Trait for Implementor' +impl Trait for Implementor { + // @has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a str = \"C\" \ + // where \ + // str: 'a" + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/impl-everywhere.rs b/tests/rustdoc/impl-everywhere.rs index 44885d430..2311c806c 100644 --- a/tests/rustdoc/impl-everywhere.rs +++ b/tests/rustdoc/impl-everywhere.rs @@ -25,6 +25,6 @@ pub fn foo_foo() -> impl Foo + Foo2 { Bar } -// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo + Foo2" +// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { } diff --git a/tests/rustdoc/inherent-projections.rs b/tests/rustdoc/inherent-projections.rs index 9bda0acaf..25f512826 100644 --- a/tests/rustdoc/inherent-projections.rs +++ b/tests/rustdoc/inherent-projections.rs @@ -13,8 +13,8 @@ impl Owner { } // Make sure we handle bound vars correctly. -// @has 'inherent_projections/type.User.html' '//pre[@class="rust item-decl"]' "for<'a> fn(_: Carrier<'a>::Focus)" -pub type User = for<'a> fn(Carrier<'a>::Focus); +// @has 'inherent_projections/fn.user.html' '//pre[@class="rust item-decl"]' "user(_: for<'a> fn(_: Carrier<'a>::Focus))" +pub fn user(_: for<'a> fn(Carrier<'a>::Focus)) {} pub struct Carrier<'a>(&'a ()); @@ -27,11 +27,11 @@ impl<'a> Carrier<'a> { // FIXME(inherent_associated_types): Below we link to `Proj` but we should link to `Proj-1`. // The current test checks for the buggy behavior for demonstration purposes. -// @has 'inherent_projections/type.Test.html' -// @has - '//pre[@class="rust item-decl"]' "Parametrized" +// @has 'inherent_projections/fn.test.html' +// @has - '//pre[@class="rust item-decl"]' "test(_: Parametrized::Proj)" // @has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj' // @!has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj-1' -pub type Test = Parametrized::Proj; +pub fn test(_: Parametrized::Proj) {} pub struct Parametrized(T); diff --git a/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs b/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs new file mode 100644 index 000000000..0fc7a7aae --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs @@ -0,0 +1,22 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From; + +pub trait Trait { + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +impl Trait for Implementor { + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs b/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs new file mode 100644 index 000000000..65f72a3b9 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs @@ -0,0 +1,21 @@ +use std::fmt::Debug; + +pub fn sized(x: impl Sized) -> impl Sized { + x +} + +pub fn sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a { + x +} + +pub fn maybe_sized(x: &impl ?Sized) -> &impl ?Sized { + x +} + +pub fn debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized) { + x +} + +pub fn maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't) { + x +} diff --git a/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs new file mode 100644 index 000000000..c72f01115 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs @@ -0,0 +1,35 @@ +#![feature(return_position_impl_trait_in_trait)] + +pub trait Trait { + fn create() -> impl Iterator { + std::iter::empty() + } +} + +pub struct Basic; +pub struct Intermediate; +pub struct Advanced; + +impl Trait for Basic { + // method provided by the trait +} + +impl Trait for Intermediate { + fn create() -> std::ops::Range { // concrete return type + 0..1 + } +} + +impl Trait for Advanced { + fn create() -> impl Iterator { // opaque return type + std::iter::repeat(0) + } +} + +// Regression test for issue #113929: + +pub trait Def { + fn def() -> impl Default {} +} + +impl Def for () {} diff --git a/tests/rustdoc/inline_cross/generic-const-items.rs b/tests/rustdoc/inline_cross/generic-const-items.rs new file mode 100644 index 000000000..70cf7af88 --- /dev/null +++ b/tests/rustdoc/inline_cross/generic-const-items.rs @@ -0,0 +1,26 @@ +#![crate_name = "user"] + +// aux-crate:generic_const_items=generic-const-items.rs +// edition:2021 + +// @has 'user/constant.K.html' +// @has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From;" +pub use generic_const_items::K; + +// @has user/trait.Trait.html +// @has - '//*[@id="associatedconstant.C"]' \ +// "const C<'a>: &'a T \ +// where \ +// T: 'a + Eq" +pub use generic_const_items::Trait; + +// @has user/struct.Implementor.html +// @has - '//h3[@class="code-header"]' 'impl Trait for Implementor' +// @has - '//*[@id="associatedconstant.C"]' \ +// "const C<'a>: &'a str = \"C\" \ +// where \ +// str: 'a" +pub use generic_const_items::Implementor; diff --git a/tests/rustdoc/inline_cross/impl-sized.rs b/tests/rustdoc/inline_cross/impl-sized.rs new file mode 100644 index 000000000..82bdce474 --- /dev/null +++ b/tests/rustdoc/inline_cross/impl-sized.rs @@ -0,0 +1,27 @@ +#![crate_name = "user"] + +// aux-crate:impl_sized=impl-sized.rs +// edition:2021 + +// @has user/fn.sized.html +// @has - '//pre[@class="rust item-decl"]' "sized(x: impl Sized) -> impl Sized" +pub use impl_sized::sized; + +// @has user/fn.sized_outlives.html +// @has - '//pre[@class="rust item-decl"]' \ +// "sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a" +pub use impl_sized::sized_outlives; + +// @has user/fn.maybe_sized.html +// @has - '//pre[@class="rust item-decl"]' "maybe_sized(x: &impl ?Sized) -> &impl ?Sized" +pub use impl_sized::maybe_sized; + +// @has user/fn.debug_maybe_sized.html +// @has - '//pre[@class="rust item-decl"]' \ +// "debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized)" +pub use impl_sized::debug_maybe_sized; + +// @has user/fn.maybe_sized_outlives.html +// @has - '//pre[@class="rust item-decl"]' \ +// "maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't)" +pub use impl_sized::maybe_sized_outlives; diff --git a/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs new file mode 100644 index 000000000..8e9ef9020 --- /dev/null +++ b/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs @@ -0,0 +1,35 @@ +#![crate_name = "user"] +// aux-crate:rpitit=ret-pos-impl-trait-in-trait.rs +// edition:2021 + +// Test that we can correctly render cross-crate RPITITs. +// In particular, check that we don't render the internal associated type generated by +// their desugaring. We count the number of associated items and ensure that it is exactly one. +// This is more robust than checking for the absence of the associated type. + +// @has user/trait.Trait.html +// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator' +// The class "method" is used for all three kinds of associated items at the time of writing. +// @count - '//*[@id="main-content"]//section[@class="method"]' 1 +pub use rpitit::Trait; + +// @has user/struct.Basic.html +// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator' +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +pub use rpitit::Basic; + +// @has user/struct.Intermediate.html +// @has - '//*[@id="method.create"]' 'fn create() -> Range' +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +pub use rpitit::Intermediate; + +// @has user/struct.Advanced.html +// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator' +// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +pub use rpitit::Advanced; + +// Regression test for issue #113929: + +// @has user/trait.Def.html +// @has - '//*[@id="method.def"]' 'fn def() -> impl Default' +pub use rpitit::Def; diff --git a/tests/rustdoc/intra-doc/basic.rs b/tests/rustdoc/intra-doc/basic.rs index 96e21137b..c88a7887f 100644 --- a/tests/rustdoc/intra-doc/basic.rs +++ b/tests/rustdoc/intra-doc/basic.rs @@ -1,3 +1,5 @@ +#![allow(rustdoc::redundant_explicit_links)] + // @has basic/index.html // @has - '//a/@href' 'struct.ThisType.html' // @has - '//a/@title' 'struct basic::ThisType' diff --git a/tests/rustdoc/intra-doc/generic-params.rs b/tests/rustdoc/intra-doc/generic-params.rs index fbc9fc6a9..359f775f9 100644 --- a/tests/rustdoc/intra-doc/generic-params.rs +++ b/tests/rustdoc/intra-doc/generic-params.rs @@ -1,6 +1,7 @@ // ignore-tidy-linelength #![crate_name = "foo"] +#![allow(rustdoc::redundant_explicit_links)] //! Here's a link to [`Vec`] and one to [`Box>>`]. //! Here's a link to [`Iterator>::Item`]. diff --git a/tests/rustdoc/intra-doc/issue-108459.rs b/tests/rustdoc/intra-doc/issue-108459.rs index eb1c7a05e..b8cd478b4 100644 --- a/tests/rustdoc/intra-doc/issue-108459.rs +++ b/tests/rustdoc/intra-doc/issue-108459.rs @@ -1,4 +1,5 @@ #![deny(rustdoc::broken_intra_doc_links)] +#![allow(rustdoc::redundant_explicit_links)] pub struct S; pub mod char {} diff --git a/tests/rustdoc/intra-doc/nested-use.rs b/tests/rustdoc/intra-doc/nested-use.rs new file mode 100644 index 000000000..19ebfff1b --- /dev/null +++ b/tests/rustdoc/intra-doc/nested-use.rs @@ -0,0 +1,16 @@ +// Regression test for issue #113896: Intra-doc links on nested use items. + +#![crate_name = "foo"] + +// @has foo/struct.Foo.html +// @has - '//a[@href="struct.Foo.html"]' 'Foo' +// @has - '//a[@href="struct.Bar.html"]' 'Bar' + +/// [`Foo`] +pub use m::{Foo, Bar}; + +mod m { + /// [`Bar`] + pub struct Foo; + pub struct Bar; +} diff --git a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs new file mode 100644 index 000000000..910824839 --- /dev/null +++ b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs @@ -0,0 +1,25 @@ +// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. + +#![crate_name = "foo"] +#![no_std] + +// @has 'foo/index.html' +// @has - '//*[@class="item-name"]/a[@class="type"]' 'AtomicU8' +// @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' +// We also ensure we don't have another item displayed. +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 2 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' + +mod other { + pub type AtomicU8 = (); +} + +mod thing { + pub use crate::other::AtomicU8; + + #[allow(non_upper_case_globals)] + pub const AtomicU8: () = (); +} + +pub use crate::thing::AtomicU8; diff --git a/tests/rustdoc/issue-105735-overlapping-reexport.rs b/tests/rustdoc/issue-105735-overlapping-reexport.rs new file mode 100644 index 000000000..50f2450b9 --- /dev/null +++ b/tests/rustdoc/issue-105735-overlapping-reexport.rs @@ -0,0 +1,21 @@ +// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. + +#![crate_name = "foo"] +#![no_std] + +// @has 'foo/index.html' +// @has - '//*[@class="item-name"]/a[@class="struct"]' 'AtomicU8' +// @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' +// We also ensure we don't have another item displayed. +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 2 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' + +mod thing { + pub use core::sync::atomic::AtomicU8; + + #[allow(non_upper_case_globals)] + pub const AtomicU8: () = (); +} + +pub use crate::thing::AtomicU8; diff --git a/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs new file mode 100644 index 000000000..88b86d15c --- /dev/null +++ b/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs @@ -0,0 +1,19 @@ +// aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs + +#![feature(no_core, doc_auto_cfg)] +#![no_core] +#![crate_name = "foo"] + +extern crate colors; + +// @has 'foo/index.html' '//*[@class="stab portability"]' 'Non-colors' +// @has 'foo/struct.Color.html' '//*[@class="stab portability"]' \ +// 'Available on non-crate feature colors only.' +#[cfg(not(feature = "colors"))] +pub use colors::*; + +// @has 'foo/index.html' '//*[@class="stab portability"]' 'Non-fruits' +// @has 'foo/struct.Red.html' '//*[@class="stab portability"]' \ +// 'Available on non-crate feature fruits only.' +#[cfg(not(feature = "fruits"))] +pub use colors::Color as Red; diff --git a/tests/rustdoc/issue-18199.rs b/tests/rustdoc/issue-18199.rs index bc0c4a565..9cc58b162 100644 --- a/tests/rustdoc/issue-18199.rs +++ b/tests/rustdoc/issue-18199.rs @@ -3,6 +3,7 @@ #![doc(test(attr(feature(staged_api))))] /// ``` +/// #![allow(internal_features)] /// #![unstable(feature="test", issue="18199")] /// fn main() {} /// ``` diff --git a/tests/rustdoc/issue-33178.rs b/tests/rustdoc/issue-33178.rs index 1f45fe723..ed643f5ae 100644 --- a/tests/rustdoc/issue-33178.rs +++ b/tests/rustdoc/issue-33178.rs @@ -4,10 +4,11 @@ // ignore-cross-compile // @has issue_33178/index.html -// @has - //a/@title empty -// @has - //a/@href ../empty/index.html +// @has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty pub extern crate empty; -// @has - //a/@title variant_struct -// @has - //a/@href ../variant_struct/index.html +// @has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct pub extern crate variant_struct as foo; + +// @has - '//a[@title="mod issue_33178"][@href="index.html"]' self +pub extern crate self as bar; diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs new file mode 100644 index 000000000..4e9d188bb --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs @@ -0,0 +1,13 @@ +// edition:2015 + +#![crate_name = "foo"] + +use external::Public as Private; + +pub mod external { + pub struct Public; + + // @has 'foo/external/fn.make.html' + // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' + pub fn make() -> ::Private { super::Private } +} diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs new file mode 100644 index 000000000..7e2895086 --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs @@ -0,0 +1,13 @@ +#![crate_name = "foo"] + +use crate::bar::Foo as Alias; + +pub mod bar { + pub struct Foo<'a, T>(&'a T); +} + +// @has "foo/fn.foo.html" +// @has - '//*[@class="rust item-decl"]/code' "pub fn foo<'a, T>(f: Foo<'a, T>) -> Foo<'a, usize>" +pub fn foo<'a, T>(f: Alias<'a, T>) -> Alias<'a, usize> { + Alias(&0) +} diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs new file mode 100644 index 000000000..5053a328b --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs @@ -0,0 +1,16 @@ +// compile-flags: -Z unstable-options --document-hidden-items + +#![crate_name = "foo"] + +#[doc(hidden)] +pub use crate::bar::Bar as Alias; + +mod bar { + pub struct Bar; +} + +// @has 'foo/fn.bar.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Alias' +pub fn bar() -> Alias { + Alias +} diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs new file mode 100644 index 000000000..15749674a --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs @@ -0,0 +1,32 @@ +// compile-flags: --document-private-items + +#![crate_name = "foo"] + +use crate::bar::Bar as Alias; +pub(crate) use crate::bar::Bar as CrateAlias; + +mod bar { + pub struct Bar; + pub use self::Bar as Inner; +} + +// It's a fully private re-export so it should not be displayed. +// @has 'foo/fn.bar.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' +pub fn bar() -> Alias { + Alias +} + +// It's public re-export inside a private module so it should be visible. +// @has 'foo/fn.bar2.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Inner' +pub fn bar2() -> crate::bar::Inner { + Alias +} + +// It's a non-public, so it doesn't appear in documentation so it should not be visible. +// @has 'foo/fn.bar3.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Bar' +pub fn bar3() -> CrateAlias { + Alias +} diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs new file mode 100644 index 000000000..bd54d02c6 --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs @@ -0,0 +1,124 @@ +// This test ensures that if a private re-export is present in a public API, it'll be +// replaced by the first public item in the re-export chain or by the private item. + +#![crate_name = "foo"] + +use crate::bar::Bar as Alias; + +pub use crate::bar::Bar as Whatever; +use crate::Whatever as Whatever2; +use crate::Whatever2 as Whatever3; +pub use crate::bar::Inner as Whatever4; + +mod bar { + pub struct Bar; + pub use self::Bar as Inner; +} + +// @has 'foo/fn.bar.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' +pub fn bar() -> Alias { + Alias +} + +// @has 'foo/fn.bar2.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Whatever' +pub fn bar2() -> Whatever3 { + Whatever +} + +// @has 'foo/fn.bar3.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Whatever4' +pub fn bar3() -> Whatever4 { + Whatever +} + +// @has 'foo/fn.bar4.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar4() -> Bar' +pub fn bar4() -> crate::Alias { + Alias +} + +// @has 'foo/fn.bar5.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar5() -> Whatever' +pub fn bar5() -> crate::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar6.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar6() -> Whatever4' +pub fn bar6() -> crate::Whatever4 { + Whatever +} + + +// @has 'foo/fn.bar7.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar7() -> Bar' +pub fn bar7() -> self::Alias { + Alias +} + +// @has 'foo/fn.bar8.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar8() -> Whatever' +pub fn bar8() -> self::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar9.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar9() -> Whatever4' +pub fn bar9() -> self::Whatever4 { + Whatever +} + +mod nested { + pub(crate) use crate::Alias; + pub(crate) use crate::Whatever3; + pub(crate) use crate::Whatever4; + pub(crate) use crate::nested as nested2; +} + +// @has 'foo/fn.bar10.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar10() -> Bar' +pub fn bar10() -> nested::Alias { + Alias +} + +// @has 'foo/fn.bar11.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar11() -> Whatever' +pub fn bar11() -> nested::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar12.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar12() -> Whatever4' +pub fn bar12() -> nested::Whatever4 { + Whatever +} + +// @has 'foo/fn.bar13.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar13() -> Bar' +pub fn bar13() -> nested::nested2::Alias { + Alias +} + +// @has 'foo/fn.bar14.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar14() -> Whatever' +pub fn bar14() -> nested::nested2::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar15.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar15() -> Whatever4' +pub fn bar15() -> nested::nested2::Whatever4 { + Whatever +} + +use external::Public as Private; + +pub mod external { + pub struct Public; + + // @has 'foo/external/fn.make.html' + // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' + pub fn make() -> super::Private { super::Private } +} diff --git a/tests/rustdoc/jump-to-def-doc-links.rs b/tests/rustdoc/jump-to-def-doc-links.rs new file mode 100644 index 000000000..014d58032 --- /dev/null +++ b/tests/rustdoc/jump-to-def-doc-links.rs @@ -0,0 +1,51 @@ +// compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +// @has 'src/foo/jump-to-def-doc-links.rs.html' + +// @has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +// @has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo' +pub struct Bar; pub struct Foo; + +// @has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum' +pub enum Enum { + Variant1(String), + Variant2(u8), +} + +// @has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct' +pub struct Struct { + pub a: u8, + b: Foo, +} + +impl Struct { + pub fn foo() {} + pub fn foo2(&self) {} + fn bar() {} + fn bar(&self) {} +} + +// @has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait' +pub trait Trait { + fn foo(); +} + +impl Trait for Struct { + fn foo() {} +} + +// @has - '//a[@href="../../foo/union.Union.html"]' 'Union' +pub union Union { + pub a: u16, + pub f: u32, +} + +// @has - '//a[@href="../../foo/fn.bar.html"]' 'bar' +pub fn bar(b: Bar) { + let x = Foo; +} + +// @has - '//a[@href="../../foo/bar/index.html"]' 'bar' +pub mod bar {} diff --git a/tests/rustdoc/private-use.rs b/tests/rustdoc/private-use.rs new file mode 100644 index 000000000..689ed7314 --- /dev/null +++ b/tests/rustdoc/private-use.rs @@ -0,0 +1,13 @@ +// Regression test for to +// ensure it doesn't panic. + +mod generics { + pub enum WherePredicate { + EqPredicate, + } +} +pub mod visit { + use *; + pub fn visit_where_predicate(_visitor: &mut V, _i: &WherePredicate) {} +} +pub use generics::*; diff --git a/tests/rustdoc/source-file.rs b/tests/rustdoc/source-file.rs index 4e1664790..16d4cbe3a 100644 --- a/tests/rustdoc/source-file.rs +++ b/tests/rustdoc/source-file.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @hasraw source-files.js source-file.rs +// @hasraw src-files.js source-file.rs pub struct Foo; diff --git a/tests/rustdoc/src-links-auto-impls.rs b/tests/rustdoc/src-links-auto-impls.rs index 953563833..1c8d15731 100644 --- a/tests/rustdoc/src-links-auto-impls.rs +++ b/tests/rustdoc/src-links-auto-impls.rs @@ -2,11 +2,11 @@ // @has foo/struct.Unsized.html // @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' -// @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="srclink"]' 'source' +// @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'source' // @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' -// @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="srclink"]' 'source' +// @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'source' // @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header"]' 'impl Any for T' -// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="srclink rightside"]' 'source' +// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="src rightside"]' 'source' pub struct Unsized { data: [u8], } diff --git a/tests/rustdoc/static-root-path.rs b/tests/rustdoc/static-root-path.rs index 86928b0fb..3148ea047 100644 --- a/tests/rustdoc/static-root-path.rs +++ b/tests/rustdoc/static-root-path.rs @@ -8,10 +8,10 @@ pub struct SomeStruct; // @has src/static_root_path/static-root-path.rs.html -// @matchesraw - '"/cache/source-script-' -// @!matchesraw - '"\.\./\.\./source-script' -// @matchesraw - '"\.\./\.\./source-files.js"' -// @!matchesraw - '"/cache/source-files\.js"' +// @matchesraw - '"/cache/src-script-' +// @!matchesraw - '"\.\./\.\./src-script' +// @matchesraw - '"\.\./\.\./src-files.js"' +// @!matchesraw - '"/cache/src-files\.js"' // @has settings.html // @matchesraw - '/cache/settings-' diff --git a/tests/ui-fulldeps/missing-rustc-driver-error.rs b/tests/ui-fulldeps/missing-rustc-driver-error.rs index 654cd6f6d..b627a207c 100644 --- a/tests/ui-fulldeps/missing-rustc-driver-error.rs +++ b/tests/ui-fulldeps/missing-rustc-driver-error.rs @@ -1,8 +1,8 @@ // Test that we get the following hint when trying to use a compiler crate without rustc_driver. // error-pattern: try adding `extern crate rustc_driver;` at the top level of this crate // compile-flags: --emit link -// The exactly list of required crates depends on the target. as such only test Unix targets. -// only-unix +// normalize-stderr-test ".*crate .* required.*\n\n" -> "" +// normalize-stderr-test: "aborting due to [0-9]+" -> "aborting due to NUMBER" #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/missing-rustc-driver-error.stderr b/tests/ui-fulldeps/missing-rustc-driver-error.stderr index 939e888e5..d7bf27d63 100644 --- a/tests/ui-fulldeps/missing-rustc-driver-error.stderr +++ b/tests/ui-fulldeps/missing-rustc-driver-error.stderr @@ -2,15 +2,5 @@ error: crate `rustc_serialize` required to be available in rlib format, but was | = help: try adding `extern crate rustc_driver;` at the top level of this crate -error: crate `smallvec` required to be available in rlib format, but was not found in this form - -error: crate `thin_vec` required to be available in rlib format, but was not found in this form - -error: crate `indexmap` required to be available in rlib format, but was not found in this form - -error: crate `hashbrown` required to be available in rlib format, but was not found in this form - -error: crate `equivalent` required to be available in rlib format, but was not found in this form - -error: aborting due to 6 previous errors +error: aborting due to NUMBER previous errors diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index ffbefce48..c30120e5c 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -53,7 +53,7 @@ enum DiagnosticOnEnum { #[derive(Diagnostic)] #[diag(no_crate_example, code = "E0123")] #[diag = "E0123"] -//~^ ERROR expected parentheses: #[diag(...)] +//~^ ERROR failed to resolve: maybe a missing crate `core` struct WrongStructAttrStyle {} #[derive(Diagnostic)] @@ -644,7 +644,7 @@ struct MissingCodeInSuggestion { //~| ERROR cannot find attribute `multipart_suggestion` in this scope #[multipart_suggestion()] //~^ ERROR cannot find attribute `multipart_suggestion` in this scope -//~| ERROR unexpected end of input, unexpected token in nested attribute, expected ident +//~| ERROR `#[multipart_suggestion(...)]` is not a valid attribute struct MultipartSuggestion { #[multipart_suggestion(no_crate_suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute @@ -797,7 +797,7 @@ struct SuggestionsNoItem { struct SuggestionsInvalidItem { #[suggestion(code(foo))] //~^ ERROR `code(...)` must contain only string literals - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core` sub: Span, } @@ -805,7 +805,7 @@ struct SuggestionsInvalidItem { #[diag(no_crate_example)] struct SuggestionsInvalidLiteral { #[suggestion(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: maybe a missing crate `core` sub: Span, } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 1398f9c96..ca09f1f01 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -20,12 +20,6 @@ LL | Bar, | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: expected parentheses: #[diag(...)] - --> $DIR/diagnostic-derive.rs:55:8 - | -LL | #[diag = "E0123"] - | ^ - error: `#[nonsense(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:60:1 | @@ -476,6 +470,14 @@ LL | #[multipart_suggestion(no_crate_suggestion)] | = help: consider creating a `Subdiagnostic` instead +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:645:1 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:649:5 | @@ -484,12 +486,6 @@ LL | #[multipart_suggestion(no_crate_suggestion)] | = help: consider creating a `Subdiagnostic` instead -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/diagnostic-derive.rs:645:24 - | -LL | #[multipart_suggestion()] - | ^ - error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:657:1 | @@ -550,18 +546,6 @@ error: `code(...)` must contain only string literals LL | #[suggestion(code(foo))] | ^^^ -error: unexpected token - --> $DIR/diagnostic-derive.rs:798:23 - | -LL | #[suggestion(code(foo))] - | ^^^ - -error: expected string literal - --> $DIR/diagnostic-derive.rs:807:25 - | -LL | #[suggestion(code = 3)] - | ^ - error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:822:5 | @@ -572,6 +556,24 @@ LL | #[suggestion(no_crate_suggestion, code = "")] = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]` = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]` +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:55:8 + | +LL | #[diag = "E0123"] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:798:23 + | +LL | #[suggestion(code(foo))] + | ^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:807:25 + | +LL | #[suggestion(code = 3)] + | ^ maybe a missing crate `core`? + error: cannot find attribute `nonsense` in this scope --> $DIR/diagnostic-derive.rs:60:3 | @@ -656,5 +658,5 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` error: aborting due to 84 previous errors -Some errors have detailed explanations: E0277, E0425. +Some errors have detailed explanations: E0277, E0425, E0433. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 38af5b0f9..dd0f7a7ef 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -95,7 +95,8 @@ struct G { #[derive(Subdiagnostic)] #[label("...")] -//~^ ERROR unexpected literal in nested attribute, expected ident +//~^ ERROR failed to resolve: maybe a missing crate `core`? +//~| NOTE maybe a missing crate `core`? struct H { #[primary_span] span: Span, @@ -134,7 +135,7 @@ struct L { #[derive(Subdiagnostic)] #[label()] -//~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident +//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { #[primary_span] span: Span, @@ -310,7 +311,8 @@ struct AB { #[derive(Subdiagnostic)] union AC { - //~^ ERROR unexpected unsupported untagged union + //~^ ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: u32, b: u64, } @@ -556,7 +558,7 @@ struct BBb { #[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] - //~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, } @@ -576,11 +578,12 @@ struct BD { //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, #[suggestion_part()] - //~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span2: Span, #[suggestion_part(foo = "bar")] //~^ ERROR `code` is the only valid nested attribute - //~| ERROR expected `,` + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span4: Span, #[suggestion_part(code = "...")] //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` @@ -672,7 +675,8 @@ enum BL { struct BM { #[suggestion_part(code("foo"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -682,7 +686,8 @@ struct BM { struct BN { #[suggestion_part(code("foo", "bar"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -692,7 +697,8 @@ struct BN { struct BO { #[suggestion_part(code(3))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -713,7 +719,8 @@ struct BP { #[multipart_suggestion(no_crate_example)] struct BQ { #[suggestion_part(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -805,7 +812,8 @@ struct SuggestionStyleInvalid3 { #[derive(Subdiagnostic)] #[suggestion(no_crate_example, code = "", style("foo"))] //~^ ERROR expected `= "xxx"` -//~| ERROr expected `,` +//~| ERROR failed to resolve: maybe a missing crate `core`? +//~| NOTE maybe a missing crate `core`? struct SuggestionStyleInvalid4 { #[primary_span] sub: Span, diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 5ddc8edd7..1f267aceb 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -38,104 +38,98 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(bug = "...")] | ^^^^^^^^^^^^^^^^^^^^^ -error: unexpected literal in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:97:9 - | -LL | #[label("...")] - | ^^^^^ - error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:106:9 + --> $DIR/subdiagnostic-derive.rs:107:9 | LL | #[label(slug = 4)] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:106:1 + --> $DIR/subdiagnostic-derive.rs:107:1 | LL | #[label(slug = 4)] | ^^^^^^^^^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:116:9 + --> $DIR/subdiagnostic-derive.rs:117:9 | LL | #[label(slug("..."))] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:116:1 + --> $DIR/subdiagnostic-derive.rs:117:1 | LL | #[label(slug("..."))] | ^^^^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:136:9 +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:137:1 | LL | #[label()] - | ^ + | ^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:145:27 + --> $DIR/subdiagnostic-derive.rs:146:27 | LL | #[label(no_crate_example, code = "...")] | ^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:154:27 + --> $DIR/subdiagnostic-derive.rs:155:27 | LL | #[label(no_crate_example, applicability = "machine-applicable")] | ^^^^^^^^^^^^^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:163:1 + --> $DIR/subdiagnostic-derive.rs:164:1 | LL | #[foo] | ^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:177:5 + --> $DIR/subdiagnostic-derive.rs:178:5 | LL | #[bar] | ^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:189:5 + --> $DIR/subdiagnostic-derive.rs:190:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:201:5 + --> $DIR/subdiagnostic-derive.rs:202:5 | LL | #[bar = 4] | ^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:213:5 + --> $DIR/subdiagnostic-derive.rs:214:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:225:13 + --> $DIR/subdiagnostic-derive.rs:226:13 | LL | #[label(code = "...")] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:225:5 + --> $DIR/subdiagnostic-derive.rs:226:5 | LL | #[label(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^ error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:254:5 + --> $DIR/subdiagnostic-derive.rs:255:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:251:1 + --> $DIR/subdiagnostic-derive.rs:252:1 | LL | / #[label(no_crate_example)] LL | | @@ -147,13 +141,13 @@ LL | | } | |_^ error: `#[applicability]` is only valid on suggestions - --> $DIR/subdiagnostic-derive.rs:264:5 + --> $DIR/subdiagnostic-derive.rs:265:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:274:5 + --> $DIR/subdiagnostic-derive.rs:275:5 | LL | #[bar] | ^^^^^^ @@ -161,97 +155,87 @@ LL | #[bar] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:285:5 + --> $DIR/subdiagnostic-derive.rs:286:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:296:5 + --> $DIR/subdiagnostic-derive.rs:297:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ | = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes -error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive.rs:312:1 - | -LL | / union AC { -LL | | -LL | | span: u32, -LL | | b: u64, -LL | | } - | |_^ - error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:327:44 + --> $DIR/subdiagnostic-derive.rs:329:44 | LL | #[label(no_crate_example, no_crate::example)] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:340:5 + --> $DIR/subdiagnostic-derive.rs:342:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:337:5 + --> $DIR/subdiagnostic-derive.rs:339:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:346:8 + --> $DIR/subdiagnostic-derive.rs:348:8 | LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:383:46 + --> $DIR/subdiagnostic-derive.rs:385:46 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:383:32 + --> $DIR/subdiagnostic-derive.rs:385:32 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:401:5 + --> $DIR/subdiagnostic-derive.rs:403:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:398:5 + --> $DIR/subdiagnostic-derive.rs:400:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive.rs:411:5 + --> $DIR/subdiagnostic-derive.rs:413:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:424:1 + --> $DIR/subdiagnostic-derive.rs:426:1 | LL | #[suggestion(no_crate_example)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:434:62 + --> $DIR/subdiagnostic-derive.rs:436:62 | LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")] | ^^^^^ error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:452:1 + --> $DIR/subdiagnostic-derive.rs:454:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -261,25 +245,25 @@ LL | | } | |_^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:466:1 + --> $DIR/subdiagnostic-derive.rs:468:1 | LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:486:39 + --> $DIR/subdiagnostic-derive.rs:488:39 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:505:43 + --> $DIR/subdiagnostic-derive.rs:507:43 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:528:5 + --> $DIR/subdiagnostic-derive.rs:530:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ @@ -287,7 +271,7 @@ LL | #[suggestion_part] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead error: `#[suggestion_part(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:531:5 + --> $DIR/subdiagnostic-derive.rs:533:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +279,7 @@ LL | #[suggestion_part(code = "...")] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:525:1 + --> $DIR/subdiagnostic-derive.rs:527:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -307,7 +291,7 @@ LL | | } | |_^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:540:42 + --> $DIR/subdiagnostic-derive.rs:542:42 | LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] | ^^^^ @@ -315,7 +299,7 @@ LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "mac = help: only `no_span`, `style` and `applicability` are valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:540:1 + --> $DIR/subdiagnostic-derive.rs:542:1 | LL | / #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] LL | | @@ -326,19 +310,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:550:5 + --> $DIR/subdiagnostic-derive.rs:552:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:558:23 +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:560:5 | LL | #[suggestion_part()] - | ^ + | ^^^^^^^^^^^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:567:5 + --> $DIR/subdiagnostic-derive.rs:569:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -346,7 +330,7 @@ LL | #[primary_span] = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:564:1 + --> $DIR/subdiagnostic-derive.rs:566:1 | LL | / #[multipart_suggestion(no_crate_example)] LL | | @@ -358,121 +342,91 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:575:5 + --> $DIR/subdiagnostic-derive.rs:577:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:580:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + error: `code` is the only valid nested attribute - --> $DIR/subdiagnostic-derive.rs:581:23 + --> $DIR/subdiagnostic-derive.rs:583:23 | LL | #[suggestion_part(foo = "bar")] | ^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:585:5 + --> $DIR/subdiagnostic-derive.rs:588:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:588:5 + --> $DIR/subdiagnostic-derive.rs:591:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:578:23 - | -LL | #[suggestion_part()] - | ^ - -error: expected `,` - --> $DIR/subdiagnostic-derive.rs:581:27 - | -LL | #[suggestion_part(foo = "bar")] - | ^ - error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:596:37 + --> $DIR/subdiagnostic-derive.rs:599:37 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:596:23 + --> $DIR/subdiagnostic-derive.rs:599:23 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` - --> $DIR/subdiagnostic-derive.rs:625:5 + --> $DIR/subdiagnostic-derive.rs:628:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:673:34 + --> $DIR/subdiagnostic-derive.rs:676:34 | LL | #[suggestion_part(code("foo"))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:673:28 - | -LL | #[suggestion_part(code("foo"))] - | ^^^^^ - error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:683:41 + --> $DIR/subdiagnostic-derive.rs:687:41 | LL | #[suggestion_part(code("foo", "bar"))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:683:28 - | -LL | #[suggestion_part(code("foo", "bar"))] - | ^^^^^ - error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:693:30 + --> $DIR/subdiagnostic-derive.rs:698:30 | LL | #[suggestion_part(code(3))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:693:28 - | -LL | #[suggestion_part(code(3))] - | ^ - error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:703:29 + --> $DIR/subdiagnostic-derive.rs:709:29 | LL | #[suggestion_part(code())] | ^ -error: expected string literal - --> $DIR/subdiagnostic-derive.rs:715:30 - | -LL | #[suggestion_part(code = 3)] - | ^ - error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:757:1 + --> $DIR/subdiagnostic-derive.rs:764:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:757:1 + --> $DIR/subdiagnostic-derive.rs:764:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:766:1 + --> $DIR/subdiagnostic-derive.rs:773:1 | LL | #[suggestion_hidden(no_crate_example, code = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -480,7 +434,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:774:1 + --> $DIR/subdiagnostic-derive.rs:781:1 | LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -488,7 +442,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: invalid suggestion style - --> $DIR/subdiagnostic-derive.rs:782:51 + --> $DIR/subdiagnostic-derive.rs:789:51 | LL | #[suggestion(no_crate_example, code = "", style = "foo")] | ^^^^^ @@ -496,31 +450,25 @@ LL | #[suggestion(no_crate_example, code = "", style = "foo")] = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:790:49 + --> $DIR/subdiagnostic-derive.rs:797:49 | LL | #[suggestion(no_crate_example, code = "", style = 42)] | ^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:798:48 + --> $DIR/subdiagnostic-derive.rs:805:48 | LL | #[suggestion(no_crate_example, code = "", style)] | ^ error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:806:48 - | -LL | #[suggestion(no_crate_example, code = "", style("foo"))] - | ^ - -error: expected `,` - --> $DIR/subdiagnostic-derive.rs:806:48 + --> $DIR/subdiagnostic-derive.rs:813:48 | LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:818:5 + --> $DIR/subdiagnostic-derive.rs:826:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -529,7 +477,7 @@ LL | #[primary_span] = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:815:1 + --> $DIR/subdiagnostic-derive.rs:823:1 | LL | / #[suggestion(no_crate_example, code = "")] LL | | @@ -540,6 +488,54 @@ LL | | sub: Vec, LL | | } | |_^ +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:97:9 + | +LL | #[label("...")] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:313:1 + | +LL | union AC { + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:583:27 + | +LL | #[suggestion_part(foo = "bar")] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:676:28 + | +LL | #[suggestion_part(code("foo"))] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:687:28 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:698:28 + | +LL | #[suggestion_part(code(3))] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:721:30 + | +LL | #[suggestion_part(code = 3)] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:813:48 + | +LL | #[suggestion(no_crate_example, code = "", style("foo"))] + | ^ maybe a missing crate `core`? + error: cannot find attribute `foo` in this scope --> $DIR/subdiagnostic-derive.rs:68:3 | @@ -547,61 +543,61 @@ LL | #[foo] | ^^^ error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive.rs:163:3 + --> $DIR/subdiagnostic-derive.rs:164:3 | LL | #[foo] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:177:7 + --> $DIR/subdiagnostic-derive.rs:178:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:189:7 + --> $DIR/subdiagnostic-derive.rs:190:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:201:7 + --> $DIR/subdiagnostic-derive.rs:202:7 | LL | #[bar = 4] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:213:7 + --> $DIR/subdiagnostic-derive.rs:214:7 | LL | #[bar("...")] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:274:7 + --> $DIR/subdiagnostic-derive.rs:275:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:285:7 + --> $DIR/subdiagnostic-derive.rs:286:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:296:7 + --> $DIR/subdiagnostic-derive.rs:297:7 | LL | #[bar("...")] | ^^^ error[E0425]: cannot find value `slug` in module `crate::fluent_generated` - --> $DIR/subdiagnostic-derive.rs:126:9 + --> $DIR/subdiagnostic-derive.rs:127:9 | LL | #[label(slug)] | ^^^^ not found in `crate::fluent_generated` error[E0425]: cannot find value `__code_29` in this scope - --> $DIR/subdiagnostic-derive.rs:709:10 + --> $DIR/subdiagnostic-derive.rs:715:10 | LL | #[derive(Subdiagnostic)] | ^^^^^^^^^^^^^ not found in this scope @@ -610,4 +606,5 @@ LL | #[derive(Subdiagnostic)] error: aborting due to 86 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/abi/relocation_model_pic.rs b/tests/ui/abi/relocation_model_pic.rs new file mode 100644 index 000000000..0cfc44cd0 --- /dev/null +++ b/tests/ui/abi/relocation_model_pic.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags: -C relocation-model=pic +// ignore-emscripten no pic +// ignore-wasm + +#![feature(cfg_relocation_model)] + +#[cfg(relocation_model = "pic")] +fn main() {} diff --git a/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr b/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr new file mode 100644 index 000000000..02082c13f --- /dev/null +++ b/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr @@ -0,0 +1,27 @@ +error[E0703]: invalid ABI: found `riscv-interrupt` + --> $DIR/riscv-discoverability-guidance.rs:17:8 + | +LL | extern "riscv-interrupt" fn isr() {} + | ^^^^^^^^^^^^^^^^^ + | | + | invalid ABI + | help: did you mean: `"riscv-interrupt-m"` + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions. + = note: please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively + +error[E0703]: invalid ABI: found `riscv-interrupt-u` + --> $DIR/riscv-discoverability-guidance.rs:23:8 + | +LL | extern "riscv-interrupt-u" fn isr_U() {} + | ^^^^^^^^^^^^^^^^^^^ + | | + | invalid ABI + | help: did you mean: `"riscv-interrupt-m"` + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions. + = note: user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0703`. diff --git a/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr b/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr new file mode 100644 index 000000000..02082c13f --- /dev/null +++ b/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr @@ -0,0 +1,27 @@ +error[E0703]: invalid ABI: found `riscv-interrupt` + --> $DIR/riscv-discoverability-guidance.rs:17:8 + | +LL | extern "riscv-interrupt" fn isr() {} + | ^^^^^^^^^^^^^^^^^ + | | + | invalid ABI + | help: did you mean: `"riscv-interrupt-m"` + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions. + = note: please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively + +error[E0703]: invalid ABI: found `riscv-interrupt-u` + --> $DIR/riscv-discoverability-guidance.rs:23:8 + | +LL | extern "riscv-interrupt-u" fn isr_U() {} + | ^^^^^^^^^^^^^^^^^^^ + | | + | invalid ABI + | help: did you mean: `"riscv-interrupt-m"` + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions. + = note: user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0703`. diff --git a/tests/ui/abi/riscv-discoverability-guidance.rs b/tests/ui/abi/riscv-discoverability-guidance.rs new file mode 100644 index 000000000..f57fcd604 --- /dev/null +++ b/tests/ui/abi/riscv-discoverability-guidance.rs @@ -0,0 +1,27 @@ +// ignore-tidy-linelength +// revisions: riscv32 riscv64 +// +// [riscv32] needs-llvm-components: riscv +// [riscv32] compile-flags: --target=riscv32i-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib +// [riscv64] needs-llvm-components: riscv +// [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib +#![no_core] +#![feature( + no_core, + lang_items, + abi_riscv_interrupt +)] +#[lang = "sized"] +trait Sized {} + +extern "riscv-interrupt" fn isr() {} +//~^ ERROR invalid ABI +//~^^ NOTE invalid ABI +//~^^^ NOTE invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +//~^^^^ NOTE please use one of riscv-interrupt-m or riscv-interrupt-s + +extern "riscv-interrupt-u" fn isr_U() {} +//~^ ERROR invalid ABI +//~^^ NOTE invalid ABI +//~^^^ NOTE invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +//~^^^^ NOTE user-mode interrupt handlers have been removed from LLVM pending standardization diff --git a/tests/ui/abi/stack-probes-lto.rs b/tests/ui/abi/stack-probes-lto.rs index 0dccb633d..7282d0970 100644 --- a/tests/ui/abi/stack-probes-lto.rs +++ b/tests/ui/abi/stack-probes-lto.rs @@ -1,13 +1,7 @@ +// revisions: x32 x64 // run-pass -// ignore-arm -// ignore-aarch64 -// ignore-mips -// ignore-mips64 -// ignore-sparc -// ignore-sparc64 -// ignore-loongarch64 -// ignore-wasm -// ignore-emscripten no processes +//[x32] only-x86 +//[x64] only-x86_64 // ignore-sgx no processes // ignore-musl FIXME #31506 // ignore-fuchsia no exception handler registered for segfault diff --git a/tests/ui/abi/stack-probes.rs b/tests/ui/abi/stack-probes.rs index 8137c9230..4b8a79a4b 100644 --- a/tests/ui/abi/stack-probes.rs +++ b/tests/ui/abi/stack-probes.rs @@ -1,12 +1,7 @@ +// revisions: x32 x64 // run-pass -// ignore-arm -// ignore-aarch64 -// ignore-mips -// ignore-mips64 -// ignore-sparc -// ignore-sparc64 -// ignore-loongarch64 -// ignore-wasm +//[x32] only-x86 +//[x64] only-x86_64 // ignore-emscripten no processes // ignore-sgx no processes // ignore-fuchsia no exception handler registered for segfault diff --git a/tests/ui/abi/stack-protector.rs b/tests/ui/abi/stack-protector.rs index 24bd2e219..e94aa816d 100644 --- a/tests/ui/abi/stack-protector.rs +++ b/tests/ui/abi/stack-protector.rs @@ -40,6 +40,8 @@ fn vulnerable_function() { // Overwrite the on-stack return address with the address of `malicious_code()`, // thereby jumping to that function when returning from `vulnerable_function()`. unsafe { fill(stackaddr, bad_code_ptr, 20); } + // Capture the address, so the write is not optimized away. + std::hint::black_box(stackaddr); } // Use an uninlined function with its own stack frame to make sure that we don't diff --git a/tests/ui/abi/unsupported.aarch64.stderr b/tests/ui/abi/unsupported.aarch64.stderr index e86a73ea6..d7b4e6150 100644 --- a/tests/ui/abi/unsupported.aarch64.stderr +++ b/tests/ui/abi/unsupported.aarch64.stderr @@ -1,53 +1,59 @@ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:26:1 + --> $DIR/unsupported.rs:30:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:28:1 + --> $DIR/unsupported.rs:32:1 | LL | extern "amdgpu-kernel" fn amdgpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"wasm"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:30:1 + --> $DIR/unsupported.rs:34:1 | LL | extern "wasm" fn wasm() {} | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:32:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:38:1 + --> $DIR/unsupported.rs:44:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:46:1 + | +LL | extern "riscv-interrupt-m" fn riscv() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:51:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:56:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:47:1 + --> $DIR/unsupported.rs:62:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,6 +62,6 @@ LL | extern "stdcall" fn stdcall() {} = note: for more information, see issue #87678 = note: `#[warn(unsupported_calling_conventions)]` on by default -error: aborting due to 8 previous errors; 1 warning emitted +error: aborting due to 9 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.arm.stderr b/tests/ui/abi/unsupported.arm.stderr index f7569c8cd..3a3ed2dd9 100644 --- a/tests/ui/abi/unsupported.arm.stderr +++ b/tests/ui/abi/unsupported.arm.stderr @@ -1,47 +1,53 @@ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:26:1 + --> $DIR/unsupported.rs:30:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:28:1 + --> $DIR/unsupported.rs:32:1 | LL | extern "amdgpu-kernel" fn amdgpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"wasm"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:30:1 + --> $DIR/unsupported.rs:34:1 | LL | extern "wasm" fn wasm() {} | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:38:1 + --> $DIR/unsupported.rs:44:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:46:1 + | +LL | extern "riscv-interrupt-m" fn riscv() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:51:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:56:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:47:1 + --> $DIR/unsupported.rs:62:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,6 +56,6 @@ LL | extern "stdcall" fn stdcall() {} = note: for more information, see issue #87678 = note: `#[warn(unsupported_calling_conventions)]` on by default -error: aborting due to 7 previous errors; 1 warning emitted +error: aborting due to 8 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.i686.stderr b/tests/ui/abi/unsupported.i686.stderr index 7ca93516d..31b7d030b 100644 --- a/tests/ui/abi/unsupported.i686.stderr +++ b/tests/ui/abi/unsupported.i686.stderr @@ -1,39 +1,45 @@ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:26:1 + --> $DIR/unsupported.rs:30:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:28:1 + --> $DIR/unsupported.rs:32:1 | LL | extern "amdgpu-kernel" fn amdgpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"wasm"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:30:1 + --> $DIR/unsupported.rs:34:1 | LL | extern "wasm" fn wasm() {} | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:32:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:38:1 + --> $DIR/unsupported.rs:44:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:46:1 + | +LL | extern "riscv-interrupt-m" fn riscv() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.riscv32.stderr b/tests/ui/abi/unsupported.riscv32.stderr new file mode 100644 index 000000000..1966e18f0 --- /dev/null +++ b/tests/ui/abi/unsupported.riscv32.stderr @@ -0,0 +1,61 @@ +error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:30:1 + | +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:32:1 + | +LL | extern "amdgpu-kernel" fn amdgpu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"wasm"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:34:1 + | +LL | extern "wasm" fn wasm() {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"aapcs"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:1 + | +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:1 + | +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:1 + | +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:51:1 + | +LL | extern "x86-interrupt" fn x86() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"thiscall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:1 + | +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:62:1 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #87678 + = note: `#[warn(unsupported_calling_conventions)]` on by default + +error: aborting due to 8 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.riscv64.stderr b/tests/ui/abi/unsupported.riscv64.stderr new file mode 100644 index 000000000..1966e18f0 --- /dev/null +++ b/tests/ui/abi/unsupported.riscv64.stderr @@ -0,0 +1,61 @@ +error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:30:1 + | +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:32:1 + | +LL | extern "amdgpu-kernel" fn amdgpu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"wasm"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:34:1 + | +LL | extern "wasm" fn wasm() {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"aapcs"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:1 + | +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:1 + | +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:1 + | +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:51:1 + | +LL | extern "x86-interrupt" fn x86() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"thiscall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:1 + | +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:62:1 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #87678 + = note: `#[warn(unsupported_calling_conventions)]` on by default + +error: aborting due to 8 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.rs b/tests/ui/abi/unsupported.rs index 6427a5695..57278e664 100644 --- a/tests/ui/abi/unsupported.rs +++ b/tests/ui/abi/unsupported.rs @@ -1,4 +1,4 @@ -// revisions: x64 i686 aarch64 arm +// revisions: x64 i686 aarch64 arm riscv32 riscv64 // // [x64] needs-llvm-components: x86 // [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib @@ -8,6 +8,10 @@ // [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu --crate-type=rlib // [arm] needs-llvm-components: arm // [arm] compile-flags: --target=armv7-unknown-linux-gnueabihf --crate-type=rlib +// [riscv32] needs-llvm-components: riscv +// [riscv32] compile-flags: --target=riscv32i-unknown-none-elf --crate-type=rlib +// [riscv64] needs-llvm-components: riscv +// [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf --crate-type=rlib #![no_core] #![feature( no_core, @@ -15,13 +19,13 @@ abi_ptx, abi_msp430_interrupt, abi_avr_interrupt, - abi_thiscall, abi_amdgpu_kernel, wasm_abi, - abi_x86_interrupt + abi_x86_interrupt, + abi_riscv_interrupt )] -#[lang="sized"] -trait Sized { } +#[lang = "sized"] +trait Sized {} extern "ptx-kernel" fn ptx() {} //~^ ERROR is not a supported ABI @@ -33,21 +37,36 @@ extern "aapcs" fn aapcs() {} //[x64]~^ ERROR is not a supported ABI //[i686]~^^ ERROR is not a supported ABI //[aarch64]~^^^ ERROR is not a supported ABI +//[riscv32]~^^^^ ERROR is not a supported ABI +//[riscv64]~^^^^^ ERROR is not a supported ABI extern "msp430-interrupt" fn msp430() {} //~^ ERROR is not a supported ABI extern "avr-interrupt" fn avr() {} //~^ ERROR is not a supported ABI +extern "riscv-interrupt-m" fn riscv() {} +//[arm]~^ ERROR is not a supported ABI +//[x64]~^^ ERROR is not a supported ABI +//[i686]~^^^ ERROR is not a supported ABI +//[aarch64]~^^^^ ERROR is not a supported ABI extern "x86-interrupt" fn x86() {} //[aarch64]~^ ERROR is not a supported ABI //[arm]~^^ ERROR is not a supported ABI +//[riscv32]~^^^ ERROR is not a supported ABI +//[riscv64]~^^^^ ERROR is not a supported ABI extern "thiscall" fn thiscall() {} //[x64]~^ ERROR is not a supported ABI -//[aarch64]~^^ ERROR is not a supported ABI -//[arm]~^^^ ERROR is not a supported ABI +//[arm]~^^ ERROR is not a supported ABI +//[aarch64]~^^^ ERROR is not a supported ABI +//[riscv32]~^^^^ ERROR is not a supported ABI +//[riscv64]~^^^^^ ERROR is not a supported ABI extern "stdcall" fn stdcall() {} //[x64]~^ WARN use of calling convention not supported //[x64]~^^ WARN this was previously accepted -//[aarch64]~^^^ WARN use of calling convention not supported -//[aarch64]~^^^^ WARN this was previously accepted -//[arm]~^^^^^ WARN use of calling convention not supported -//[arm]~^^^^^^ WARN this was previously accepted +//[arm]~^^^ WARN use of calling convention not supported +//[arm]~^^^^ WARN this was previously accepted +//[aarch64]~^^^^^ WARN use of calling convention not supported +//[aarch64]~^^^^^^ WARN this was previously accepted +//[riscv32]~^^^^^^^ WARN use of calling convention not supported +//[riscv32]~^^^^^^^^ WARN this was previously accepted +//[riscv64]~^^^^^^^^^ WARN use of calling convention not supported +//[riscv64]~^^^^^^^^^^ WARN this was previously accepted diff --git a/tests/ui/abi/unsupported.x64.stderr b/tests/ui/abi/unsupported.x64.stderr index 26023a458..ea62cb151 100644 --- a/tests/ui/abi/unsupported.x64.stderr +++ b/tests/ui/abi/unsupported.x64.stderr @@ -1,47 +1,53 @@ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:26:1 + --> $DIR/unsupported.rs:30:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:28:1 + --> $DIR/unsupported.rs:32:1 | LL | extern "amdgpu-kernel" fn amdgpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"wasm"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:30:1 + --> $DIR/unsupported.rs:34:1 | LL | extern "wasm" fn wasm() {} | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:32:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:38:1 + --> $DIR/unsupported.rs:44:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:46:1 + | +LL | extern "riscv-interrupt-m" fn riscv() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:56:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:47:1 + --> $DIR/unsupported.rs:62:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,6 +56,6 @@ LL | extern "stdcall" fn stdcall() {} = note: for more information, see issue #87678 = note: `#[warn(unsupported_calling_conventions)]` on by default -error: aborting due to 7 previous errors; 1 warning emitted +error: aborting due to 8 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/annotate-snippet/auxiliary/other_file.rs b/tests/ui/annotate-snippet/auxiliary/other_file.rs new file mode 100644 index 000000000..6f5f412d0 --- /dev/null +++ b/tests/ui/annotate-snippet/auxiliary/other_file.rs @@ -0,0 +1,6 @@ +pub struct WithPrivateMethod; + +impl WithPrivateMethod { + /// Private to get an error involving two files + fn private_method(&self) {} +} diff --git a/tests/ui/annotate-snippet/multiple-files.rs b/tests/ui/annotate-snippet/multiple-files.rs new file mode 100644 index 000000000..981cdbb10 --- /dev/null +++ b/tests/ui/annotate-snippet/multiple-files.rs @@ -0,0 +1,8 @@ +// aux-build:other_file.rs +// compile-flags: --error-format human-annotate-rs -Z unstable-options + +extern crate other_file; + +fn main() { + other_file::WithPrivateMethod.private_method(); +} diff --git a/tests/ui/annotate-snippet/multiple-files.stderr b/tests/ui/annotate-snippet/multiple-files.stderr new file mode 100644 index 000000000..4236ec811 --- /dev/null +++ b/tests/ui/annotate-snippet/multiple-files.stderr @@ -0,0 +1,11 @@ +error[E0624]: method `private_method` is private + --> $DIR/multiple-files.rs:7:35 + | +LL | other_file::WithPrivateMethod.private_method(); + | ^^^^^^^^^^^^^^ private method + | + ::: $DIR/auxiliary/other_file.rs:5:5 + | +LL | fn private_method(&self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ private method defined here + | diff --git a/tests/ui/anonymous-higher-ranked-lifetime.stderr b/tests/ui/anonymous-higher-ranked-lifetime.stderr index c023d1b15..e441cbdc8 100644 --- a/tests/ui/anonymous-higher-ranked-lifetime.stderr +++ b/tests/ui/anonymous-higher-ranked-lifetime.stderr @@ -13,7 +13,7 @@ note: required by a bound in `f1` | LL | fn f1(_: F) where F: Fn(&(), &()) {} | ^^^^^^^^^^^^ required by this bound in `f1` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | f1(|_: &(), _: &()| {}); | + + @@ -33,7 +33,7 @@ note: required by a bound in `f2` | LL | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f2` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | f2(|_: &(), _: &()| {}); | + + @@ -53,7 +53,7 @@ note: required by a bound in `f3` | LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} | ^^^^^^^^^^^^^^^ required by this bound in `f3` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | f3(|_: &(), _: &()| {}); | + + @@ -73,7 +73,7 @@ note: required by a bound in `f4` | LL | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f4` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | f4(|_: &(), _: &()| {}); | + + @@ -93,7 +93,7 @@ note: required by a bound in `f5` | LL | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f5` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | f5(|_: &(), _: &()| {}); | + + @@ -113,7 +113,7 @@ note: required by a bound in `g1` | LL | fn g1(_: F) where F: Fn(&(), Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g1` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | g1(|_: &(), _: ()| {}); | + @@ -133,7 +133,7 @@ note: required by a bound in `g2` | LL | fn g2(_: F) where F: Fn(&(), fn(&())) {} | ^^^^^^^^^^^^^^^^ required by this bound in `g2` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | g2(|_: &(), _: ()| {}); | + @@ -153,7 +153,7 @@ note: required by a bound in `g3` | LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g3` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | g3(|_: &(), _: ()| {}); | + @@ -173,7 +173,7 @@ note: required by a bound in `g4` | LL | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g4` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | g4(|_: &(), _: ()| {}); | + @@ -193,7 +193,7 @@ note: required by a bound in `h1` | LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h1` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | h1(|_: &(), _: (), _: &(), _: ()| {}); | + + @@ -213,7 +213,7 @@ note: required by a bound in `h2` | LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its arguments | LL | h2(|_: &(), _: (), _: &(), _: ()| {}); | + + diff --git a/tests/ui/argument-suggestions/extra_arguments.rs b/tests/ui/argument-suggestions/extra_arguments.rs index 144206232..4f2f3517d 100644 --- a/tests/ui/argument-suggestions/extra_arguments.rs +++ b/tests/ui/argument-suggestions/extra_arguments.rs @@ -1,12 +1,18 @@ fn empty() {} -fn one_arg(_a: i32) {} +fn one_arg(_a: T) {} fn two_arg_same(_a: i32, _b: i32) {} fn two_arg_diff(_a: i32, _b: &str) {} macro_rules! foo { - ($x:expr) => { + ($x:expr, ~) => { empty($x, 1); //~ ERROR function takes - } + }; + ($x:expr, $y:expr) => { + empty($x, $y); //~ ERROR function takes + }; + (~, $y:expr) => { + empty(1, $y); //~ ERROR function takes + }; } fn main() { @@ -39,5 +45,17 @@ fn main() { 1, "" ); - foo!(1); + + // Check with macro expansions + foo!(1, ~); + foo!(~, 1); + foo!(1, 1); + one_arg(1, panic!()); //~ ERROR function takes + one_arg(panic!(), 1); //~ ERROR function takes + one_arg(stringify!($e), 1); //~ ERROR function takes + + // Not a macro, but this also has multiple spans with equal source code, + // but different expansion contexts. + // https://github.com/rust-lang/rust/issues/114255 + one_arg(for _ in 1.. {}, 1); //~ ERROR function takes } diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr index 11c710997..5ad8e3592 100644 --- a/tests/ui/argument-suggestions/extra_arguments.stderr +++ b/tests/ui/argument-suggestions/extra_arguments.stderr @@ -1,5 +1,5 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/extra_arguments.rs:13:3 + --> $DIR/extra_arguments.rs:19:3 | LL | empty(""); | ^^^^^ -- @@ -14,7 +14,7 @@ LL | fn empty() {} | ^^^^^ error[E0061]: this function takes 0 arguments but 2 arguments were supplied - --> $DIR/extra_arguments.rs:14:3 + --> $DIR/extra_arguments.rs:20:3 | LL | empty(1, 1); | ^^^^^ - - unexpected argument of type `{integer}` @@ -33,7 +33,7 @@ LL + empty(); | error[E0061]: this function takes 1 argument but 2 arguments were supplied - --> $DIR/extra_arguments.rs:16:3 + --> $DIR/extra_arguments.rs:22:3 | LL | one_arg(1, 1); | ^^^^^^^ --- @@ -44,11 +44,11 @@ LL | one_arg(1, 1); note: function defined here --> $DIR/extra_arguments.rs:2:4 | -LL | fn one_arg(_a: i32) {} - | ^^^^^^^ ------- +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- error[E0061]: this function takes 1 argument but 2 arguments were supplied - --> $DIR/extra_arguments.rs:17:3 + --> $DIR/extra_arguments.rs:23:3 | LL | one_arg(1, ""); | ^^^^^^^ ---- @@ -59,11 +59,11 @@ LL | one_arg(1, ""); note: function defined here --> $DIR/extra_arguments.rs:2:4 | -LL | fn one_arg(_a: i32) {} - | ^^^^^^^ ------- +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- error[E0061]: this function takes 1 argument but 3 arguments were supplied - --> $DIR/extra_arguments.rs:18:3 + --> $DIR/extra_arguments.rs:24:3 | LL | one_arg(1, "", 1.0); | ^^^^^^^ -- --- unexpected argument of type `{float}` @@ -73,8 +73,8 @@ LL | one_arg(1, "", 1.0); note: function defined here --> $DIR/extra_arguments.rs:2:4 | -LL | fn one_arg(_a: i32) {} - | ^^^^^^^ ------- +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- help: remove the extra arguments | LL - one_arg(1, "", 1.0); @@ -82,7 +82,7 @@ LL + one_arg(1); | error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:20:3 + --> $DIR/extra_arguments.rs:26:3 | LL | two_arg_same(1, 1, 1); | ^^^^^^^^^^^^ --- @@ -97,7 +97,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:21:3 + --> $DIR/extra_arguments.rs:27:3 | LL | two_arg_same(1, 1, 1.0); | ^^^^^^^^^^^^ ----- @@ -112,7 +112,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:23:3 + --> $DIR/extra_arguments.rs:29:3 | LL | two_arg_diff(1, 1, ""); | ^^^^^^^^^^^^ --- @@ -127,7 +127,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:24:3 + --> $DIR/extra_arguments.rs:30:3 | LL | two_arg_diff(1, "", ""); | ^^^^^^^^^^^^ ---- @@ -142,7 +142,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- error[E0061]: this function takes 2 arguments but 4 arguments were supplied - --> $DIR/extra_arguments.rs:25:3 + --> $DIR/extra_arguments.rs:31:3 | LL | two_arg_diff(1, 1, "", ""); | ^^^^^^^^^^^^ - -- unexpected argument of type `&'static str` @@ -161,7 +161,7 @@ LL + two_arg_diff(1, ""); | error[E0061]: this function takes 2 arguments but 4 arguments were supplied - --> $DIR/extra_arguments.rs:26:3 + --> $DIR/extra_arguments.rs:32:3 | LL | two_arg_diff(1, "", 1, ""); | ^^^^^^^^^^^^ - -- unexpected argument of type `&'static str` @@ -180,7 +180,7 @@ LL + two_arg_diff(1, ""); | error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:29:3 + --> $DIR/extra_arguments.rs:35:3 | LL | two_arg_same(1, 1, ""); | ^^^^^^^^^^^^ -------- @@ -195,7 +195,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:30:3 + --> $DIR/extra_arguments.rs:36:3 | LL | two_arg_diff(1, 1, ""); | ^^^^^^^^^^^^ --- @@ -210,7 +210,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:31:3 + --> $DIR/extra_arguments.rs:37:3 | LL | two_arg_same( | ^^^^^^^^^^^^ @@ -230,7 +230,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- error[E0061]: this function takes 2 arguments but 3 arguments were supplied - --> $DIR/extra_arguments.rs:37:3 + --> $DIR/extra_arguments.rs:43:3 | LL | two_arg_diff( | ^^^^^^^^^^^^ @@ -254,11 +254,10 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied LL | empty($x, 1); | ^^^^^ - unexpected argument of type `{integer}` ... -LL | foo!(1); - | ------- +LL | foo!(1, ~); + | ---------- | | | | | unexpected argument of type `{integer}` - | | help: remove the extra argument | in this macro invocation | note: function defined here @@ -268,6 +267,105 @@ LL | fn empty() {} | ^^^^^ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 16 previous errors +error[E0061]: this function takes 0 arguments but 2 arguments were supplied + --> $DIR/extra_arguments.rs:14:9 + | +LL | empty(1, $y); + | ^^^^^ - unexpected argument of type `{integer}` +... +LL | foo!(~, 1); + | ---------- + | | | + | | unexpected argument of type `{integer}` + | in this macro invocation + | +note: function defined here + --> $DIR/extra_arguments.rs:1:4 + | +LL | fn empty() {} + | ^^^^^ + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0061]: this function takes 0 arguments but 2 arguments were supplied + --> $DIR/extra_arguments.rs:11:9 + | +LL | empty($x, $y); + | ^^^^^ +... +LL | foo!(1, 1); + | ---------- + | | | | + | | | unexpected argument of type `{integer}` + | | unexpected argument of type `{integer}` + | in this macro invocation + | +note: function defined here + --> $DIR/extra_arguments.rs:1:4 + | +LL | fn empty() {} + | ^^^^^ + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0061]: this function takes 1 argument but 2 arguments were supplied + --> $DIR/extra_arguments.rs:53:3 + | +LL | one_arg(1, panic!()); + | ^^^^^^^ ---------- + | | | + | | unexpected argument + | help: remove the extra argument + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- + +error[E0061]: this function takes 1 argument but 2 arguments were supplied + --> $DIR/extra_arguments.rs:54:3 + | +LL | one_arg(panic!(), 1); + | ^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- + +error[E0061]: this function takes 1 argument but 2 arguments were supplied + --> $DIR/extra_arguments.rs:55:3 + | +LL | one_arg(stringify!($e), 1); + | ^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- + +error[E0061]: this function takes 1 argument but 2 arguments were supplied + --> $DIR/extra_arguments.rs:60:3 + | +LL | one_arg(for _ in 1.. {}, 1); + | ^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: T) {} + | ^^^^^^^ ----- + +error: aborting due to 22 previous errors For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/array-slice-vec/infer_array_len.rs b/tests/ui/array-slice-vec/infer_array_len.rs index 22fe7cb88..547c1f572 100644 --- a/tests/ui/array-slice-vec/infer_array_len.rs +++ b/tests/ui/array-slice-vec/infer_array_len.rs @@ -1,4 +1,4 @@ -// see issue #70529 +// check-pass struct A; impl From for [u8; 2] { @@ -13,9 +13,7 @@ impl From for [u8; 3] { } } - fn main() { let a = A; let [_, _] = a.into(); - //~^ ERROR type annotations needed } diff --git a/tests/ui/array-slice-vec/infer_array_len.stderr b/tests/ui/array-slice-vec/infer_array_len.stderr deleted file mode 100644 index c2a509a19..000000000 --- a/tests/ui/array-slice-vec/infer_array_len.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/infer_array_len.rs:19:9 - | -LL | let [_, _] = a.into(); - | ^^^^^^ - | -help: consider giving this pattern a type - | -LL | let [_, _]: /* Type */ = a.into(); - | ++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/array-slice-vec/slice-2.stderr b/tests/ui/array-slice-vec/slice-2.stderr index 561feb90f..b122b4691 100644 --- a/tests/ui/array-slice-vec/slice-2.stderr +++ b/tests/ui/array-slice-vec/slice-2.stderr @@ -1,26 +1,26 @@ error[E0608]: cannot index into a value of type `Foo` - --> $DIR/slice-2.rs:7:6 + --> $DIR/slice-2.rs:7:7 | LL | &x[..]; - | ^^^^^ + | ^^^^ error[E0608]: cannot index into a value of type `Foo` - --> $DIR/slice-2.rs:8:6 + --> $DIR/slice-2.rs:8:7 | LL | &x[Foo..]; - | ^^^^^^^^ + | ^^^^^^^ error[E0608]: cannot index into a value of type `Foo` - --> $DIR/slice-2.rs:9:6 + --> $DIR/slice-2.rs:9:7 | LL | &x[..Foo]; - | ^^^^^^^^ + | ^^^^^^^ error[E0608]: cannot index into a value of type `Foo` - --> $DIR/slice-2.rs:10:6 + --> $DIR/slice-2.rs:10:7 | LL | &x[Foo..Foo]; - | ^^^^^^^^^^^ + | ^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs b/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs index 521b898e7..03a1876fd 100644 --- a/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs +++ b/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs @@ -2,7 +2,7 @@ fn main() { match "foo".to_string() { ['f', 'o', ..] => {} //~^ ERROR expected an array or slice, found `String` - _ => { } + _ => {} }; // Note that this one works with default binding modes. @@ -15,7 +15,7 @@ fn main() { }; match [0, 1, 2] { - [0] => {}, //~ ERROR pattern requires + [0] => {} //~ ERROR pattern requires [0, 1, x @ ..] => { let a: [_; 1] = x; @@ -23,14 +23,15 @@ fn main() { [0, 1, 2, 3, x @ ..] => {} //~ ERROR pattern requires }; - match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope - [] => {} + match does_not_exist { + //~^ ERROR cannot find value `does_not_exist` in this scope + [] => {} // ERROR cannot find value `does_not_exist` in this scope }; } fn another_fn_to_avoid_suppression() { - match Default::default() - { - [] => {} //~ ERROR type annotations needed + match Default::default() { + [] => {} + //~^ ERROR type annotations needed }; } diff --git a/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr b/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr index 70a4cbebe..d1d042c47 100644 --- a/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr +++ b/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr @@ -13,7 +13,7 @@ LL | ['f', 'o', ..] => {} error[E0527]: pattern requires 1 element but array has 3 --> $DIR/slice-pat-type-mismatches.rs:18:9 | -LL | [0] => {}, +LL | [0] => {} | ^^^ expected 3 elements error[E0528]: pattern requires at least 4 elements but array has 3 diff --git a/tests/ui/array-slice-vec/vec-mut-iter-borrow.stderr b/tests/ui/array-slice-vec/vec-mut-iter-borrow.stderr index 0ec263c85..679fd8997 100644 --- a/tests/ui/array-slice-vec/vec-mut-iter-borrow.stderr +++ b/tests/ui/array-slice-vec/vec-mut-iter-borrow.stderr @@ -7,7 +7,7 @@ LL | for x in &mut xs { | first mutable borrow occurs here | first borrow later used here LL | xs.push(1) - | ^^^^^^^^^^ second mutable borrow occurs here + | ^^ second mutable borrow occurs here error: aborting due to previous error diff --git a/tests/ui/asm/issue-113788.rs b/tests/ui/asm/issue-113788.rs new file mode 100644 index 000000000..903b44476 --- /dev/null +++ b/tests/ui/asm/issue-113788.rs @@ -0,0 +1,7 @@ +// test that "error: arguments for inline assembly must be copyable" doesn't show up in this code +// needs-asm-support +// only-x86_64 +fn main() { + let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0412] + unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); } +} diff --git a/tests/ui/asm/issue-113788.stderr b/tests/ui/asm/issue-113788.stderr new file mode 100644 index 000000000..f8e65b6f5 --- /dev/null +++ b/tests/ui/asm/issue-113788.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `PEB` in this scope + --> $DIR/issue-113788.rs:5:21 + | +LL | let peb: *const PEB; + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/asm/x86_64/issue-96797.rs b/tests/ui/asm/x86_64/issue-96797.rs index 954f8c5cc..951dd949b 100644 --- a/tests/ui/asm/x86_64/issue-96797.rs +++ b/tests/ui/asm/x86_64/issue-96797.rs @@ -1,6 +1,5 @@ // build-pass // compile-flags: -O -// min-llvm-version: 14.0.5 // needs-asm-support // only-x86_64 // only-linux diff --git a/tests/ui/associated-consts/defaults-cyclic-fail.stderr b/tests/ui/associated-consts/defaults-cyclic-fail.stderr index a1483911b..ebdb76e42 100644 --- a/tests/ui/associated-consts/defaults-cyclic-fail.stderr +++ b/tests/ui/associated-consts/defaults-cyclic-fail.stderr @@ -15,6 +15,7 @@ note: cycle used when const-evaluating + checking `main::promoted[1]` | LL | assert_eq!(<() as Tr>::A, 0); | ^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-consts/issue-105330.stderr b/tests/ui/associated-consts/issue-105330.stderr index bbafc55da..e9fe3a5e5 100644 --- a/tests/ui/associated-consts/issue-105330.stderr +++ b/tests/ui/associated-consts/issue-105330.stderr @@ -39,6 +39,12 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t LL | impl TraitWAssocConst for impl Demo { | ^^^^^^^^^ +error[E0131]: `main` function is not allowed to have generic parameters + --> $DIR/issue-105330.rs:17:8 + | +LL | fn main>() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters + error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied --> $DIR/issue-105330.rs:12:11 | @@ -101,12 +107,6 @@ note: required by a bound in `foo` LL | fn foo>() { | ^^^^ required by this bound in `foo` -error[E0131]: `main` function is not allowed to have generic parameters - --> $DIR/issue-105330.rs:17:8 - | -LL | fn main>() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters - error: aborting due to 11 previous errors Some errors have detailed explanations: E0131, E0271, E0277, E0404, E0562, E0618, E0658. diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr index be5781761..51bf0cb5e 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr @@ -26,6 +26,7 @@ LL | const BAR: u32 = IMPL_REF_BAR; | ^^^^^^^^^^^^^^ = note: ...which again requires elaborating drops for `::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr index 8347b260b..8277d41a1 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr @@ -26,6 +26,7 @@ LL | const BAR: u32 = DEFAULT_REF_BAR; | ^^^^^^^^^^^^^^ = note: ...which again requires elaborating drops for `FooDefault::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr index 3955a3120..9983ba794 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr @@ -26,6 +26,7 @@ LL | const BAR: u32 = TRAIT_REF_BAR; | ^^^^^^^^^^^^^^ = note: ...which again requires elaborating drops for `::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr index 23269e1af..3c373f139 100644 --- a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr @@ -37,6 +37,7 @@ LL | | LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr index aaa9a39ea..ab6a97b3d 100644 --- a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr @@ -31,6 +31,7 @@ LL | | // FIXME(inherent_associated_types): This shouldn't lead to a cycle error LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-inherent-types/inference.rs b/tests/ui/associated-inherent-types/inference.rs index ebd8e1d55..66f879c5a 100644 --- a/tests/ui/associated-inherent-types/inference.rs +++ b/tests/ui/associated-inherent-types/inference.rs @@ -1,5 +1,7 @@ // Testing inference capabilities. // check-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next #![feature(inherent_associated_types)] #![allow(incomplete_features)] diff --git a/tests/ui/associated-inherent-types/issue-111879-0.rs b/tests/ui/associated-inherent-types/issue-111879-0.rs index e37f7d34a..d01354465 100644 --- a/tests/ui/associated-inherent-types/issue-111879-0.rs +++ b/tests/ui/associated-inherent-types/issue-111879-0.rs @@ -5,10 +5,8 @@ pub struct Carrier<'a>(&'a ()); -pub type User = for<'b> fn(Carrier<'b>::Focus); - impl<'a> Carrier<'a> { - pub type Focus = &'a mut User; //~ ERROR overflow evaluating associated type + pub type Focus = &'a mut for<'b> fn(Carrier<'b>::Focus); //~ ERROR overflow evaluating associated type } fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-111879-0.stderr b/tests/ui/associated-inherent-types/issue-111879-0.stderr index 7bdbad440..f6367c88a 100644 --- a/tests/ui/associated-inherent-types/issue-111879-0.stderr +++ b/tests/ui/associated-inherent-types/issue-111879-0.stderr @@ -1,8 +1,8 @@ error: overflow evaluating associated type `Carrier<'b>::Focus` - --> $DIR/issue-111879-0.rs:11:25 + --> $DIR/issue-111879-0.rs:9:25 | -LL | pub type Focus = &'a mut User; - | ^^^^^^^^^^^^ +LL | pub type Focus = &'a mut for<'b> fn(Carrier<'b>::Focus); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/associated-inherent-types/late-bound-regions.rs b/tests/ui/associated-inherent-types/late-bound-regions.rs index 488a2cda6..1dbeb00d4 100644 --- a/tests/ui/associated-inherent-types/late-bound-regions.rs +++ b/tests/ui/associated-inherent-types/late-bound-regions.rs @@ -3,8 +3,6 @@ // Test if we correctly normalize `S<'a>::P` with respect to late-bound regions. -type Function = for<'a> fn(&'a i32) -> S<'a>::P; - struct S<'a>(&'a ()); trait Inter { @@ -16,7 +14,7 @@ impl<'a> S<'a> { } fn ret_ref_local<'e>() -> &'e i32 { - let f: Function = |x| x; + let f: for<'a> fn(&'a i32) -> S<'a>::P = |x| x; let local = 0; f(&local) //~ ERROR cannot return value referencing local variable `local` diff --git a/tests/ui/associated-inherent-types/late-bound-regions.stderr b/tests/ui/associated-inherent-types/late-bound-regions.stderr index 4706fcca9..0dd17b05c 100644 --- a/tests/ui/associated-inherent-types/late-bound-regions.stderr +++ b/tests/ui/associated-inherent-types/late-bound-regions.stderr @@ -1,5 +1,5 @@ error[E0515]: cannot return value referencing local variable `local` - --> $DIR/late-bound-regions.rs:22:5 + --> $DIR/late-bound-regions.rs:20:5 | LL | f(&local) | ^^------^ diff --git a/tests/ui/associated-inherent-types/not-found-self-type-differs.alias.stderr b/tests/ui/associated-inherent-types/not-found-self-type-differs.alias.stderr deleted file mode 100644 index 4396435a6..000000000 --- a/tests/ui/associated-inherent-types/not-found-self-type-differs.alias.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0220]: associated type `Proj` not found for `Family>` in the current scope - --> $DIR/not-found-self-type-differs.rs:17:34 - | -LL | struct Family(T); - | ---------------- associated item `Proj` not found for this struct -... -LL | type Alias = Family>::Proj; - | ^^^^ associated item not found in `Family>` - | - = note: the associated type was found for - - `Family<()>` - - `Family>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/associated-inherent-types/not-found-self-type-differs.local.stderr b/tests/ui/associated-inherent-types/not-found-self-type-differs.local.stderr deleted file mode 100644 index d527db022..000000000 --- a/tests/ui/associated-inherent-types/not-found-self-type-differs.local.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0220]: associated type `Proj` not found for `Family` in the current scope - --> $DIR/not-found-self-type-differs.rs:21:40 - | -LL | struct Family(T); - | ---------------- associated item `Proj` not found for this struct -... -LL | let _: Family::Proj = (); - | ^^^^ associated item not found in `Family` - | - = note: the associated type was found for - - `Family<()>` - - `Family>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/associated-inherent-types/not-found-self-type-differs.rs b/tests/ui/associated-inherent-types/not-found-self-type-differs.rs index 93f58dcb6..76c5d4e7f 100644 --- a/tests/ui/associated-inherent-types/not-found-self-type-differs.rs +++ b/tests/ui/associated-inherent-types/not-found-self-type-differs.rs @@ -1,5 +1,3 @@ -// revisions: local alias - #![feature(inherent_associated_types)] #![allow(incomplete_features)] @@ -13,10 +11,7 @@ impl Family> { type Proj = Self; } -#[cfg(alias)] -type Alias = Family>::Proj; //[alias]~ ERROR associated type `Proj` not found for `Family>` - fn main() { - #[cfg(local)] - let _: Family::Proj = (); //[local]~ ERROR associated type `Proj` not found for `Family` + let _: Family>::Proj; //~ ERROR associated type `Proj` not found for `Family>` + let _: Family::Proj = (); //~ ERROR associated type `Proj` not found for `Family` } diff --git a/tests/ui/associated-inherent-types/not-found-self-type-differs.stderr b/tests/ui/associated-inherent-types/not-found-self-type-differs.stderr new file mode 100644 index 000000000..1871407c6 --- /dev/null +++ b/tests/ui/associated-inherent-types/not-found-self-type-differs.stderr @@ -0,0 +1,29 @@ +error[E0220]: associated type `Proj` not found for `Family>` in the current scope + --> $DIR/not-found-self-type-differs.rs:15:32 + | +LL | struct Family(T); + | ---------------- associated item `Proj` not found for this struct +... +LL | let _: Family>::Proj; + | ^^^^ associated item not found in `Family>` + | + = note: the associated type was found for + - `Family<()>` + - `Family>` + +error[E0220]: associated type `Proj` not found for `Family` in the current scope + --> $DIR/not-found-self-type-differs.rs:16:40 + | +LL | struct Family(T); + | ---------------- associated item `Proj` not found for this struct +... +LL | let _: Family::Proj = (); + | ^^^^ associated item not found in `Family` + | + = note: the associated type was found for + - `Family<()>` + - `Family>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/associated-inherent-types/substitute-params-bad.rs b/tests/ui/associated-inherent-types/substitute-params-bad.rs index 00eb1a14d..a5d73c7b4 100644 --- a/tests/ui/associated-inherent-types/substitute-params-bad.rs +++ b/tests/ui/associated-inherent-types/substitute-params-bad.rs @@ -17,7 +17,7 @@ impl Subj<(T, S)> { } fn main() { - type A = S<()>::P; + let _: S<()>::P; let _: Subj<(i32, i32)>::Un = 0i32; //~ ERROR mismatched types } diff --git a/tests/ui/associated-inherent-types/substitute-params.rs b/tests/ui/associated-inherent-types/substitute-params.rs index e94d68331..631340b2b 100644 --- a/tests/ui/associated-inherent-types/substitute-params.rs +++ b/tests/ui/associated-inherent-types/substitute-params.rs @@ -15,8 +15,7 @@ impl S<(T,)> { fn main() { // Regression test for issue #104240. - type A = S<()>::P; - let _: A = (); + let _: S<()>::P = (); // Regression test for issue #107468. let _: S<(i32,)>::Un = 0i32; diff --git a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs index b32b4288a..5c59f217b 100644 --- a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs +++ b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs @@ -1,4 +1,5 @@ -// check-pass +// FIXME(inherent_associated_types): This should be `check-pass` +// known-bug: #108491 // compile-flags: --crate-type=lib #![feature(inherent_associated_types)] @@ -17,7 +18,6 @@ pub type Alias = (Source::Assoc,); - pub struct Source(T); pub trait Bound {} diff --git a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr new file mode 100644 index 000000000..5e18543fc --- /dev/null +++ b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr @@ -0,0 +1,55 @@ +error[E0391]: cycle detected when expanding type alias `Alias` + --> $DIR/type-alias-bounds-are-enforced.rs:19:1 + | +LL | pub type Alias = (Source::Assoc,); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires computing the variances of `Source`... + --> $DIR/type-alias-bounds-are-enforced.rs:21:1 + | +LL | pub struct Source(T); + | ^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing the variances for items in this crate... + = note: ...which again requires expanding type alias `Alias`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/type-alias-bounds-are-enforced.rs:5:1 + | +LL | / #![feature(inherent_associated_types)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | // Bounds on the self type play a major role in the resolution of inherent associated types (*). +... | +LL | | pub type Assoc = (); +LL | | } + | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error[E0391]: cycle detected when expanding type alias `Alias` + --> $DIR/type-alias-bounds-are-enforced.rs:19:1 + | +LL | pub type Alias = (Source::Assoc,); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires computing the variances of `Source`... + --> $DIR/type-alias-bounds-are-enforced.rs:21:1 + | +LL | pub struct Source(T); + | ^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing the variances for items in this crate... + = note: ...which again requires expanding type alias `Alias`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/type-alias-bounds-are-enforced.rs:5:1 + | +LL | / #![feature(inherent_associated_types)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | // Bounds on the self type play a major role in the resolution of inherent associated types (*). +... | +LL | | pub type Assoc = (); +LL | | } + | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/associated-type-bounds/ambiguous-associated-type2.rs b/tests/ui/associated-type-bounds/ambiguous-associated-type2.rs index 48de59334..e9cd57f17 100644 --- a/tests/ui/associated-type-bounds/ambiguous-associated-type2.rs +++ b/tests/ui/associated-type-bounds/ambiguous-associated-type2.rs @@ -7,4 +7,6 @@ trait Bar { trait Baz: Foo + Bar {} //~^ ERROR cycle detected when computing the super traits of `Baz` with associated type name `Item` [E0391] + + fn main() {} diff --git a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr index 575b00e09..f2604f0ba 100644 --- a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr +++ b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr @@ -10,6 +10,7 @@ note: cycle used when computing the super predicates of `Baz` | LL | trait Baz: Foo + Bar {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/associated-type-bounds/consts.rs b/tests/ui/associated-type-bounds/consts.rs new file mode 100644 index 000000000..9b95b1b52 --- /dev/null +++ b/tests/ui/associated-type-bounds/consts.rs @@ -0,0 +1,10 @@ +#![feature(associated_type_bounds)] + +pub fn accept(_: impl Trait) {} +//~^ ERROR expected associated type, found associated constant + +pub trait Trait { + const K: i32; +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/consts.stderr b/tests/ui/associated-type-bounds/consts.stderr new file mode 100644 index 000000000..ddfb6612b --- /dev/null +++ b/tests/ui/associated-type-bounds/consts.stderr @@ -0,0 +1,10 @@ +error: expected associated type, found associated constant + --> $DIR/consts.rs:3:29 + | +LL | pub fn accept(_: impl Trait) {} + | ^ + | + = note: trait bounds not allowed on associated constant + +error: aborting due to previous error + diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 771acb6c4..58ce41d1a 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr new file mode 100644 index 000000000..95ef7d82f --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -0,0 +1,48 @@ +error: return type notation uses `()` instead of `(..)` for elided arguments + --> $DIR/bad-inputs-and-output.rs:18:24 + | +LL | fn baz>() {} + | ^^ help: remove the `..` + +error[E0658]: associated type bounds are unstable + --> $DIR/bad-inputs-and-output.rs:10:17 + | +LL | fn foo>() {} + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #52662 for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/bad-inputs-and-output.rs:14:17 + | +LL | fn bar (): Send>>() {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #52662 for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-inputs-and-output.rs:3:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: argument types not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:10:23 + | +LL | fn foo>() {} + | ^^^^^ help: remove the input types: `()` + +error: return type not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:14:25 + | +LL | fn bar (): Send>>() {} + | ^^^^^^ help: remove the return type + +error: aborting due to 5 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs index d443c9dc1..3dd9249a7 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -1,9 +1,6 @@ -// revisions: current_with current_without next_with next_without -// [next_with] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// [next_without] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: with without // edition: 2021 -// [current_with] check-pass -// [next_with] check-pass +// [with] check-pass #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete @@ -20,12 +17,11 @@ async fn foo() -> Result<(), ()> { fn is_send(_: impl Send) {} fn test< - #[cfg(any(current_with, next_with))] T: Foo, - #[cfg(any(current_without, next_without))] T: Foo, + #[cfg(with)] T: Foo, + #[cfg(without)] T: Foo, >() { is_send(foo::()); - //[current_without]~^ ERROR future cannot be sent between threads safely - //[next_without]~^^ ERROR future cannot be sent between threads safely + //[without]~^ ERROR future cannot be sent between threads safely } fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs index 0d6545cc2..6884305d7 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr new file mode 100644 index 000000000..490bfdc4c --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -0,0 +1,17 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/equality.rs:3:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: return type notation is not allowed to use type equality + --> $DIR/equality.rs:12:18 + | +LL | fn test>>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs b/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs index 6894f6b6c..0848b4c55 100644 --- a/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs +++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -fn foo(mut iter: I, value: &I::Item) +pub fn foo(mut iter: I, value: &I::Item) where I::Item: Eq + Debug, { diff --git a/tests/ui/associated-types/issue-20825.stderr b/tests/ui/associated-types/issue-20825.stderr index c4dea68b8..02b3536e2 100644 --- a/tests/ui/associated-types/issue-20825.stderr +++ b/tests/ui/associated-types/issue-20825.stderr @@ -10,6 +10,7 @@ note: cycle used when computing the super predicates of `Processor` | LL | pub trait Processor: Subscriber { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs index 554ac673d..ab675d0a1 100644 --- a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs +++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs @@ -49,13 +49,11 @@ async fn foo8() -> Result<(), ()> { Ok(()) } fn foo9() -> Result<(), ()> { - let _ = await bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks - //~^ ERROR incorrect use of `await` + let _ = await bar(); //~ ERROR incorrect use of `await` Ok(()) } fn foo10() -> Result<(), ()> { - let _ = await? bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks - //~^ ERROR incorrect use of `await` + let _ = await? bar(); //~ ERROR incorrect use of `await` Ok(()) } fn foo11() -> Result<(), ()> { @@ -63,8 +61,7 @@ fn foo11() -> Result<(), ()> { Ok(()) } fn foo12() -> Result<(), ()> { - let _ = (await bar())?; //~ ERROR `await` is only allowed inside `async` functions and blocks - //~^ ERROR incorrect use of `await` + let _ = (await bar())?; //~ ERROR incorrect use of `await` Ok(()) } fn foo13() -> Result<(), ()> { @@ -111,7 +108,6 @@ async fn foo27() -> Result<(), ()> { fn foo28() -> Result<(), ()> { fn foo() -> Result<(), ()> { let _ = await!(bar())?; //~ ERROR incorrect use of `await` - //~^ ERROR `await` is only allowed inside `async` functions Ok(()) } foo() @@ -119,7 +115,6 @@ fn foo28() -> Result<(), ()> { fn foo29() -> Result<(), ()> { let foo = || { let _ = await!(bar())?; //~ ERROR incorrect use of `await` - //~^ ERROR `await` is only allowed inside `async` functions Ok(()) }; foo() diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr index 7b03e5666..928eb0b82 100644 --- a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr +++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr @@ -59,61 +59,61 @@ LL | let _ = await bar(); | ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:57:13 + --> $DIR/incorrect-syntax-suggestions.rs:56:13 | LL | let _ = await? bar(); | ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await?` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:62:13 + --> $DIR/incorrect-syntax-suggestions.rs:60:13 | LL | let _ = await bar()?; | ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:66:14 + --> $DIR/incorrect-syntax-suggestions.rs:64:14 | LL | let _ = (await bar())?; | ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:71:24 + --> $DIR/incorrect-syntax-suggestions.rs:68:24 | LL | let _ = bar().await(); | ^^ help: `await` is not a method call, remove the parentheses error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:76:24 + --> $DIR/incorrect-syntax-suggestions.rs:73:24 | LL | let _ = bar().await()?; | ^^ help: `await` is not a method call, remove the parentheses error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:104:13 + --> $DIR/incorrect-syntax-suggestions.rs:101:13 | LL | let _ = await!(bar()); | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:108:13 + --> $DIR/incorrect-syntax-suggestions.rs:105:13 | LL | let _ = await!(bar())?; | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:113:17 + --> $DIR/incorrect-syntax-suggestions.rs:110:17 | LL | let _ = await!(bar())?; | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:121:17 + --> $DIR/incorrect-syntax-suggestions.rs:117:17 | LL | let _ = await!(bar())?; | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` error: expected expression, found `=>` - --> $DIR/incorrect-syntax-suggestions.rs:129:25 + --> $DIR/incorrect-syntax-suggestions.rs:124:25 | LL | match await { await => () } | ----- ^^ expected expression @@ -121,13 +121,13 @@ LL | match await { await => () } | while parsing this incorrect await expression error: incorrect use of `await` - --> $DIR/incorrect-syntax-suggestions.rs:129:11 + --> $DIR/incorrect-syntax-suggestions.rs:124:11 | LL | match await { await => () } | ^^^^^^^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ await => () }.await` error: expected one of `.`, `?`, `{`, or an operator, found `}` - --> $DIR/incorrect-syntax-suggestions.rs:132:1 + --> $DIR/incorrect-syntax-suggestions.rs:127:1 | LL | match await { await => () } | ----- - expected one of `.`, `?`, `{`, or an operator @@ -138,31 +138,7 @@ LL | } | ^ unexpected token error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:52:13 - | -LL | fn foo9() -> Result<(), ()> { - | ---- this is not `async` -LL | let _ = await bar(); - | ^^^^^ only allowed inside `async` functions and blocks - -error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:57:13 - | -LL | fn foo10() -> Result<(), ()> { - | ----- this is not `async` -LL | let _ = await? bar(); - | ^^^^^ only allowed inside `async` functions and blocks - -error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:66:14 - | -LL | fn foo12() -> Result<(), ()> { - | ----- this is not `async` -LL | let _ = (await bar())?; - | ^^^^^ only allowed inside `async` functions and blocks - -error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:71:19 + --> $DIR/incorrect-syntax-suggestions.rs:68:19 | LL | fn foo13() -> Result<(), ()> { | ----- this is not `async` @@ -170,7 +146,7 @@ LL | let _ = bar().await(); | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:76:19 + --> $DIR/incorrect-syntax-suggestions.rs:73:19 | LL | fn foo14() -> Result<(), ()> { | ----- this is not `async` @@ -178,7 +154,7 @@ LL | let _ = bar().await()?; | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:81:19 + --> $DIR/incorrect-syntax-suggestions.rs:78:19 | LL | fn foo15() -> Result<(), ()> { | ----- this is not `async` @@ -186,7 +162,7 @@ LL | let _ = bar().await; | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:85:19 + --> $DIR/incorrect-syntax-suggestions.rs:82:19 | LL | fn foo16() -> Result<(), ()> { | ----- this is not `async` @@ -194,7 +170,7 @@ LL | let _ = bar().await?; | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:90:23 + --> $DIR/incorrect-syntax-suggestions.rs:87:23 | LL | fn foo() -> Result<(), ()> { | --- this is not `async` @@ -202,29 +178,13 @@ LL | let _ = bar().await?; | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:97:23 + --> $DIR/incorrect-syntax-suggestions.rs:94:23 | LL | let foo = || { | -- this is not `async` LL | let _ = bar().await?; | ^^^^^ only allowed inside `async` functions and blocks -error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:113:17 - | -LL | fn foo() -> Result<(), ()> { - | --- this is not `async` -LL | let _ = await!(bar())?; - | ^^^^^ only allowed inside `async` functions and blocks - -error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:121:17 - | -LL | let foo = || { - | -- this is not `async` -LL | let _ = await!(bar())?; - | ^^^^^ only allowed inside `async` functions and blocks - -error: aborting due to 33 previous errors +error: aborting due to 28 previous errors For more information about this error, try `rustc --explain E0728`. diff --git a/tests/ui/async-await/clone-suggestion.stderr b/tests/ui/async-await/clone-suggestion.stderr index c02206f6f..b5c8ef699 100644 --- a/tests/ui/async-await/clone-suggestion.stderr +++ b/tests/ui/async-await/clone-suggestion.stderr @@ -13,7 +13,7 @@ note: `into_future` takes ownership of the receiver `self`, which moves `f` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | f.clone().await; - | ++++++++ + | ++++++++ error: aborting due to previous error diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.rs b/tests/ui/async-await/edition-deny-async-fns-2015.rs index d4c30dc9d..6bd6d879a 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.rs +++ b/tests/ui/async-await/edition-deny-async-fns-2015.rs @@ -1,6 +1,4 @@ // edition:2015 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.stderr new file mode 100644 index 000000000..ba918eb28 --- /dev/null +++ b/tests/ui/async-await/edition-deny-async-fns-2015.stderr @@ -0,0 +1,98 @@ +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:3:1 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:5:12 + | +LL | fn baz() { async fn foo() {} } + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:7:1 + | +LL | async fn async_baz() { + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:8:5 + | +LL | async fn bar() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:14:5 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:18:5 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:36:9 + | +LL | async fn bar() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:26:9 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:31:13 + | +LL | async fn bar() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/edition-deny-async-fns-2015.rs:18:5 + | +LL | async fn foo() {} + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error: aborting due to 10 previous errors + +Some errors have detailed explanations: E0670, E0706. +For more information about an error, try `rustc --explain E0670`. diff --git a/tests/ui/async-await/in-trait/async-associated-types.rs b/tests/ui/async-await/in-trait/async-associated-types.rs index 89ca4039b..974f5aaff 100644 --- a/tests/ui/async-await/in-trait/async-associated-types.rs +++ b/tests/ui/async-await/in-trait/async-associated-types.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(impl_trait_projections)] diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index 99c3ba6a3..06413fe6f 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -1,7 +1,5 @@ // run-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.current.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.current.stderr deleted file mode 100644 index b5ace9ada..000000000 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.current.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:17:28 - | -LL | async fn foo(&self) -> i32 { - | ^^^ expected `Pin>>`, found future - | -note: type in trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:13:22 - | -LL | fn foo(&self) -> Pin + '_>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected signature `fn(&i32) -> Pin>>` - found signature `fn(&i32) -> impl Future` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr deleted file mode 100644 index b5ace9ada..000000000 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:17:28 - | -LL | async fn foo(&self) -> i32 { - | ^^^ expected `Pin>>`, found future - | -note: type in trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:13:22 - | -LL | fn foo(&self) -> Pin + '_>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected signature `fn(&i32) -> Pin>>` - found signature `fn(&i32) -> impl Future` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs index 7b53379b2..38ba29718 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr new file mode 100644 index 000000000..168ef8e9e --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -0,0 +1,17 @@ +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/async-example-desugared-boxed-in-trait.rs:15:28 + | +LL | async fn foo(&self) -> i32 { + | ^^^ expected `Pin>>`, found future + | +note: type in trait + --> $DIR/async-example-desugared-boxed-in-trait.rs:11:22 + | +LL | fn foo(&self) -> Pin + '_>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected signature `fn(&i32) -> Pin>>` + found signature `fn(&i32) -> impl Future` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.current.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.current.stderr deleted file mode 100644 index 6c0b58591..000000000 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-boxed.rs:17:5 - | -LL | async fn foo(&self) -> i32; - | --------------------------- required because the trait method is async -... -LL | fn foo(&self) -> Pin + '_>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr deleted file mode 100644 index 6c0b58591..000000000 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-boxed.rs:17:5 - | -LL | async fn foo(&self) -> i32; - | --------------------------- required because the trait method is async -... -LL | fn foo(&self) -> Pin + '_>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs index 916488ffa..1b1b3cffd 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr new file mode 100644 index 000000000..60fa534a6 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/async-example-desugared-boxed.rs:15:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> Pin + '_>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs index edac0b374..81e1e59a3 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs index 934f7643d..feeda719e 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.current.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.current.stderr deleted file mode 100644 index 0d2551ab8..000000000 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-manual.rs:25:5 - | -LL | async fn foo(&self) -> i32; - | --------------------------- required because the trait method is async -... -LL | fn foo(&self) -> MyFuture { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr deleted file mode 100644 index 0d2551ab8..000000000 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-manual.rs:25:5 - | -LL | async fn foo(&self) -> i32; - | --------------------------- required because the trait method is async -... -LL | fn foo(&self) -> MyFuture { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs index 4883828d3..71473e745 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr new file mode 100644 index 000000000..567a36a86 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/async-example-desugared-manual.rs:23:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> MyFuture { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/async-example-desugared.rs b/tests/ui/async-await/in-trait/async-example-desugared.rs index 214171b2e..fb92ec786 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr deleted file mode 100644 index 780da0689..000000000 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - | -note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:14:18 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - -error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:14:18 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr deleted file mode 100644 index 780da0689..000000000 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - | -note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:14:18 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - -error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:14:18 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:14:28 - | -LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index 146e74ec2..a73d55adf 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs @@ -1,8 +1,6 @@ // check-fail // known-bug: #102682 // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr new file mode 100644 index 000000000..5c8d64fc6 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -0,0 +1,37 @@ +error[E0311]: the parameter type `U` may not live long enough + --> $DIR/async-generics-and-bounds.rs:12:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + | +note: the parameter type `U` must be valid for the anonymous lifetime as defined here... + --> $DIR/async-generics-and-bounds.rs:12:18 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics-and-bounds.rs:12:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/async-generics-and-bounds.rs:12:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... + --> $DIR/async-generics-and-bounds.rs:12:18 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics-and-bounds.rs:12:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics.current.stderr b/tests/ui/async-await/in-trait/async-generics.current.stderr deleted file mode 100644 index 04e1ab6d7..000000000 --- a/tests/ui/async-await/in-trait/async-generics.current.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - | -note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:11:18 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - -error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:11:18 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics.next.stderr b/tests/ui/async-await/in-trait/async-generics.next.stderr deleted file mode 100644 index 04e1ab6d7..000000000 --- a/tests/ui/async-await/in-trait/async-generics.next.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - | -note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:11:18 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - -error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:11:18 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^ -note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:11:28 - | -LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index 507500abf..67000e577 100644 --- a/tests/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs @@ -1,8 +1,6 @@ // check-fail // known-bug: #102682 // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr new file mode 100644 index 000000000..6ae73d9e3 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-generics.stderr @@ -0,0 +1,37 @@ +error[E0311]: the parameter type `U` may not live long enough + --> $DIR/async-generics.rs:9:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + | +note: the parameter type `U` must be valid for the anonymous lifetime as defined here... + --> $DIR/async-generics.rs:9:18 + | +LL | async fn foo(&self) -> &(T, U); + | ^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics.rs:9:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/async-generics.rs:9:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... + --> $DIR/async-generics.rs:9:18 + | +LL | async fn foo(&self) -> &(T, U); + | ^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics.rs:9:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs index 9869a8d71..d5481d277 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-lifetimes.rs b/tests/ui/async-await/in-trait/async-lifetimes.rs index ecbd1910a..f298e45d2 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.current.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.current.stderr deleted file mode 100644 index 67b491f19..000000000 --- a/tests/ui/async-await/in-trait/async-recursive-generic.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive-generic.rs:13:48 - | -LL | async fn foo_recursive(&self, n: usize) -> T { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.next.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.next.stderr deleted file mode 100644 index 67b491f19..000000000 --- a/tests/ui/async-await/in-trait/async-recursive-generic.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive-generic.rs:13:48 - | -LL | async fn foo_recursive(&self, n: usize) -> T { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.rs b/tests/ui/async-await/in-trait/async-recursive-generic.rs index 64c6ba15c..6839abd38 100644 --- a/tests/ui/async-await/in-trait/async-recursive-generic.rs +++ b/tests/ui/async-await/in-trait/async-recursive-generic.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.stderr new file mode 100644 index 000000000..cab173bdd --- /dev/null +++ b/tests/ui/async-await/in-trait/async-recursive-generic.stderr @@ -0,0 +1,12 @@ +error[E0733]: recursion in an `async fn` requires boxing + --> $DIR/async-recursive-generic.rs:11:48 + | +LL | async fn foo_recursive(&self, n: usize) -> T { + | ^ recursive `async fn` + | + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` + = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive.current.stderr b/tests/ui/async-await/in-trait/async-recursive.current.stderr deleted file mode 100644 index 85af27e37..000000000 --- a/tests/ui/async-await/in-trait/async-recursive.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive.rs:13:48 - | -LL | async fn foo_recursive(&self, n: usize) -> i32 { - | ^^^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive.next.stderr b/tests/ui/async-await/in-trait/async-recursive.next.stderr deleted file mode 100644 index 85af27e37..000000000 --- a/tests/ui/async-await/in-trait/async-recursive.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive.rs:13:48 - | -LL | async fn foo_recursive(&self, n: usize) -> i32 { - | ^^^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive.rs b/tests/ui/async-await/in-trait/async-recursive.rs index d928909e3..61119f809 100644 --- a/tests/ui/async-await/in-trait/async-recursive.rs +++ b/tests/ui/async-await/in-trait/async-recursive.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-recursive.stderr b/tests/ui/async-await/in-trait/async-recursive.stderr new file mode 100644 index 000000000..9feff37b3 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-recursive.stderr @@ -0,0 +1,12 @@ +error[E0733]: recursion in an `async fn` requires boxing + --> $DIR/async-recursive.rs:11:48 + | +LL | async fn foo_recursive(&self, n: usize) -> i32 { + | ^^^ recursive `async fn` + | + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` + = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/bad-signatures.current.stderr b/tests/ui/async-await/in-trait/bad-signatures.current.stderr deleted file mode 100644 index ae590fb05..000000000 --- a/tests/ui/async-await/in-trait/bad-signatures.current.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:8:23 - | -LL | async fn bar(&abc self); - | ^^^^ expected identifier, found keyword - -error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:8:23 - | -LL | async fn bar(&abc self); - | -----^^^^ - | | | - | | expected one of `:`, `@`, or `|` - | help: declare the type after the parameter binding: `: ` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/async-await/in-trait/bad-signatures.next.stderr b/tests/ui/async-await/in-trait/bad-signatures.next.stderr deleted file mode 100644 index ae590fb05..000000000 --- a/tests/ui/async-await/in-trait/bad-signatures.next.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:8:23 - | -LL | async fn bar(&abc self); - | ^^^^ expected identifier, found keyword - -error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:8:23 - | -LL | async fn bar(&abc self); - | -----^^^^ - | | | - | | expected one of `:`, `@`, or `|` - | help: declare the type after the parameter binding: `: ` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/async-await/in-trait/bad-signatures.rs b/tests/ui/async-await/in-trait/bad-signatures.rs index 4baddd8cc..98dddc126 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.rs +++ b/tests/ui/async-await/in-trait/bad-signatures.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/bad-signatures.stderr b/tests/ui/async-await/in-trait/bad-signatures.stderr new file mode 100644 index 000000000..7cbd96e24 --- /dev/null +++ b/tests/ui/async-await/in-trait/bad-signatures.stderr @@ -0,0 +1,17 @@ +error: expected identifier, found keyword `self` + --> $DIR/bad-signatures.rs:6:23 + | +LL | async fn bar(&abc self); + | ^^^^ expected identifier, found keyword + +error: expected one of `:`, `@`, or `|`, found keyword `self` + --> $DIR/bad-signatures.rs:6:23 + | +LL | async fn bar(&abc self); + | -----^^^^ + | | | + | | expected one of `:`, `@`, or `|` + | help: declare the type after the parameter binding: `: ` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr deleted file mode 100644 index eec5ab065..000000000 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: async associated function in trait cannot be specialized - --> $DIR/dont-project-to-specializable-projection.rs:16:5 - | -LL | default async fn foo(_: T) -> &'static str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr deleted file mode 100644 index 25a7f3bb5..000000000 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/dont-project-to-specializable-projection.rs:16:35 - | -LL | default async fn foo(_: T) -> &'static str { - | ^^^^^^^^^^^^ expected associated type, found future - | -note: type in trait - --> $DIR/dont-project-to-specializable-projection.rs:12:27 - | -LL | async fn foo(_: T) -> &'static str; - | ^^^^^^^^^^^^ - = note: expected signature `fn(_) -> impl Future` - found signature `fn(_) -> impl Future` - -error: async associated function in trait cannot be specialized - --> $DIR/dont-project-to-specializable-projection.rs:16:5 - | -LL | default async fn foo(_: T) -> &'static str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs index 7183eaccc..afd3db5e0 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs @@ -1,7 +1,5 @@ // edition: 2021 // known-bug: #108309 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(min_specialization)] diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr new file mode 100644 index 000000000..7c750bf51 --- /dev/null +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -0,0 +1,25 @@ +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/dont-project-to-specializable-projection.rs:14:35 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^ expected associated type, found future + | +note: type in trait + --> $DIR/dont-project-to-specializable-projection.rs:10:27 + | +LL | async fn foo(_: T) -> &'static str; + | ^^^^^^^^^^^^ + = note: expected signature `fn(_) -> impl Future` + found signature `fn(_) -> impl Future` + +error: async associated function in trait cannot be specialized + --> $DIR/dont-project-to-specializable-projection.rs:14:5 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/early-bound-1.rs b/tests/ui/async-await/in-trait/early-bound-1.rs index 30843473d..6b3b14201 100644 --- a/tests/ui/async-await/in-trait/early-bound-1.rs +++ b/tests/ui/async-await/in-trait/early-bound-1.rs @@ -1,7 +1,5 @@ // check-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/early-bound-2.rs b/tests/ui/async-await/in-trait/early-bound-2.rs index 1c5a68c2a..270443229 100644 --- a/tests/ui/async-await/in-trait/early-bound-2.rs +++ b/tests/ui/async-await/in-trait/early-bound-2.rs @@ -1,7 +1,5 @@ // check-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.current.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.current.stderr deleted file mode 100644 index 1a7495149..000000000 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types - --> $DIR/fn-not-async-err2.rs:15:22 - | -LL | fn foo(&self) -> impl Future { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr deleted file mode 100644 index 1a7495149..000000000 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types - --> $DIR/fn-not-async-err2.rs:15:22 - | -LL | fn foo(&self) -> impl Future { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.rs b/tests/ui/async-await/in-trait/fn-not-async-err2.rs index 5fdb7296a..78017429f 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr new file mode 100644 index 000000000..37d9669c0 --- /dev/null +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr @@ -0,0 +1,12 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types + --> $DIR/fn-not-async-err2.rs:13:22 + | +LL | fn foo(&self) -> impl Future { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/async-await/in-trait/generics-mismatch.current.stderr b/tests/ui/async-await/in-trait/generics-mismatch.current.stderr deleted file mode 100644 index be23384e0..000000000 --- a/tests/ui/async-await/in-trait/generics-mismatch.current.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` - --> $DIR/generics-mismatch.rs:13:18 - | -LL | trait Foo { - | --- -LL | async fn foo(); - | - expected type parameter -... -LL | impl Foo for () { - | --------------- -LL | async fn foo() {} - | ^^^^^^^^^^^^^^ found const parameter of type `usize` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/generics-mismatch.next.stderr b/tests/ui/async-await/in-trait/generics-mismatch.next.stderr deleted file mode 100644 index be23384e0..000000000 --- a/tests/ui/async-await/in-trait/generics-mismatch.next.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` - --> $DIR/generics-mismatch.rs:13:18 - | -LL | trait Foo { - | --- -LL | async fn foo(); - | - expected type parameter -... -LL | impl Foo for () { - | --------------- -LL | async fn foo() {} - | ^^^^^^^^^^^^^^ found const parameter of type `usize` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/implied-bounds.rs b/tests/ui/async-await/in-trait/implied-bounds.rs index 45ada1d84..52bceb3cc 100644 --- a/tests/ui/async-await/in-trait/implied-bounds.rs +++ b/tests/ui/async-await/in-trait/implied-bounds.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-102138.rs b/tests/ui/async-await/in-trait/issue-102138.rs index ced30b7e4..f61b34ed9 100644 --- a/tests/ui/async-await/in-trait/issue-102138.rs +++ b/tests/ui/async-await/in-trait/issue-102138.rs @@ -1,7 +1,5 @@ // check-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-102219.rs b/tests/ui/async-await/in-trait/issue-102219.rs index f3fdfa345..9a35f6515 100644 --- a/tests/ui/async-await/in-trait/issue-102219.rs +++ b/tests/ui/async-await/in-trait/issue-102219.rs @@ -1,8 +1,6 @@ // compile-flags:--crate-type=lib // edition:2021 // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-102310.rs b/tests/ui/async-await/in-trait/issue-102310.rs index 8e5dbd08e..49c3e9fee 100644 --- a/tests/ui/async-await/in-trait/issue-102310.rs +++ b/tests/ui/async-await/in-trait/issue-102310.rs @@ -1,7 +1,5 @@ // check-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-104678.rs b/tests/ui/async-await/in-trait/issue-104678.rs index 3d010f180..e396df4e5 100644 --- a/tests/ui/async-await/in-trait/issue-104678.rs +++ b/tests/ui/async-await/in-trait/issue-104678.rs @@ -1,7 +1,5 @@ // edition:2021 // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr deleted file mode 100644 index 69e7c65ee..000000000 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:13:17 - | -LL | async fn foo<'a>(&self); - | ---- lifetimes in impl do not match this method in trait -... -LL | async fn foo(&self) {} - | ^ lifetimes do not match method in trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr deleted file mode 100644 index 69e7c65ee..000000000 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:13:17 - | -LL | async fn foo<'a>(&self); - | ---- lifetimes in impl do not match this method in trait -... -LL | async fn foo(&self) {} - | ^ lifetimes do not match method in trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index 46183f72b..bb793df5d 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr new file mode 100644 index 000000000..86592269c --- /dev/null +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration + --> $DIR/lifetime-mismatch.rs:11:17 + | +LL | async fn foo<'a>(&self); + | ---- lifetimes in impl do not match this method in trait +... +LL | async fn foo(&self) {} + | ^ lifetimes do not match method in trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/missing-feature-flag.current.stderr b/tests/ui/async-await/in-trait/missing-feature-flag.current.stderr deleted file mode 100644 index e6ac9bc22..000000000 --- a/tests/ui/async-await/in-trait/missing-feature-flag.current.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/missing-feature-flag.rs:14:1 - | -LL | async fn foo(_: T) -> &'static str; - | ----------------------------------- `foo` from trait -... -LL | impl MyTrait for MyStruct {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - -error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` - --> $DIR/missing-feature-flag.rs:18:5 - | -LL | impl MyTrait for MyStruct {} - | ------------------------------- parent `impl` is here -... -LL | async fn foo(_: i32) -> &'static str {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo` - | - = note: to specialize, `foo` in the parent `impl` must be marked `default` - -error[E0308]: mismatched types - --> $DIR/missing-feature-flag.rs:18:42 - | -LL | async fn foo(_: i32) -> &'static str {} - | ^^ expected `&str`, found `()` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0046, E0308, E0520. -For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/async-await/in-trait/missing-feature-flag.next.stderr b/tests/ui/async-await/in-trait/missing-feature-flag.next.stderr deleted file mode 100644 index e6ac9bc22..000000000 --- a/tests/ui/async-await/in-trait/missing-feature-flag.next.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/missing-feature-flag.rs:14:1 - | -LL | async fn foo(_: T) -> &'static str; - | ----------------------------------- `foo` from trait -... -LL | impl MyTrait for MyStruct {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - -error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` - --> $DIR/missing-feature-flag.rs:18:5 - | -LL | impl MyTrait for MyStruct {} - | ------------------------------- parent `impl` is here -... -LL | async fn foo(_: i32) -> &'static str {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo` - | - = note: to specialize, `foo` in the parent `impl` must be marked `default` - -error[E0308]: mismatched types - --> $DIR/missing-feature-flag.rs:18:42 - | -LL | async fn foo(_: i32) -> &'static str {} - | ^^ expected `&str`, found `()` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0046, E0308, E0520. -For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/async-await/in-trait/missing-feature-flag.rs b/tests/ui/async-await/in-trait/missing-feature-flag.rs index 6481f4a70..34dd50a1c 100644 --- a/tests/ui/async-await/in-trait/missing-feature-flag.rs +++ b/tests/ui/async-await/in-trait/missing-feature-flag.rs @@ -1,6 +1,4 @@ // edition:2018 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] #![feature(min_specialization)] diff --git a/tests/ui/async-await/in-trait/missing-feature-flag.stderr b/tests/ui/async-await/in-trait/missing-feature-flag.stderr new file mode 100644 index 000000000..f6aba1fcd --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-feature-flag.stderr @@ -0,0 +1,30 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/missing-feature-flag.rs:12:1 + | +LL | async fn foo(_: T) -> &'static str; + | ----------------------------------- `foo` from trait +... +LL | impl MyTrait for MyStruct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/missing-feature-flag.rs:16:5 + | +LL | impl MyTrait for MyStruct {} + | ------------------------------- parent `impl` is here +... +LL | async fn foo(_: i32) -> &'static str {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo` + | + = note: to specialize, `foo` in the parent `impl` must be marked `default` + +error[E0308]: mismatched types + --> $DIR/missing-feature-flag.rs:16:42 + | +LL | async fn foo(_: i32) -> &'static str {} + | ^^ expected `&str`, found `()` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0046, E0308, E0520. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/async-await/in-trait/missing-send-bound.current.stderr b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr deleted file mode 100644 index 9aa37f743..000000000 --- a/tests/ui/async-await/in-trait/missing-send-bound.current.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:16:20 - | -LL | assert_is_send(test::()); - | ^^^^^^^^^^^ future returned by `test` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `impl Future` -note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:12:5 - | -LL | T::bar().await; - | ^^^^^^^^ await occurs here on type `impl Future`, which is not `Send` -note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:20:27 - | -LL | fn assert_is_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_is_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr deleted file mode 100644 index 9aa37f743..000000000 --- a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:16:20 - | -LL | assert_is_send(test::()); - | ^^^^^^^^^^^ future returned by `test` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `impl Future` -note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:12:5 - | -LL | T::bar().await; - | ^^^^^^^^ await occurs here on type `impl Future`, which is not `Send` -note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:20:27 - | -LL | fn assert_is_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_is_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/in-trait/missing-send-bound.rs b/tests/ui/async-await/in-trait/missing-send-bound.rs index b602865cb..dbcc66576 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.rs +++ b/tests/ui/async-await/in-trait/missing-send-bound.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/missing-send-bound.stderr b/tests/ui/async-await/in-trait/missing-send-bound.stderr new file mode 100644 index 000000000..18185b755 --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-send-bound.stderr @@ -0,0 +1,20 @@ +error: future cannot be sent between threads safely + --> $DIR/missing-send-bound.rs:14:20 + | +LL | assert_is_send(test::()); + | ^^^^^^^^^^^ future returned by `test` is not `Send` + | + = help: within `impl Future`, the trait `Send` is not implemented for `impl Future` +note: future is not `Send` as it awaits another future which is not `Send` + --> $DIR/missing-send-bound.rs:10:5 + | +LL | T::bar().await; + | ^^^^^^^^ await occurs here on type `impl Future`, which is not `Send` +note: required by a bound in `assert_is_send` + --> $DIR/missing-send-bound.rs:18:27 + | +LL | fn assert_is_send(_: impl Send) {} + | ^^^^ required by this bound in `assert_is_send` + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/object-safety.current.stderr b/tests/ui/async-await/in-trait/object-safety.current.stderr deleted file mode 100644 index 7f7ec3914..000000000 --- a/tests/ui/async-await/in-trait/object-safety.current.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:12:12 - | -LL | let x: &dyn Foo = todo!(); - | ^^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:8:14 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | async fn foo(&self); - | ^^^ ...because method `foo` is `async` - = help: consider moving `foo` to another trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.next.stderr b/tests/ui/async-await/in-trait/object-safety.next.stderr deleted file mode 100644 index 7f7ec3914..000000000 --- a/tests/ui/async-await/in-trait/object-safety.next.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:12:12 - | -LL | let x: &dyn Foo = todo!(); - | ^^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:8:14 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | async fn foo(&self); - | ^^^ ...because method `foo` is `async` - = help: consider moving `foo` to another trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.rs b/tests/ui/async-await/in-trait/object-safety.rs index 4edad1512..441539e5d 100644 --- a/tests/ui/async-await/in-trait/object-safety.rs +++ b/tests/ui/async-await/in-trait/object-safety.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/object-safety.stderr b/tests/ui/async-await/in-trait/object-safety.stderr new file mode 100644 index 000000000..ccdf9d887 --- /dev/null +++ b/tests/ui/async-await/in-trait/object-safety.stderr @@ -0,0 +1,18 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:10:12 + | +LL | let x: &dyn Foo = todo!(); + | ^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-safety.rs:6:14 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | async fn foo(&self); + | ^^^ ...because method `foo` is `async` + = help: consider moving `foo` to another trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/return-not-existing-pair.current.stderr b/tests/ui/async-await/in-trait/return-not-existing-pair.current.stderr deleted file mode 100644 index 56973a1d1..000000000 --- a/tests/ui/async-await/in-trait/return-not-existing-pair.current.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0726]: implicit elided lifetime not allowed here - --> $DIR/return-not-existing-pair.rs:12:20 - | -LL | impl<'a, 'b, T, U> MyTrait for U { - | ^^^^^^^^^^ expected lifetime parameters - | -help: indicate the anonymous lifetimes - | -LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U { - | +++++++ - -error[E0412]: cannot find type `ConnImpl` in this scope - --> $DIR/return-not-existing-pair.rs:8:48 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); - | ^^^^^^^^ not found in this scope - -error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl - --> $DIR/return-not-existing-pair.rs:14:5 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); - | ------------------------------------------------------------ `&self` used in trait -... -LL | async fn foo(_: T) -> (&'a U, &'b T) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl - -error[E0308]: mismatched types - --> $DIR/return-not-existing-pair.rs:14:42 - | -LL | async fn foo(_: T) -> (&'a U, &'b T) {} - | ^^ expected `(&U, &T)`, found `()` - | - = note: expected tuple `(&'a U, &'b T)` - found unit type `()` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0186, E0308, E0412, E0726. -For more information about an error, try `rustc --explain E0186`. diff --git a/tests/ui/async-await/in-trait/return-not-existing-pair.next.stderr b/tests/ui/async-await/in-trait/return-not-existing-pair.next.stderr deleted file mode 100644 index 56973a1d1..000000000 --- a/tests/ui/async-await/in-trait/return-not-existing-pair.next.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0726]: implicit elided lifetime not allowed here - --> $DIR/return-not-existing-pair.rs:12:20 - | -LL | impl<'a, 'b, T, U> MyTrait for U { - | ^^^^^^^^^^ expected lifetime parameters - | -help: indicate the anonymous lifetimes - | -LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U { - | +++++++ - -error[E0412]: cannot find type `ConnImpl` in this scope - --> $DIR/return-not-existing-pair.rs:8:48 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); - | ^^^^^^^^ not found in this scope - -error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl - --> $DIR/return-not-existing-pair.rs:14:5 - | -LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); - | ------------------------------------------------------------ `&self` used in trait -... -LL | async fn foo(_: T) -> (&'a U, &'b T) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl - -error[E0308]: mismatched types - --> $DIR/return-not-existing-pair.rs:14:42 - | -LL | async fn foo(_: T) -> (&'a U, &'b T) {} - | ^^ expected `(&U, &T)`, found `()` - | - = note: expected tuple `(&'a U, &'b T)` - found unit type `()` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0186, E0308, E0412, E0726. -For more information about an error, try `rustc --explain E0186`. diff --git a/tests/ui/async-await/in-trait/return-not-existing-pair.rs b/tests/ui/async-await/in-trait/return-not-existing-pair.rs index d1b3832d1..a14dfceed 100644 --- a/tests/ui/async-await/in-trait/return-not-existing-pair.rs +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/return-not-existing-pair.stderr b/tests/ui/async-await/in-trait/return-not-existing-pair.stderr new file mode 100644 index 000000000..e573b8517 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.stderr @@ -0,0 +1,39 @@ +error[E0726]: implicit elided lifetime not allowed here + --> $DIR/return-not-existing-pair.rs:10:20 + | +LL | impl<'a, 'b, T, U> MyTrait for U { + | ^^^^^^^^^^ expected lifetime parameters + | +help: indicate the anonymous lifetimes + | +LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U { + | +++++++ + +error[E0412]: cannot find type `ConnImpl` in this scope + --> $DIR/return-not-existing-pair.rs:6:48 + | +LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); + | ^^^^^^^^ not found in this scope + +error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl + --> $DIR/return-not-existing-pair.rs:12:5 + | +LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); + | ------------------------------------------------------------ `&self` used in trait +... +LL | async fn foo(_: T) -> (&'a U, &'b T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl + +error[E0308]: mismatched types + --> $DIR/return-not-existing-pair.rs:12:42 + | +LL | async fn foo(_: T) -> (&'a U, &'b T) {} + | ^^ expected `(&U, &T)`, found `()` + | + = note: expected tuple `(&'a U, &'b T)` + found unit type `()` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0186, E0308, E0412, E0726. +For more information about an error, try `rustc --explain E0186`. diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.current.stderr b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.current.stderr deleted file mode 100644 index 2564d68d5..000000000 --- a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.current.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0412]: cannot find type `Missing` in this scope - --> $DIR/return-not-existing-type-wrapping-rpitit.rs:10:25 - | -LL | fn bar() -> Wrapper>; - | ^^^^^^^ not found in this scope - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.next.stderr b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.next.stderr deleted file mode 100644 index 2564d68d5..000000000 --- a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.next.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0412]: cannot find type `Missing` in this scope - --> $DIR/return-not-existing-type-wrapping-rpitit.rs:10:25 - | -LL | fn bar() -> Wrapper>; - | ^^^^^^^ not found in this scope - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs index 37c02827e..254b9a782 100644 --- a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr new file mode 100644 index 000000000..059934d24 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/return-not-existing-type-wrapping-rpitit.rs:8:25 + | +LL | fn bar() -> Wrapper>; + | ^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr deleted file mode 100644 index 6a107d7be..000000000 --- a/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:9:9 - | -LL | Ok(()) - | ^^^^^^- help: consider using a semicolon here: `;` - | | - | expected `()`, found `Result<(), _>` - | - = note: expected unit type `()` - found enum `Result<(), _>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr deleted file mode 100644 index 6a107d7be..000000000 --- a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:9:9 - | -LL | Ok(()) - | ^^^^^^- help: consider using a semicolon here: `;` - | | - | expected `()`, found `Result<(), _>` - | - = note: expected unit type `()` - found enum `Result<(), _>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index d63bccefa..cdab4ea0f 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait)] @@ -8,7 +6,6 @@ trait A { async fn e() { Ok(()) //~^ ERROR mismatched types - //~| HELP consider using a semicolon here } } diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.stderr new file mode 100644 index 000000000..179c9ed93 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-type-suggestion.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/return-type-suggestion.rs:7:9 + | +LL | Ok(()) + | ^^^^^^ expected `()`, found `Result<(), _>` + | + = note: expected unit type `()` + found enum `Result<(), _>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/issue-61452.stderr b/tests/ui/async-await/issue-61452.stderr index bf5044328..3f623ba8a 100644 --- a/tests/ui/async-await/issue-61452.stderr +++ b/tests/ui/async-await/issue-61452.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/issue-61452.rs:4:5 | LL | x.take(); - | ^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/async-await/issues/issue-61187.stderr b/tests/ui/async-await/issues/issue-61187.stderr index e58f74546..203b17550 100644 --- a/tests/ui/async-await/issues/issue-61187.stderr +++ b/tests/ui/async-await/issues/issue-61187.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `data` as mutable, as it is not declared as mutable --> $DIR/issue-61187.rs:6:5 | LL | data.reverse(); - | ^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs index ade386a60..725caddae 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs @@ -2,7 +2,8 @@ // be talking about `async fn`s instead. // run-fail -// error-pattern: thread 'main' panicked at '`async fn` resumed after completion' +// error-pattern: thread 'main' panicked +// error-pattern: `async fn` resumed after completion // edition:2018 // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs index b4ea4c9f6..5909c3a5e 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs @@ -3,7 +3,8 @@ // run-fail // needs-unwind -// error-pattern: thread 'main' panicked at '`async fn` resumed after panicking' +// error-pattern: thread 'main' panicked +// error-pattern: `async fn` resumed after panicking // edition:2018 // ignore-wasm no panic or subprocess support diff --git a/tests/ui/async-await/normalize-output-in-signature-deduction.rs b/tests/ui/async-await/normalize-output-in-signature-deduction.rs new file mode 100644 index 000000000..960065a83 --- /dev/null +++ b/tests/ui/async-await/normalize-output-in-signature-deduction.rs @@ -0,0 +1,19 @@ +// edition:2021 +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(type_alias_impl_trait)] + +struct Foo; + +impl Trait for Foo {} +pub trait Trait {} + +pub type TAIT = impl Trait; + +async fn foo() -> TAIT { + Foo +} + +fn main() {} diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.rs b/tests/ui/async-await/return-type-notation/issue-110963-early.rs index eee31aa1f..0ecbca5c1 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.rs @@ -1,7 +1,5 @@ // edition: 2021 // known-bug: #110963 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_type_notation)] #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr new file mode 100644 index 000000000..33e22dec3 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr @@ -0,0 +1,37 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-110963-early.rs:4:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: higher-ranked lifetime error + --> $DIR/issue-110963-early.rs:15:5 + | +LL | / spawn(async move { +LL | | let mut hc = hc; +LL | | if !hc.check().await { +LL | | log_health_check_failure().await; +LL | | } +LL | | }); + | |______^ + | + = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` + +error: higher-ranked lifetime error + --> $DIR/issue-110963-early.rs:15:5 + | +LL | / spawn(async move { +LL | | let mut hc = hc; +LL | | if !hc.check().await { +LL | | log_health_check_failure().await; +LL | | } +LL | | }); + | |______^ + | + = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs index ea047cd3b..17b5d775d 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-late.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.rs @@ -1,7 +1,5 @@ // edition: 2021 // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.stderr b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr new file mode 100644 index 000000000..9c6966537 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-110963-late.rs:4:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.rs b/tests/ui/async-await/return-type-notation/super-method-bound.rs index 0163c62f5..58ea3578d 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound.rs +++ b/tests/ui/async-await/return-type-notation/super-method-bound.rs @@ -1,7 +1,5 @@ // edition:2021 // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait, return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.stderr new file mode 100644 index 000000000..ac0668d3c --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/super-method-bound.rs:4:31 + | +LL | #![feature(async_fn_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.rs b/tests/ui/async-await/return-type-notation/supertrait-bound.rs index 09de32c5d..19bcfe304 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.rs +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait, return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete and may not be safe to use diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr new file mode 100644 index 000000000..c8cec4946 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/supertrait-bound.rs:3:49 + | +LL | #![feature(return_position_impl_trait_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs index 3141da1d2..7871a2fed 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs @@ -1,6 +1,4 @@ // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait, return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr new file mode 100644 index 000000000..76928c5d7 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr @@ -0,0 +1,29 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/ty-or-ct-params.rs:3:31 + | +LL | #![feature(async_fn_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: return type notation is not allowed for functions that have type parameters + --> $DIR/ty-or-ct-params.rs:14:12 + | +LL | async fn bar() {} + | - type parameter declared here +... +LL | T: Foo, + | ^^^^^^^^^^^ + +error: return type notation is not allowed for functions that have const parameters + --> $DIR/ty-or-ct-params.rs:14:25 + | +LL | async fn baz() {} + | -------------- const parameter declared here +... +LL | T: Foo, + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/tests/ui/async-await/track-caller/async-block.afn.stderr b/tests/ui/async-await/track-caller/async-block.afn.stderr new file mode 100644 index 000000000..2302722ee --- /dev/null +++ b/tests/ui/async-await/track-caller/async-block.afn.stderr @@ -0,0 +1,30 @@ +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-block.rs:8:13 + | +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-block.rs:15:13 + | +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-block.rs:23:17 + | +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-block.nofeat.stderr b/tests/ui/async-await/track-caller/async-block.nofeat.stderr new file mode 100644 index 000000000..2302722ee --- /dev/null +++ b/tests/ui/async-await/track-caller/async-block.nofeat.stderr @@ -0,0 +1,30 @@ +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-block.rs:8:13 + | +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-block.rs:15:13 + | +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-block.rs:23:17 + | +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-block.rs b/tests/ui/async-await/track-caller/async-block.rs index 8ddd4ab11..24711b966 100644 --- a/tests/ui/async-await/track-caller/async-block.rs +++ b/tests/ui/async-await/track-caller/async-block.rs @@ -1,9 +1,27 @@ // edition:2021 +// revisions: afn nofeat #![feature(stmt_expr_attributes)] +#![cfg_attr(afn, feature(async_fn_track_caller))] fn main() { let _ = #[track_caller] async { //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] }; } + +#[track_caller] +async fn foo() { + let _ = #[track_caller] async { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; +} + +#[track_caller] +async fn foo2() { + let _ = async { + let _ = #[track_caller] async { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; + }; +} diff --git a/tests/ui/async-await/track-caller/async-block.stderr b/tests/ui/async-await/track-caller/async-block.stderr deleted file mode 100644 index 21d1054d2..000000000 --- a/tests/ui/async-await/track-caller/async-block.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:6:13 - | -LL | let _ = #[track_caller] async { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr new file mode 100644 index 000000000..739c04a76 --- /dev/null +++ b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr @@ -0,0 +1,57 @@ +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:8:13 + | +LL | let _ = #[track_caller] async || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:15:13 + | +LL | let _ = #[track_caller] async || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:21:13 + | +LL | let _ = #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:28:17 + | +LL | let _ = #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:36:9 + | +LL | #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:45:13 + | +LL | #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr new file mode 100644 index 000000000..739c04a76 --- /dev/null +++ b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr @@ -0,0 +1,57 @@ +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:8:13 + | +LL | let _ = #[track_caller] async || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:15:13 + | +LL | let _ = #[track_caller] async || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:21:13 + | +LL | let _ = #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:28:17 + | +LL | let _ = #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:36:9 + | +LL | #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/async-closure-gate.rs:45:13 + | +LL | #[track_caller] || { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-closure-gate.rs b/tests/ui/async-await/track-caller/async-closure-gate.rs index d9d556855..8d8d081aa 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.rs +++ b/tests/ui/async-await/track-caller/async-closure-gate.rs @@ -1,9 +1,50 @@ // edition:2021 +// revisions: afn nofeat #![feature(async_closure, stmt_expr_attributes)] +#![cfg_attr(afn, feature(async_fn_track_caller))] fn main() { let _ = #[track_caller] async || { //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] }; } + +#[track_caller] +async fn foo() { + let _ = #[track_caller] async || { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; +} + +async fn foo2() { + let _ = #[track_caller] || { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; +} + +fn foo3() { + async { + let _ = #[track_caller] || { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; + } +} + +async fn foo4() { + let _ = || { + #[track_caller] || { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; + }; +} + +fn foo5() { + async { + let _ = || { + #[track_caller] || { + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + }; + }; + } +} diff --git a/tests/ui/async-await/track-caller/async-closure-gate.stderr b/tests/ui/async-await/track-caller/async-closure-gate.stderr deleted file mode 100644 index 498f1b43b..000000000 --- a/tests/ui/async-await/track-caller/async-closure-gate.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:6:13 - | -LL | let _ = #[track_caller] async || { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/panic-track-caller.cls.stderr b/tests/ui/async-await/track-caller/panic-track-caller.cls.stderr new file mode 100644 index 000000000..f3090e3b9 --- /dev/null +++ b/tests/ui/async-await/track-caller/panic-track-caller.cls.stderr @@ -0,0 +1,31 @@ +warning: `#[track_caller]` on async functions is a no-op + --> $DIR/panic-track-caller.rs:53:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +... +LL | / async fn bar_track_caller() { +LL | | panic!() +LL | | } + | |_- this function will not propagate the caller location + | + = note: see issue #110011 for more information + = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable + = note: `#[warn(ungated_async_fn_track_caller)]` on by default + +warning: `#[track_caller]` on async functions is a no-op + --> $DIR/panic-track-caller.rs:67:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +... +LL | / async fn bar_assoc() { +LL | | panic!(); +LL | | } + | |_____- this function will not propagate the caller location + | + = note: see issue #110011 for more information + = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable + +warning: 2 warnings emitted + diff --git a/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr b/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr index 51ea225f4..f3090e3b9 100644 --- a/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr +++ b/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr @@ -1,29 +1,31 @@ warning: `#[track_caller]` on async functions is a no-op - --> $DIR/panic-track-caller.rs:50:1 + --> $DIR/panic-track-caller.rs:53:1 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ +... LL | / async fn bar_track_caller() { LL | | panic!() LL | | } | |_- this function will not propagate the caller location | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + = note: see issue #110011 for more information + = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable = note: `#[warn(ungated_async_fn_track_caller)]` on by default warning: `#[track_caller]` on async functions is a no-op - --> $DIR/panic-track-caller.rs:62:5 + --> $DIR/panic-track-caller.rs:67:5 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ +... LL | / async fn bar_assoc() { LL | | panic!(); LL | | } | |_____- this function will not propagate the caller location | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + = note: see issue #110011 for more information + = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable warning: 2 warnings emitted diff --git a/tests/ui/async-await/track-caller/panic-track-caller.rs b/tests/ui/async-await/track-caller/panic-track-caller.rs index 65bb23e0b..df8290e5f 100644 --- a/tests/ui/async-await/track-caller/panic-track-caller.rs +++ b/tests/ui/async-await/track-caller/panic-track-caller.rs @@ -1,9 +1,12 @@ // run-pass // edition:2021 -// revisions: feat nofeat +// revisions: afn cls nofeat // needs-unwind +// gate-test-async_fn_track_caller #![feature(async_closure, stmt_expr_attributes)] -#![cfg_attr(feat, feature(closure_track_caller))] +#![cfg_attr(afn, feature(async_fn_track_caller))] +#![cfg_attr(cls, feature(closure_track_caller))] +#![allow(unused)] use std::future::Future; use std::panic; @@ -47,7 +50,9 @@ async fn foo() { bar().await } -#[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op +#[track_caller] +//[cls]~^ WARN `#[track_caller]` on async functions is a no-op +//[nofeat]~^^ WARN `#[track_caller]` on async functions is a no-op async fn bar_track_caller() { panic!() } @@ -59,7 +64,9 @@ async fn foo_track_caller() { struct Foo; impl Foo { - #[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op + #[track_caller] + //[cls]~^ WARN `#[track_caller]` on async functions is a no-op + //[nofeat]~^^ WARN `#[track_caller]` on async functions is a no-op async fn bar_assoc() { panic!(); } @@ -71,7 +78,7 @@ async fn foo_assoc() { // Since compilation is expected to fail for this fn when using // `nofeat`, we test that separately in `async-closure-gate.rs` -#[cfg(feat)] +#[cfg(cls)] async fn foo_closure() { let c = #[track_caller] async || { panic!(); @@ -81,7 +88,7 @@ async fn foo_closure() { // Since compilation is expected to fail for this fn when using // `nofeat`, we test that separately in `async-block.rs` -#[cfg(feat)] +#[cfg(cls)] async fn foo_block() { let a = #[track_caller] async { panic!(); @@ -106,21 +113,22 @@ fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 { } fn main() { - assert_eq!(panicked_at(|| block_on(foo())), 43); + assert_eq!(panicked_at(|| block_on(foo())), 46 +); - #[cfg(feat)] - assert_eq!(panicked_at(|| block_on(foo_track_caller())), 56); - #[cfg(nofeat)] - assert_eq!(panicked_at(|| block_on(foo_track_caller())), 52); + #[cfg(afn)] + assert_eq!(panicked_at(|| block_on(foo_track_caller())), 61); + #[cfg(any(cls, nofeat))] + assert_eq!(panicked_at(|| block_on(foo_track_caller())), 57); - #[cfg(feat)] - assert_eq!(panicked_at(|| block_on(foo_assoc())), 69); - #[cfg(nofeat)] - assert_eq!(panicked_at(|| block_on(foo_assoc())), 64); + #[cfg(afn)] + assert_eq!(panicked_at(|| block_on(foo_assoc())), 76); + #[cfg(any(cls, nofeat))] + assert_eq!(panicked_at(|| block_on(foo_assoc())), 71); - #[cfg(feat)] - assert_eq!(panicked_at(|| block_on(foo_closure())), 79); + #[cfg(cls)] + assert_eq!(panicked_at(|| block_on(foo_closure())), 84); - #[cfg(feat)] - assert_eq!(panicked_at(|| block_on(foo_block())), 89); + #[cfg(cls)] + assert_eq!(panicked_at(|| block_on(foo_block())), 96); } diff --git a/tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs b/tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs new file mode 100644 index 000000000..2fb2d3ad4 --- /dev/null +++ b/tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs @@ -0,0 +1,11 @@ +#![feature(rustc_attrs)] + +pub struct BTreeSet; + +impl BTreeSet { + #[rustc_confusables("push", "test_b")] + pub fn insert(&self) {} + + #[rustc_confusables("pulled")] + pub fn pull(&self) {} +} diff --git a/tests/ui/attributes/invalid-doc-attr.rs b/tests/ui/attributes/invalid-doc-attr.rs deleted file mode 100644 index c231e43b3..000000000 --- a/tests/ui/attributes/invalid-doc-attr.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![crate_type = "lib"] -#![deny(warnings)] - -#[doc(test(no_crate_inject))] -//~^ ERROR can only be applied at the crate level -//~| WARN is being phased out -//~| HELP to apply to the crate, use an inner attribute -//~| SUGGESTION ! -#[doc(inline)] -//~^ ERROR can only be applied to a `use` item -//~| WARN is being phased out -pub fn foo() {} - -pub mod bar { - #![doc(test(no_crate_inject))] - //~^ ERROR can only be applied at the crate level - //~| WARN is being phased out - - #[doc(test(no_crate_inject))] - //~^ ERROR can only be applied at the crate level - //~| WARN is being phased out - #[doc(inline)] - //~^ ERROR can only be applied to a `use` item - //~| WARN is being phased out - pub fn baz() {} -} - -#[doc(inline)] -#[doc(no_inline)] -//~^^ ERROR conflicting doc inlining attributes -//~| HELP remove one of the conflicting attributes -pub use bar::baz; diff --git a/tests/ui/attributes/invalid-doc-attr.stderr b/tests/ui/attributes/invalid-doc-attr.stderr deleted file mode 100644 index b23b8ded8..000000000 --- a/tests/ui/attributes/invalid-doc-attr.stderr +++ /dev/null @@ -1,78 +0,0 @@ -error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:4:7 - | -LL | #[doc(test(no_crate_inject))] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 - = note: read for more information -note: the lint level is defined here - --> $DIR/invalid-doc-attr.rs:2:9 - | -LL | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` -help: to apply to the crate, use an inner attribute - | -LL | #![doc(test(no_crate_inject))] - | + - -error: this attribute can only be applied to a `use` item - --> $DIR/invalid-doc-attr.rs:9:7 - | -LL | #[doc(inline)] - | ^^^^^^ only applicable on `use` items -... -LL | pub fn foo() {} - | ------------ not a `use` item - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 - = note: read for more information - -error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:15:12 - | -LL | #![doc(test(no_crate_inject))] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 - = note: read for more information - -error: conflicting doc inlining attributes - --> $DIR/invalid-doc-attr.rs:28:7 - | -LL | #[doc(inline)] - | ^^^^^^ this attribute... -LL | #[doc(no_inline)] - | ^^^^^^^^^ ...conflicts with this attribute - | - = help: remove one of the conflicting attributes - -error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:19:11 - | -LL | #[doc(test(no_crate_inject))] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 - = note: read for more information - -error: this attribute can only be applied to a `use` item - --> $DIR/invalid-doc-attr.rs:22:11 - | -LL | #[doc(inline)] - | ^^^^^^ only applicable on `use` items -... -LL | pub fn baz() {} - | ------------ not a `use` item - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 - = note: read for more information - -error: aborting due to 6 previous errors - diff --git a/tests/ui/attributes/macro_export_on_decl_macro.rs b/tests/ui/attributes/macro_export_on_decl_macro.rs new file mode 100644 index 000000000..e6fe66ac6 --- /dev/null +++ b/tests/ui/attributes/macro_export_on_decl_macro.rs @@ -0,0 +1,9 @@ +// Using #[macro_export] on a decl macro has no effect and should warn + +#![feature(decl_macro)] +#![deny(unused)] + +#[macro_export] //~ ERROR `#[macro_export]` has no effect on declarative macro definitions +pub macro foo() {} + +fn main() {} diff --git a/tests/ui/attributes/macro_export_on_decl_macro.stderr b/tests/ui/attributes/macro_export_on_decl_macro.stderr new file mode 100644 index 000000000..565e07919 --- /dev/null +++ b/tests/ui/attributes/macro_export_on_decl_macro.stderr @@ -0,0 +1,16 @@ +error: `#[macro_export]` has no effect on declarative macro definitions + --> $DIR/macro_export_on_decl_macro.rs:6:1 + | +LL | #[macro_export] + | ^^^^^^^^^^^^^^^ + | + = note: declarative macros follow the same exporting rules as regular items +note: the lint level is defined here + --> $DIR/macro_export_on_decl_macro.rs:4:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` + +error: aborting due to previous error + diff --git a/tests/ui/attributes/rustc_confusables.rs b/tests/ui/attributes/rustc_confusables.rs new file mode 100644 index 000000000..352e91d06 --- /dev/null +++ b/tests/ui/attributes/rustc_confusables.rs @@ -0,0 +1,47 @@ +// aux-build: rustc_confusables_across_crate.rs + +#![feature(rustc_attrs)] + +extern crate rustc_confusables_across_crate; + +use rustc_confusables_across_crate::BTreeSet; + +fn main() { + // Misspellings (similarly named methods) take precedence over `rustc_confusables`. + let x = BTreeSet {}; + x.inser(); + //~^ ERROR no method named + //~| HELP there is a method with a similar name + x.foo(); + //~^ ERROR no method named + x.push(); + //~^ ERROR no method named + //~| HELP you might have meant to use `insert` + x.test(); + //~^ ERROR no method named + x.pulled(); + //~^ ERROR no method named + //~| HELP there is a method with a similar name +} + +struct Bar; + +impl Bar { + #[rustc_confusables()] + //~^ ERROR expected at least one confusable name + fn baz() {} + + #[rustc_confusables] + //~^ ERROR malformed `rustc_confusables` attribute input + //~| HELP must be of the form + fn qux() {} + + #[rustc_confusables(invalid_meta_item)] + //~^ ERROR expected a quoted string literal + //~| HELP consider surrounding this with quotes + fn quux() {} +} + +#[rustc_confusables("blah")] +//~^ ERROR attribute should be applied to an inherent method +fn not_inherent_impl_method() {} diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr new file mode 100644 index 000000000..9fd4470cd --- /dev/null +++ b/tests/ui/attributes/rustc_confusables.stderr @@ -0,0 +1,68 @@ +error: malformed `rustc_confusables` attribute input + --> $DIR/rustc_confusables.rs:34:5 + | +LL | #[rustc_confusables] + | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` + +error: attribute should be applied to an inherent method + --> $DIR/rustc_confusables.rs:45:1 + | +LL | #[rustc_confusables("blah")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: expected at least one confusable name + --> $DIR/rustc_confusables.rs:30:5 + | +LL | #[rustc_confusables()] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0539]: expected a quoted string literal + --> $DIR/rustc_confusables.rs:39:25 + | +LL | #[rustc_confusables(invalid_meta_item)] + | ^^^^^^^^^^^^^^^^^ + | +help: consider surrounding this with quotes + | +LL | #[rustc_confusables("invalid_meta_item")] + | + + + +error[E0599]: no method named `inser` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:12:7 + | +LL | x.inser(); + | ^^^^^ help: there is a method with a similar name: `insert` + +error[E0599]: no method named `foo` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:15:7 + | +LL | x.foo(); + | ^^^ method not found in `BTreeSet` + +error[E0599]: no method named `push` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:17:7 + | +LL | x.push(); + | ^^^^ method not found in `BTreeSet` + | +help: you might have meant to use `insert` + | +LL | x.insert(); + | ~~~~~~ + +error[E0599]: no method named `test` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:20:7 + | +LL | x.test(); + | ^^^^ method not found in `BTreeSet` + +error[E0599]: no method named `pulled` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:22:7 + | +LL | x.pulled(); + | ^^^^^^ help: there is a method with a similar name: `pull` + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0539, E0599. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/auto-traits/issue-83857-ub.rs b/tests/ui/auto-traits/issue-83857-ub.rs new file mode 100644 index 000000000..626e60c37 --- /dev/null +++ b/tests/ui/auto-traits/issue-83857-ub.rs @@ -0,0 +1,33 @@ +#![allow(suspicious_auto_trait_impls)] +// Tests that we don't incorrectly allow overlap between a builtin auto trait +// impl and a user written one. See #83857 for more details + +struct Always(T, U); +unsafe impl Send for Always {} +struct Foo(Always); + +trait False {} +unsafe impl Send for Foo {} + +trait WithAssoc { + type Output; +} +impl WithAssoc for T { + type Output = Self; +} +impl WithAssoc for Foo { + type Output = Box; +} + +fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) { + //~^ ERROR `Foo` cannot be sent between threads safely + f(foo(v)); +} + +fn foo(x: T) -> ::Output { + x +} + +fn main() { + generic(Foo(Always(0, ())), |b| *b); +} diff --git a/tests/ui/auto-traits/issue-83857-ub.stderr b/tests/ui/auto-traits/issue-83857-ub.stderr new file mode 100644 index 000000000..23a2f62d9 --- /dev/null +++ b/tests/ui/auto-traits/issue-83857-ub.stderr @@ -0,0 +1,22 @@ +error[E0277]: `Foo` cannot be sent between threads safely + --> $DIR/issue-83857-ub.rs:22:38 + | +LL | fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be sent between threads safely + | + = help: the trait `Send` is not implemented for `Foo` +note: required for `Foo` to implement `WithAssoc` + --> $DIR/issue-83857-ub.rs:15:15 + | +LL | impl WithAssoc for T { + | ---- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) where Foo: Send { + | +++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/binop/binop-move-semantics.stderr b/tests/ui/binop/binop-move-semantics.stderr index 8645169b9..1dd8c9a87 100644 --- a/tests/ui/binop/binop-move-semantics.stderr +++ b/tests/ui/binop/binop-move-semantics.stderr @@ -27,7 +27,7 @@ LL | x | - value moved here LL | + LL | x.clone(); - | ^^^^^^^^^ value borrowed here after move + | ^ value borrowed here after move | help: consider cloning the value if the performance cost is acceptable | diff --git a/tests/ui/binop/borrow-suggestion-109352-2.rs b/tests/ui/binop/borrow-suggestion-109352-2.rs new file mode 100644 index 000000000..43dab9529 --- /dev/null +++ b/tests/ui/binop/borrow-suggestion-109352-2.rs @@ -0,0 +1,27 @@ +struct Bar; + +impl std::ops::Mul for &mut Bar { + type Output = Bar; + + fn mul(self, _rhs: Self) -> Self::Output { + unimplemented!() + } +} + +fn main() { + let ref_mut_bar: &mut Bar = &mut Bar; + let ref_bar: &Bar = &Bar; + let owned_bar: Bar = Bar; + + let _ = ref_mut_bar * ref_mut_bar; + + // FIXME: we should be able to suggest borrowing both side + let _ = owned_bar * owned_bar; + //~^ ERROR cannot multiply + let _ = ref_bar * ref_bar; + //~^ ERROR cannot multiply + let _ = ref_bar * ref_mut_bar; + //~^ ERROR cannot multiply + let _ = ref_mut_bar * ref_bar; + //~^ ERROR mismatched types +} diff --git a/tests/ui/binop/borrow-suggestion-109352-2.stderr b/tests/ui/binop/borrow-suggestion-109352-2.stderr new file mode 100644 index 000000000..18ed08d73 --- /dev/null +++ b/tests/ui/binop/borrow-suggestion-109352-2.stderr @@ -0,0 +1,64 @@ +error[E0369]: cannot multiply `Bar` by `Bar` + --> $DIR/borrow-suggestion-109352-2.rs:19:23 + | +LL | let _ = owned_bar * owned_bar; + | --------- ^ --------- Bar + | | + | Bar + | +note: an implementation of `Mul` might be missing for `Bar` + --> $DIR/borrow-suggestion-109352-2.rs:1:1 + | +LL | struct Bar; + | ^^^^^^^^^^ must implement `Mul` +note: the trait `Mul` must be implemented + --> $SRC_DIR/core/src/ops/arith.rs:LL:COL + +error[E0369]: cannot multiply `&Bar` by `&Bar` + --> $DIR/borrow-suggestion-109352-2.rs:21:21 + | +LL | let _ = ref_bar * ref_bar; + | ------- ^ ------- &Bar + | | + | &Bar + | + = note: an implementation for `&mut Bar * &mut Bar` exists +help: consider making this expression a mutable borrow + --> $DIR/borrow-suggestion-109352-2.rs:21:13 + | +LL | let _ = ref_bar * ref_bar; + | ^^^^^^^ +help: consider making this expression a mutable borrow + --> $DIR/borrow-suggestion-109352-2.rs:21:23 + | +LL | let _ = ref_bar * ref_bar; + | ^^^^^^^ + +error[E0369]: cannot multiply `&Bar` by `&mut Bar` + --> $DIR/borrow-suggestion-109352-2.rs:23:21 + | +LL | let _ = ref_bar * ref_mut_bar; + | ------- ^ ----------- &mut Bar + | | + | &Bar + | + = note: an implementation for `&mut Bar * &mut Bar` exists +help: consider making this expression a mutable borrow + --> $DIR/borrow-suggestion-109352-2.rs:23:13 + | +LL | let _ = ref_bar * ref_mut_bar; + | ^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/borrow-suggestion-109352-2.rs:25:27 + | +LL | let _ = ref_mut_bar * ref_bar; + | ^^^^^^^ types differ in mutability + | + = note: expected mutable reference `&mut Bar` + found reference `&Bar` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0308, E0369. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/binop/borrow-suggestion-109352.fixed b/tests/ui/binop/borrow-suggestion-109352.fixed new file mode 100644 index 000000000..3374a9d78 --- /dev/null +++ b/tests/ui/binop/borrow-suggestion-109352.fixed @@ -0,0 +1,27 @@ +// run-rustfix + +struct Foo; + +impl std::ops::Mul for &Foo { + type Output = Foo; + + fn mul(self, _rhs: Self) -> Self::Output { + unimplemented!() + } +} + +fn main() { + let ref_mut_foo: &mut Foo = &mut Foo; + let ref_foo: &Foo = &Foo; + let owned_foo: Foo = Foo; + + let _ = ref_foo * ref_foo; + let _ = ref_foo * ref_mut_foo; + + let _ = &*ref_mut_foo * ref_foo; + //~^ ERROR cannot multiply + let _ = &*ref_mut_foo * &*ref_mut_foo; + //~^ ERROR cannot multiply + let _ = &*ref_mut_foo * &owned_foo; + //~^ ERROR cannot multiply +} diff --git a/tests/ui/binop/borrow-suggestion-109352.rs b/tests/ui/binop/borrow-suggestion-109352.rs new file mode 100644 index 000000000..4e8510e0d --- /dev/null +++ b/tests/ui/binop/borrow-suggestion-109352.rs @@ -0,0 +1,27 @@ +// run-rustfix + +struct Foo; + +impl std::ops::Mul for &Foo { + type Output = Foo; + + fn mul(self, _rhs: Self) -> Self::Output { + unimplemented!() + } +} + +fn main() { + let ref_mut_foo: &mut Foo = &mut Foo; + let ref_foo: &Foo = &Foo; + let owned_foo: Foo = Foo; + + let _ = ref_foo * ref_foo; + let _ = ref_foo * ref_mut_foo; + + let _ = ref_mut_foo * ref_foo; + //~^ ERROR cannot multiply + let _ = ref_mut_foo * ref_mut_foo; + //~^ ERROR cannot multiply + let _ = ref_mut_foo * &owned_foo; + //~^ ERROR cannot multiply +} diff --git a/tests/ui/binop/borrow-suggestion-109352.stderr b/tests/ui/binop/borrow-suggestion-109352.stderr new file mode 100644 index 000000000..71e44f54b --- /dev/null +++ b/tests/ui/binop/borrow-suggestion-109352.stderr @@ -0,0 +1,45 @@ +error[E0369]: cannot multiply `&mut Foo` by `&Foo` + --> $DIR/borrow-suggestion-109352.rs:21:25 + | +LL | let _ = ref_mut_foo * ref_foo; + | ----------- ^ ------- &Foo + | | + | &mut Foo + | + = note: an implementation for `&Foo * &Foo` exists +help: consider reborrowing this side + | +LL | let _ = &*ref_mut_foo * ref_foo; + | ++ + +error[E0369]: cannot multiply `&mut Foo` by `&mut Foo` + --> $DIR/borrow-suggestion-109352.rs:23:25 + | +LL | let _ = ref_mut_foo * ref_mut_foo; + | ----------- ^ ----------- &mut Foo + | | + | &mut Foo + | + = note: an implementation for `&Foo * &Foo` exists +help: consider reborrowing both sides + | +LL | let _ = &*ref_mut_foo * &*ref_mut_foo; + | ++ ++ + +error[E0369]: cannot multiply `&mut Foo` by `&Foo` + --> $DIR/borrow-suggestion-109352.rs:25:25 + | +LL | let _ = ref_mut_foo * &owned_foo; + | ----------- ^ ---------- &Foo + | | + | &mut Foo + | + = note: an implementation for `&Foo * &Foo` exists +help: consider reborrowing this side + | +LL | let _ = &*ref_mut_foo * &owned_foo; + | ++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/borrowck/borrow-tuple-fields.stderr b/tests/ui/borrowck/borrow-tuple-fields.stderr index d7d3efe49..e324ebfb5 100644 --- a/tests/ui/borrowck/borrow-tuple-fields.stderr +++ b/tests/ui/borrowck/borrow-tuple-fields.stderr @@ -9,7 +9,7 @@ LL | let y = x; | ^ move out of `x` occurs here LL | LL | r.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable --> $DIR/borrow-tuple-fields.rs:18:13 @@ -19,7 +19,7 @@ LL | let a = &x.0; LL | let b = &mut x.0; | ^^^^^^^^ mutable borrow occurs here LL | a.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time --> $DIR/borrow-tuple-fields.rs:23:13 @@ -29,7 +29,7 @@ LL | let a = &mut x.0; LL | let b = &mut x.0; | ^^^^^^^^ second mutable borrow occurs here LL | a.use_ref(); - | ----------- first borrow later used here + | - first borrow later used here error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrow-tuple-fields.rs:28:13 @@ -41,7 +41,7 @@ LL | let r = &x.0; LL | let y = x; | ^ move out of `x` occurs here LL | r.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable --> $DIR/borrow-tuple-fields.rs:33:13 @@ -51,7 +51,7 @@ LL | let a = &x.0; LL | let b = &mut x.0; | ^^^^^^^^ mutable borrow occurs here LL | a.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time --> $DIR/borrow-tuple-fields.rs:38:13 @@ -61,7 +61,7 @@ LL | let a = &mut x.0; LL | let b = &mut x.0; | ^^^^^^^^ second mutable borrow occurs here LL | a.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to 6 previous errors diff --git a/tests/ui/borrowck/borrowck-argument.stderr b/tests/ui/borrowck/borrowck-argument.stderr index 1c992dfcc..8ad5623c8 100644 --- a/tests/ui/borrowck/borrowck-argument.stderr +++ b/tests/ui/borrowck/borrowck-argument.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:10:5 | LL | arg.mutate(); - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:15:9 | LL | arg.mutate(); - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -24,7 +24,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:21:9 | LL | arg.mutate(); - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -35,7 +35,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:32:17 | LL | (|arg: S| { arg.mutate() })(s); - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr b/tests/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr index 19ef0301a..25d642c30 100644 --- a/tests/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr +++ b/tests/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5 | LL | x.printme(); - | ^^^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr b/tests/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr index 3c28ff56e..a61fdbf6c 100644 --- a/tests/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr +++ b/tests/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5 | LL | a.foo(); - | ^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/borrowck/borrowck-borrow-mut-object-twice.stderr b/tests/ui/borrowck/borrowck-borrow-mut-object-twice.stderr index 42b6c34cd..fa0ae318e 100644 --- a/tests/ui/borrowck/borrowck-borrow-mut-object-twice.stderr +++ b/tests/ui/borrowck/borrowck-borrow-mut-object-twice.stderr @@ -2,11 +2,11 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-mut-object-twice.rs:13:5 | LL | let y = x.f1(); - | ------ first mutable borrow occurs here + | - first mutable borrow occurs here LL | x.f2(); - | ^^^^^^ second mutable borrow occurs here + | ^ second mutable borrow occurs here LL | y.use_ref(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr b/tests/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr index fdf6568d8..426d5bc47 100644 --- a/tests/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr +++ b/tests/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr @@ -58,7 +58,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:72:5 | LL | x.set(0, 0); - | ^^^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` @@ -66,7 +66,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:76:5 | LL | x.set(0, 0); - | ^^^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` @@ -74,7 +74,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:84:5 | LL | x.y_mut() - | ^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` @@ -82,7 +82,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:88:5 | LL | x.y_mut() - | ^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` @@ -90,7 +90,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:92:6 | LL | *x.y_mut() = 3; - | ^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` @@ -98,7 +98,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:96:6 | LL | *x.y_mut() = 3; - | ^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` @@ -106,7 +106,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:100:6 | LL | *x.y_mut() = 3; - | ^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc` diff --git a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr index 4eeec09b9..6e112e270 100644 --- a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr +++ b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr @@ -8,8 +8,12 @@ LL | let x = defer(&vec!["Goodbye", "world!"]); LL | x.x[0]; | ------ borrow later used here | - = note: consider using a `let` binding to create a longer lived value = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = vec!["Goodbye", "world!"]; +LL ~ let x = defer(&binding); + | error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr index c62d5f903..7ee840b34 100644 --- a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr +++ b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr @@ -7,7 +7,7 @@ LL | buggy_map.insert(42, &*Box::new(1)); | creates a temporary value which is freed while still in use ... LL | buggy_map.insert(43, &*tmp); - | --------------------------- borrow later used here + | --------- borrow later used here | help: consider using a `let` binding to create a longer lived value | diff --git a/tests/ui/borrowck/borrowck-closures-unique-imm.stderr b/tests/ui/borrowck/borrowck-closures-unique-imm.stderr index 0c5fd39b7..b8bbb31a3 100644 --- a/tests/ui/borrowck/borrowck-closures-unique-imm.stderr +++ b/tests/ui/borrowck/borrowck-closures-unique-imm.stderr @@ -6,7 +6,7 @@ LL | let p = &this.x; LL | &mut this.x; | ^^^^^^^^^^^ mutable borrow occurs here LL | p.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-describe-lvalue.stderr b/tests/ui/borrowck/borrowck-describe-lvalue.stderr index cb29c9fda..11f2e42d4 100644 --- a/tests/ui/borrowck/borrowck-describe-lvalue.stderr +++ b/tests/ui/borrowck/borrowck-describe-lvalue.stderr @@ -45,7 +45,7 @@ error[E0503]: cannot use `f.x` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:37:9 | LL | let x = f.x(); - | ----- `f` is borrowed here + | - `f` is borrowed here LL | f.x; | ^^^ use of borrowed `f` LL | drop(x); @@ -55,7 +55,7 @@ error[E0503]: cannot use `g.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:44:9 | LL | let x = g.x(); - | ----- `g` is borrowed here + | - `g` is borrowed here LL | g.0; | ^^^ use of borrowed `g` LL | drop(x); @@ -75,7 +75,7 @@ error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:59:20 | LL | let x = e.x(); - | ----- `e` is borrowed here + | - `e` is borrowed here LL | match e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `e` @@ -97,7 +97,7 @@ error[E0503]: cannot use `f.x` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:74:9 | LL | let x = f.x(); - | ----- `*f` is borrowed here + | - `*f` is borrowed here LL | f.x; | ^^^ use of borrowed `*f` LL | drop(x); @@ -107,7 +107,7 @@ error[E0503]: cannot use `g.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:81:9 | LL | let x = g.x(); - | ----- `*g` is borrowed here + | - `*g` is borrowed here LL | g.0; | ^^^ use of borrowed `*g` LL | drop(x); @@ -127,7 +127,7 @@ error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:96:20 | LL | let x = e.x(); - | ----- `*e` is borrowed here + | - `*e` is borrowed here LL | match *e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `*e` diff --git a/tests/ui/borrowck/borrowck-insert-during-each.stderr b/tests/ui/borrowck/borrowck-insert-during-each.stderr index 99d08e905..a1ac45795 100644 --- a/tests/ui/borrowck/borrowck-insert-during-each.stderr +++ b/tests/ui/borrowck/borrowck-insert-during-each.stderr @@ -16,17 +16,15 @@ LL | | }) error[E0500]: closure requires unique access to `f` but it is already borrowed --> $DIR/borrowck-insert-during-each.rs:18:9 | -LL | f.foo( - | - --- first borrow later used by call - | _____| - | | -LL | | -LL | | |a| { - | | ^^^ closure construction occurs here -LL | | f.n.insert(*a); - | | --- second borrow occurs due to use of `f` in closure -LL | | }) - | |__________- borrow occurs here +LL | f.foo( + | - --- first borrow later used by call + | | + | borrow occurs here +LL | +LL | |a| { + | ^^^ closure construction occurs here +LL | f.n.insert(*a); + | --- second borrow occurs due to use of `f` in closure error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-issue-2657-1.stderr b/tests/ui/borrowck/borrowck-issue-2657-1.stderr index 390bb9384..4ea4eb8f0 100644 --- a/tests/ui/borrowck/borrowck-issue-2657-1.stderr +++ b/tests/ui/borrowck/borrowck-issue-2657-1.stderr @@ -6,7 +6,7 @@ LL | Some(ref _y) => { LL | let _a = x; | ^ move out of `x` occurs here LL | _y.use_ref(); - | ------------ borrow later used here + | -- borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-lend-flow-if.stderr b/tests/ui/borrowck/borrowck-lend-flow-if.stderr index e47efc0e0..68a82bdb5 100644 --- a/tests/ui/borrowck/borrowck-lend-flow-if.stderr +++ b/tests/ui/borrowck/borrowck-lend-flow-if.stderr @@ -7,7 +7,7 @@ LL | } LL | borrow_mut(&mut *v); | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); - | ------------ immutable borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-lend-flow.stderr b/tests/ui/borrowck/borrowck-lend-flow.stderr index 40c14f54c..07b11b3e7 100644 --- a/tests/ui/borrowck/borrowck-lend-flow.stderr +++ b/tests/ui/borrowck/borrowck-lend-flow.stderr @@ -6,7 +6,7 @@ LL | let _w = &v; LL | borrow_mut(&mut *v); | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); - | ------------ immutable borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr index 6eabfff90..86479043a 100644 --- a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr +++ b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr @@ -12,7 +12,7 @@ LL | println!("v={}", *v); | -- move occurs due to use in closure LL | }); LL | w.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 @@ -28,7 +28,7 @@ LL | println!("v={}", *v); | -- move occurs due to use in closure LL | }); LL | w.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr index 38e06fa01..de8da490c 100644 --- a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr +++ b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr @@ -8,7 +8,7 @@ LL | let w = &v; LL | take(v); | ^ move out of `v` occurs here LL | w.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-loan-in-overloaded-op.stderr b/tests/ui/borrowck/borrowck-loan-in-overloaded-op.stderr index e1b991620..93622a0c5 100644 --- a/tests/ui/borrowck/borrowck-loan-in-overloaded-op.stderr +++ b/tests/ui/borrowck/borrowck-loan-in-overloaded-op.stderr @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `x` LL | let x = Foo(Box::new(3)); | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur - | - ^^^^^^^^^ value borrowed here after move + | - ^ value borrowed here after move | | | value moved here | diff --git a/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr b/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr index f1640d3b7..bb90b2d15 100644 --- a/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr +++ b/tests/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr @@ -17,7 +17,7 @@ LL | let q = &mut p; | ------ mutable borrow occurs here ... LL | p.times(3); - | ^^^^^^^^^^ immutable borrow occurs here + | ^ immutable borrow occurs here LL | LL | *q + 3; // OK to use the new alias `q` | -- mutable borrow later used here diff --git a/tests/ui/borrowck/borrowck-loan-rcvr.stderr b/tests/ui/borrowck/borrowck-loan-rcvr.stderr index 1d6bd4e2e..317423ecf 100644 --- a/tests/ui/borrowck/borrowck-loan-rcvr.stderr +++ b/tests/ui/borrowck/borrowck-loan-rcvr.stderr @@ -1,15 +1,13 @@ error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-rcvr.rs:23:14 | -LL | p.blockm(|| { - | - ------ ^^ mutable borrow occurs here - | | | - | _____| immutable borrow later used by call - | | -LL | | p.x = 10; - | | --- second borrow occurs due to use of `p` in closure -LL | | }) - | |______- immutable borrow occurs here +LL | p.blockm(|| { + | - ------ ^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call + | immutable borrow occurs here +LL | p.x = 10; + | --- second borrow occurs due to use of `p` in closure error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr.rs:34:5 @@ -17,7 +15,7 @@ error[E0502]: cannot borrow `p` as immutable because it is also borrowed as muta LL | let l = &mut p; | ------ mutable borrow occurs here LL | p.impurem(); - | ^^^^^^^^^^^ immutable borrow occurs here + | ^ immutable borrow occurs here LL | LL | l.x += 1; | -------- mutable borrow later used here diff --git a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr index bd94f1a42..4f0202f38 100644 --- a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr +++ b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr @@ -9,7 +9,7 @@ LL | LL | let z = *a; | ^^ move out of `*a` occurs here LL | b.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr index cdad20c52..e1e3c7f8a 100644 --- a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr +++ b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr @@ -9,7 +9,7 @@ LL | let t1 = t0; | ^^ move out of `t0` occurs here LL | *t1 = 22; LL | p.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr b/tests/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr index 87135f0bb..934dd8df1 100644 --- a/tests/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr +++ b/tests/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr @@ -2,9 +2,8 @@ error[E0507]: cannot move out of an `Rc` --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14 | LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^^----------- - | | | - | | value moved due to this method call + | ^^^^^^^^^^^^^^^^^^^ ----------- value moved due to this method call + | | | move occurs because value has type `Vec`, which does not implement the `Copy` trait | note: `into_iter` takes ownership of the receiver `self`, which moves value @@ -12,7 +11,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves value help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | let _x = Rc::new(vec![1, 2]).clone().into_iter(); - | ++++++++ + | ++++++++ error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr b/tests/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr index d2b845619..3653de0e8 100644 --- a/tests/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr +++ b/tests/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr @@ -5,9 +5,8 @@ LL | 1 => { addr.push(&mut x); } | ^^^^^^ second mutable borrow occurs here LL | 2 => { addr.push(&mut x); } LL | _ => { addr.push(&mut x); } - | ----------------- - | | | - | | first mutable borrow occurs here + | ---- ------ first mutable borrow occurs here + | | | first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time @@ -16,18 +15,16 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time LL | 2 => { addr.push(&mut x); } | ^^^^^^ second mutable borrow occurs here LL | _ => { addr.push(&mut x); } - | ----------------- - | | | - | | first mutable borrow occurs here + | ---- ------ first mutable borrow occurs here + | | | first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 | LL | _ => { addr.push(&mut x); } - | ----------^^^^^^- - | | | - | | `x` was mutably borrowed here in the previous iteration of the loop + | ---- ^^^^^^ `x` was mutably borrowed here in the previous iteration of the loop + | | | first borrow used here, in later iteration of loop error: aborting due to 3 previous errors diff --git a/tests/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr index ef811b849..f2baee093 100644 --- a/tests/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr +++ b/tests/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr @@ -7,7 +7,7 @@ LL | let mut t2 = &mut t0; | ^^^^^^^ mutable borrow occurs here LL | **t2 += 1; // Mutates `*t0` LL | p.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `t0` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18 @@ -18,7 +18,7 @@ LL | let mut t2 = &mut t0; | ^^^^^^^ second mutable borrow occurs here LL | **t2 += 1; // Mutates `*t0` but not through `*p` LL | p.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-object-lifetime.stderr b/tests/ui/borrowck/borrowck-object-lifetime.stderr index 215ed760a..cf94c74de 100644 --- a/tests/ui/borrowck/borrowck-object-lifetime.stderr +++ b/tests/ui/borrowck/borrowck-object-lifetime.stderr @@ -2,21 +2,21 @@ error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immut --> $DIR/borrowck-object-lifetime.rs:20:13 | LL | let y = x.borrowed(); - | ------------ immutable borrow occurs here + | - immutable borrow occurs here LL | let z = x.mut_borrowed(); | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/borrowck-object-lifetime.rs:26:13 | LL | let y = x.borrowed(); - | ------------ immutable borrow occurs here + | - immutable borrow occurs here LL | let z = &mut x; | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr b/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr index fb7af50bc..2e7a6778d 100644 --- a/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr +++ b/tests/ui/borrowck/borrowck-overloaded-index-autoderef.stderr @@ -6,7 +6,7 @@ LL | let p = &mut f[&s]; LL | let q = &f[&s]; | ^ immutable borrow occurs here LL | p.use_mut(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:43:18 @@ -16,7 +16,7 @@ LL | let p = &mut f[&s]; LL | let q = &mut f[&s]; | ^ second mutable borrow occurs here LL | p.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error[E0499]: cannot borrow `f.foo` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 @@ -26,7 +26,7 @@ LL | let p = &mut f.foo[&s]; LL | let q = &mut f.foo[&s]; | ^^^^^ second mutable borrow occurs here LL | p.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-overloaded-index-autoderef.rs:65:18 @@ -36,7 +36,7 @@ LL | let p = &f.foo[&s]; LL | let q = &mut f.foo[&s]; | ^^^^^ mutable borrow occurs here LL | p.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 @@ -46,7 +46,7 @@ LL | let p = &f.foo[&s]; LL | f.foo = g; | ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed LL | p.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 @@ -56,7 +56,7 @@ LL | let p = &f.foo[&s]; LL | *f = g; | ^^^^^^ `*f` is assigned to here but it was already borrowed LL | p.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 @@ -66,7 +66,7 @@ LL | let p = &mut f.foo[&s]; LL | f.foo = g; | ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed LL | p.use_mut(); - | ----------- borrow later used here + | - borrow later used here error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 @@ -76,7 +76,7 @@ LL | let p = &mut f.foo[&s]; LL | *f = g; | ^^^^^^ `*f` is assigned to here but it was already borrowed LL | p.use_mut(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to 8 previous errors diff --git a/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr b/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr index d05996413..db73d4c04 100644 --- a/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr +++ b/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr @@ -8,7 +8,7 @@ LL | let z = &x; | ^^ immutable borrow occurs here ... LL | y.use_mut(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21 @@ -20,7 +20,7 @@ LL | let z = &mut x; | ^^^^^^ mutable borrow occurs here ... LL | y.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17 @@ -32,7 +32,7 @@ LL | let z = &mut x; | ^^^^^^ second mutable borrow occurs here ... LL | y.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to 3 previous errors diff --git a/tests/ui/borrowck/borrowck-swap-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-swap-mut-base-ptr.stderr index b39215b9a..1c55953c9 100644 --- a/tests/ui/borrowck/borrowck-swap-mut-base-ptr.stderr +++ b/tests/ui/borrowck/borrowck-swap-mut-base-ptr.stderr @@ -7,7 +7,7 @@ LL | swap(&mut t0, &mut t1); | ^^^^^^^ mutable borrow occurs here LL | *t1 = 22; LL | p.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-union-borrow-nested.stderr b/tests/ui/borrowck/borrowck-union-borrow-nested.stderr index a87a14e7c..f2e549cd8 100644 --- a/tests/ui/borrowck/borrowck-union-borrow-nested.stderr +++ b/tests/ui/borrowck/borrowck-union-borrow-nested.stderr @@ -6,7 +6,7 @@ LL | let ra = &mut u.s.a; LL | let b = u.c; | ^^^ use of borrowed `u.s.a` LL | ra.use_mut(); - | ------------ borrow later used here + | -- borrow later used here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-uniq-via-lend.stderr b/tests/ui/borrowck/borrowck-uniq-via-lend.stderr index 6dbe4c74b..923edc8ed 100644 --- a/tests/ui/borrowck/borrowck-uniq-via-lend.stderr +++ b/tests/ui/borrowck/borrowck-uniq-via-lend.stderr @@ -6,7 +6,7 @@ LL | let w = &mut v; LL | borrow(&*v); | ^^^ immutable borrow occurs here LL | w.use_mut(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable --> $DIR/borrowck-uniq-via-lend.rs:53:12 @@ -16,7 +16,7 @@ LL | x = &mut v; LL | borrow(&*v); | ^^^ immutable borrow occurs here LL | x.use_mut(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr b/tests/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr index eb0f24b9b..5141fcc1b 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr @@ -5,9 +5,8 @@ LL | let vb: &mut [isize] = &mut v; | ------ first mutable borrow occurs here ... LL | v.push(tail[0] + tail[1]); - | ^^^^^^^-------^^^^^^^^^^^ - | | | - | | first borrow later used here + | ^ ------- first borrow later used here + | | | second mutable borrow occurs here error: aborting due to previous error diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 70b9e4f44..024cb006c 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -8,7 +8,7 @@ LL | vec[0] = Box::new(4); | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed LL | LL | _a.use_ref(); - | ------------ borrow later used here + | -- borrow later used here error[E0506]: cannot assign to `vec[_]` because it is borrowed --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 @@ -20,7 +20,7 @@ LL | vec[0] = Box::new(4); | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed LL | LL | _b.use_ref(); - | ------------ borrow later used here + | -- borrow later used here error[E0508]: cannot move out of type `[Box]`, a non-copy slice --> $DIR/borrowck-vec-pattern-nesting.rs:34:11 diff --git a/tests/ui/borrowck/clone-span-on-try-operator.fixed b/tests/ui/borrowck/clone-span-on-try-operator.fixed new file mode 100644 index 000000000..52f66e43a --- /dev/null +++ b/tests/ui/borrowck/clone-span-on-try-operator.fixed @@ -0,0 +1,11 @@ +// run-rustfix + +#[derive(Clone)] +struct Foo; +impl Foo { + fn foo(self) {} +} +fn main() { + let foo = &Foo; + (*foo).clone().foo(); //~ ERROR cannot move out +} diff --git a/tests/ui/borrowck/clone-span-on-try-operator.rs b/tests/ui/borrowck/clone-span-on-try-operator.rs new file mode 100644 index 000000000..031a35e20 --- /dev/null +++ b/tests/ui/borrowck/clone-span-on-try-operator.rs @@ -0,0 +1,11 @@ +// run-rustfix + +#[derive(Clone)] +struct Foo; +impl Foo { + fn foo(self) {} +} +fn main() { + let foo = &Foo; + (*foo).foo(); //~ ERROR cannot move out +} diff --git a/tests/ui/borrowck/clone-span-on-try-operator.stderr b/tests/ui/borrowck/clone-span-on-try-operator.stderr new file mode 100644 index 000000000..85785e670 --- /dev/null +++ b/tests/ui/borrowck/clone-span-on-try-operator.stderr @@ -0,0 +1,21 @@ +error[E0507]: cannot move out of `*foo` which is behind a shared reference + --> $DIR/clone-span-on-try-operator.rs:10:5 + | +LL | (*foo).foo(); + | ^^^^^^ ----- `*foo` moved due to this method call + | | + | move occurs because `*foo` has type `Foo`, which does not implement the `Copy` trait + | +note: `Foo::foo` takes ownership of the receiver `self`, which moves `*foo` + --> $DIR/clone-span-on-try-operator.rs:6:12 + | +LL | fn foo(self) {} + | ^^^^ +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | (*foo).clone().foo(); + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/borrowck/copy-suggestion-region-vid.rs b/tests/ui/borrowck/copy-suggestion-region-vid.rs index dff952834..3c5b887ce 100644 --- a/tests/ui/borrowck/copy-suggestion-region-vid.rs +++ b/tests/ui/borrowck/copy-suggestion-region-vid.rs @@ -1,3 +1,4 @@ +//@run-rustfix pub struct DataStruct(); pub struct HelperStruct<'n> { diff --git a/tests/ui/borrowck/copy-suggestion-region-vid.stderr b/tests/ui/borrowck/copy-suggestion-region-vid.stderr index 1685acf87..b344aa664 100644 --- a/tests/ui/borrowck/copy-suggestion-region-vid.stderr +++ b/tests/ui/borrowck/copy-suggestion-region-vid.stderr @@ -1,13 +1,18 @@ error[E0382]: borrow of moved value: `helpers` - --> $DIR/copy-suggestion-region-vid.rs:12:43 + --> $DIR/copy-suggestion-region-vid.rs:13:43 | LL | let helpers = [vec![], vec![]]; | ------- move occurs because `helpers` has type `[Vec<&i64>; 2]`, which does not implement the `Copy` trait LL | LL | HelperStruct { helpers, is_empty: helpers[0].is_empty() } - | ------- ^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move + | ------- ^^^^^^^^^^ value borrowed here after move | | | value moved here + | +help: consider cloning the value if the performance cost is acceptable + | +LL | HelperStruct { helpers: helpers.clone(), is_empty: helpers[0].is_empty() } + | +++++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/borrowck/index-mut-help-with-impl.stderr b/tests/ui/borrowck/index-mut-help-with-impl.stderr index 69dca7e7b..89391f409 100644 --- a/tests/ui/borrowck/index-mut-help-with-impl.stderr +++ b/tests/ui/borrowck/index-mut-help-with-impl.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/index-mut-help-with-impl.rs:9:5 | LL | Index::index(&v, 1..2).make_ascii_uppercase(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/tests/ui/borrowck/index-mut-help.stderr b/tests/ui/borrowck/index-mut-help.stderr index f42d7e015..fde2b5dc0 100644 --- a/tests/ui/borrowck/index-mut-help.stderr +++ b/tests/ui/borrowck/index-mut-help.stderr @@ -2,13 +2,10 @@ error[E0596]: cannot borrow data in an index of `HashMap<&str, String>` as mutab --> $DIR/index-mut-help.rs:10:5 | LL | map["peter"].clear(); - | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>` -help: to modify a `HashMap<&str, String>` use `.get_mut()` - | -LL | map.get_mut("peter").map(|val| val.clear()); - | ~~~~~~~~~ ~~~~~~~~~~~~~~~ + + = help: to modify a `HashMap<&str, String>`, use `.get_mut()`, `.insert()` or the entry API error[E0594]: cannot assign to data in an index of `HashMap<&str, String>` --> $DIR/index-mut-help.rs:11:5 diff --git a/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr b/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr index 25974e0d0..4e3bf1d70 100644 --- a/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr +++ b/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr @@ -26,9 +26,8 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/issue-109271-pass-self-into-closure.rs:21:12 | LL | v.call(|(), this: &mut S| v.set()); - | -------^^^^^^^^^^^^^^^^^^--------- - | | | | | - | | | | second borrow occurs due to use of `v` in closure + | - ---- ^^^^^^^^^^^^^^^^^^ - second borrow occurs due to use of `v` in closure + | | | | | | | second mutable borrow occurs here | | first borrow later used by call | first mutable borrow occurs here @@ -63,21 +62,14 @@ LL ~ S::get(&this); error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/issue-109271-pass-self-into-closure.rs:25:12 | -LL | v.call(|(), this: &mut S| { - | - ---- ^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | _____| first borrow later used by call - | | -LL | | -LL | | -LL | | -LL | | _ = v; -LL | | v.set(); - | | - second borrow occurs due to use of `v` in closure -... | -LL | | _ = v.add(3); -LL | | }); - | |______- first mutable borrow occurs here +LL | v.call(|(), this: &mut S| { + | - ---- ^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call + | first mutable borrow occurs here +... +LL | v.set(); + | - second borrow occurs due to use of `v` in closure error: aborting due to 5 previous errors diff --git a/tests/ui/borrowck/issue-42344.stderr b/tests/ui/borrowck/issue-42344.stderr index 29b4c8c38..5cffa1b51 100644 --- a/tests/ui/borrowck/issue-42344.stderr +++ b/tests/ui/borrowck/issue-42344.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable stati --> $DIR/issue-42344.rs:4:5 | LL | TAB[0].iter_mut(); - | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-47646.stderr b/tests/ui/borrowck/issue-47646.stderr index 84cf9237a..d82e1f908 100644 --- a/tests/ui/borrowck/issue-47646.stderr +++ b/tests/ui/borrowck/issue-47646.stderr @@ -2,7 +2,7 @@ error[E0502]: cannot borrow `heap` as immutable because it is also borrowed as m --> $DIR/issue-47646.rs:9:30 | LL | let borrow = heap.peek_mut(); - | --------------- mutable borrow occurs here + | ---- mutable borrow occurs here LL | LL | match (borrow, ()) { | ------------ a temporary with access to the mutable borrow is created here ... diff --git a/tests/ui/borrowck/issue-51117.stderr b/tests/ui/borrowck/issue-51117.stderr index ef1a16ea9..f8a9608ad 100644 --- a/tests/ui/borrowck/issue-51117.stderr +++ b/tests/ui/borrowck/issue-51117.stderr @@ -4,7 +4,7 @@ error[E0499]: cannot borrow `*bar` as mutable more than once at a time LL | Some(baz) => { | --- first mutable borrow occurs here LL | bar.take(); - | ^^^^^^^^^^ second mutable borrow occurs here + | ^^^ second mutable borrow occurs here LL | drop(baz); | --- first borrow later used here diff --git a/tests/ui/borrowck/issue-81365-10.stderr b/tests/ui/borrowck/issue-81365-10.stderr index d0986e9f9..2bbde82fa 100644 --- a/tests/ui/borrowck/issue-81365-10.stderr +++ b/tests/ui/borrowck/issue-81365-10.stderr @@ -2,7 +2,7 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-10.rs:21:9 | LL | let first = &self.deref().target_field; - | ------------ `self.container_field` is borrowed here + | ---- `self.container_field` is borrowed here LL | self.container_field = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; diff --git a/tests/ui/borrowck/issue-81365-5.stderr b/tests/ui/borrowck/issue-81365-5.stderr index c00e48288..094cec021 100644 --- a/tests/ui/borrowck/issue-81365-5.stderr +++ b/tests/ui/borrowck/issue-81365-5.stderr @@ -2,7 +2,7 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed --> $DIR/issue-81365-5.rs:28:9 | LL | let first = self.get(); - | ---------- `self.container_field` is borrowed here + | ---- `self.container_field` is borrowed here LL | self.container_field = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed LL | first; diff --git a/tests/ui/borrowck/issue-82032.stderr b/tests/ui/borrowck/issue-82032.stderr index 25f343117..f272477a9 100644 --- a/tests/ui/borrowck/issue-82032.stderr +++ b/tests/ui/borrowck/issue-82032.stderr @@ -7,7 +7,7 @@ LL | for v in self.0.values() { | | help: use mutable method: `values_mut()` | this iterator yields `&` references LL | v.flush(); - | ^^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `v` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-85581.stderr b/tests/ui/borrowck/issue-85581.stderr index 59ca4867f..29c0429f2 100644 --- a/tests/ui/borrowck/issue-85581.stderr +++ b/tests/ui/borrowck/issue-85581.stderr @@ -7,7 +7,7 @@ LL | match heap.peek_mut() { | first mutable borrow occurs here | a temporary with access to the first borrow is created here ... LL | Some(_) => { heap.pop(); }, - | ^^^^^^^^^^ second mutable borrow occurs here + | ^^^^ second mutable borrow occurs here ... LL | } | - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option>` diff --git a/tests/ui/borrowck/issue-85765-closure.rs b/tests/ui/borrowck/issue-85765-closure.rs new file mode 100644 index 000000000..f2d1dd0fb --- /dev/null +++ b/tests/ui/borrowck/issue-85765-closure.rs @@ -0,0 +1,31 @@ +fn main() { + let _ = || { + let mut test = Vec::new(); + let rofl: &Vec> = &mut test; + //~^ HELP consider changing this binding's type + rofl.push(Vec::new()); + //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference + //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + + let mut mutvar = 42; + let r = &mutvar; + //~^ HELP consider changing this to be a mutable reference + *r = 0; + //~^ ERROR cannot assign to `*r`, which is behind a `&` reference + //~| NOTE `r` is a `&` reference, so the data it refers to cannot be written + + #[rustfmt::skip] + let x: &usize = &mut{0}; + //~^ HELP consider changing this binding's type + *x = 1; + //~^ ERROR cannot assign to `*x`, which is behind a `&` reference + //~| NOTE `x` is a `&` reference, so the data it refers to cannot be written + + #[rustfmt::skip] + let y: &usize = &mut(0); + //~^ HELP consider changing this binding's type + *y = 1; + //~^ ERROR cannot assign to `*y`, which is behind a `&` reference + //~| NOTE `y` is a `&` reference, so the data it refers to cannot be written + }; +} diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr new file mode 100644 index 000000000..936ddd67b --- /dev/null +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -0,0 +1,48 @@ +error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference + --> $DIR/issue-85765-closure.rs:6:9 + | +LL | rofl.push(Vec::new()); + | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing this binding's type + | +LL | let rofl: &mut Vec> = &mut test; + | ~~~~~~~~~~~~~~~~~~ + +error[E0594]: cannot assign to `*r`, which is behind a `&` reference + --> $DIR/issue-85765-closure.rs:13:9 + | +LL | *r = 0; + | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this to be a mutable reference + | +LL | let r = &mut mutvar; + | +++ + +error[E0594]: cannot assign to `*x`, which is behind a `&` reference + --> $DIR/issue-85765-closure.rs:20:9 + | +LL | *x = 1; + | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this binding's type + | +LL | let x: &mut usize = &mut{0}; + | ~~~~~~~~~~ + +error[E0594]: cannot assign to `*y`, which is behind a `&` reference + --> $DIR/issue-85765-closure.rs:27:9 + | +LL | *y = 1; + | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this binding's type + | +LL | let y: &mut usize = &mut(0); + | ~~~~~~~~~~ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 2985a658f..57900bfb6 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference --> $DIR/issue-85765.rs:5:5 | LL | rofl.push(Vec::new()); - | ^^^^^^^^^^^^^^^^^^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this binding's type | diff --git a/tests/ui/borrowck/issue-91206.stderr b/tests/ui/borrowck/issue-91206.stderr index 6653d4978..30f836565 100644 --- a/tests/ui/borrowck/issue-91206.stderr +++ b/tests/ui/borrowck/issue-91206.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference --> $DIR/issue-91206.rs:13:5 | LL | inner.clear(); - | ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider specifying this binding's type | diff --git a/tests/ui/borrowck/issue-93078.stderr b/tests/ui/borrowck/issue-93078.stderr index 771a652a1..bcbcbe724 100644 --- a/tests/ui/borrowck/issue-93078.stderr +++ b/tests/ui/borrowck/issue-93078.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable --> $DIR/issue-93078.rs:11:9 | LL | self.modify(); - | ^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^ cannot borrow as mutable | = note: as `Self` may be unsized, this call attempts to take `&mut &mut self` = note: however, `&mut self` expands to `self: &mut Self`, therefore `self` cannot be borrowed mutably diff --git a/tests/ui/borrowck/many-mutable-borrows.stderr b/tests/ui/borrowck/many-mutable-borrows.stderr index aa0cbcffd..0f808ac92 100644 --- a/tests/ui/borrowck/many-mutable-borrows.stderr +++ b/tests/ui/borrowck/many-mutable-borrows.stderr @@ -4,23 +4,23 @@ error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable LL | let v = Vec::new(); | ^ not mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable LL | v.push(0); - | --------- cannot borrow as mutable + | - cannot borrow as mutable | = note: ...and 5 other attempted mutable borrows help: consider changing this to be mutable diff --git a/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr b/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr index c6f75b1c0..f448e009b 100644 --- a/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr +++ b/tests/ui/borrowck/mut-borrow-of-mut-ref.stderr @@ -47,7 +47,7 @@ error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable --> $DIR/mut-borrow-of-mut-ref.rs:34:5 | LL | f.bar(); - | ^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider making the binding mutable | diff --git a/tests/ui/borrowck/mut-borrow-outside-loop.stderr b/tests/ui/borrowck/mut-borrow-outside-loop.stderr index e6895b27f..4fcb693f1 100644 --- a/tests/ui/borrowck/mut-borrow-outside-loop.stderr +++ b/tests/ui/borrowck/mut-borrow-outside-loop.stderr @@ -6,7 +6,7 @@ LL | let first = &mut void; LL | let second = &mut void; | ^^^^^^^^^ second mutable borrow occurs here LL | first.use_mut(); - | --------------- first borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `inner_void` as mutable more than once at a time --> $DIR/mut-borrow-outside-loop.rs:15:28 @@ -17,7 +17,7 @@ LL | let inner_second = &mut inner_void; | ^^^^^^^^^^^^^^^ second mutable borrow occurs here LL | inner_second.use_mut(); LL | inner_first.use_mut(); - | --------------------- first borrow later used here + | ----------- first borrow later used here error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr b/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr index 4621d8793..bada08368 100644 --- a/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr +++ b/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr @@ -2,9 +2,8 @@ error[E0507]: cannot move out of `*cb` which is behind a mutable reference --> $DIR/suggest-as-ref-on-mut-closure.rs:7:5 | LL | cb.map(|cb| cb()); - | ^^^-------------- - | | | - | | `*cb` moved due to this method call + | ^^ -------------- `*cb` moved due to this method call + | | | help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents | move occurs because `*cb` has type `Option<&mut dyn FnMut()>`, which does not implement the `Copy` trait | diff --git a/tests/ui/borrowck/suggest-local-var-double-mut.stderr b/tests/ui/borrowck/suggest-local-var-double-mut.stderr index 3a43c18a7..8bec0788f 100644 --- a/tests/ui/borrowck/suggest-local-var-double-mut.stderr +++ b/tests/ui/borrowck/suggest-local-var-double-mut.stderr @@ -2,9 +2,8 @@ error[E0499]: cannot borrow `*self` as mutable more than once at a time --> $DIR/suggest-local-var-double-mut.rs:12:22 | LL | self.foo(self.bar()); - | ---------^^^^^^^^^^- - | | | | - | | | second mutable borrow occurs here + | ---- --- ^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here | diff --git a/tests/ui/borrowck/suggest-local-var-for-vector.stderr b/tests/ui/borrowck/suggest-local-var-for-vector.stderr index 615fffcd5..c8d00f7b2 100644 --- a/tests/ui/borrowck/suggest-local-var-for-vector.stderr +++ b/tests/ui/borrowck/suggest-local-var-for-vector.stderr @@ -2,11 +2,11 @@ error[E0502]: cannot borrow `vec` as immutable because it is also borrowed as mu --> $DIR/suggest-local-var-for-vector.rs:3:9 | LL | vec[vec.len() - 1] = 123; - | ----^^^^^^^^^----- - | | | - | | immutable borrow occurs here + | ----^^^----------- + | | || + | | |immutable borrow occurs here + | | mutable borrow later used here | mutable borrow occurs here - | mutable borrow later used here | help: try adding a local storing this... --> $DIR/suggest-local-var-for-vector.rs:3:9 @@ -14,10 +14,10 @@ help: try adding a local storing this... LL | vec[vec.len() - 1] = 123; | ^^^^^^^^^ help: ...and then using that local here - --> $DIR/suggest-local-var-for-vector.rs:3:5 + --> $DIR/suggest-local-var-for-vector.rs:3:8 | LL | vec[vec.len() - 1] = 123; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/borrowck/suggest-local-var-imm-and-mut.stderr b/tests/ui/borrowck/suggest-local-var-imm-and-mut.stderr index eb934e7b7..1ef643e21 100644 --- a/tests/ui/borrowck/suggest-local-var-imm-and-mut.stderr +++ b/tests/ui/borrowck/suggest-local-var-imm-and-mut.stderr @@ -2,9 +2,8 @@ error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as im --> $DIR/suggest-local-var-imm-and-mut.rs:12:22 | LL | self.foo(self.bar()); - | ---------^^^^^^^^^^- - | | | | - | | | mutable borrow occurs here + | ---- --- ^^^^^^^^^^ mutable borrow occurs here + | | | | | immutable borrow later used by call | immutable borrow occurs here diff --git a/tests/ui/borrowck/suggest-storing-local-var-for-vector.stderr b/tests/ui/borrowck/suggest-storing-local-var-for-vector.stderr index e3a16eddf..368d72810 100644 --- a/tests/ui/borrowck/suggest-storing-local-var-for-vector.stderr +++ b/tests/ui/borrowck/suggest-storing-local-var-for-vector.stderr @@ -2,11 +2,11 @@ error[E0502]: cannot borrow `vec` as immutable because it is also borrowed as mu --> $DIR/suggest-storing-local-var-for-vector.rs:3:9 | LL | vec[vec.len() - 1] = 123; - | ----^^^^^^^^^----- - | | | - | | immutable borrow occurs here + | ----^^^----------- + | | || + | | |immutable borrow occurs here + | | mutable borrow later used here | mutable borrow occurs here - | mutable borrow later used here | help: try adding a local storing this... --> $DIR/suggest-storing-local-var-for-vector.rs:3:9 @@ -14,10 +14,10 @@ help: try adding a local storing this... LL | vec[vec.len() - 1] = 123; | ^^^^^^^^^ help: ...and then using that local here - --> $DIR/suggest-storing-local-var-for-vector.rs:3:5 + --> $DIR/suggest-storing-local-var-for-vector.rs:3:8 | LL | vec[vec.len() - 1] = 123; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/borrowck/two-phase-across-loop.stderr b/tests/ui/borrowck/two-phase-across-loop.stderr index 22f9b39df..d7c0210cc 100644 --- a/tests/ui/borrowck/two-phase-across-loop.stderr +++ b/tests/ui/borrowck/two-phase-across-loop.stderr @@ -2,9 +2,8 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-across-loop.rs:17:22 | LL | strings.push(foo.get_string()); - | -------------^^^^^^^^^^^^^^^^- - | | | - | | `foo` was mutably borrowed here in the previous iteration of the loop + | ------- ^^^ `foo` was mutably borrowed here in the previous iteration of the loop + | | | first borrow used here, in later iteration of loop error: aborting due to previous error diff --git a/tests/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr b/tests/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr index 21b0eddb9..2c3f1c18a 100644 --- a/tests/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr +++ b/tests/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr @@ -1,18 +1,13 @@ error[E0502]: cannot borrow `vec` as mutable because it is also borrowed as immutable --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:14:9 | -LL | vec.get({ - | - --- immutable borrow later used by call - | _____| - | | -LL | | -LL | | vec.push(2); - | | ^^^^^^^^^^^ mutable borrow occurs here -LL | | -LL | | -LL | | 0 -LL | | }); - | |______- immutable borrow occurs here +LL | vec.get({ + | --- --- immutable borrow later used by call + | | + | immutable borrow occurs here +LL | +LL | vec.push(2); + | ^^^^^^^^^^^ mutable borrow occurs here error: aborting due to previous error diff --git a/tests/ui/borrowck/two-phase-multi-mut.stderr b/tests/ui/borrowck/two-phase-multi-mut.stderr index 2e53e17a3..33fa4a3a1 100644 --- a/tests/ui/borrowck/two-phase-multi-mut.stderr +++ b/tests/ui/borrowck/two-phase-multi-mut.stderr @@ -12,9 +12,8 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:11:16 | LL | foo.method(&mut foo); - | -----------^^^^^^^^- - | | | | - | | | second mutable borrow occurs here + | --- ------ ^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here diff --git a/tests/ui/borrowck/two-phase-nonrecv-autoref.base.stderr b/tests/ui/borrowck/two-phase-nonrecv-autoref.base.stderr index efd63a08a..e122977b9 100644 --- a/tests/ui/borrowck/two-phase-nonrecv-autoref.base.stderr +++ b/tests/ui/borrowck/two-phase-nonrecv-autoref.base.stderr @@ -50,42 +50,42 @@ error[E0502]: cannot borrow `i` as immutable because it is also borrowed as muta | LL | i[i[3]] = 4; | --^---- - | | | - | | immutable borrow occurs here + | ||| + | ||immutable borrow occurs here + | |mutable borrow later used here | mutable borrow occurs here - | mutable borrow later used here | help: try adding a local storing this... - --> $DIR/two-phase-nonrecv-autoref.rs:132:7 + --> $DIR/two-phase-nonrecv-autoref.rs:132:8 | LL | i[i[3]] = 4; - | ^^^^ + | ^^^ help: ...and then using that local here - --> $DIR/two-phase-nonrecv-autoref.rs:132:5 + --> $DIR/two-phase-nonrecv-autoref.rs:132:6 | LL | i[i[3]] = 4; - | ^^^^^^^ + | ^^^^^^ error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:138:7 | LL | i[i[3]] = i[4]; | --^---- - | | | - | | immutable borrow occurs here + | ||| + | ||immutable borrow occurs here + | |mutable borrow later used here | mutable borrow occurs here - | mutable borrow later used here | help: try adding a local storing this... - --> $DIR/two-phase-nonrecv-autoref.rs:138:7 + --> $DIR/two-phase-nonrecv-autoref.rs:138:8 | LL | i[i[3]] = i[4]; - | ^^^^ + | ^^^ help: ...and then using that local here - --> $DIR/two-phase-nonrecv-autoref.rs:138:5 + --> $DIR/two-phase-nonrecv-autoref.rs:138:6 | LL | i[i[3]] = i[4]; - | ^^^^^^^ + | ^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/borrowck/two-phase-sneaky.stderr b/tests/ui/borrowck/two-phase-sneaky.stderr index 117d7ceae..4db970c1d 100644 --- a/tests/ui/borrowck/two-phase-sneaky.stderr +++ b/tests/ui/borrowck/two-phase-sneaky.stderr @@ -7,7 +7,7 @@ LL | v[0].push_str({ | first mutable borrow occurs here LL | LL | v.push(format!("foo")); - | ^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | ^ second mutable borrow occurs here error: aborting due to previous error diff --git a/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr b/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr index e75094d4f..9f9d4bd8d 100644 --- a/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr +++ b/tests/ui/borrowck/two-phase-surprise-no-conflict.stderr @@ -13,7 +13,7 @@ error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as im --> $DIR/two-phase-surprise-no-conflict.rs:57:17 | LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ^^^^^---------^^---------------------^^^^^^^ + | ^^^^^---------^^-----------^^^^^^^^^^^^^^^^^ | | | | | | | immutable borrow occurs here | | immutable borrow later used by call @@ -23,9 +23,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:119:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | | - | | | second mutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here @@ -33,9 +32,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:122:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | | - | | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here @@ -43,9 +41,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:125:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | | - | | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here @@ -53,9 +50,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:128:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | | - | | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here @@ -106,9 +102,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:154:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | | - | | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here @@ -129,9 +124,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:158:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | | - | | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here @@ -149,9 +143,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:162:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | | - | | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here diff --git a/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr b/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr index f033d53bf..a2f6365b7 100644 --- a/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr +++ b/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr @@ -15,7 +15,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves `y` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | y.clone().into_iter(); - | ++++++++ + | ++++++++ error: aborting due to previous error diff --git a/tests/ui/box/leak-alloc.stderr b/tests/ui/box/leak-alloc.stderr index 5140b5893..feda8841f 100644 --- a/tests/ui/box/leak-alloc.stderr +++ b/tests/ui/box/leak-alloc.stderr @@ -4,7 +4,7 @@ error[E0505]: cannot move out of `alloc` because it is borrowed LL | let alloc = Alloc {}; | ----- binding `alloc` declared here LL | let boxed = Box::new_in(10, alloc.by_ref()); - | -------------- borrow of `alloc` occurs here + | ----- borrow of `alloc` occurs here LL | let theref = Box::leak(boxed); LL | drop(alloc); | ^^^^^ move out of `alloc` occurs here diff --git a/tests/ui/btreemap/btreemap-index-mut-2.rs b/tests/ui/btreemap/btreemap-index-mut-2.rs new file mode 100644 index 000000000..fe676210a --- /dev/null +++ b/tests/ui/btreemap/btreemap-index-mut-2.rs @@ -0,0 +1,8 @@ +use std::collections::BTreeMap; + +fn main() { + let _ = || { + let mut map = BTreeMap::::new(); + map[&0] = 1; //~ ERROR cannot assign + }; +} diff --git a/tests/ui/btreemap/btreemap-index-mut-2.stderr b/tests/ui/btreemap/btreemap-index-mut-2.stderr new file mode 100644 index 000000000..c8d4fd595 --- /dev/null +++ b/tests/ui/btreemap/btreemap-index-mut-2.stderr @@ -0,0 +1,19 @@ +error[E0594]: cannot assign to data in an index of `BTreeMap` + --> $DIR/btreemap-index-mut-2.rs:6:9 + | +LL | map[&0] = 1; + | ^^^^^^^^^^^ cannot assign + | + = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `BTreeMap` +help: to modify a `BTreeMap`, use `.get_mut()`, `.insert()` or the entry API + | +LL | map.insert(&0, 1); + | ~~~~~~~~ ~ + +LL | map.get_mut(&0).map(|val| { *val = 1; }); + | ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ++++ +LL | let val = map.entry(&0).or_insert(1); + | +++++++++ ~~~~~~~ ~~~~~~~~~~~~ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/cannot-mutate-captured-non-mut-var.stderr b/tests/ui/cannot-mutate-captured-non-mut-var.stderr index 06b5ca407..2d6e83c9e 100644 --- a/tests/ui/cannot-mutate-captured-non-mut-var.stderr +++ b/tests/ui/cannot-mutate-captured-non-mut-var.stderr @@ -12,7 +12,7 @@ error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable LL | let s = std::io::stdin(); | - help: consider changing this to be mutable: `mut s` LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable error: aborting due to 2 previous errors diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 70a967c0e..b7269a652 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition value LL | #[cfg(target(os = "linux", arch = "X"))] | ^^^^^^^^^^ | - = note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips64`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64` + = note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/values-target-json.stderr b/tests/ui/check-cfg/values-target-json.stderr index eb81535e3..e773d5d83 100644 --- a/tests/ui/check-cfg/values-target-json.stderr +++ b/tests/ui/check-cfg/values-target-json.stderr @@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")] | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` + = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 2d18cb82e..1f7758146 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")] | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` + = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value diff --git a/tests/ui/closures/binder/nested-closures-regions.stderr b/tests/ui/closures/binder/nested-closures-regions.stderr index 381aadb15..a30339ac6 100644 --- a/tests/ui/closures/binder/nested-closures-regions.stderr +++ b/tests/ui/closures/binder/nested-closures-regions.stderr @@ -4,7 +4,7 @@ note: external requirements LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: main::{closure#0}::{closure#0} with closure substs [ + = note: defining type: main::{closure#0}::{closure#0} with closure args [ i8, extern "rust-call" fn((&(),)), (), @@ -21,7 +21,7 @@ note: no external requirements LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; | ^^^^^^^^^^^^^^^^ | - = note: defining type: main::{closure#0} with closure substs [ + = note: defining type: main::{closure#0} with closure args [ i8, extern "rust-call" fn(()), (), diff --git a/tests/ui/closures/multiple-fn-bounds.stderr b/tests/ui/closures/multiple-fn-bounds.stderr index 32a1edb00..d94c902f7 100644 --- a/tests/ui/closures/multiple-fn-bounds.stderr +++ b/tests/ui/closures/multiple-fn-bounds.stderr @@ -18,7 +18,7 @@ note: required by a bound in `foo` | LL | fn foo bool + Fn(char) -> bool>(f: F) { | ^^^^^^^^^^^^^^^^ required by this bound in `foo` -help: do not borrow the argument +help: consider adjusting the signature so it does not borrow its argument | LL | foo(move |char| v); | ~~~~ diff --git a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr index 381bb0c08..49453b053 100644 --- a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr @@ -9,7 +9,7 @@ LL | let c1 : () = c; | expected due to this | = note: expected unit type `()` - found closure `[mod1::f::{closure#0} closure_substs=(unavailable) substs=[T, ?16t, extern "rust-call" fn(()), ?15t]]` + found closure `[mod1::f::{closure#0} closure_args=(unavailable) args=[T, ?16t, extern "rust-call" fn(()), ?15t]]` help: use parentheses to call this closure | LL | let c1 : () = c(); diff --git a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr index 2a4d16c48..d2deba3dd 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr @@ -9,7 +9,7 @@ LL | let c1 : () = c; | expected due to this | = note: expected unit type `()` - found closure `[f::{closure#0} closure_substs=(unavailable) substs=[T, ?16t, extern "rust-call" fn(()), ?15t]]` + found closure `[f::{closure#0} closure_args=(unavailable) args=[T, ?16t, extern "rust-call" fn(()), ?15t]]` help: use parentheses to call this closure | LL | let c1 : () = c(); diff --git a/tests/ui/closures/print/closure-print-verbose.stderr b/tests/ui/closures/print/closure-print-verbose.stderr index 9e219435e..acc81f5e4 100644 --- a/tests/ui/closures/print/closure-print-verbose.stderr +++ b/tests/ui/closures/print/closure-print-verbose.stderr @@ -7,7 +7,7 @@ LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; | expected due to this | = note: expected fn pointer `fn(u8) -> u8` - found closure `[main::{closure#0} closure_substs=(unavailable) substs=[i8, extern "rust-call" fn((u8,)) -> u8, ?6t]]` + found closure `[main::{closure#0} closure_args=(unavailable) args=[i8, extern "rust-call" fn((u8,)) -> u8, ?6t]]` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-print-verbose.rs:10:39 | diff --git a/tests/ui/codegen/issue-55976.rs b/tests/ui/codegen/issue-55976.rs index 3142704b7..fee54fc62 100644 --- a/tests/ui/codegen/issue-55976.rs +++ b/tests/ui/codegen/issue-55976.rs @@ -1,7 +1,5 @@ // run-pass // ^-- The above is needed as this issue is related to LLVM/codegen. -// min-llvm-version:15.0.0 -// ^-- The above is needed as this issue is fixed by the opaque pointers. fn main() { type_error(|x| &x); diff --git a/tests/ui/codegen/target-cpus.rs b/tests/ui/codegen/target-cpus.rs new file mode 100644 index 000000000..1dff3ee60 --- /dev/null +++ b/tests/ui/codegen/target-cpus.rs @@ -0,0 +1,4 @@ +// needs-llvm-components: webassembly +// min-llvm-version: 17 +// compile-flags: --print=target-cpus --target=wasm32-unknown-unknown +// check-pass diff --git a/tests/ui/codegen/target-cpus.stdout b/tests/ui/codegen/target-cpus.stdout new file mode 100644 index 000000000..f60ba0f50 --- /dev/null +++ b/tests/ui/codegen/target-cpus.stdout @@ -0,0 +1,4 @@ +Available CPUs for this target: + bleeding-edge + generic - This is the default target CPU for the current build target (currently wasm32-unknown-unknown). + mvp diff --git a/tests/ui/codemap_tests/issue-11715.stderr b/tests/ui/codemap_tests/issue-11715.stderr index a6b2b2e50..d0c29c768 100644 --- a/tests/ui/codemap_tests/issue-11715.stderr +++ b/tests/ui/codemap_tests/issue-11715.stderr @@ -7,7 +7,7 @@ LL | let z = &mut x; | ^^^^^^ second mutable borrow occurs here LL | z.use_mut(); LL | y.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/tests/ui/codemap_tests/one_line.stderr b/tests/ui/codemap_tests/one_line.stderr index 6fe6e2613..75fbbada7 100644 --- a/tests/ui/codemap_tests/one_line.stderr +++ b/tests/ui/codemap_tests/one_line.stderr @@ -2,9 +2,8 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/one_line.rs:3:12 | LL | v.push(v.pop().unwrap()); - | -------^^^^^^^---------- - | | | | - | | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | | | first borrow later used by call | first mutable borrow occurs here | diff --git a/tests/ui/codemap_tests/tab_3.stderr b/tests/ui/codemap_tests/tab_3.stderr index 17bea2f36..b17159be6 100644 --- a/tests/ui/codemap_tests/tab_3.stderr +++ b/tests/ui/codemap_tests/tab_3.stderr @@ -15,7 +15,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves `some_vec` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | some_vec.clone().into_iter(); - | ++++++++ + | ++++++++ error: aborting due to previous error diff --git a/tests/ui/coercion/coerce-block-tail-83783.fixed b/tests/ui/coercion/coerce-block-tail-83783.fixed new file mode 100644 index 000000000..0df0a64ac --- /dev/null +++ b/tests/ui/coercion/coerce-block-tail-83783.fixed @@ -0,0 +1,13 @@ +// run-rustfix +// edition:2018 +fn _consume_reference(_: &T) {} + +async fn _foo() { + _consume_reference::(&Box::new(7_i32)); + _consume_reference::(&*async { Box::new(7_i32) }.await); + //~^ ERROR mismatched types + _consume_reference::<[i32]>(&vec![7_i32]); + _consume_reference::<[i32]>(&async { vec![7_i32] }.await); +} + +fn main() { } diff --git a/tests/ui/coercion/coerce-block-tail-83783.rs b/tests/ui/coercion/coerce-block-tail-83783.rs index 18c8ae3bb..ee6036b4d 100644 --- a/tests/ui/coercion/coerce-block-tail-83783.rs +++ b/tests/ui/coercion/coerce-block-tail-83783.rs @@ -1,4 +1,4 @@ -// check-fail +// run-rustfix // edition:2018 fn _consume_reference(_: &T) {} diff --git a/tests/ui/coercion/coerce-block-tail-83783.stderr b/tests/ui/coercion/coerce-block-tail-83783.stderr index d556d013b..da3c38777 100644 --- a/tests/ui/coercion/coerce-block-tail-83783.stderr +++ b/tests/ui/coercion/coerce-block-tail-83783.stderr @@ -6,6 +6,10 @@ LL | _consume_reference::(&async { Box::new(7_i32) }.await); | = note: expected type `i32` found struct `Box` +help: consider unboxing the value + | +LL | _consume_reference::(&*async { Box::new(7_i32) }.await); + | + error: aborting due to previous error diff --git a/tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.rs b/tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.rs new file mode 100644 index 000000000..063826f1d --- /dev/null +++ b/tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.rs @@ -0,0 +1,24 @@ +// check-pass +// issue: 113415 + +// Makes sure that coherence doesn't call any of the `predicate_may_hold`-esque fns, +// since they are using a different infcx which doesn't preserve the intercrate flag. + +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +trait Assoc { + type Output; +} + +default impl Assoc for T { + type Output = bool; +} + +impl Assoc for u8 {} + +trait Foo {} +impl Foo for u32 {} +impl Foo for ::Output {} + +fn main() {} diff --git a/tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.stderr b/tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.stderr new file mode 100644 index 000000000..56eb21cd2 --- /dev/null +++ b/tests/ui/coherence/coherence-doesnt-use-infcx-evaluate.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/coherence-doesnt-use-infcx-evaluate.rs:7:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr index 7bd50649d..684e52822 100644 --- a/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr +++ b/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr @@ -20,6 +20,7 @@ note: cycle used when coherence checking all impls of trait `Trait` | LL | trait Trait { type Assoc; } | ^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs new file mode 100644 index 000000000..01f7d6ce9 --- /dev/null +++ b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.rs @@ -0,0 +1,35 @@ +#![deny(coinductive_overlap_in_coherence)] + +use std::borrow::Borrow; +use std::cmp::Ordering; +use std::marker::PhantomData; + +#[derive(PartialEq, Default)] +pub(crate) struct Interval(PhantomData); + +// This impl overlaps with the `derive` unless we reject the nested +// `Interval: PartialOrd>` candidate which results +// in a - currently inductive - cycle. +impl PartialEq for Interval +//~^ ERROR implementations of `PartialEq>` for `Interval<_>` will conflict in the future +//~| WARN this was previously accepted by the compiler but is being phased out +where + T: Borrow, + Q: ?Sized + PartialOrd, +{ + fn eq(&self, _: &Q) -> bool { + true + } +} + +impl PartialOrd for Interval +where + T: Borrow, + Q: ?Sized + PartialOrd, +{ + fn partial_cmp(&self, _: &Q) -> Option { + None + } +} + +fn main() {} diff --git a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr new file mode 100644 index 000000000..f315ba821 --- /dev/null +++ b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr @@ -0,0 +1,23 @@ +error: implementations of `PartialEq>` for `Interval<_>` will conflict in the future + --> $DIR/warn-when-cycle-is-error-in-coherence.rs:13:1 + | +LL | #[derive(PartialEq, Default)] + | --------- the second impl is here +... +LL | impl PartialEq for Interval + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the first impl is here +... +LL | Q: ?Sized + PartialOrd, + | ---------- `Interval<_>: PartialOrd` may be considered to hold in future releases, causing the impls to overlap + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114040 + = note: impls that are not considered to overlap may be considered to overlap in the future +note: the lint level is defined here + --> $DIR/warn-when-cycle-is-error-in-coherence.rs:1:9 + | +LL | #![deny(coinductive_overlap_in_coherence)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/command/need-crate-arg-ignore-tidy.x.rs b/tests/ui/command/need-crate-arg-ignore-tidy.x.rs new file mode 100644 index 000000000..b1ac4a4ae --- /dev/null +++ b/tests/ui/command/need-crate-arg-ignore-tidy.x.rs @@ -0,0 +1,2 @@ +// issue: 113981 +pub fn main() {} diff --git a/tests/ui/command/need-crate-arg-ignore-tidy.x.stderr b/tests/ui/command/need-crate-arg-ignore-tidy.x.stderr new file mode 100644 index 000000000..305f76694 --- /dev/null +++ b/tests/ui/command/need-crate-arg-ignore-tidy.x.stderr @@ -0,0 +1,6 @@ +error: invalid character `'.'` in crate name: `need_crate_arg_ignore_tidy.x` + | + = help: you can either pass `--crate-name` on the command line or add `#![crate_name="…"]` to set the crate name + +error: aborting due to previous error + diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-1.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-1.rs index d20e79b9d..0898ca9cd 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-1.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-1.rs @@ -1,3 +1,3 @@ -// compile-flags: --cfg a(b=c) +// compile-flags: --error-format=human --cfg a(b=c) // error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\") fn main() {} diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-2.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-2.rs index 48d656a4a..70e425600 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-2.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-2.rs @@ -1,3 +1,3 @@ -// compile-flags: --cfg a{b} +// compile-flags: --error-format=human --cfg a{b} // error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`) fn main() {} diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-4.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-4.rs index e7dfa17b4..2adc27eb9 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-4.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-4.rs @@ -1,3 +1,3 @@ -// compile-flags: --cfg a(b) +// compile-flags: --error-format=human --cfg a(b) // error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`) fn main() {} diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-6.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-6.rs index 9fa726f93..be3ded7dd 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-6.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-6.rs @@ -1,3 +1,3 @@ -// compile-flags: --cfg a{ +// compile-flags: --error-format=human --cfg a{ // error-pattern: invalid `--cfg` argument: `a{` (expected `key` or `key="value"`) fn main() {} diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-8.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-8.rs index 1d7fa7885..4a2f16f11 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-8.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-8.rs @@ -1,3 +1,3 @@ -// compile-flags: --cfg ) +// compile-flags: --error-format=human --cfg ) // error-pattern: invalid `--cfg` argument: `)` (expected `key` or `key="value"`) fn main() {} diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-9.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-9.rs index 628b335c8..a61989a3e 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-9.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-9.rs @@ -1,4 +1,4 @@ // Test for missing quotes around value, issue #66450. -// compile-flags: --cfg key=value +// compile-flags: --error-format=human --cfg key=value // error-pattern: invalid `--cfg` argument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\") fn main() {} diff --git a/tests/ui/conditional-compilation/cfg-empty-codemap.rs b/tests/ui/conditional-compilation/cfg-empty-codemap.rs index 9e34cacf7..c7aded733 100644 --- a/tests/ui/conditional-compilation/cfg-empty-codemap.rs +++ b/tests/ui/conditional-compilation/cfg-empty-codemap.rs @@ -1,6 +1,6 @@ // Tests that empty source_maps don't ICE (#23301) -// compile-flags: --cfg "" +// compile-flags: --error-format=human --cfg "" // error-pattern: invalid `--cfg` argument: `""` (expected `key` or `key="value"`) diff --git a/tests/ui/const-generics/const-generic-default-wont-borrowck.stderr b/tests/ui/const-generics/const-generic-default-wont-borrowck.stderr index 0ed370b83..a345c48b0 100644 --- a/tests/ui/const-generics/const-generic-default-wont-borrowck.stderr +++ b/tests/ui/const-generics/const-generic-default-wont-borrowck.stderr @@ -2,7 +2,7 @@ error[E0381]: used binding `s` isn't initialized --> $DIR/const-generic-default-wont-borrowck.rs:2:26 | LL | let s: &'static str; s.len() - | - ^^^^^^^ `*s` used here but it isn't initialized + | - ^ `*s` used here but it isn't initialized | | | binding declared here but left uninitialized | diff --git a/tests/ui/const-generics/const_trait_fn-issue-88433.rs b/tests/ui/const-generics/const_trait_fn-issue-88433.rs index 6e04cfaec..88dff9192 100644 --- a/tests/ui/const-generics/const_trait_fn-issue-88433.rs +++ b/tests/ui/const-generics/const_trait_fn-issue-88433.rs @@ -1,6 +1,6 @@ // build-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] trait Func { diff --git a/tests/ui/const-generics/generic_const_exprs/closures.stderr b/tests/ui/const-generics/generic_const_exprs/closures.stderr index a7d891d77..45d7922bd 100644 --- a/tests/ui/const-generics/generic_const_exprs/closures.stderr +++ b/tests/ui/const-generics/generic_const_exprs/closures.stderr @@ -20,6 +20,7 @@ note: cycle used when checking that `test` is well-formed | LL | fn test() -> [u8; N + (|| 42)()] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr index f61edd60e..8b8489ac2 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*self.0` as mutable, as it is behind a `&` referenc --> $DIR/issue-109141.rs:6:9 | LL | self.0.iter_mut() - | ^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs index 275f69953..6b2a0153f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs @@ -1,4 +1,9 @@ // check-fail +// known-bug: #97477 +// failure-status: 101 +// normalize-stderr-test "note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// rustc-env:RUST_BACKTRACE=0 // This test used to cause an ICE in rustc_mir::interpret::step::eval_rvalue_into_place @@ -27,6 +32,5 @@ where } fn main() { - let dst = Inline::::new(0); //~ ERROR - //~^ ERROR + let dst = Inline::::new(0); } diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr index dc3a400cb..79ed82e02 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -1,71 +1,10 @@ -error[E0080]: evaluation of `Inline::::{constant#0}` failed +error: internal compiler error: compiler/rustc_const_eval/src/interpret/step.rs:272:21: SizeOf MIR operator called for unsized type dyn Debug --> $SRC_DIR/core/src/mem/mod.rs:LL:COL - | - = note: size_of called on unsized type `dyn Debug` - | -note: inside `std::mem::size_of::` - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `Inline::::{constant#0}` - --> $DIR/issue-80742.rs:22:10 - | -LL | [u8; size_of::() + 1]: , - | ^^^^^^^^^^^^^^ - -error[E0599]: the function or associated item `new` exists for struct `Inline`, but its trait bounds were not satisfied - --> $DIR/issue-80742.rs:30:36 - | -LL | struct Inline - | ---------------- function or associated item `new` not found for this struct -... -LL | let dst = Inline::::new(0); - | ^^^ function or associated item cannot be called on `Inline` due to unsatisfied trait bounds - --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL - | - = note: doesn't satisfy `dyn Debug: Sized` - | -note: trait bound `dyn Debug: Sized` was not satisfied - --> $DIR/issue-80742.rs:20:6 - | -LL | impl Inline - | ^ --------- - | | - | unsatisfied trait bound introduced here -help: consider relaxing the type parameter's implicit `Sized` bound - | -LL | impl Inline - | ++++++++ - -error[E0080]: evaluation of `Inline::::{constant#0}` failed - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL - | - = note: size_of called on unsized type `dyn Debug` - | -note: inside `std::mem::size_of::` - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `Inline::::{constant#0}` - --> $DIR/issue-80742.rs:14:10 - | -LL | [u8; size_of::() + 1]: , - | ^^^^^^^^^^^^^^ - -error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/issue-80742.rs:30:15 - | -LL | let dst = Inline::::new(0); - | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Debug` -note: required by a bound in `Inline` - --> $DIR/issue-80742.rs:12:15 - | -LL | struct Inline - | ^ required by this bound in `Inline` -help: consider relaxing the implicit `Sized` restriction - | -LL | struct Inline - | ++++++++ -error: aborting due to 4 previous errors +Box +query stack during panic: +#0 [eval_to_allocation_raw] const-evaluating + checking `::{constant#0}` +#1 [eval_to_valtree] evaluating type-level constant +end of query stack +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0277, E0599. -For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr index 7f28771ce..eb71ebb62 100644 --- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr @@ -1,11 +1,39 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/unify-op-with-fn-call.rs:10:12 +error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/unify-op-with-fn-call.rs:18:29 | -LL | impl const std::ops::Add for Foo { - | ^^^^^^^^^^^^^ +LL | struct Evaluatable; + | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct Foo(u8); + | + +error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/unify-op-with-fn-call.rs:20:17 + | +LL | fn foo(a: Evaluatable<{ N + N }>) { + | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct Foo(u8); + | + +error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/unify-op-with-fn-call.rs:24:17 + | +LL | fn bar() {} + | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct Foo(u8); | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change -error: aborting due to previous error +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0741`. diff --git a/tests/ui/const-generics/issue-93647.rs b/tests/ui/const-generics/issue-93647.rs index a0083a0c6..806540e17 100644 --- a/tests/ui/const-generics/issue-93647.rs +++ b/tests/ui/const-generics/issue-93647.rs @@ -1,7 +1,6 @@ struct X; fn main() {} diff --git a/tests/ui/const-generics/issue-93647.stderr b/tests/ui/const-generics/issue-93647.stderr index 20a6af5c5..18370eea5 100644 --- a/tests/ui/const-generics/issue-93647.stderr +++ b/tests/ui/const-generics/issue-93647.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-93647.rs:2:6: 2:8]: Fn<()>` is not satisfied - --> $DIR/issue-93647.rs:2:5 - | -LL | (||1usize)() - | ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-93647.rs:2:6: 2:8]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-93647.rs:2:6: 2:8]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-93647.rs:2:6: 2:8]`, but that implementation is not `const` - --> $DIR/issue-93647.rs:2:5 - | -LL | (||1usize)() - | ^^^^^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-93647.rs:2:6: 2:8]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/issue-93647.rs:2:5 | @@ -22,7 +8,6 @@ LL | (||1usize)() = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 4e9d3626a..9af9b5ca4 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -9,6 +9,7 @@ impl T { unsafe { *(B as *const bool as *mut bool) = false; //~^ ERROR evaluation of constant value failed [E0080] + //~| ERROR assigning to `&T` is undefined behavior } } } diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index d4b486376..42ad4d61c 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,3 +1,11 @@ +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/issue-100313.rs:10:13 + | +LL | *(B as *const bool as *mut bool) = false; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[deny(invalid_reference_casting)]` on by default + error[E0080]: evaluation of constant value failed --> $DIR/issue-100313.rs:10:13 | @@ -10,11 +18,11 @@ note: inside `T::<&true>::set_false` LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside `_` - --> $DIR/issue-100313.rs:18:5 + --> $DIR/issue-100313.rs:19:5 | LL | x.set_false(); | ^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/const-generics/issues/issue-67375.full.stderr b/tests/ui/const-generics/issues/issue-67375.full.stderr index 0cf69879a..13cb8d1cd 100644 --- a/tests/ui/const-generics/issues/issue-67375.full.stderr +++ b/tests/ui/const-generics/issues/issue-67375.full.stderr @@ -2,7 +2,7 @@ error: overly complex generic constant --> $DIR/issue-67375.rs:7:17 | LL | inner: [(); { [|_: &T| {}; 0].len() }], - | ^^---------------------^^ + | ^^---------------^^^^^^^^ | | | pointer casts are not allowed in generic constants | diff --git a/tests/ui/const-generics/issues/issue-83765.stderr b/tests/ui/const-generics/issues/issue-83765.stderr index d7b2b006c..df734933c 100644 --- a/tests/ui/const-generics/issues/issue-83765.stderr +++ b/tests/ui/const-generics/issues/issue-83765.stderr @@ -15,6 +15,7 @@ note: cycle used when computing candidate for ` "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "thread.*panicked.*\n" -> "" +// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> "" // normalize-stderr-test "stack backtrace:\n" -> "" // normalize-stderr-test "\s\d{1,}: .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> "" -// normalize-stderr-test "\n\n[ ]*\n" -> "" +// normalize-stderr-test "\n[ ]*\n" -> "" // normalize-stderr-test "compiler/.*: projection" -> "projection" +// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> "" +// normalize-stderr-test "error: [\s\n]*query stack during panic:\n" -> "" // this should run-pass #![feature(generic_const_exprs)] diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.stderr b/tests/ui/const-generics/late-bound-vars/in_closure.stderr index 557fbea2e..ac406bf2b 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.stderr +++ b/tests/ui/const-generics/late-bound-vars/in_closure.stderr @@ -1,4 +1,3 @@ -error: query stack during panic: #0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}` #1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}` #2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE @@ -6,8 +5,6 @@ error: query stack during panic: #4 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` #5 [eval_to_valtree] evaluating type-level constant #6 [typeck] type-checking `test` -#7 [used_trait_imports] finding used_trait_imports `test` -#8 [analysis] running analysis passes on this crate +#7 [analysis] running analysis passes on this crate end of query stack -error: aborting due to previous error - +error: aborting due to previous error \ No newline at end of file diff --git a/tests/ui/const-generics/late-bound-vars/simple.rs b/tests/ui/const-generics/late-bound-vars/simple.rs index 5d19aaf0b..544073b5a 100644 --- a/tests/ui/const-generics/late-bound-vars/simple.rs +++ b/tests/ui/const-generics/late-bound-vars/simple.rs @@ -8,13 +8,15 @@ // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "thread.*panicked.*\n" -> "" +// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> "" // normalize-stderr-test "stack backtrace:\n" -> "" // normalize-stderr-test "\s\d{1,}: .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> "" // normalize-stderr-test "\n\n[ ]*\n" -> "" // normalize-stderr-test "compiler/.*: projection" -> "projection" +// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> "" +// normalize-stderr-test "error: [\s\n]*query stack" -> "error: query stack" #![feature(generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/late-bound-vars/simple.stderr b/tests/ui/const-generics/late-bound-vars/simple.stderr index c0568f5a5..c9f2164b6 100644 --- a/tests/ui/const-generics/late-bound-vars/simple.stderr +++ b/tests/ui/const-generics/late-bound-vars/simple.stderr @@ -6,8 +6,7 @@ error: query stack during panic: #4 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}` #5 [eval_to_valtree] evaluating type-level constant #6 [typeck] type-checking `test` -#7 [used_trait_imports] finding used_trait_imports `test` -#8 [analysis] running analysis passes on this crate +#7 [analysis] running analysis passes on this crate end of query stack error: aborting due to previous error diff --git a/tests/ui/const-generics/lifetime-in-const-param.rs b/tests/ui/const-generics/lifetime-in-const-param.rs new file mode 100644 index 000000000..be90dbb21 --- /dev/null +++ b/tests/ui/const-generics/lifetime-in-const-param.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/113462 + +struct S2<'b>(&'b ()); + +struct S<'a, const N: S2>(&'a ()); +//~^ ERROR missing lifetime specifier [E0106] +//~| ERROR `S2<'_>` is forbidden as the type of a const generic parameter + +fn main() {} diff --git a/tests/ui/const-generics/lifetime-in-const-param.stderr b/tests/ui/const-generics/lifetime-in-const-param.stderr new file mode 100644 index 000000000..8fd9068e8 --- /dev/null +++ b/tests/ui/const-generics/lifetime-in-const-param.stderr @@ -0,0 +1,18 @@ +error[E0106]: missing lifetime specifier + --> $DIR/lifetime-in-const-param.rs:5:23 + | +LL | struct S<'a, const N: S2>(&'a ()); + | ^^ expected named lifetime parameter + +error: `S2<'_>` is forbidden as the type of a const generic parameter + --> $DIR/lifetime-in-const-param.rs:5:23 + | +LL | struct S<'a, const N: S2>(&'a ()); + | ^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/const-generics/slice-const-param.rs b/tests/ui/const-generics/slice-const-param.rs index 05d21e08d..90c573ab3 100644 --- a/tests/ui/const-generics/slice-const-param.rs +++ b/tests/ui/const-generics/slice-const-param.rs @@ -11,9 +11,30 @@ pub fn function_with_bytes() -> &'static [u8] { BYTES } +// Also check the codepaths for custom DST +#[derive(PartialEq, Eq)] +struct MyStr(str); +impl std::marker::ConstParamTy for MyStr {} + +fn function_with_my_str() -> &'static MyStr { + S +} + +impl MyStr { + const fn new(s: &'static str) -> &'static MyStr { + unsafe { std::mem::transmute(s) } + } + + fn as_str(&self) -> &str { + &self.0 + } +} + pub fn main() { assert_eq!(function_with_str::<"Rust">(), "Rust"); assert_eq!(function_with_str::<"ℇ㇈↦">(), "ℇ㇈↦"); assert_eq!(function_with_bytes::(), &[0x41, 0x41, 0x41, 0x41]); assert_eq!(function_with_bytes::<{&[0x41, 0x41, 0x41, 0x41]}>(), b"AAAA"); + + assert_eq!(function_with_my_str::<{ MyStr::new("hello") }>().as_str(), "hello"); } diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr index 9e308620a..12644b9f3 100644 --- a/tests/ui/const-generics/transmute-fail.stderr +++ b/tests/ui/const-generics/transmute-fail.stderr @@ -16,18 +16,6 @@ LL | std::mem::transmute(v) = note: source type: `[[u32; H]; W]` (this type does not have a fixed size) = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W]) -error[E0308]: mismatched types - --> $DIR/transmute-fail.rs:12:53 - | -LL | fn bar(v: [[u32; H]; W]) -> [[u32; W]; H] { - | ^ expected `usize`, found `bool` - -error[E0308]: mismatched types - --> $DIR/transmute-fail.rs:12:67 - | -LL | fn bar(v: [[u32; H]; W]) -> [[u32; W]; H] { - | ^ expected `usize`, found `bool` - error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> $DIR/transmute-fail.rs:23:5 | @@ -46,6 +34,18 @@ LL | std::mem::transmute(v) = note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[u32; 8888888]; 9999999]` are too big for the current architecture) = note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture) +error[E0308]: mismatched types + --> $DIR/transmute-fail.rs:12:53 + | +LL | fn bar(v: [[u32; H]; W]) -> [[u32; W]; H] { + | ^ expected `usize`, found `bool` + +error[E0308]: mismatched types + --> $DIR/transmute-fail.rs:12:67 + | +LL | fn bar(v: [[u32; H]; W]) -> [[u32; W]; H] { + | ^ expected `usize`, found `bool` + error: aborting due to 6 previous errors Some errors have detailed explanations: E0308, E0512. diff --git a/tests/ui/const-generics/type_mismatch.stderr b/tests/ui/const-generics/type_mismatch.stderr index 394dd44d4..07476ae76 100644 --- a/tests/ui/const-generics/type_mismatch.stderr +++ b/tests/ui/const-generics/type_mismatch.stderr @@ -10,12 +10,6 @@ note: required by a bound in `bar` LL | fn bar() -> [u8; N] {} | ^^^^^^^^^^^ required by this bound in `bar` -error[E0308]: mismatched types - --> $DIR/type_mismatch.rs:2:11 - | -LL | bar::() - | ^ expected `u8`, found `usize` - error[E0308]: mismatched types --> $DIR/type_mismatch.rs:6:26 | @@ -24,6 +18,12 @@ LL | fn bar() -> [u8; N] {} | | | implicitly returns `()` as its body has no tail or `return` expression +error[E0308]: mismatched types + --> $DIR/type_mismatch.rs:2:11 + | +LL | bar::() + | ^ expected `u8`, found `usize` + error[E0308]: mismatched types --> $DIR/type_mismatch.rs:6:31 | diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 22c3dfa64..294bc77aa 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -41,7 +41,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:26:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -52,8 +52,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:28:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } @@ -75,7 +76,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:33:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -143,7 +144,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:53:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -154,8 +155,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:58:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } diff --git a/tests/ui/const_prop/apfloat-f64-roundtrip.rs b/tests/ui/const_prop/apfloat-f64-roundtrip.rs new file mode 100644 index 000000000..9fb2ac96b --- /dev/null +++ b/tests/ui/const_prop/apfloat-f64-roundtrip.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags: -O -Zmir-opt-level=3 -Cno-prepopulate-passes +// min-llvm-version: 16.0 (requires APFloat fixes in LLVM) + +// Regression test for a broken MIR optimization (issue #113407). +pub fn main() { + let f = f64::from_bits(0x19873cc2) as f32; + assert_eq!(f.to_bits(), 0); +} diff --git a/tests/ui/const_prop/apfloat-remainder-regression.rs b/tests/ui/const_prop/apfloat-remainder-regression.rs new file mode 100644 index 000000000..08932c333 --- /dev/null +++ b/tests/ui/const_prop/apfloat-remainder-regression.rs @@ -0,0 +1,15 @@ +// run-pass +// compile-flags: -O -Zmir-opt-level=3 -Cno-prepopulate-passes + +// Regression test for a broken MIR optimization (issue #102403). +pub fn f() -> f64 { + std::hint::black_box(-1.0) % std::hint::black_box(-1.0) +} + +pub fn g() -> f64 { + -1.0 % -1.0 +} + +pub fn main() { + assert_eq!(f().signum(), g().signum()); +} diff --git a/tests/ui/const_prop/ice-issue-111353.rs b/tests/ui/const_prop/ice-issue-111353.rs new file mode 100644 index 000000000..99d1b792f --- /dev/null +++ b/tests/ui/const_prop/ice-issue-111353.rs @@ -0,0 +1,7 @@ +// build-pass +#![crate_type = "lib"] +#![feature(unsized_fn_params)] + +pub fn f(mut x: [i32]) { + x[0] = 1; +} diff --git a/tests/ui/const_prop/ice-issue-96944.rs b/tests/ui/const_prop/ice-issue-96944.rs new file mode 100644 index 000000000..74baffddd --- /dev/null +++ b/tests/ui/const_prop/ice-issue-96944.rs @@ -0,0 +1,26 @@ +// build-pass +#![crate_type = "lib"] +#![allow(arithmetic_overflow)] + +pub trait BitSplit { + type Half; + fn merge(halves: [Self::Half; 2]) -> Self; +} + +macro_rules! impl_ints { + ($int:ty => $half:ty; $mask:expr) => { + impl BitSplit for $int { + type Half = $half; + #[inline] + fn merge(halves: [Self::Half; 2]) -> Self { + const HALF_SIZE: usize = std::mem::size_of::<$half>() * 8; + (halves[0] << HALF_SIZE) as $int | halves[1] as $int + } + } + }; +} + +impl_ints!(u128 => u64; 0x0000_0000_0000_0000_FFFF_FFFF_FFFF_FFFF); +impl_ints!( u64 => u32; 0x0000_0000_FFFF_FFFF); +impl_ints!( u32 => u16; 0x0000_FFFF); +impl_ints!( u16 => u8; 0x00FF); diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index 3704a1a5a..123e5cb1b 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -1,3 +1,5 @@ +// known-bug: #103507 + #![allow(unused)] #![feature(const_trait_impl, inline_const, negative_impls)] @@ -14,6 +16,6 @@ impl Drop for UnconstDrop { fn main() { const { f(UnconstDrop); - //~^ ERROR can't drop + //FIXME ~^ ERROR can't drop } } diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index caf24e7af..b402f0ea9 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,17 +1,11 @@ -error[E0277]: can't drop `UnconstDrop` in const contexts - --> $DIR/const-block-const-bound.rs:16:9 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-block-const-bound.rs:8:32 | -LL | f(UnconstDrop); - | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` - | - = note: the trait bound `UnconstDrop: ~const Destruct` is not satisfied -help: consider borrowing here - | -LL | &f(UnconstDrop); - | + -LL | &mut f(UnconstDrop); - | ++++ +LL | const fn f(x: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/const-compare-bytes-ub.rs b/tests/ui/consts/const-compare-bytes-ub.rs new file mode 100644 index 000000000..2b4062fd2 --- /dev/null +++ b/tests/ui/consts/const-compare-bytes-ub.rs @@ -0,0 +1,41 @@ +// check-fail + +#![feature(core_intrinsics)] +#![feature(const_intrinsic_compare_bytes)] +use std::intrinsics::compare_bytes; +use std::mem::MaybeUninit; + +fn main() { + const LHS_NULL: i32 = unsafe { + compare_bytes(0 as *const u8, 2 as *const u8, 0) + //~^ ERROR evaluation of constant value failed + }; + const RHS_NULL: i32 = unsafe { + compare_bytes(1 as *const u8, 0 as *const u8, 0) + //~^ ERROR evaluation of constant value failed + }; + const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe { + compare_bytes(1 as *const u8, 2 as *const u8, 1) + //~^ ERROR evaluation of constant value failed + }; + const LHS_OUT_OF_BOUNDS: i32 = unsafe { + compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) + //~^ ERROR evaluation of constant value failed + }; + const RHS_OUT_OF_BOUNDS: i32 = unsafe { + compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) + //~^ ERROR evaluation of constant value failed + }; + const LHS_UNINIT: i32 = unsafe { + compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) + //~^ ERROR evaluation of constant value failed + }; + const RHS_UNINIT: i32 = unsafe { + compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) + //~^ ERROR evaluation of constant value failed + }; + const WITH_PROVENANCE: i32 = unsafe { + compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) + //~^ ERROR evaluation of constant value failed + }; +} diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr new file mode 100644 index 000000000..54fafded0 --- /dev/null +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -0,0 +1,54 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:10:9 + | +LL | compare_bytes(0 as *const u8, 2 as *const u8, 0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:14:9 + | +LL | compare_bytes(1 as *const u8, 0 as *const u8, 0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:18:9 + | +LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance) + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:22:9 + | +LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc6 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:26:9 + | +LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc13 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:30:9 + | +LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc17[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:34:9 + | +LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc25[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:38:9 + | +LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-compare-bytes.rs b/tests/ui/consts/const-compare-bytes.rs new file mode 100644 index 000000000..74e29f813 --- /dev/null +++ b/tests/ui/consts/const-compare-bytes.rs @@ -0,0 +1,27 @@ +// run-pass + +#![feature(core_intrinsics)] +#![feature(const_intrinsic_compare_bytes)] +use std::intrinsics::compare_bytes; + +fn main() { + const A: i32 = unsafe { + compare_bytes(1 as *const u8, 2 as *const u8, 0) + }; + assert_eq!(A, 0); + + const B: i32 = unsafe { + compare_bytes([1, 2].as_ptr(), [1, 3].as_ptr(), 1) + }; + assert_eq!(B, 0); + + const C: i32 = unsafe { + compare_bytes([1, 2, 9].as_ptr(), [1, 3, 8].as_ptr(), 2) + }; + assert!(C < 0); + + const D: i32 = unsafe { + compare_bytes([1, 3, 8].as_ptr(), [1, 2, 9].as_ptr(), 2) + }; + assert!(D > 0); +} diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.rs b/tests/ui/consts/const-eval/const-eval-query-stack.rs index 81f28c175..4eaff4947 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.rs +++ b/tests/ui/consts/const-eval/const-eval-query-stack.rs @@ -5,12 +5,12 @@ // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "thread.*panicked.*\n" -> "" +// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> "" // normalize-stderr-test "stack backtrace:\n" -> "" // normalize-stderr-test "\s\d{1,}: .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> "" - +// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> "" #![allow(unconditional_panic)] const X: i32 = 1 / 0; //~ERROR constant diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index bf98d0394..f099bc7ef 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:26:49 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:29:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:32:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -29,7 +29,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:35:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -38,7 +38,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:38:45 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -53,7 +53,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:45:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -62,7 +62,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -71,7 +71,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:51:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -80,7 +80,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:54:45 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -95,7 +95,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:61:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -104,7 +104,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:64:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -113,7 +113,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:67:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -122,7 +122,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:70:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -131,7 +131,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:73:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -140,7 +140,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:76:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -149,7 +149,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:79:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -158,7 +158,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:82:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -167,7 +167,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:85:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -176,7 +176,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:88:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -185,7 +185,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:91:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -194,7 +194,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:94:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -203,7 +203,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:97:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -212,7 +212,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:100:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -221,7 +221,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:103:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -230,7 +230,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:106:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -239,7 +239,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:109:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -248,7 +248,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:112:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/const_fn_target_feature.rs b/tests/ui/consts/const-eval/const_fn_target_feature.rs new file mode 100644 index 000000000..5d02ce3f2 --- /dev/null +++ b/tests/ui/consts/const-eval/const_fn_target_feature.rs @@ -0,0 +1,17 @@ +// only-x86_64 +// compile-flags:-C target-feature=+ssse3 + +#![crate_type = "lib"] + +// ok (ssse3 enabled at compile time) +const A: () = unsafe { ssse3_fn() }; + +// error (avx2 not enabled at compile time) +const B: () = unsafe { avx2_fn() }; +//~^ ERROR evaluation of constant value failed + +#[target_feature(enable = "ssse3")] +const unsafe fn ssse3_fn() {} + +#[target_feature(enable = "avx2")] +const unsafe fn avx2_fn() {} diff --git a/tests/ui/consts/const-eval/const_fn_target_feature.stderr b/tests/ui/consts/const-eval/const_fn_target_feature.stderr new file mode 100644 index 000000000..36918b52c --- /dev/null +++ b/tests/ui/consts/const-eval/const_fn_target_feature.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const_fn_target_feature.rs:10:24 + | +LL | const B: () = unsafe { avx2_fn() }; + | ^^^^^^^^^ calling a function that requires unavailable target features: avx2 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index 4eb1c42e1..b50ef0c68 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_dangling.rs:10:5 | LL | &*ptr - | ^^^^^ pointer to alloc2 was dereferenced after this allocation got freed + | ^^^^^ dereferencing pointer failed: alloc2 has been freed, so this pointer is dangling error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_dangling.rs:18:5 | LL | *reference - | ^^^^^^^^^^ pointer to alloc4 was dereferenced after this allocation got freed + | ^^^^^^^^^^ dereferencing pointer failed: alloc4 has been freed, so this pointer is dangling error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr index 8177a0850..0884ade45 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | LL | intrinsics::const_deallocate(ptr, 4, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc2 has been freed, so this pointer is dangling error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index cc4f1594c..45ba0ea18 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^ pointer to alloc3 was dereferenced after this allocation got freed + | ^^^^^^^^ dereferencing pointer failed: alloc3 has been freed, so this pointer is dangling error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/nonnull_as_ref.rs b/tests/ui/consts/const-eval/nonnull_as_ref.rs new file mode 100644 index 000000000..eb4683e2c --- /dev/null +++ b/tests/ui/consts/const-eval/nonnull_as_ref.rs @@ -0,0 +1,8 @@ +// check-pass + +use std::ptr::NonNull; + +const NON_NULL: NonNull = unsafe { NonNull::new_unchecked((&42u8 as *const u8).cast_mut()) }; +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); + +fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs new file mode 100644 index 000000000..3b48e9729 --- /dev/null +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs @@ -0,0 +1,6 @@ +use std::ptr::NonNull; + +const NON_NULL: NonNull = unsafe { NonNull::dangling() }; +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); + +fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr new file mode 100644 index 000000000..de93cb0c3 --- /dev/null +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -0,0 +1,16 @@ +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + | + = note: dereferencing pointer failed: 0x1[noalloc] is a dangling pointer (it has no provenance) + | +note: inside `NonNull::::as_ref::<'_>` + --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL +note: inside `_` + --> $DIR/nonnull_as_ref_ub.rs:4:39 + | +LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index c0ddaceea..e087a0ebe 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -24,7 +24,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:42:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:44:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of uninhabited type `Never` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -266,7 +266,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:144:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized data in `str` + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { @@ -277,7 +277,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:146:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized data in `str` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { @@ -288,8 +288,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a pointer, but expected a string | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } @@ -516,7 +517,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:215:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { @@ -527,8 +528,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:218:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } @@ -550,7 +552,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:225:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { @@ -561,7 +563,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:232:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { @@ -572,8 +574,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:237:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 20c905878..4c655161f 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -24,7 +24,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:42:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:44:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of uninhabited type `Never` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -266,7 +266,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:144:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized data in `str` + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { @@ -277,7 +277,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:146:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized data in `str` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { @@ -288,8 +288,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a pointer, but expected a string | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -516,7 +517,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:215:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { @@ -527,8 +528,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:218:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -550,7 +552,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:225:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { @@ -561,7 +563,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:232:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { @@ -572,8 +574,9 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:237:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr index eaa2d6b27..8175fe601 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index eaa2d6b27..8175fe601 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ub-enum.32bit.stderr b/tests/ui/consts/const-eval/ub-enum.32bit.stderr index 1810600b7..c0ad6caec 100644 --- a/tests/ui/consts/const-eval/ub-enum.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.32bit.stderr @@ -13,7 +13,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -22,7 +22,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:33:1 | LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -42,7 +42,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -51,7 +51,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:50:1 | LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -66,7 +66,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:64:1 | LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -75,7 +75,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:81:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -86,7 +86,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:83:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of uninhabited type `Never` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -108,14 +108,27 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:96:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered a value of uninhabited type `Never` + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant -error: aborting due to 13 previous errors +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + = note: read discriminant of an uninhabited enum variant + | +note: inside `discriminant::` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL +note: inside `TEST_ICE_89765` + --> $DIR/ub-enum.rs:103:14 + | +LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-enum.64bit.stderr b/tests/ui/consts/const-eval/ub-enum.64bit.stderr index fb40babb0..6db43d379 100644 --- a/tests/ui/consts/const-eval/ub-enum.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.64bit.stderr @@ -13,7 +13,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -22,7 +22,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:33:1 | LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -42,7 +42,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -51,7 +51,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:50:1 | LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -66,7 +66,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:64:1 | LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -75,7 +75,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:81:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -86,7 +86,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:83:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a value of uninhabited type `Never` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -108,14 +108,27 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:96:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered a value of uninhabited type `Never` + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant -error: aborting due to 13 previous errors +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + = note: read discriminant of an uninhabited enum variant + | +note: inside `discriminant::` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL +note: inside `TEST_ICE_89765` + --> $DIR/ub-enum.rs:103:14 + | +LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index 8f26d9a00..078283fbd 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -2,7 +2,7 @@ // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" -#![feature(never_type)] +#![feature(never_type, const_discriminant)] #![allow(invalid_value)] use std::mem; @@ -66,8 +66,8 @@ const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; // # valid discriminant for uninhabited variant -// An enum with 3 variants of which some are uninhabited -- so the uninhabited variants *do* -// have a discriminant. +// An enum with uninhabited variants but also at least 2 inhabited variants -- so the uninhabited +// variants *do* have a discriminant. enum UninhDiscriminant { A, B(!), @@ -98,5 +98,11 @@ const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem: const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; //~^ ERROR evaluation of constant value failed +const TEST_ICE_89765: () = { + // This is a regression test for https://github.com/rust-lang/rust/issues/89765. + unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; + //~^ inside `TEST_ICE_89765` +}; + fn main() { } diff --git a/tests/ui/consts/const-eval/ub-int-array.32bit.stderr b/tests/ui/consts/const-eval/ub-int-array.32bit.stderr index edcde13b0..b3df41304 100644 --- a/tests/ui/consts/const-eval/ub-int-array.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.32bit.stderr @@ -1,20 +1,35 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:15:9 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-int-array.rs:19:1 | -LL | MaybeUninit { uninit: () }.init, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_INT_0: [u32; 3] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 12, align: 4) { + __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:30:13 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-int-array.rs:24:1 + | +LL | const UNINIT_INT_1: [u32; 3] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer | -LL | MaybeUninit { uninit: () }.init, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 12, align: 4) { + 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:56:13 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-int-array.rs:42:1 + | +LL | const UNINIT_INT_2: [u32; 3] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer | -LL | MaybeUninit { uninit: () }.init, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 12, align: 4) { + 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ + } error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/ub-int-array.64bit.stderr b/tests/ui/consts/const-eval/ub-int-array.64bit.stderr index edcde13b0..b3df41304 100644 --- a/tests/ui/consts/const-eval/ub-int-array.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.64bit.stderr @@ -1,20 +1,35 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:15:9 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-int-array.rs:19:1 | -LL | MaybeUninit { uninit: () }.init, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_INT_0: [u32; 3] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 12, align: 4) { + __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:30:13 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-int-array.rs:24:1 + | +LL | const UNINIT_INT_1: [u32; 3] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer | -LL | MaybeUninit { uninit: () }.init, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 12, align: 4) { + 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. + } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:56:13 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-int-array.rs:42:1 + | +LL | const UNINIT_INT_2: [u32; 3] = unsafe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer | -LL | MaybeUninit { uninit: () }.init, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 12, align: 4) { + 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ + } error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/ub-int-array.rs b/tests/ui/consts/const-eval/ub-int-array.rs index a68d3fb17..adcf376b9 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -10,54 +10,52 @@ union MaybeUninit { init: T, } +impl MaybeUninit { + const fn new(t: T) -> Self { + MaybeUninit { init: t } + } +} + const UNINIT_INT_0: [u32; 3] = unsafe { - [ - MaybeUninit { uninit: () }.init, - //~^ ERROR evaluation of constant value failed - //~| uninitialized - 1, - 2, - ] + //~^ ERROR it is undefined behavior to use this value + //~| invalid value at [0] + mem::transmute([MaybeUninit { uninit: () }, MaybeUninit::new(1), MaybeUninit::new(2)]) }; const UNINIT_INT_1: [u32; 3] = unsafe { - mem::transmute( - [ - 0u8, - 0u8, - 0u8, - 0u8, - 1u8, - MaybeUninit { uninit: () }.init, - //~^ ERROR evaluation of constant value failed - //~| uninitialized - 1u8, - 1u8, - 2u8, - 2u8, - MaybeUninit { uninit: () }.init, - 2u8, - ] - ) + //~^ ERROR it is undefined behavior to use this value + //~| invalid value at [1] + mem::transmute([ + MaybeUninit::new(0u8), + MaybeUninit::new(0u8), + MaybeUninit::new(0u8), + MaybeUninit::new(0u8), + MaybeUninit::new(1u8), + MaybeUninit { uninit: () }, + MaybeUninit::new(1u8), + MaybeUninit::new(1u8), + MaybeUninit::new(2u8), + MaybeUninit::new(2u8), + MaybeUninit { uninit: () }, + MaybeUninit::new(2u8), + ]) }; const UNINIT_INT_2: [u32; 3] = unsafe { - mem::transmute( - [ - 0u8, - 0u8, - 0u8, - 0u8, - 1u8, - 1u8, - 1u8, - 1u8, - 2u8, - 2u8, - 2u8, - MaybeUninit { uninit: () }.init, - //~^ ERROR evaluation of constant value failed - //~| uninitialized - ] - ) + //~^ ERROR it is undefined behavior to use this value + //~| invalid value at [2] + mem::transmute([ + MaybeUninit::new(0u8), + MaybeUninit::new(0u8), + MaybeUninit::new(0u8), + MaybeUninit::new(0u8), + MaybeUninit::new(1u8), + MaybeUninit::new(1u8), + MaybeUninit::new(1u8), + MaybeUninit::new(1u8), + MaybeUninit::new(2u8), + MaybeUninit::new(2u8), + MaybeUninit::new(2u8), + MaybeUninit { uninit: () }, + ]) }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 1d19dfff5..0ee1e6087 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -46,7 +46,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:33:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -55,7 +55,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:36:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -70,7 +70,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:39:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -141,7 +141,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc39, but expected a function pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index f38e7916b..02bbbf504 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -24,7 +24,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-wide-ptr.rs:43:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -33,7 +33,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-wide-ptr.rs:46:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -53,7 +53,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:52:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized data in `str` + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -64,7 +64,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-wide-ptr.rs:55:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized data in `str` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -103,7 +103,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-wide-ptr.rs:75:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported @@ -123,7 +123,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-wide-ptr.rs:81:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-float-classify.rs b/tests/ui/consts/const-float-classify.rs index 3a5d5bb46..877ce0219 100644 --- a/tests/ui/consts/const-float-classify.rs +++ b/tests/ui/consts/const-float-classify.rs @@ -1,5 +1,6 @@ // compile-flags: -Zmir-opt-level=0 -// run-pass +// known-bug: #110395 +// FIXME run-pass #![feature(const_float_bits_conv)] #![feature(const_float_classify)] diff --git a/tests/ui/consts/const-float-classify.stderr b/tests/ui/consts/const-float-classify.stderr new file mode 100644 index 000000000..a23d81c0e --- /dev/null +++ b/tests/ui/consts/const-float-classify.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `>::eq` in constant functions + --> $DIR/const-float-classify.rs:31:7 + | +LL | x.eq(y) + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-size_of-cycle.stderr b/tests/ui/consts/const-size_of-cycle.stderr index 17088d999..46b432357 100644 --- a/tests/ui/consts/const-size_of-cycle.stderr +++ b/tests/ui/consts/const-size_of-cycle.stderr @@ -23,6 +23,7 @@ note: cycle used when checking that `Foo` is well-formed | LL | struct Foo { | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/consts/const-try.stderr b/tests/ui/consts/const-try.stderr index 37014f9b8..94f4153a2 100644 --- a/tests/ui/consts/const-try.stderr +++ b/tests/ui/consts/const-try.stderr @@ -1,20 +1,29 @@ -error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` - --> $DIR/const-try.rs:15:12 +error[E0015]: `?` cannot determine the branch of `TryMe` in constant functions + --> $DIR/const-try.rs:33:5 | -LL | impl const FromResidual for TryMe { - | ^^^^^^^^^^^^^^^^^^^ +LL | TryMe?; + | ^^^^^^ | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: const `impl` for trait `Try` which is not marked with `#[const_trait]` - --> $DIR/const-try.rs:21:12 +note: impl defined here, but it is not `const` + --> $DIR/const-try.rs:21:1 | LL | impl const Try for TryMe { - | ^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error[E0015]: `?` cannot convert from residual of `TryMe` in constant functions + --> $DIR/const-try.rs:33:5 | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change +LL | TryMe?; + | ^^^^^^ + | +note: impl defined here, but it is not `const` + --> $DIR/const-try.rs:15:1 + | +LL | impl const FromResidual for TryMe { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr index dc2c702d8..0d915cec0 100644 --- a/tests/ui/consts/const_cmp_type_id.stderr +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -1,16 +1,3 @@ -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/const_cmp_type_id.rs:8:13 - | -LL | assert!(TypeId::of::() == TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` - | - = help: the trait `~const PartialEq` is not implemented for `TypeId` -note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/const_cmp_type_id.rs:8:13 - | -LL | assert!(TypeId::of::() == TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/const_cmp_type_id.rs:8:13 | @@ -21,19 +8,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/const_cmp_type_id.rs:9:13 - | -LL | assert!(TypeId::of::<()>() != TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` - | - = help: the trait `~const PartialEq` is not implemented for `TypeId` -note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/const_cmp_type_id.rs:9:13 - | -LL | assert!(TypeId::of::<()>() != TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/const_cmp_type_id.rs:9:13 | @@ -44,19 +18,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/const_cmp_type_id.rs:10:22 - | -LL | const _A: bool = TypeId::of::() < TypeId::of::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId < TypeId` and `TypeId > TypeId` - | - = help: the trait `~const PartialOrd` is not implemented for `TypeId` -note: the trait `PartialOrd` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/const_cmp_type_id.rs:10:22 - | -LL | const _A: bool = TypeId::of::() < TypeId::of::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constants --> $DIR/const_cmp_type_id.rs:10:22 | @@ -68,7 +29,6 @@ note: impl defined here, but it is not `const` = note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const_discriminant.rs b/tests/ui/consts/const_discriminant.rs index 79e68590e..b1180faa6 100644 --- a/tests/ui/consts/const_discriminant.rs +++ b/tests/ui/consts/const_discriminant.rs @@ -24,13 +24,6 @@ enum SingleVariant { const TEST_V: Discriminant = discriminant(&SingleVariant::V); -pub const TEST_VOID: () = { - // This is UB, but CTFE does not check validity so it does not detect this. - // This is a regression test for https://github.com/rust-lang/rust/issues/89765. - unsafe { std::mem::discriminant(&*(&() as *const () as *const Void)); }; -}; - - fn main() { assert_eq!(TEST_A, TEST_A_OTHER); assert_eq!(TEST_A, discriminant(black_box(&Test::A(17)))); diff --git a/tests/ui/consts/const_let_assign3.stderr b/tests/ui/consts/const_let_assign3.stderr index b550ac545..89073f975 100644 --- a/tests/ui/consts/const_let_assign3.stderr +++ b/tests/ui/consts/const_let_assign3.stderr @@ -11,7 +11,7 @@ error[E0658]: mutable references are not allowed in constants --> $DIR/const_let_assign3.rs:14:5 | LL | s.foo(3); - | ^^^^^^^^ + | ^ | = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable diff --git a/tests/ui/consts/constifconst-call-in-const-position.stderr b/tests/ui/consts/constifconst-call-in-const-position.stderr index d4a445120..6eee46661 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.stderr +++ b/tests/ui/consts/constifconst-call-in-const-position.stderr @@ -7,12 +7,22 @@ LL | #![feature(const_trait_impl, generic_const_exprs)] = note: see issue #76560 for more information = note: `#[warn(incomplete_features)]` on by default -error[E0080]: evaluation of `foo::<()>::{constant#0}` failed +error[E0015]: cannot call non-const fn `::a` in constants + --> $DIR/constifconst-call-in-const-position.rs:17:9 + | +LL | [0; T::a()] + | ^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error[E0015]: cannot call non-const fn `::a` in constants --> $DIR/constifconst-call-in-const-position.rs:16:38 | LL | const fn foo() -> [u8; T::a()] { - | ^^^^^^ calling non-const function `<() as Tr>::a` + | ^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted -For more information about this error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/drop-maybe_uninit.rs b/tests/ui/consts/drop-maybe_uninit.rs new file mode 100644 index 000000000..2fdeae5f1 --- /dev/null +++ b/tests/ui/consts/drop-maybe_uninit.rs @@ -0,0 +1,17 @@ +// build-pass + +pub const fn f(_: [std::mem::MaybeUninit; N]) {} + +pub struct Blubb(*const T); + +pub const fn g(_: [Blubb; N]) {} + +pub struct Blorb([String; N]); + +pub const fn h(_: Blorb<0>) {} + +pub struct Wrap(Blorb<0>); + +pub const fn i(_: Wrap) {} + +fn main() {} diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs index 6a3c93ce7..37b37e965 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -1,8 +1,29 @@ // revisions: no_flag with_flag // [no_flag] check-pass // [with_flag] compile-flags: -Zextra-const-ub-checks +#![feature(never_type, pointer_byte_offsets)] use std::mem::transmute; +use std::ptr::addr_of; + +#[derive(Clone, Copy)] +enum E { A, B } + +#[derive(Clone, Copy)] +enum Never {} + +#[repr(usize)] +enum PtrSizedEnum { V } + +// An enum with uninhabited variants but also at least 2 inhabited variants -- so the uninhabited +// variants *do* have a discriminant. +#[derive(Clone, Copy)] +enum UninhDiscriminant { + A, + B(!), + C, + D(Never), +} const INVALID_BOOL: () = unsafe { let _x: bool = transmute(3u8); @@ -13,12 +34,20 @@ const INVALID_BOOL: () = unsafe { const INVALID_PTR_IN_INT: () = unsafe { let _x: usize = transmute(&3u8); //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value +}; + +const INVALID_PTR_IN_ENUM: () = unsafe { + let _x: PtrSizedEnum = transmute(&3u8); + //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value }; const INVALID_SLICE_TO_USIZE_TRANSMUTE: () = unsafe { let x: &[u8] = &[0; 32]; let _x: (usize, usize) = transmute(x); //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value }; const UNALIGNED_PTR: () = unsafe { @@ -27,4 +56,36 @@ const UNALIGNED_PTR: () = unsafe { //[with_flag]~| invalid value }; +const UNINHABITED_VARIANT: () = unsafe { + let data = [1u8]; + // Not using transmute, we want to hit the ImmTy code path. + let v = *addr_of!(data).cast::(); + //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value +}; + +const PARTIAL_POINTER: () = unsafe { + #[repr(C, packed)] + struct Packed { + pad1: u8, + ptr: *const u8, + pad2: [u8; 7], + } + // `Align` ensures that the entire thing has pointer alignment again. + #[repr(C)] + struct Align { + p: Packed, + align: usize, + } + let mem = Packed { pad1: 0, ptr: &0u8 as *const u8, pad2: [0; 7] }; + let mem = Align { p: mem, align: 0 }; + let _val = *(&mem as *const Align as *const [*const u8; 2]); + //[with_flag]~^ ERROR: evaluation of constant value failed + //[with_flag]~| invalid value +}; + +// Regression tests for an ICE (related to ). +const VALID_ENUM1: E = { let e = E::A; e }; +const VALID_ENUM2: Result<&'static [u8], ()> = { let e = Err(()); e }; + fn main() {} diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index 3970baefc..4ee12d501 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -1,33 +1,57 @@ error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:8:20 + --> $DIR/detect-extra-ub.rs:29:20 | LL | let _x: bool = transmute(3u8); | ^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:14:21 + --> $DIR/detect-extra-ub.rs:35:21 | LL | let _x: usize = transmute(&3u8); - | ^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a pointer, but expected an integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:20:30 + --> $DIR/detect-extra-ub.rs:41:28 + | +LL | let _x: PtrSizedEnum = transmute(&3u8); + | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered a pointer, but expected an integer + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:48:30 | LL | let _x: (usize, usize) = transmute(x); - | ^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^ constructing invalid value at .0: encountered a pointer, but expected an integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:25:20 + --> $DIR/detect-extra-ub.rs:54:20 | LL | let _x: &u32 = transmute(&[0u8; 4]); | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) -error: aborting due to 4 previous errors +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:62:13 + | +LL | let v = *addr_of!(data).cast::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + +error[E0080]: evaluation of constant value failed + --> $DIR/detect-extra-ub.rs:82:16 + | +LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a partial pointer or a mix of pointers + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.rs b/tests/ui/consts/invalid-inline-const-in-match-arm.rs index 17acb2d9d..4d2d8fb13 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.rs +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.rs @@ -5,6 +5,5 @@ fn main() { match () { const { (|| {})() } => {} //~^ ERROR cannot call non-const closure in constants - //~| ERROR the trait bound } } diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr index ac174849f..257ecd7f3 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]: Fn<()>` is not satisfied - --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 - | -LL | const { (|| {})() } => {} - | ^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]`, but that implementation is not `const` - --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 - | -LL | const { (|| {})() } => {} - | ^^^^^^^^^ - = note: wrap the `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 | @@ -22,7 +8,6 @@ LL | const { (|| {})() } => {} = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-103790.stderr b/tests/ui/consts/issue-103790.stderr index 34d8ee281..67334469d 100644 --- a/tests/ui/consts/issue-103790.stderr +++ b/tests/ui/consts/issue-103790.stderr @@ -34,6 +34,7 @@ note: cycle used when computing type of `S` | LL | struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `S` --> $DIR/issue-103790.rs:4:1 @@ -58,6 +59,7 @@ LL | | struct S; LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 4 previous errors diff --git a/tests/ui/consts/issue-28113.rs b/tests/ui/consts/issue-28113.rs index e45c009d6..f8131c9f3 100644 --- a/tests/ui/consts/issue-28113.rs +++ b/tests/ui/consts/issue-28113.rs @@ -3,7 +3,6 @@ const X: u8 = || -> u8 { 5 }() //~^ ERROR cannot call non-const closure - //~| ERROR the trait bound ; fn main() {} diff --git a/tests/ui/consts/issue-28113.stderr b/tests/ui/consts/issue-28113.stderr index e177a3585..1294cc99b 100644 --- a/tests/ui/consts/issue-28113.stderr +++ b/tests/ui/consts/issue-28113.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-28113.rs:4:5: 4:13]: Fn<()>` is not satisfied - --> $DIR/issue-28113.rs:4:5 - | -LL | || -> u8 { 5 }() - | ^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-28113.rs:4:5: 4:13]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-28113.rs:4:5: 4:13]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-28113.rs:4:5: 4:13]`, but that implementation is not `const` - --> $DIR/issue-28113.rs:4:5 - | -LL | || -> u8 { 5 }() - | ^^^^^^^^^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-28113.rs:4:5: 4:13]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/issue-28113.rs:4:5 | @@ -22,7 +8,6 @@ LL | || -> u8 { 5 }() = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-36163.stderr b/tests/ui/consts/issue-36163.stderr index 7137c0538..190b41062 100644 --- a/tests/ui/consts/issue-36163.stderr +++ b/tests/ui/consts/issue-36163.stderr @@ -15,6 +15,7 @@ note: cycle used when simplifying constant for the type system `Foo::B::{constan | LL | B = A, | ^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/consts/issue-44415.stderr b/tests/ui/consts/issue-44415.stderr index ec64b956d..01d24a620 100644 --- a/tests/ui/consts/issue-44415.stderr +++ b/tests/ui/consts/issue-44415.stderr @@ -23,6 +23,7 @@ note: cycle used when checking that `Foo` is well-formed | LL | struct Foo { | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/consts/issue-56164.rs b/tests/ui/consts/issue-56164.rs index 00875c4b5..22c257d0b 100644 --- a/tests/ui/consts/issue-56164.rs +++ b/tests/ui/consts/issue-56164.rs @@ -1,6 +1,5 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure -//~| ERROR the trait bound const fn bad(input: fn()) { input() diff --git a/tests/ui/consts/issue-56164.stderr b/tests/ui/consts/issue-56164.stderr index e46c649fa..1b267214a 100644 --- a/tests/ui/consts/issue-56164.stderr +++ b/tests/ui/consts/issue-56164.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-56164.rs:1:19: 1:21]: Fn<()>` is not satisfied - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-56164.rs:1:19: 1:21]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-56164.rs:1:19: 1:21]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-56164.rs:1:19: 1:21]`, but that implementation is not `const` - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-56164.rs:1:19: 1:21]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constant functions --> $DIR/issue-56164.rs:1:18 | @@ -23,12 +9,11 @@ LL | const fn foo() { (||{})() } = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable error: function pointer calls are not allowed in constant functions - --> $DIR/issue-56164.rs:6:5 + --> $DIR/issue-56164.rs:5:5 | LL | input() | ^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-68542-closure-in-array-len.rs b/tests/ui/consts/issue-68542-closure-in-array-len.rs index a88e0cc60..37958e791 100644 --- a/tests/ui/consts/issue-68542-closure-in-array-len.rs +++ b/tests/ui/consts/issue-68542-closure-in-array-len.rs @@ -4,7 +4,6 @@ struct Bug { a: [(); (|| { 0 })()] //~ ERROR cannot call non-const closure - //~^ ERROR the trait bound } fn main() {} diff --git a/tests/ui/consts/issue-68542-closure-in-array-len.stderr b/tests/ui/consts/issue-68542-closure-in-array-len.stderr index ace62f09d..d23513ed7 100644 --- a/tests/ui/consts/issue-68542-closure-in-array-len.stderr +++ b/tests/ui/consts/issue-68542-closure-in-array-len.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]: Fn<()>` is not satisfied - --> $DIR/issue-68542-closure-in-array-len.rs:6:13 - | -LL | a: [(); (|| { 0 })()] - | ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`, but that implementation is not `const` - --> $DIR/issue-68542-closure-in-array-len.rs:6:13 - | -LL | a: [(); (|| { 0 })()] - | ^^^^^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/issue-68542-closure-in-array-len.rs:6:13 | @@ -22,7 +8,6 @@ LL | a: [(); (|| { 0 })()] = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-73976-monomorphic.stderr b/tests/ui/consts/issue-73976-monomorphic.stderr index 09661d3f3..b23796db4 100644 --- a/tests/ui/consts/issue-73976-monomorphic.stderr +++ b/tests/ui/consts/issue-73976-monomorphic.stderr @@ -1,16 +1,3 @@ -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/issue-73976-monomorphic.rs:21:5 - | -LL | GetTypeId::::VALUE == GetTypeId::::VALUE - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` - | - = help: the trait `~const PartialEq` is not implemented for `TypeId` -note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/issue-73976-monomorphic.rs:21:5 - | -LL | GetTypeId::::VALUE == GetTypeId::::VALUE - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/issue-73976-monomorphic.rs:21:5 | @@ -21,7 +8,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-83182.rs b/tests/ui/consts/issue-83182.rs deleted file mode 100644 index b62f903bd..000000000 --- a/tests/ui/consts/issue-83182.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Strip out raw byte dumps to make comparison platform-independent: -// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" -// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" - -use std::mem; -struct MyStr(str); -const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; -//~^ ERROR: it is undefined behavior to use this value -fn main() {} diff --git a/tests/ui/consts/issue-83182.stderr b/tests/ui/consts/issue-83182.stderr deleted file mode 100644 index ca4e0f7aa..000000000 --- a/tests/ui/consts/issue-83182.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/issue-83182.rs:7:1 - | -LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs index 38c8129b8..2358175fe 100644 --- a/tests/ui/consts/issue-94675.rs +++ b/tests/ui/consts/issue-94675.rs @@ -1,3 +1,5 @@ +// known-bug: #103507 + #![feature(const_trait_impl, const_mut_refs)] struct Foo<'a> { @@ -7,9 +9,9 @@ struct Foo<'a> { impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec) { self.bar[0] = baz.len(); - //~^ ERROR: cannot call - //~| ERROR: cannot call - //~| ERROR: the trait bound + //FIXME ~^ ERROR: cannot call + //FIXME ~| ERROR: cannot call + //FIXME ~| ERROR: the trait bound } } diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr index b4e5db44e..f51f305ac 100644 --- a/tests/ui/consts/issue-94675.stderr +++ b/tests/ui/consts/issue-94675.stderr @@ -1,35 +1,21 @@ error[E0015]: cannot call non-const fn `Vec::::len` in constant functions - --> $DIR/issue-94675.rs:9:27 + --> $DIR/issue-94675.rs:11:27 | LL | self.bar[0] = baz.len(); | ^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0277]: the trait bound `Vec: ~const IndexMut` is not satisfied - --> $DIR/issue-94675.rs:9:9 - | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` - | - = help: the trait `~const IndexMut` is not implemented for `Vec` -note: the trait `IndexMut` is implemented for `Vec`, but that implementation is not `const` - --> $DIR/issue-94675.rs:9:9 - | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-94675.rs:9:9 + --> $DIR/issue-94675.rs:11:17 | LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ + | ^^^ | note: impl defined here, but it is not `const` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 67797e6fb..af0f77c67 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,7 +1,7 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: unable to turn pointer into raw bytes + = note: unable to turn pointer into integer | note: inside `std::ptr::read::` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.rs b/tests/ui/consts/miri_unleashed/ptr_arith.rs index 4d12960b8..5cda3c411 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.rs +++ b/tests/ui/consts/miri_unleashed/ptr_arith.rs @@ -1,5 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![feature(core_intrinsics)] +#![feature(core_intrinsics, pointer_byte_offsets)] // During CTFE, we prevent pointer-to-int casts. // Pointer comparisons are prevented in the trait system. @@ -15,7 +15,7 @@ static PTR_INT_TRANSMUTE: () = unsafe { let x: usize = std::mem::transmute(&0); let _v = x + 0; //~^ ERROR could not evaluate static initializer - //~| unable to turn pointer into raw bytes + //~| unable to turn pointer into integer }; // I'd love to test pointer comparison, but that is not possible since diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr index 30fd3a55e..25ca6bc4e 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr @@ -8,7 +8,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/ptr_arith.rs:16:14 | LL | let _v = x + 0; - | ^ unable to turn pointer into raw bytes + | ^ unable to turn pointer into integer | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/precise-drop-with-promoted.rs b/tests/ui/consts/precise-drop-with-promoted.rs index 6f2317a5a..0c0514dd9 100644 --- a/tests/ui/consts/precise-drop-with-promoted.rs +++ b/tests/ui/consts/precise-drop-with-promoted.rs @@ -1,6 +1,12 @@ // Regression test for issue #89938. -// check-pass // compile-flags: --crate-type=lib +// known-bug: #103507 +// failure-status: 101 +// normalize-stderr-test "note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" +// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +// rustc-env:RUST_BACKTRACE=0 + #![feature(const_precise_live_drops)] pub const fn f() { diff --git a/tests/ui/consts/precise-drop-with-promoted.stderr b/tests/ui/consts/precise-drop-with-promoted.stderr new file mode 100644 index 000000000..a56672048 --- /dev/null +++ b/tests/ui/consts/precise-drop-with-promoted.stderr @@ -0,0 +1,6 @@ +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `f` +#1 [analysis] running analysis passes on this crate +end of query stack diff --git a/tests/ui/consts/promoted_const_call.rs b/tests/ui/consts/promoted_const_call.rs index dae6cafae..d6e48266f 100644 --- a/tests/ui/consts/promoted_const_call.rs +++ b/tests/ui/consts/promoted_const_call.rs @@ -1,3 +1,5 @@ +// known-bug: #103507 + #![feature(const_mut_refs)] #![feature(const_trait_impl)] @@ -7,15 +9,15 @@ impl const Drop for Panic { fn drop(&mut self) { panic!(); } } pub const fn id(x: T) -> T { x } pub const C: () = { let _: &'static _ = &id(&Panic); - //~^ ERROR: temporary value dropped while borrowed - //~| ERROR: temporary value dropped while borrowed + //FIXME ~^ ERROR: temporary value dropped while borrowed + //FIXME ~| ERROR: temporary value dropped while borrowed }; fn main() { let _: &'static _ = &id(&Panic); - //~^ ERROR: temporary value dropped while borrowed - //~| ERROR: temporary value dropped while borrowed + //FIXME ~^ ERROR: temporary value dropped while borrowed + //FIXME ~| ERROR: temporary value dropped while borrowed let _: &'static _ = &&(Panic, 0).1; - //~^ ERROR: temporary value dropped while borrowed - //~| ERROR: temporary value dropped while borrowed + //FIXME~^ ERROR: temporary value dropped while borrowed + //FIXME~| ERROR: temporary value dropped while borrowed } diff --git a/tests/ui/consts/promoted_const_call.stderr b/tests/ui/consts/promoted_const_call.stderr index 1cbd8cbe6..1f6abc0ce 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr @@ -1,5 +1,13 @@ +error[E0493]: destructor of `Panic` cannot be evaluated at compile-time + --> $DIR/promoted_const_call.rs:11:30 + | +LL | let _: &'static _ = &id(&Panic); + | ^^^^^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:9:26 + --> $DIR/promoted_const_call.rs:11:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -10,7 +18,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:9:30 + --> $DIR/promoted_const_call.rs:11:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -19,7 +27,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:15:26 + --> $DIR/promoted_const_call.rs:17:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -30,7 +38,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:15:30 + --> $DIR/promoted_const_call.rs:17:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -39,7 +47,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:18:26 + --> $DIR/promoted_const_call.rs:20:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -50,7 +58,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:18:27 + --> $DIR/promoted_const_call.rs:20:27 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -60,6 +68,7 @@ LL | let _: &'static _ = &&(Panic, 0).1; LL | } | - temporary value is freed at the end of this statement -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0716`. +Some errors have detailed explanations: E0493, E0716. +For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/ptr_comparisons.rs b/tests/ui/consts/ptr_comparisons.rs index f442e6138..a5b6cd9d2 100644 --- a/tests/ui/consts/ptr_comparisons.rs +++ b/tests/ui/consts/ptr_comparisons.rs @@ -1,8 +1,5 @@ // compile-flags: --crate-type=lib -// normalize-stderr-32bit: "8 bytes" -> "$$TWO_WORDS bytes" -// normalize-stderr-64bit: "16 bytes" -> "$$TWO_WORDS bytes" -// normalize-stderr-32bit: "size 4" -> "size $$WORD" -// normalize-stderr-64bit: "size 8" -> "size $$WORD" +// check-pass #![feature( core_intrinsics, @@ -34,30 +31,13 @@ check!(ne, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0); // We want pointers to be equal to themselves, but aren't checking this yet because // there are some open questions (e.g. whether function pointers to the same function -// compare equal, they don't necessarily at runtime). -// The case tested here should work eventually, but does not work yet. +// compare equal: they don't necessarily do at runtime). check!(!, FOO as *const _, FOO as *const _); +// aside from 0, these pointers might end up pretty much anywhere. +check!(!, FOO as *const _, 1); // this one could be `ne` by taking into account alignment +check!(!, FOO as *const _, 1024); -/////////////////////////////////////////////////////////////////////////////// -// If any of the below start compiling, make sure to add a `check` test for it. -// These invocations exist as canaries so we don't forget to check that the -// behaviour of `guaranteed_eq` and `guaranteed_ne` is still correct. -// All of these try to obtain an out of bounds pointer in some manner. If we -// can create out of bounds pointers, we can offset a pointer far enough that -// at runtime it would be zero and at compile-time it would not be zero. - -const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; - -const _: *const u8 = - unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; -//~^ ERROR evaluation of constant value failed -//~| out-of-bounds - -const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; -//~^ ERROR evaluation of constant value failed -//~| unable to turn pointer into raw bytes - -const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; -//~^ ERROR evaluation of constant value failed -//~| unable to turn pointer into raw bytes +// When pointers go out-of-bounds, they *might* become null, so these comparions cannot work. +check!(!, unsafe { (FOO as *const usize).wrapping_add(2) }, 0); +check!(!, unsafe { (FOO as *const usize).wrapping_sub(1) }, 0); diff --git a/tests/ui/consts/ptr_comparisons.stderr b/tests/ui/consts/ptr_comparisons.stderr deleted file mode 100644 index fea924d12..000000000 --- a/tests/ui/consts/ptr_comparisons.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL - | - = note: out-of-bounds pointer arithmetic: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds - | -note: inside `ptr::const_ptr::::offset` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `_` - --> $DIR/ptr_comparisons.rs:50:34 - | -LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0080]: evaluation of constant value failed - --> $DIR/ptr_comparisons.rs:53:33 - | -LL | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: alloc3 has size $WORD, so pointer to 1000 bytes starting at offset 0 is out-of-bounds - -error[E0080]: evaluation of constant value failed - --> $DIR/ptr_comparisons.rs:57:27 - | -LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -error[E0080]: evaluation of constant value failed - --> $DIR/ptr_comparisons.rs:61:27 - | -LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/ptr_is_null.rs b/tests/ui/consts/ptr_is_null.rs index 8babb6858..43b9767db 100644 --- a/tests/ui/consts/ptr_is_null.rs +++ b/tests/ui/consts/ptr_is_null.rs @@ -2,6 +2,7 @@ // check-pass #![feature(const_ptr_is_null)] +#![allow(useless_ptr_null_checks)] const FOO: &usize = &42; diff --git a/tests/ui/consts/recursive-zst-static.default.stderr b/tests/ui/consts/recursive-zst-static.default.stderr index d68960b09..d592b5aee 100644 --- a/tests/ui/consts/recursive-zst-static.default.stderr +++ b/tests/ui/consts/recursive-zst-static.default.stderr @@ -19,6 +19,7 @@ LL | | fn main() { LL | | FOO LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/consts/recursive-zst-static.unleash.stderr b/tests/ui/consts/recursive-zst-static.unleash.stderr index d68960b09..d592b5aee 100644 --- a/tests/ui/consts/recursive-zst-static.unleash.stderr +++ b/tests/ui/consts/recursive-zst-static.unleash.stderr @@ -19,6 +19,7 @@ LL | | fn main() { LL | | FOO LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/consts/rustc-impl-const-stability.rs b/tests/ui/consts/rustc-impl-const-stability.rs index a1a741e80..2b67c2f2c 100644 --- a/tests/ui/consts/rustc-impl-const-stability.rs +++ b/tests/ui/consts/rustc-impl-const-stability.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] #![feature(staged_api)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![stable(feature = "foo", since = "1.0.0")] #[stable(feature = "potato", since = "1.27.0")] diff --git a/tests/ui/consts/rustc-impl-const-stability.stderr b/tests/ui/consts/rustc-impl-const-stability.stderr index e6930da71..ba8e6c155 100644 --- a/tests/ui/consts/rustc-impl-const-stability.stderr +++ b/tests/ui/consts/rustc-impl-const-stability.stderr @@ -7,5 +7,15 @@ LL | impl const Default for Data { = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` = note: adding a non-const method body in the future would be a breaking change -error: aborting due to previous error +error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates + --> $DIR/rustc-impl-const-stability.rs:15:6 + | +LL | impl const Default for Data { + | ^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.rs b/tests/ui/consts/unstable-const-fn-in-libcore.rs index ca4ed8f0b..61e28117e 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.rs +++ b/tests/ui/consts/unstable-const-fn-in-libcore.rs @@ -20,6 +20,7 @@ impl Opt { match self { Opt::Some(t) => t, Opt::None => f(), + //~^ ERROR cannot call } } } diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index e5b00dd07..95d7b7e85 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,3 +1,15 @@ +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/unstable-const-fn-in-libcore.rs:22:26 + | +LL | Opt::None => f(), + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | const fn unwrap_or_else T + ~const std::ops::FnOnce<()>>(self, f: F) -> T { + | +++++++++++++++++++++++++++++ + error[E0493]: destructor of `F` cannot be evaluated at compile-time --> $DIR/unstable-const-fn-in-libcore.rs:17:60 | @@ -16,6 +28,7 @@ LL | const fn unwrap_or_else T>(self, f: F) -> T { LL | } | - value is dropped here -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0493`. +Some errors have detailed explanations: E0015, E0493. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/write-to-static-mut-in-static.stderr b/tests/ui/consts/write-to-static-mut-in-static.stderr index 395b2d42f..5665e5643 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.stderr +++ b/tests/ui/consts/write-to-static-mut-in-static.stderr @@ -27,6 +27,7 @@ LL | | LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 2 previous errors diff --git a/tests/ui/cross-crate/auxiliary/static_init_aux.rs b/tests/ui/cross-crate/auxiliary/static_init_aux.rs index 3b664f436..5e172ef31 100644 --- a/tests/ui/cross-crate/auxiliary/static_init_aux.rs +++ b/tests/ui/cross-crate/auxiliary/static_init_aux.rs @@ -1,10 +1,14 @@ pub static V: &u32 = &X; pub static F: fn() = f; +pub static G: fn() = G0; static X: u32 = 42; +static G0: fn() = g; pub fn v() -> *const u32 { V } fn f() {} + +fn g() {} diff --git a/tests/ui/cross-crate/static-init.rs b/tests/ui/cross-crate/static-init.rs index 2e893c5d9..0b50c41fc 100644 --- a/tests/ui/cross-crate/static-init.rs +++ b/tests/ui/cross-crate/static-init.rs @@ -1,9 +1,11 @@ +// Regression test for #84455 and #115052. // run-pass // aux-build:static_init_aux.rs extern crate static_init_aux as aux; static V: &u32 = aux::V; static F: fn() = aux::F; +static G: fn() = aux::G; fn v() -> *const u32 { V @@ -12,4 +14,5 @@ fn v() -> *const u32 { fn main() { assert_eq!(aux::v(), crate::v()); F(); + G(); } diff --git a/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr index 9d715f494..3b66704d6 100644 --- a/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr +++ b/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr @@ -14,6 +14,7 @@ LL | | } LL | | LL | | fn main() { } | |_____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr index e2b2aac05..03cb5015a 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -12,6 +12,7 @@ LL | / trait Chromosome: Chromosome { LL | | LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr index c903e1146..c7cc31435 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr @@ -15,6 +15,7 @@ note: cycle used when computing the super predicates of `A` | LL | trait A: B { | ^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/cycle-trait/issue-12511.stderr b/tests/ui/cycle-trait/issue-12511.stderr index 558aad109..f5e4f8347 100644 --- a/tests/ui/cycle-trait/issue-12511.stderr +++ b/tests/ui/cycle-trait/issue-12511.stderr @@ -17,6 +17,7 @@ LL | / trait T1 : T2 { LL | | LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/debuginfo/sroa-fragment-debuginfo.rs b/tests/ui/debuginfo/sroa-fragment-debuginfo.rs new file mode 100644 index 000000000..9c3c359e3 --- /dev/null +++ b/tests/ui/debuginfo/sroa-fragment-debuginfo.rs @@ -0,0 +1,31 @@ +// Verify that we do not trigger a LLVM assertion by creating zero-sized DWARF fragments. +// +// build-pass +// compile-flags: -g -Zmir-opt-level=0 -Zmir-enable-passes=+ScalarReplacementOfAggregates +// compile-flags: -Cno-prepopulate-passes + +#![crate_type = "lib"] + +pub struct ExtraSlice<'input> { + slice: &'input [u8], + extra: u32, +} + +#[no_mangle] +pub fn extra(s: &[u8]) { + let slice = ExtraSlice { slice: s, extra: s.len() as u32 }; +} + +struct Zst; + +pub struct ZstSlice<'input> { + slice: &'input [u8], + extra: Zst, +} + +#[no_mangle] +pub fn zst(s: &[u8]) { + // The field `extra` is a ZST. The fragment for the field `slice` encompasses the whole + // variable, so is not a fragment. In that case, the variable must have no fragment. + let slice = ZstSlice { slice: s, extra: Zst }; +} diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index d6a2c80cc..6bfc859bf 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -798,14 +798,14 @@ impl ::core::marker::Copy for Enum0 { } #[automatically_derived] impl ::core::fmt::Debug for Enum0 { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - unsafe { ::core::intrinsics::unreachable() } + match *self {} } } #[automatically_derived] impl ::core::hash::Hash for Enum0 { #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { - unsafe { ::core::intrinsics::unreachable() } + match *self {} } } #[automatically_derived] @@ -813,9 +813,7 @@ impl ::core::marker::StructuralPartialEq for Enum0 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum0 { #[inline] - fn eq(&self, other: &Enum0) -> bool { - unsafe { ::core::intrinsics::unreachable() } - } + fn eq(&self, other: &Enum0) -> bool { match *self {} } } #[automatically_derived] impl ::core::marker::StructuralEq for Enum0 { } @@ -831,15 +829,13 @@ impl ::core::cmp::PartialOrd for Enum0 { #[inline] fn partial_cmp(&self, other: &Enum0) -> ::core::option::Option<::core::cmp::Ordering> { - unsafe { ::core::intrinsics::unreachable() } + match *self {} } } #[automatically_derived] impl ::core::cmp::Ord for Enum0 { #[inline] - fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering { - unsafe { ::core::intrinsics::unreachable() } - } + fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering { match *self {} } } // A single-variant enum. diff --git a/tests/ui/destructuring-assignment/slice_destructure_fail.rs b/tests/ui/destructuring-assignment/slice_destructure_fail.rs index 33b09eb34..e5bb50030 100644 --- a/tests/ui/destructuring-assignment/slice_destructure_fail.rs +++ b/tests/ui/destructuring-assignment/slice_destructure_fail.rs @@ -1,6 +1,8 @@ fn main() { - let (mut a, mut b); - [a, .., b, ..] = [0, 1]; //~ ERROR `..` can only be used once per slice pattern - [a, a, b] = [1, 2]; //~ ERROR pattern requires 3 elements but array has 2 - [_] = [1, 2]; //~ ERROR pattern requires 1 element but array has 2 + let (mut a, mut b); + [a, .., b, ..] = [0, 1]; //~ ERROR `..` can only be used once per slice pattern + [a, a, b] = [1, 2]; + //~^ ERROR pattern requires 3 elements but array has 2 + [_] = [1, 2]; + //~^ ERROR pattern requires 1 element but array has 2 } diff --git a/tests/ui/destructuring-assignment/slice_destructure_fail.stderr b/tests/ui/destructuring-assignment/slice_destructure_fail.stderr index 92c86feba..acf44ceb1 100644 --- a/tests/ui/destructuring-assignment/slice_destructure_fail.stderr +++ b/tests/ui/destructuring-assignment/slice_destructure_fail.stderr @@ -1,22 +1,22 @@ error: `..` can only be used once per slice pattern - --> $DIR/slice_destructure_fail.rs:3:14 + --> $DIR/slice_destructure_fail.rs:3:16 | -LL | [a, .., b, ..] = [0, 1]; - | -- ^^ can only be used once per slice pattern - | | - | previously used here +LL | [a, .., b, ..] = [0, 1]; + | -- ^^ can only be used once per slice pattern + | | + | previously used here error[E0527]: pattern requires 3 elements but array has 2 - --> $DIR/slice_destructure_fail.rs:4:3 + --> $DIR/slice_destructure_fail.rs:4:5 | -LL | [a, a, b] = [1, 2]; - | ^^^^^^^^^ expected 2 elements +LL | [a, a, b] = [1, 2]; + | ^^^^^^^^^ expected 2 elements error[E0527]: pattern requires 1 element but array has 2 - --> $DIR/slice_destructure_fail.rs:5:3 + --> $DIR/slice_destructure_fail.rs:6:5 | -LL | [_] = [1, 2]; - | ^^^ expected 2 elements +LL | [_] = [1, 2]; + | ^^^ expected 2 elements error: aborting due to 3 previous errors diff --git a/tests/ui/diagnostic-flags/colored-session-opt-error.rs b/tests/ui/diagnostic-flags/colored-session-opt-error.rs new file mode 100644 index 000000000..b9f47285c --- /dev/null +++ b/tests/ui/diagnostic-flags/colored-session-opt-error.rs @@ -0,0 +1,4 @@ +// check-pass +// ignore-windows +// compile-flags: -Cremark=foo --error-format=human --color always +fn main() {} diff --git a/tests/ui/diagnostic-flags/colored-session-opt-error.stderr b/tests/ui/diagnostic-flags/colored-session-opt-error.stderr new file mode 100644 index 000000000..ef79d5b0f --- /dev/null +++ b/tests/ui/diagnostic-flags/colored-session-opt-error.stderr @@ -0,0 +1,2 @@ +warning: -C remark requires "-C debuginfo=n" to show source locations + diff --git a/tests/ui/diagnostic-width/E0271.stderr b/tests/ui/diagnostic-width/E0271.stderr index 52f415037..c1b8b3207 100644 --- a/tests/ui/diagnostic-width/E0271.stderr +++ b/tests/ui/diagnostic-width/E0271.stderr @@ -15,8 +15,7 @@ note: expected this to be `Foo` | LL | type Error = E; | ^ - = note: required for the cast from `Box>` to `Box<(dyn Future + 'static)>` - = note: the full name for the source type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271/E0271.long-type-hash.txt' + = note: required for the cast from `Box>, ()>>, ()>>, ()>>` to `Box<(dyn Future + 'static)>` error: aborting due to previous error diff --git a/tests/ui/diagnostic-width/long-E0308.rs b/tests/ui/diagnostic-width/long-E0308.rs index f021f1029..0ae5e19ab 100644 --- a/tests/ui/diagnostic-width/long-E0308.rs +++ b/tests/ui/diagnostic-width/long-E0308.rs @@ -1,4 +1,4 @@ -// compile-flags: --diagnostic-width=60 +// compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes // normalize-stderr-test: "long-type-\d+" -> "long-type-hash" mod a { diff --git a/tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs b/tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs new file mode 100644 index 000000000..759c32c84 --- /dev/null +++ b/tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs @@ -0,0 +1,12 @@ +// force-host +// no-prefer-dynamic +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn diagnostic(i: TokenStream, _: TokenStream) -> TokenStream { + i +} diff --git a/tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs b/tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs new file mode 100644 index 000000000..08b4d6877 --- /dev/null +++ b/tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs @@ -0,0 +1,13 @@ +// check-pass + +mod diagnostic {} + +macro_rules! diagnostic{ + () => {} +} + +#[allow(non_upper_case_globals)] +const diagnostic: () = (); + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/existing_proc_macros.rs b/tests/ui/diagnostic_namespace/existing_proc_macros.rs new file mode 100644 index 000000000..d6d1fb014 --- /dev/null +++ b/tests/ui/diagnostic_namespace/existing_proc_macros.rs @@ -0,0 +1,24 @@ +#![feature(diagnostic_namespace)] +// check-pass +// aux-build:proc-macro-helper.rs + +extern crate proc_macro_helper; + +mod test1 { + use proc_macro_helper::diagnostic; + + #[diagnostic] + struct Foo; + +} + +mod test2 { + mod diagnostic { + pub use proc_macro_helper::diagnostic as on_unimplemented; + } + + #[diagnostic::on_unimplemented] + trait Foo {} +} + +fn main() {} diff --git a/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs new file mode 100644 index 000000000..a686ed9c8 --- /dev/null +++ b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs @@ -0,0 +1,13 @@ +#[diagnostic::non_existing_attribute] +//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658] +//~|WARNING unknown diagnostic attribute [unknown_diagnostic_attributes] +pub trait Bar { +} + +#[diagnostic::non_existing_attribute(with_option = "foo")] +//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658] +//~|WARNING unknown diagnostic attribute [unknown_diagnostic_attributes] +struct Foo; + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr new file mode 100644 index 000000000..45c95cbb3 --- /dev/null +++ b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr @@ -0,0 +1,35 @@ +error[E0658]: `#[diagnostic]` attribute name space is experimental + --> $DIR/feature-gate-diagnostic_namespace.rs:1:3 + | +LL | #[diagnostic::non_existing_attribute] + | ^^^^^^^^^^ + | + = note: see issue #94785 for more information + = help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable + +error[E0658]: `#[diagnostic]` attribute name space is experimental + --> $DIR/feature-gate-diagnostic_namespace.rs:7:3 + | +LL | #[diagnostic::non_existing_attribute(with_option = "foo")] + | ^^^^^^^^^^ + | + = note: see issue #94785 for more information + = help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable + +warning: unknown diagnostic attribute + --> $DIR/feature-gate-diagnostic_namespace.rs:1:15 + | +LL | #[diagnostic::non_existing_attribute] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_diagnostic_attributes)]` on by default + +warning: unknown diagnostic attribute + --> $DIR/feature-gate-diagnostic_namespace.rs:7:15 + | +LL | #[diagnostic::non_existing_attribute(with_option = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors; 2 warnings emitted + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs new file mode 100644 index 000000000..677bd5a73 --- /dev/null +++ b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs @@ -0,0 +1,13 @@ +#![feature(diagnostic_namespace)] +// check-pass +#[diagnostic::non_existing_attribute] +//~^WARN unknown diagnostic attribute +pub trait Bar { +} + +#[diagnostic::non_existing_attribute(with_option = "foo")] +//~^WARN unknown diagnostic attribute +struct Foo; + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr new file mode 100644 index 000000000..4f9b7ba2b --- /dev/null +++ b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr @@ -0,0 +1,16 @@ +warning: unknown diagnostic attribute + --> $DIR/non_existing_attributes_accepted.rs:3:15 + | +LL | #[diagnostic::non_existing_attribute] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_diagnostic_attributes)]` on by default + +warning: unknown diagnostic attribute + --> $DIR/non_existing_attributes_accepted.rs:8:15 + | +LL | #[diagnostic::non_existing_attribute(with_option = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: 2 warnings emitted + diff --git a/tests/ui/diagnostic_namespace/requires_path.rs b/tests/ui/diagnostic_namespace/requires_path.rs new file mode 100644 index 000000000..e8d6ca73a --- /dev/null +++ b/tests/ui/diagnostic_namespace/requires_path.rs @@ -0,0 +1,9 @@ +#![feature(diagnostic_namespace)] + +#[diagnostic] +//~^ERROR cannot find attribute `diagnostic` in this scope +pub struct Bar; + + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/requires_path.stderr b/tests/ui/diagnostic_namespace/requires_path.stderr new file mode 100644 index 000000000..ce867621d --- /dev/null +++ b/tests/ui/diagnostic_namespace/requires_path.stderr @@ -0,0 +1,8 @@ +error: cannot find attribute `diagnostic` in this scope + --> $DIR/requires_path.rs:3:3 + | +LL | #[diagnostic] + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/did_you_mean/compatible-variants.stderr b/tests/ui/did_you_mean/compatible-variants.stderr index 7b88d93ea..f2bbd8ced 100644 --- a/tests/ui/did_you_mean/compatible-variants.stderr +++ b/tests/ui/did_you_mean/compatible-variants.stderr @@ -61,6 +61,8 @@ LL + Some(()) error[E0308]: `?` operator has incompatible types --> $DIR/compatible-variants.rs:35:5 | +LL | fn d() -> Option<()> { + | ---------- expected `Option<()>` because of return type LL | c()? | ^^^^ expected `Option<()>`, found `()` | diff --git a/tests/ui/did_you_mean/issue-114112.rs b/tests/ui/did_you_mean/issue-114112.rs new file mode 100644 index 000000000..0fde12ecd --- /dev/null +++ b/tests/ui/did_you_mean/issue-114112.rs @@ -0,0 +1,11 @@ +enum E { + A(T) +} + +fn main() { + match E::::A(1) { + E::A(v) => { //~ ERROR generic args in patterns require the turbofish syntax + println!("{v:?}"); + }, + } +} diff --git a/tests/ui/did_you_mean/issue-114112.stderr b/tests/ui/did_you_mean/issue-114112.stderr new file mode 100644 index 000000000..d76b5f72e --- /dev/null +++ b/tests/ui/did_you_mean/issue-114112.stderr @@ -0,0 +1,13 @@ +error: generic args in patterns require the turbofish syntax + --> $DIR/issue-114112.rs:7:10 + | +LL | E::A(v) => { + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | E::::A(v) => { + | ++ + +error: aborting due to previous error + diff --git a/tests/ui/did_you_mean/issue-34126.stderr b/tests/ui/did_you_mean/issue-34126.stderr index 5343acea4..9f7920706 100644 --- a/tests/ui/did_you_mean/issue-34126.stderr +++ b/tests/ui/did_you_mean/issue-34126.stderr @@ -19,9 +19,8 @@ error[E0502]: cannot borrow `self` as mutable because it is also borrowed as imm --> $DIR/issue-34126.rs:6:18 | LL | self.run(&mut self); - | ---------^^^^^^^^^- - | | | | - | | | mutable borrow occurs here + | ---- --- ^^^^^^^^^ mutable borrow occurs here + | | | | | immutable borrow later used by call | immutable borrow occurs here diff --git a/tests/ui/did_you_mean/issue-35937.stderr b/tests/ui/did_you_mean/issue-35937.stderr index 1670da559..3081f2cec 100644 --- a/tests/ui/did_you_mean/issue-35937.stderr +++ b/tests/ui/did_you_mean/issue-35937.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable --> $DIR/issue-35937.rs:7:5 | LL | f.v.push("cat".to_string()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/did_you_mean/issue-38147-1.stderr b/tests/ui/did_you_mean/issue-38147-1.stderr index 74fb1c2ec..790ad54a5 100644 --- a/tests/ui/did_you_mean/issue-38147-1.stderr +++ b/tests/ui/did_you_mean/issue-38147-1.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc --> $DIR/issue-38147-1.rs:17:9 | LL | self.s.push('x'); - | ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/did_you_mean/issue-38147-2.stderr b/tests/ui/did_you_mean/issue-38147-2.stderr index 7c287a7db..d708be3d3 100644 --- a/tests/ui/did_you_mean/issue-38147-2.stderr +++ b/tests/ui/did_you_mean/issue-38147-2.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc --> $DIR/issue-38147-2.rs:9:9 | LL | self.s.push('x'); - | ^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*self.longer_name` as mutable, as it is behind a `& --> $DIR/issue-38147-2.rs:12:9 | LL | self.longer_name.push(13); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^^^^^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/did_you_mean/issue-38147-3.stderr b/tests/ui/did_you_mean/issue-38147-3.stderr index 94ffe17f1..5b32b5a78 100644 --- a/tests/ui/did_you_mean/issue-38147-3.stderr +++ b/tests/ui/did_you_mean/issue-38147-3.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc --> $DIR/issue-38147-3.rs:7:9 | LL | self.s.push('x'); - | ^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/did_you_mean/issue-38147-4.stderr b/tests/ui/did_you_mean/issue-38147-4.stderr index 43647fa56..38ab3c54d 100644 --- a/tests/ui/did_you_mean/issue-38147-4.stderr +++ b/tests/ui/did_you_mean/issue-38147-4.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-4.rs:6:5 | LL | f.s.push('x'); - | ^^^^^^^^^^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/did_you_mean/issue-40823.stderr b/tests/ui/did_you_mean/issue-40823.stderr index ba94a5702..6f1ed3554 100644 --- a/tests/ui/did_you_mean/issue-40823.stderr +++ b/tests/ui/did_you_mean/issue-40823.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference --> $DIR/issue-40823.rs:3:5 | LL | buf.iter_mut(); - | ^^^^^^^^^^^^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/dropck/drop-with-active-borrows-1.stderr b/tests/ui/dropck/drop-with-active-borrows-1.stderr index 4585b2297..0409ffa02 100644 --- a/tests/ui/dropck/drop-with-active-borrows-1.stderr +++ b/tests/ui/dropck/drop-with-active-borrows-1.stderr @@ -4,7 +4,7 @@ error[E0505]: cannot move out of `a` because it is borrowed LL | let a = "".to_string(); | - binding `a` declared here LL | let b: Vec<&str> = a.lines().collect(); - | --------- borrow of `a` occurs here + | - borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here LL | for s in &b { diff --git a/tests/ui/dropck/drop-with-active-borrows-2.stderr b/tests/ui/dropck/drop-with-active-borrows-2.stderr index 24650dfac..ffec9306b 100644 --- a/tests/ui/dropck/drop-with-active-borrows-2.stderr +++ b/tests/ui/dropck/drop-with-active-borrows-2.stderr @@ -2,7 +2,7 @@ error[E0515]: cannot return value referencing local variable `raw_lines` --> $DIR/drop-with-active-borrows-2.rs:3:5 | LL | raw_lines.iter().map(|l| l.trim()).collect() - | ----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | returns a value referencing data owned by the current function | `raw_lines` is borrowed here diff --git a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr index 3b506c7e7..3ef11e2c0 100644 --- a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr +++ b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr @@ -15,10 +15,10 @@ LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply | ~~~~~~~~~~~~~~~~~~~~~~ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:32:13 + --> $DIR/explicit-drop-bounds.rs:32:18 | LL | fn drop(&mut self) {} - | ^^^^^^^^^ the trait `Copy` is not implemented for `T` + | ^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 diff --git a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr index 832af3e52..8138b86dd 100644 --- a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr +++ b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr @@ -15,10 +15,10 @@ LL | impl Drop for DropMe | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:40:13 + --> $DIR/explicit-drop-bounds.rs:40:18 | LL | fn drop(&mut self) {} - | ^^^^^^^^^ the trait `Copy` is not implemented for `T` + | ^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 diff --git a/tests/ui/dst/issue-113447.fixed b/tests/ui/dst/issue-113447.fixed new file mode 100644 index 000000000..536f680f6 --- /dev/null +++ b/tests/ui/dst/issue-113447.fixed @@ -0,0 +1,25 @@ +// run-rustfix + +pub struct Bytes; + +impl Bytes { + pub fn as_slice(&self) -> &[u8] { + todo!() + } +} + +impl PartialEq<[u8]> for Bytes { + fn eq(&self, other: &[u8]) -> bool { + self.as_slice() == other + } +} + +impl PartialEq for &[u8] { + fn eq(&self, other: &Bytes) -> bool { + *other == **self + } +} + +fn main() { + let _ = &[0u8] == &[0xAA][..]; //~ ERROR can't compare `&[u8; 1]` with `[{integer}; 1]` +} diff --git a/tests/ui/dst/issue-113447.rs b/tests/ui/dst/issue-113447.rs new file mode 100644 index 000000000..c10a4f2ff --- /dev/null +++ b/tests/ui/dst/issue-113447.rs @@ -0,0 +1,25 @@ +// run-rustfix + +pub struct Bytes; + +impl Bytes { + pub fn as_slice(&self) -> &[u8] { + todo!() + } +} + +impl PartialEq<[u8]> for Bytes { + fn eq(&self, other: &[u8]) -> bool { + self.as_slice() == other + } +} + +impl PartialEq for &[u8] { + fn eq(&self, other: &Bytes) -> bool { + *other == **self + } +} + +fn main() { + let _ = &[0u8] == [0xAA]; //~ ERROR can't compare `&[u8; 1]` with `[{integer}; 1]` +} diff --git a/tests/ui/dst/issue-113447.stderr b/tests/ui/dst/issue-113447.stderr new file mode 100644 index 000000000..240553a67 --- /dev/null +++ b/tests/ui/dst/issue-113447.stderr @@ -0,0 +1,25 @@ +error[E0277]: can't compare `&[u8; 1]` with `[{integer}; 1]` + --> $DIR/issue-113447.rs:24:20 + | +LL | let _ = &[0u8] == [0xAA]; + | ^^ no implementation for `&[u8; 1] == [{integer}; 1]` + | + = help: the trait `PartialEq<[{integer}; 1]>` is not implemented for `&[u8; 1]` + = help: the following other types implement trait `PartialEq`: + <[A; N] as PartialEq<[B; N]>> + <[A; N] as PartialEq<[B]>> + <[A; N] as PartialEq<&[B]>> + <[A; N] as PartialEq<&mut [B]>> + <[T] as PartialEq>> + <[A] as PartialEq<[B]>> + <[B] as PartialEq<[A; N]>> + <&[u8] as PartialEq> + and 4 others +help: convert the array to a `&[u8]` slice instead + | +LL | let _ = &[0u8] == &[0xAA][..]; + | + ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.rs b/tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.rs new file mode 100644 index 000000000..c6ef8379f --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.rs @@ -0,0 +1,13 @@ +trait Test {} +impl Test for &[u8] {} + +fn needs_test() -> T { + panic!() +} + +fn main() { + needs_test::<[u8; 1]>(); + //~^ ERROR the trait bound + let x: [u8; 1] = needs_test(); + //~^ ERROR the trait bound +} diff --git a/tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.stderr b/tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.stderr new file mode 100644 index 000000000..6752a4844 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-not-suggestion-110063.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `[u8; 1]: Test` is not satisfied + --> $DIR/issue-90528-unsizing-not-suggestion-110063.rs:9:18 + | +LL | needs_test::<[u8; 1]>(); + | ^^^^^^^ the trait `Test` is not implemented for `[u8; 1]` + | + = help: the trait `Test` is implemented for `&[u8]` +note: required by a bound in `needs_test` + --> $DIR/issue-90528-unsizing-not-suggestion-110063.rs:4:18 + | +LL | fn needs_test() -> T { + | ^^^^ required by this bound in `needs_test` + +error[E0277]: the trait bound `[u8; 1]: Test` is not satisfied + --> $DIR/issue-90528-unsizing-not-suggestion-110063.rs:11:22 + | +LL | let x: [u8; 1] = needs_test(); + | ^^^^^^^^^^ the trait `Test` is not implemented for `[u8; 1]` + | + = help: the trait `Test` is implemented for `&[u8]` +note: required by a bound in `needs_test` + --> $DIR/issue-90528-unsizing-not-suggestion-110063.rs:4:18 + | +LL | fn needs_test() -> T { + | ^^^^ required by this bound in `needs_test` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/llvm-old-style-ptrs.rs b/tests/ui/dyn-star/llvm-old-style-ptrs.rs deleted file mode 100644 index d35519632..000000000 --- a/tests/ui/dyn-star/llvm-old-style-ptrs.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -// compile-flags: -Copt-level=0 -Cllvm-args=-opaque-pointers=0 - -// (opaque-pointers flag is called force-opaque-pointers in LLVM 13...) -// min-llvm-version: 14.0 - -// This test can be removed once non-opaque pointers are gone from LLVM, maybe. - -#![feature(dyn_star, pointer_like_trait)] -#![allow(incomplete_features)] - -use std::fmt::Debug; -use std::marker::PointerLike; - -fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a { - t as _ -} - -fn main() { - println!("{:?}", make_dyn_star(Box::new(1i32))); - println!("{:?}", make_dyn_star(2usize)); - println!("{:?}", make_dyn_star((3usize,))); -} diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr index 902053ecf..b982be451 100644 --- a/tests/ui/dyn-star/param-env-region-infer.current.stderr +++ b/tests/ui/dyn-star/param-env-region-infer.current.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/param-env-region-infer.rs:18:10 + --> $DIR/param-env-region-infer.rs:19:10 | LL | t as _ | ^ cannot infer type diff --git a/tests/ui/dyn-star/param-env-region-infer.next.stderr b/tests/ui/dyn-star/param-env-region-infer.next.stderr deleted file mode 100644 index dd724a659..000000000 --- a/tests/ui/dyn-star/param-env-region-infer.next.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}` - --> $DIR/param-env-region-infer.rs:16:60 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires type-checking `make_dyn_star`... - --> $DIR/param-env-region-infer.rs:16:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing layout of `make_dyn_star::{opaque#0}`... - = note: ...which requires normalizing `make_dyn_star::{opaque#0}`... - = note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/param-env-region-infer.rs:10:1 - | -LL | / #![feature(dyn_star, pointer_like_trait)] -LL | | #![allow(incomplete_features)] -LL | | -LL | | use std::fmt::Debug; -... | -LL | | -LL | | fn main() {} - | |____________^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/dyn-star/param-env-region-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs index 537473abc..50dec94d2 100644 --- a/tests/ui/dyn-star/param-env-region-infer.rs +++ b/tests/ui/dyn-star/param-env-region-infer.rs @@ -1,9 +1,10 @@ -// revisions: current next -// Need `-Zdeduplicate-diagnostics=yes` because the number of cycle errors -// emitted is for some horrible reason platform-specific. -//[next] compile-flags: -Ztrait-solver=next -Zdeduplicate-diagnostics=yes +// revisions: current // incremental +// FIXME(-Ztrait-solver=next): THis currently results in unstable query results: +// `normalizes-to(opaque, opaque)` changes from `Maybe(Ambiguous)` to `Maybe(Overflow)` +// once the hidden type of the opaque is already defined to be itself. + // checks that we don't ICE if there are region inference variables in the environment // when computing `PointerLike` builtin candidates. diff --git a/tests/ui/error-codes/E0161.base.stderr b/tests/ui/error-codes/E0161.base.stderr index 15d98b657..ae82e6702 100644 --- a/tests/ui/error-codes/E0161.base.stderr +++ b/tests/ui/error-codes/E0161.base.stderr @@ -2,7 +2,7 @@ error[E0161]: cannot move a value of type `dyn Bar` --> $DIR/E0161.rs:16:5 | LL | x.f(); - | ^^^^^ the size of `dyn Bar` cannot be statically determined + | ^ the size of `dyn Bar` cannot be statically determined error: aborting due to previous error diff --git a/tests/ui/error-codes/E0275.stderr b/tests/ui/error-codes/E0275.stderr index 03c37d6f0..c702c3790 100644 --- a/tests/ui/error-codes/E0275.stderr +++ b/tests/ui/error-codes/E0275.stderr @@ -5,12 +5,11 @@ LL | impl Foo for T where Bar: Foo {} | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) -note: required for `Bar>>>>>>>>>>>>>>>>>>>>` to implement `Foo` +note: required for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` --> $DIR/E0275.rs:6:9 | LL | impl Foo for T where Bar: Foo {} | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/error-codes/E0275/E0275.long-type-hash.txt' = note: 126 redundant requirements hidden = note: required for `Bar` to implement `Foo` diff --git a/tests/ui/error-codes/E0283.stderr b/tests/ui/error-codes/E0283.stderr index 89e634a70..fa8d4b6e0 100644 --- a/tests/ui/error-codes/E0283.stderr +++ b/tests/ui/error-codes/E0283.stderr @@ -7,7 +7,7 @@ LL | fn create() -> u32; LL | let cont: u32 = Generator::create(); | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait | -help: use a fully-qualified path to a specific available implementation (2 found) +help: use a fully-qualified path to a specific available implementation | LL | let cont: u32 = ::create(); | +++++++++++++++++++ + diff --git a/tests/ui/error-codes/E0499.stderr b/tests/ui/error-codes/E0499.stderr index af5a1e186..d56baf722 100644 --- a/tests/ui/error-codes/E0499.stderr +++ b/tests/ui/error-codes/E0499.stderr @@ -7,7 +7,7 @@ LL | let mut a = &mut i; | ^^^^^^ second mutable borrow occurs here LL | a.use_mut(); LL | x.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to previous error diff --git a/tests/ui/error-codes/E0502.stderr b/tests/ui/error-codes/E0502.stderr index 94cc89754..cade6d718 100644 --- a/tests/ui/error-codes/E0502.stderr +++ b/tests/ui/error-codes/E0502.stderr @@ -6,7 +6,7 @@ LL | let ref y = a; LL | bar(a); | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff --git a/tests/ui/error-codes/E0503.stderr b/tests/ui/error-codes/E0503.stderr index 2f02e3b1a..275abb23f 100644 --- a/tests/ui/error-codes/E0503.stderr +++ b/tests/ui/error-codes/E0503.stderr @@ -6,7 +6,7 @@ LL | let _borrow = &mut value; LL | let _sum = value + 1; | ^^^^^ use of borrowed `value` LL | _borrow.use_mut(); - | ----------------- borrow later used here + | ------- borrow later used here error: aborting due to previous error diff --git a/tests/ui/error-codes/E0505.stderr b/tests/ui/error-codes/E0505.stderr index 2ecb4a75c..1a85e0317 100644 --- a/tests/ui/error-codes/E0505.stderr +++ b/tests/ui/error-codes/E0505.stderr @@ -9,7 +9,7 @@ LL | let _ref_to_val: &Value = &x; LL | eat(x); | ^ move out of `x` occurs here LL | _ref_to_val.use_ref(); - | --------------------- borrow later used here + | ----------- borrow later used here error: aborting due to previous error diff --git a/tests/ui/error-codes/E0507.stderr b/tests/ui/error-codes/E0507.stderr index 03630f389..089939516 100644 --- a/tests/ui/error-codes/E0507.stderr +++ b/tests/ui/error-codes/E0507.stderr @@ -2,9 +2,8 @@ error[E0507]: cannot move out of dereference of `Ref<'_, TheDarkKnight>` --> $DIR/E0507.rs:12:5 | LL | x.borrow().nothing_is_true(); - | ^^^^^^^^^^^----------------- - | | | - | | value moved due to this method call + | ^^^^^^^^^^ ----------------- value moved due to this method call + | | | move occurs because value has type `TheDarkKnight`, which does not implement the `Copy` trait | note: `TheDarkKnight::nothing_is_true` takes ownership of the receiver `self`, which moves value diff --git a/tests/ui/error-codes/E0608.stderr b/tests/ui/error-codes/E0608.stderr index 3aec50993..f23f9977b 100644 --- a/tests/ui/error-codes/E0608.stderr +++ b/tests/ui/error-codes/E0608.stderr @@ -1,8 +1,8 @@ error[E0608]: cannot index into a value of type `u8` - --> $DIR/E0608.rs:2:5 + --> $DIR/E0608.rs:2:8 | LL | 0u8[2]; - | ^^^^^^ + | ^^^ error: aborting due to previous error diff --git a/tests/ui/error-codes/E0790.stderr b/tests/ui/error-codes/E0790.stderr index 724876628..f559abae3 100644 --- a/tests/ui/error-codes/E0790.stderr +++ b/tests/ui/error-codes/E0790.stderr @@ -63,7 +63,7 @@ LL | fn my_fn(); LL | MyTrait2::my_fn(); | ^^^^^^^^^^^^^^^ cannot call associated function of trait | -help: use a fully-qualified path to a specific available implementation (2 found) +help: use a fully-qualified path to a specific available implementation | LL | ::my_fn(); | +++++++++++++++++++ + diff --git a/tests/ui/extern/extern-thiscall.rs b/tests/ui/extern/extern-thiscall.rs index 717df57ec..c491c156a 100644 --- a/tests/ui/extern/extern-thiscall.rs +++ b/tests/ui/extern/extern-thiscall.rs @@ -1,8 +1,6 @@ // run-pass // only-x86 -#![feature(abi_thiscall)] - trait A { extern "thiscall" fn test1(i: i32); } diff --git a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs new file mode 100644 index 000000000..7755a46da --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs @@ -0,0 +1,33 @@ +// needs-llvm-components: riscv +// compile-flags: --target=riscv32imc-unknown-none-elf --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang = "sized"] +trait Sized {} + +// Test that the riscv interrupt ABIs cannot be used when riscv_interrupt +// feature gate is not used. + +extern "riscv-interrupt-m" fn f() {} +//~^ ERROR riscv-interrupt ABIs are experimental +extern "riscv-interrupt-s" fn f_s() {} +//~^ ERROR riscv-interrupt ABIs are experimental + +trait T { + extern "riscv-interrupt-m" fn m(); + //~^ ERROR riscv-interrupt ABIs are experimental +} + +struct S; +impl T for S { + extern "riscv-interrupt-m" fn m() {} + //~^ ERROR riscv-interrupt ABIs are experimental +} + +impl S { + extern "riscv-interrupt-m" fn im() {} + //~^ ERROR riscv-interrupt ABIs are experimental +} + +type TA = extern "riscv-interrupt-m" fn(); +//~^ ERROR riscv-interrupt ABIs are experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr new file mode 100644 index 000000000..60c7fa0ea --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr @@ -0,0 +1,57 @@ +error[E0658]: riscv-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-riscv-interrupt.rs:11:8 + | +LL | extern "riscv-interrupt-m" fn f() {} + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #111889 for more information + = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable + +error[E0658]: riscv-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-riscv-interrupt.rs:13:8 + | +LL | extern "riscv-interrupt-s" fn f_s() {} + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #111889 for more information + = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable + +error[E0658]: riscv-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-riscv-interrupt.rs:17:12 + | +LL | extern "riscv-interrupt-m" fn m(); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #111889 for more information + = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable + +error[E0658]: riscv-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-riscv-interrupt.rs:23:12 + | +LL | extern "riscv-interrupt-m" fn m() {} + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #111889 for more information + = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable + +error[E0658]: riscv-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-riscv-interrupt.rs:28:12 + | +LL | extern "riscv-interrupt-m" fn im() {} + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #111889 for more information + = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable + +error[E0658]: riscv-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-riscv-interrupt.rs:32:18 + | +LL | type TA = extern "riscv-interrupt-m" fn(); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #111889 for more information + = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs new file mode 100644 index 000000000..7529014ec --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs @@ -0,0 +1,4 @@ +#[cfg(relocation_model = "pic")] //~ ERROR +fn _foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr new file mode 100644 index 000000000..592768a42 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr @@ -0,0 +1,12 @@ +error[E0658]: `cfg(relocation_model)` is experimental and subject to change + --> $DIR/feature-gate-cfg-relocation-model.rs:1:7 + | +LL | #[cfg(relocation_model = "pic")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #114929 for more information + = help: add `#![feature(cfg_relocation_model)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr index 3bae23a4a..7de67da9b 100644 --- a/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr +++ b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr @@ -13,6 +13,15 @@ LL | let _: u8 = ::core::default::Default(); | ^^^^ maybe a missing crate `core`? | = help: consider adding `extern crate core` to use the `core` crate +help: consider importing this module + | +LL + use std::default; + | +help: if you import `default`, refer to it directly + | +LL - let _: u8 = ::core::default::Default(); +LL + let _: u8 = default::Default(); + | error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs index 7e8c1eb95..ae12495b5 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -1,10 +1,7 @@ // edition: 2021 -// revisions: cfg_current cfg_next no_current no_next -// [cfg_next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// [no_next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: cfg no -// [no_current] check-pass -// [no_next] check-pass +// [no] check-pass // Since we're not adding new syntax, `cfg`'d out RTN must pass. #![feature(async_fn_in_trait)] @@ -13,17 +10,12 @@ trait Trait { async fn m(); } -#[cfg(any(cfg_current, cfg_next))] +#[cfg(cfg)] fn foo>() {} -//[cfg_current]~^ ERROR return type notation is experimental -//[cfg_current]~| ERROR parenthesized generic arguments cannot be used in associated type constraints -//[cfg_current]~| ERROR associated type `m` not found for `Trait` -//[cfg_next]~^^^^ ERROR return type notation is experimental -//[cfg_next]~| ERROR parenthesized generic arguments cannot be used in associated type constraints -//[cfg_next]~| ERROR associated type `m` not found for `Trait` -//[no_current]~^^^^^^^ WARN return type notation is experimental -//[no_current]~| WARN unstable syntax can change at any point in the future, causing a hard error! -//[no_next]~^^^^^^^^^ WARN return type notation is experimental -//[no_next]~| WARN unstable syntax can change at any point in the future, causing a hard error! +//[cfg]~^ ERROR return type notation is experimental +//[cfg]~| ERROR parenthesized generic arguments cannot be used in associated type constraints +//[cfg]~| ERROR associated type `m` not found for `Trait` +//[no]~^^^^ WARN return type notation is experimental +//[no]~| WARN unstable syntax can change at any point in the future, causing a hard error! fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-thiscall.rs b/tests/ui/feature-gates/feature-gate-thiscall.rs deleted file mode 100644 index 97a732bcf..000000000 --- a/tests/ui/feature-gates/feature-gate-thiscall.rs +++ /dev/null @@ -1,38 +0,0 @@ -// gate-test-abi_thiscall -// needs-llvm-components: x86 -// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -#![no_core] -#![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } - -// Test that the "thiscall" ABI is feature-gated, and cannot be used when -// the `abi_thiscall` feature gate is not used. - -extern "thiscall-unwind" fn fu() {} //~ ERROR thiscall-unwind ABI is experimental -extern "thiscall" fn f() {} //~ ERROR thiscall is experimental - -trait T { - extern "thiscall" fn m(); //~ ERROR thiscall is experimental - extern "thiscall-unwind" fn mu(); //~ ERROR thiscall-unwind ABI is experimental - - extern "thiscall" fn dm() {} //~ ERROR thiscall is experimental - extern "thiscall-unwind" fn dmu() {} //~ ERROR thiscall-unwind ABI is experimental -} - -struct S; -impl T for S { - extern "thiscall" fn m() {} //~ ERROR thiscall is experimental - extern "thiscall-unwind" fn mu() {} //~ ERROR thiscall-unwind ABI is experimental -} - -impl S { - extern "thiscall" fn im() {} //~ ERROR thiscall is experimental - extern "thiscall-unwind" fn imu() {} //~ ERROR thiscall-unwind ABI is experimental -} - -type TA = extern "thiscall" fn(); //~ ERROR thiscall is experimental -type TAU = extern "thiscall-unwind" fn(); //~ ERROR thiscall-unwind ABI is experimental - -extern "thiscall" {} //~ ERROR thiscall is experimental -extern "thiscall-unwind" {} //~ ERROR thiscall-unwind ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-thiscall.stderr b/tests/ui/feature-gates/feature-gate-thiscall.stderr deleted file mode 100644 index 346e45952..000000000 --- a/tests/ui/feature-gates/feature-gate-thiscall.stderr +++ /dev/null @@ -1,115 +0,0 @@ -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:12:8 - | -LL | extern "thiscall-unwind" fn fu() {} - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:13:8 - | -LL | extern "thiscall" fn f() {} - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:16:12 - | -LL | extern "thiscall" fn m(); - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:17:12 - | -LL | extern "thiscall-unwind" fn mu(); - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:19:12 - | -LL | extern "thiscall" fn dm() {} - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:20:12 - | -LL | extern "thiscall-unwind" fn dmu() {} - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:25:12 - | -LL | extern "thiscall" fn m() {} - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:26:12 - | -LL | extern "thiscall-unwind" fn mu() {} - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:30:12 - | -LL | extern "thiscall" fn im() {} - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:31:12 - | -LL | extern "thiscall-unwind" fn imu() {} - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:34:18 - | -LL | type TA = extern "thiscall" fn(); - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:35:19 - | -LL | type TAU = extern "thiscall-unwind" fn(); - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:37:8 - | -LL | extern "thiscall" {} - | ^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall.rs:38:8 - | -LL | extern "thiscall-unwind" {} - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs index dce94c9ea..134ea25b7 100644 --- a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs +++ b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs @@ -1,7 +1,7 @@ // edition:2018 -#![forbid(incomplete_features, unsafe_code)] +#![forbid(internal_features, unsafe_code)] #![feature(unsafe_pin_internals)] -//~^ ERROR the feature `unsafe_pin_internals` is incomplete and may not be safe to use +//~^ ERROR the feature `unsafe_pin_internals` is internal to the compiler or standard library use core::{marker::PhantomPinned, pin::Pin}; diff --git a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr index 4d0c931b4..39afbf2db 100644 --- a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr +++ b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr @@ -1,14 +1,15 @@ -error: the feature `unsafe_pin_internals` is incomplete and may not be safe to use and/or cause compiler crashes +error: the feature `unsafe_pin_internals` is internal to the compiler or standard library --> $DIR/feature-gate-unsafe_pin_internals.rs:3:12 | LL | #![feature(unsafe_pin_internals)] | ^^^^^^^^^^^^^^^^^^^^ | + = note: using it is strongly discouraged note: the lint level is defined here --> $DIR/feature-gate-unsafe_pin_internals.rs:2:11 | -LL | #![forbid(incomplete_features, unsafe_code)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![forbid(internal_features, unsafe_code)] + | ^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/feature-gates/print-with-path.cfg.stderr b/tests/ui/feature-gates/print-with-path.cfg.stderr new file mode 100644 index 000000000..a6c51baa3 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.cfg.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/feature-gates/print-with-path.rs b/tests/ui/feature-gates/print-with-path.rs new file mode 100644 index 000000000..f929c14c2 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.rs @@ -0,0 +1,7 @@ +// check-fail +// revisions: cfg target-features target-cpus +// [cfg]compile-flags: --print cfg=cfg.txt +// [target-cpus]compile-flags: --print target-cpu=target_cpu.txt +// [target-features]compile-flags: --print target-features=target_features.txt + +fn main() {} diff --git a/tests/ui/feature-gates/print-with-path.target-cpus.stderr b/tests/ui/feature-gates/print-with-path.target-cpus.stderr new file mode 100644 index 000000000..a6c51baa3 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.target-cpus.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/feature-gates/print-with-path.target-features.stderr b/tests/ui/feature-gates/print-with-path.target-features.stderr new file mode 100644 index 000000000..a6c51baa3 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.target-features.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/fmt/closing-brace-as-fill.rs b/tests/ui/fmt/closing-brace-as-fill.rs new file mode 100644 index 000000000..6ad257f94 --- /dev/null +++ b/tests/ui/fmt/closing-brace-as-fill.rs @@ -0,0 +1,8 @@ +// issue: 112732 + +// `}` is typoed since it is interpreted as a fill character rather than a closing bracket + +fn main() { + println!("Hello, world! {0:}<3", 2); + //~^ ERROR invalid format string: expected `'}'` but string was terminated +} diff --git a/tests/ui/fmt/closing-brace-as-fill.stderr b/tests/ui/fmt/closing-brace-as-fill.stderr new file mode 100644 index 000000000..aa1e5aff6 --- /dev/null +++ b/tests/ui/fmt/closing-brace-as-fill.stderr @@ -0,0 +1,12 @@ +error: invalid format string: expected `'}'` but string was terminated + --> $DIR/closing-brace-as-fill.rs:6:35 + | +LL | println!("Hello, world! {0:}<3", 2); + | - ^ expected `'}'` in format string + | | + | this is not interpreted as a formatting closing brace + | + = note: the character `'}'` is interpreted as a fill character because of the `:` that precedes it + +error: aborting due to previous error + diff --git a/tests/ui/fmt/format-string-error-2.stderr b/tests/ui/fmt/format-string-error-2.stderr index 76cdfbb93..dfd24bf60 100644 --- a/tests/ui/fmt/format-string-error-2.stderr +++ b/tests/ui/fmt/format-string-error-2.stderr @@ -10,7 +10,7 @@ error: invalid format string: expected `'}'`, found `'a'` LL | format!("{ | - because of this opening brace LL | a"); - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -21,7 +21,7 @@ LL | format!("{ \ | - because of this opening brace LL | \ LL | b"); - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -29,7 +29,7 @@ error: invalid format string: expected `'}'`, found `'\'` --> $DIR/format-string-error-2.rs:11:18 | LL | format!(r#"{ \ - | - ^ expected `}` in format string + | - ^ expected `'}'` in format string | | | because of this opening brace | @@ -39,7 +39,7 @@ error: invalid format string: expected `'}'`, found `'\'` --> $DIR/format-string-error-2.rs:15:18 | LL | format!(r#"{ \n - | - ^ expected `}` in format string + | - ^ expected `'}'` in format string | | | because of this opening brace | @@ -52,7 +52,7 @@ LL | format!("{ \n | - because of this opening brace LL | \n LL | e"); - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -62,7 +62,7 @@ error: invalid format string: expected `'}'`, found `'a'` LL | { | - because of this opening brace LL | a"); - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -72,7 +72,7 @@ error: invalid format string: expected `'}'`, found `'a'` LL | { | - because of this opening brace LL | a - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -83,7 +83,7 @@ LL | { \ | - because of this opening brace LL | \ LL | b"); - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -94,7 +94,7 @@ LL | { \ | - because of this opening brace LL | \ LL | b \ - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -102,7 +102,7 @@ error: invalid format string: expected `'}'`, found `'\'` --> $DIR/format-string-error-2.rs:45:8 | LL | raw { \ - | - ^ expected `}` in format string + | - ^ expected `'}'` in format string | | | because of this opening brace | @@ -112,7 +112,7 @@ error: invalid format string: expected `'}'`, found `'\'` --> $DIR/format-string-error-2.rs:50:8 | LL | raw { \n - | - ^ expected `}` in format string + | - ^ expected `'}'` in format string | | | because of this opening brace | @@ -125,7 +125,7 @@ LL | { \n | - because of this opening brace LL | \n LL | e"); - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` @@ -135,7 +135,7 @@ error: invalid format string: expected `'}'`, found `'a'` LL | { | - because of this opening brace LL | asdf} - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` diff --git a/tests/ui/fmt/format-string-error.stderr b/tests/ui/fmt/format-string-error.stderr index 8a32c2254..37a181e6f 100644 --- a/tests/ui/fmt/format-string-error.stderr +++ b/tests/ui/fmt/format-string-error.stderr @@ -62,7 +62,7 @@ error: invalid format string: expected `'}'`, found `'\'` --> $DIR/format-string-error.rs:19:23 | LL | let _ = format!("{\}"); - | -^ expected `}` in format string + | -^ expected `'}'` in format string | | | because of this opening brace | diff --git a/tests/ui/fmt/format-string-wrong-order.stderr b/tests/ui/fmt/format-string-wrong-order.stderr index 461af354a..0a2e04026 100644 --- a/tests/ui/fmt/format-string-wrong-order.stderr +++ b/tests/ui/fmt/format-string-wrong-order.stderr @@ -26,7 +26,7 @@ error: invalid format string: expected `'}'`, found `'?'` --> $DIR/format-string-wrong-order.rs:9:15 | LL | format!("{??}", bar); - | -^ expected `}` in format string + | -^ expected `'}'` in format string | | | because of this opening brace | @@ -36,7 +36,7 @@ error: invalid format string: expected `'}'`, found `'?'` --> $DIR/format-string-wrong-order.rs:11:15 | LL | format!("{?;bar}"); - | -^ expected `}` in format string + | -^ expected `'}'` in format string | | | because of this opening brace | diff --git a/tests/ui/fmt/ifmt-bad-arg.stderr b/tests/ui/fmt/ifmt-bad-arg.stderr index ed008c454..09ce3dca4 100644 --- a/tests/ui/fmt/ifmt-bad-arg.stderr +++ b/tests/ui/fmt/ifmt-bad-arg.stderr @@ -178,7 +178,7 @@ error: invalid format string: expected `'}'`, found `'t'` LL | ninth number: { | - because of this opening brace LL | tenth number: {}", - | ^ expected `}` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` diff --git a/tests/ui/fmt/suggest-inline-args.rs b/tests/ui/fmt/suggest-inline-args.rs new file mode 100644 index 000000000..515335ed9 --- /dev/null +++ b/tests/ui/fmt/suggest-inline-args.rs @@ -0,0 +1,28 @@ +mod foo { + pub fn bar() -> i32 { + 1 + } +} + +fn bar() -> i32 { + 2 +} + +fn main() { + let stderr = 3; + eprintln!({stderr}); + //~^ ERROR format argument must be a string literal + //~| HELP quote your inlined format argument to use as string literal + eprintln!({1}); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + eprintln!({foo::bar()}); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + eprintln!({bar()}); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + eprintln!({1; 2}); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with +} diff --git a/tests/ui/fmt/suggest-inline-args.stderr b/tests/ui/fmt/suggest-inline-args.stderr new file mode 100644 index 000000000..cf70568cf --- /dev/null +++ b/tests/ui/fmt/suggest-inline-args.stderr @@ -0,0 +1,57 @@ +error: format argument must be a string literal + --> $DIR/suggest-inline-args.rs:13:15 + | +LL | eprintln!({stderr}); + | ^^^^^^^^ + | +help: quote your inlined format argument to use as string literal + | +LL | eprintln!("{stderr}"); + | + + + +error: format argument must be a string literal + --> $DIR/suggest-inline-args.rs:16:15 + | +LL | eprintln!({1}); + | ^^^ + | +help: you might be missing a string literal to format with + | +LL | eprintln!("{}", {1}); + | +++++ + +error: format argument must be a string literal + --> $DIR/suggest-inline-args.rs:19:15 + | +LL | eprintln!({foo::bar()}); + | ^^^^^^^^^^^^ + | +help: you might be missing a string literal to format with + | +LL | eprintln!("{}", {foo::bar()}); + | +++++ + +error: format argument must be a string literal + --> $DIR/suggest-inline-args.rs:22:15 + | +LL | eprintln!({bar()}); + | ^^^^^^^ + | +help: you might be missing a string literal to format with + | +LL | eprintln!("{}", {bar()}); + | +++++ + +error: format argument must be a string literal + --> $DIR/suggest-inline-args.rs:25:15 + | +LL | eprintln!({1; 2}); + | ^^^^^^ + | +help: you might be missing a string literal to format with + | +LL | eprintln!("{}", {1; 2}); + | +++++ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr index d55efedfc..0955efdbb 100644 --- a/tests/ui/for/issue-20605.next.stderr +++ b/tests/ui/for/issue-20605.next.stderr @@ -34,12 +34,6 @@ error: the type `&mut as IntoIterator>::IntoIte LL | for item in *things { *item = 0 } | ^^^^^^^ -error[E0614]: type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced - --> $DIR/issue-20605.rs:5:27 - | -LL | for item in *things { *item = 0 } - | ^^^^^ - error[E0277]: the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time --> $DIR/issue-20605.rs:5:9 | @@ -66,6 +60,12 @@ LL | for item in *things { *item = 0 } note: required by a bound in `None` --> $SRC_DIR/core/src/option.rs:LL:COL +error[E0614]: type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced + --> $DIR/issue-20605.rs:5:27 + | +LL | for item in *things { *item = 0 } + | ^^^^^ + error: aborting due to 9 previous errors Some errors have detailed explanations: E0277, E0614. diff --git a/tests/ui/generator/auto-trait-regions.rs b/tests/ui/generator/auto-trait-regions.rs index fd13e4131..350f3cc34 100644 --- a/tests/ui/generator/auto-trait-regions.rs +++ b/tests/ui/generator/auto-trait-regions.rs @@ -26,7 +26,7 @@ fn assert_foo(f: T) {} fn main() { // Make sure 'static is erased for generator interiors so we can't match it in trait selection let x: &'static _ = &OnlyFooIfStaticRef(No); - let gen = || { + let gen = move || { let x = x; yield; assert_foo(x); @@ -36,7 +36,7 @@ fn main() { // Allow impls which matches any lifetime let x = &OnlyFooIfRef(No); - let gen = || { + let gen = move || { let x = x; yield; assert_foo(x); @@ -44,7 +44,7 @@ fn main() { assert_foo(gen); // ok // Disallow impls which relates lifetimes in the generator interior - let gen = || { + let gen = move || { let a = A(&mut true, &mut true, No); //~^ temporary value dropped while borrowed //~| temporary value dropped while borrowed diff --git a/tests/ui/generator/dropck-resume.stderr b/tests/ui/generator/dropck-resume.stderr index b0756eb55..ecf92e7e3 100644 --- a/tests/ui/generator/dropck-resume.stderr +++ b/tests/ui/generator/dropck-resume.stderr @@ -5,7 +5,7 @@ LL | let z = &mut y; | ------ mutable borrow occurs here ... LL | r = y.as_ref().unwrap(); - | ^^^^^^^^^^ immutable borrow occurs here + | ^ immutable borrow occurs here LL | LL | } | - mutable borrow might be used here, when `g` is dropped and runs the destructor for generator diff --git a/tests/ui/generator/dropck.stderr b/tests/ui/generator/dropck.stderr index b9a3a124a..246ac99f8 100644 --- a/tests/ui/generator/dropck.stderr +++ b/tests/ui/generator/dropck.stderr @@ -5,7 +5,7 @@ LL | let (mut gen, cell); | ---- binding `cell` declared here LL | cell = Box::new(RefCell::new(0)); LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - | ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^ borrowed value does not live long enough ... LL | } | - diff --git a/tests/ui/generator/issue-113279.rs b/tests/ui/generator/issue-113279.rs new file mode 100644 index 000000000..f69f804b7 --- /dev/null +++ b/tests/ui/generator/issue-113279.rs @@ -0,0 +1,27 @@ +#![feature(generators)] + +// `foo` attempts to dereference `""`, which results in an error being reported. Later, the +// generator transform for `foo` then produces a union which contains a `str` type - unions should +// not contain unsized types, but this is okay because an error has been reported already. +// When const propagation happens later in compilation, it attempts to compute the layout of the +// generator (as part of checking whether something can be const propagated) and in turn attempts +// to compute the layout of `str` in the context of a union - where this caused an ICE. This test +// makes sure that doesn't happen again. + +fn foo() { + let _y = static || { + let x = &mut 0; + *{ + yield; + x + } += match { *"" }.len() { + //~^ ERROR cannot move a value of type `str` [E0161] + //~^^ ERROR cannot move out of a shared reference [E0507] + _ => 0, + }; + }; +} + +fn main() { + foo() +} diff --git a/tests/ui/generator/issue-113279.stderr b/tests/ui/generator/issue-113279.stderr new file mode 100644 index 000000000..cc9b64ef9 --- /dev/null +++ b/tests/ui/generator/issue-113279.stderr @@ -0,0 +1,16 @@ +error[E0161]: cannot move a value of type `str` + --> $DIR/issue-113279.rs:17:20 + | +LL | } += match { *"" }.len() { + | ^^^^^^^ the size of `str` cannot be statically determined + +error[E0507]: cannot move out of a shared reference + --> $DIR/issue-113279.rs:17:22 + | +LL | } += match { *"" }.len() { + | ^^^ move occurs because value has type `str`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0161, E0507. +For more information about an error, try `rustc --explain E0161`. diff --git a/tests/ui/generic-associated-types/issue-102114.current.stderr b/tests/ui/generic-associated-types/issue-102114.current.stderr new file mode 100644 index 000000000..6e7a0b1f6 --- /dev/null +++ b/tests/ui/generic-associated-types/issue-102114.current.stderr @@ -0,0 +1,12 @@ +error[E0049]: type `B` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/issue-102114.rs:14:12 + | +LL | type B<'b>; + | -- expected 0 type parameters +... +LL | type B = Wrapper; + | ^ found 1 type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-associated-types/issue-102114.next.stderr b/tests/ui/generic-associated-types/issue-102114.next.stderr new file mode 100644 index 000000000..6e7a0b1f6 --- /dev/null +++ b/tests/ui/generic-associated-types/issue-102114.next.stderr @@ -0,0 +1,12 @@ +error[E0049]: type `B` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/issue-102114.rs:14:12 + | +LL | type B<'b>; + | -- expected 0 type parameters +... +LL | type B = Wrapper; + | ^ found 1 type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-associated-types/issue-102114.rs b/tests/ui/generic-associated-types/issue-102114.rs index de31737ef..bb6622c0a 100644 --- a/tests/ui/generic-associated-types/issue-102114.rs +++ b/tests/ui/generic-associated-types/issue-102114.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + trait A { type B<'b>; fn a() -> Self::B<'static>; diff --git a/tests/ui/generic-associated-types/issue-102114.stderr b/tests/ui/generic-associated-types/issue-102114.stderr deleted file mode 100644 index 8e41dee54..000000000 --- a/tests/ui/generic-associated-types/issue-102114.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0049]: type `B` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/issue-102114.rs:11:12 - | -LL | type B<'b>; - | -- expected 0 type parameters -... -LL | type B = Wrapper; - | ^ found 1 type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-associated-types/issue-86218.rs b/tests/ui/generic-associated-types/issue-86218.rs index 61cfdd35a..397a0f2c6 100644 --- a/tests/ui/generic-associated-types/issue-86218.rs +++ b/tests/ui/generic-associated-types/issue-86218.rs @@ -17,7 +17,6 @@ trait Yay { impl<'a> Yay<&'a ()> for () { type InnerStream<'s> = impl Stream + 's; - //^ ERROR does not fulfill the required lifetime fn foo<'s>() -> Self::InnerStream<'s> { () } diff --git a/tests/ui/generic-associated-types/issue-90014-tait.rs b/tests/ui/generic-associated-types/issue-90014-tait.rs index bc3a4e129..1ce5cd319 100644 --- a/tests/ui/generic-associated-types/issue-90014-tait.rs +++ b/tests/ui/generic-associated-types/issue-90014-tait.rs @@ -13,7 +13,6 @@ struct Foo<'a>(&'a mut ()); impl Foo<'_> { type Fut<'a> = impl Future; - //^ ERROR: the type `&mut ()` does not fulfill the required lifetime fn make_fut<'a>(&'a self) -> Self::Fut<'a> { async { () } diff --git a/tests/ui/generic-associated-types/issue-90014-tait.stderr b/tests/ui/generic-associated-types/issue-90014-tait.stderr index 8330a387e..1dec7edce 100644 --- a/tests/ui/generic-associated-types/issue-90014-tait.stderr +++ b/tests/ui/generic-associated-types/issue-90014-tait.stderr @@ -1,18 +1,18 @@ error[E0308]: mismatched types - --> $DIR/issue-90014-tait.rs:19:9 + --> $DIR/issue-90014-tait.rs:18:9 | LL | type Fut<'a> = impl Future; | ------------------------ the expected future -... +LL | LL | fn make_fut<'a>(&'a self) -> Self::Fut<'a> { | ------------- expected `Foo<'_>::Fut<'a>` because of return type LL | async { () } | ^^^^^^^^^^^^ expected future, found `async` block | = note: expected opaque type `Foo<'_>::Fut<'a>` - found `async` block `[async block@$DIR/issue-90014-tait.rs:19:9: 19:21]` + found `async` block `[async block@$DIR/issue-90014-tait.rs:18:9: 18:21]` note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/issue-90014-tait.rs:18:8 + --> $DIR/issue-90014-tait.rs:17:8 | LL | fn make_fut<'a>(&'a self) -> Self::Fut<'a> { | ^^^^^^^^ diff --git a/tests/ui/generic-associated-types/issue-90014-tait2.rs b/tests/ui/generic-associated-types/issue-90014-tait2.rs index dacbc93de..7fb14eddc 100644 --- a/tests/ui/generic-associated-types/issue-90014-tait2.rs +++ b/tests/ui/generic-associated-types/issue-90014-tait2.rs @@ -1,24 +1,9 @@ //! This test checks that opaque type collection doesn't try to normalize the projection //! without respecting its binders (which would ICE). //! Unfortunately we don't even reach opaque type collection, as we ICE in typeck before that. -// known-bug: #109281 -// failure-status: 101 -// error-pattern:internal compiler error -// normalize-stderr-test "internal compiler error.*" -> "" -// normalize-stderr-test "DefId\([^)]*\)" -> "..." -// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" -// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" -// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" -// normalize-stderr-test "note: compiler flags.*\n\n" -> "" -// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "thread.*panicked.*\n" -> "" -// normalize-stderr-test "stack backtrace:\n" -> "" -// normalize-stderr-test "\s\d{1,}: .*\n" -> "" -// normalize-stderr-test "\s at .*\n" -> "" -// normalize-stderr-test ".*note: Some details.*\n" -> "" -// normalize-stderr-test "\n\n[ ]*\n" -> "" -// normalize-stderr-test "compiler/.*: projection" -> "projection" +//! See #109281 for the original report. // edition:2018 +// error-pattern: expected generic lifetime parameter, found `'a` #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/generic-associated-types/issue-90014-tait2.stderr b/tests/ui/generic-associated-types/issue-90014-tait2.stderr index 3187be333..d04788a91 100644 --- a/tests/ui/generic-associated-types/issue-90014-tait2.stderr +++ b/tests/ui/generic-associated-types/issue-90014-tait2.stderr @@ -1,12 +1,5 @@ -error: - --> $DIR/issue-90014-tait2.rs:41:27 - | -LL | fn make_fut(&self) -> Box Trait<'a, Thing = Fut<'a>>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^query stack during panic: -#0 [typeck] type-checking `::make_fut` -#1 [type_of] computing type of `Fut::{opaque#0}` -#2 [check_mod_item_types] checking item types in top-level module -#3 [analysis] running analysis passes on this crate -end of query stack +error[E0792]: expected generic lifetime parameter, found `'a` + error: aborting due to previous error +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/generic-associated-types/streaming_iterator.rs b/tests/ui/generic-associated-types/streaming_iterator.rs index 408b8dc99..656fb743e 100644 --- a/tests/ui/generic-associated-types/streaming_iterator.rs +++ b/tests/ui/generic-associated-types/streaming_iterator.rs @@ -15,8 +15,7 @@ struct Foo { // Users can bound parameters by the type constructed by that trait's associated type constructor // of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid: -//FIXME(#44265): This next line should parse and be valid -//fn foo StreamingIterator=&'a [i32]>>(_iter: T) { /* ... */ } +fn _bar StreamingIterator=&'a [i32]>>(_iter: T) { /* ... */ } fn _foo(_iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } // Full example of enumerate iterator diff --git a/tests/ui/generic-const-items/associated-const-equality.rs b/tests/ui/generic-const-items/associated-const-equality.rs new file mode 100644 index 000000000..785d3aa50 --- /dev/null +++ b/tests/ui/generic-const-items/associated-const-equality.rs @@ -0,0 +1,22 @@ +// check-pass + +#![feature(generic_const_items, associated_const_equality)] +#![allow(incomplete_features)] + +trait Owner { + const C: u32; + const K: u32; +} + +impl Owner for () { + const C: u32 = N; + const K: u32 = N + 1; +} + +fn take0(_: impl Owner = { N }>) {} +fn take1(_: impl Owner = 100>) {} + +fn main() { + take0::<128>(()); + take1(()); +} diff --git a/tests/ui/generic-const-items/basic.rs b/tests/ui/generic-const-items/basic.rs new file mode 100644 index 000000000..73bfa803a --- /dev/null +++ b/tests/ui/generic-const-items/basic.rs @@ -0,0 +1,61 @@ +// check-pass + +// Basic usage patterns of free & associated generic const items. + +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +fn main() { + const NULL: Option = None::; + const NOTHING: Option = None; // arg inferred + + let _ = NOTHING::; + let _: Option = NULL; // arg inferred + + const IDENTITY: u64 = X; + + const COUNT: u64 = IDENTITY::<48>; + const AMOUNT: u64 = IDENTITY::; + const NUMBER: u64 = IDENTITY::<{ AMOUNT * 2 }>; + let _ = NUMBER; + let _ = IDENTITY::<0>; + + let _ = match 0 { + IDENTITY::<1> => 2, + IDENTITY::<{ 1 + 1 }> => 4, + _ => 0, + }; + + const CREATE: I = I::PROOF; + let _ = CREATE::; + let _: u64 = CREATE; // arg inferred + + let _ = <() as Main>::MAKE::; + let _: (u64, u64) = <()>::MAKE; // args inferred +} + +pub fn usage<'any>() { + const REGION_POLY<'a>: &'a () = &(); + + let _: &'any () = REGION_POLY::<'any>; + let _: &'any () = REGION_POLY::<'_>; + let _: &'static () = REGION_POLY; +} + +trait Main { + type Output; + const MAKE: Self::Output; +} + +impl Main for () { + type Output = (O, I); + const MAKE: Self::Output = (O::PROOF, I::PROOF); +} + +trait Inhabited { + const PROOF: Self; +} + +impl Inhabited for u64 { + const PROOF: Self = 512; +} diff --git a/tests/ui/generic-const-items/compare-impl-item.rs b/tests/ui/generic-const-items/compare-impl-item.rs new file mode 100644 index 000000000..01e4477c6 --- /dev/null +++ b/tests/ui/generic-const-items/compare-impl-item.rs @@ -0,0 +1,30 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +trait Trait

{ + const A: (); + const B: u64; + const C: T; + const D: usize; + + const E: usize; + const F: (); +} + +impl

Trait

for () { + const A: () = (); + //~^ ERROR const `A` has 1 type parameter but its trait declaration has 0 type parameters + const B: u64 = 0; + //~^ ERROR const `B` has 1 const parameter but its trait declaration has 2 const parameters + const C<'a>: &'a str = ""; + //~^ ERROR const `C` has 0 type parameters but its trait declaration has 1 type parameter + const D: u16 = N; + //~^ ERROR const `D` has an incompatible generic parameter for trait `Trait` + + const E: usize = 1024 + where + P: Copy; //~ ERROR impl has stricter requirements than trait + const F: () = (); //~ ERROR impl has stricter requirements than trait +} + +fn main() {} diff --git a/tests/ui/generic-const-items/compare-impl-item.stderr b/tests/ui/generic-const-items/compare-impl-item.stderr new file mode 100644 index 000000000..8610d8cba --- /dev/null +++ b/tests/ui/generic-const-items/compare-impl-item.stderr @@ -0,0 +1,66 @@ +error[E0049]: const `A` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/compare-impl-item.rs:15:13 + | +LL | const A: (); + | - expected 0 type parameters +... +LL | const A: () = (); + | ^ found 1 type parameter + +error[E0049]: const `B` has 1 const parameter but its trait declaration has 2 const parameters + --> $DIR/compare-impl-item.rs:17:13 + | +LL | const B: u64; + | ------------ ------------ + | | + | expected 2 const parameters +... +LL | const B: u64 = 0; + | ^^^^^^^^^^^^ found 1 const parameter + +error[E0049]: const `C` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/compare-impl-item.rs:19:13 + | +LL | const C: T; + | - expected 1 type parameter +... +LL | const C<'a>: &'a str = ""; + | ^^ found 0 type parameters + +error[E0053]: const `D` has an incompatible generic parameter for trait `Trait` + --> $DIR/compare-impl-item.rs:21:13 + | +LL | trait Trait

{ + | ----- +... +LL | const D: usize; + | -------------- expected const parameter of type `usize` +... +LL | impl

Trait

for () { + | ----------------------- +... +LL | const D: u16 = N; + | ^^^^^^^^^^^^ found const parameter of type `u16` + +error[E0276]: impl has stricter requirements than trait + --> $DIR/compare-impl-item.rs:26:12 + | +LL | const E: usize; + | -------------- definition of `E` from trait +... +LL | P: Copy; + | ^^^^ impl has extra requirement `P: Copy` + +error[E0276]: impl has stricter requirements than trait + --> $DIR/compare-impl-item.rs:27:16 + | +LL | const F: (); + | ------------------------- definition of `F` from trait +... +LL | const F: () = (); + | ^^ impl has extra requirement `T: Eq` + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0049, E0053, E0276. +For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs new file mode 100644 index 000000000..d30f7af17 --- /dev/null +++ b/tests/ui/generic-const-items/const-trait-impl.rs @@ -0,0 +1,25 @@ +// known-bug: #110395 +// FIXME check-pass + +// Test that we can call methods from const trait impls inside of generic const items. + +#![feature(generic_const_items, const_trait_impl)] +#![allow(incomplete_features)] +#![crate_type = "lib"] + +// FIXME(generic_const_items): Interpret `~const` as always-const. +const CREATE: T = T::create(); + +pub const K0: i32 = CREATE::; +pub const K1: i32 = CREATE; // arg inferred + +#[const_trait] +trait Create { + fn create() -> Self; +} + +impl const Create for i32 { + fn create() -> i32 { + 4096 + } +} diff --git a/tests/ui/generic-const-items/const-trait-impl.stderr b/tests/ui/generic-const-items/const-trait-impl.stderr new file mode 100644 index 000000000..34360c581 --- /dev/null +++ b/tests/ui/generic-const-items/const-trait-impl.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `::create` in constants + --> $DIR/const-trait-impl.rs:11:37 + | +LL | const CREATE: T = T::create(); + | ^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/generic-const-items/duplicate-where-clause.rs b/tests/ui/generic-const-items/duplicate-where-clause.rs new file mode 100644 index 000000000..68da4073f --- /dev/null +++ b/tests/ui/generic-const-items/duplicate-where-clause.rs @@ -0,0 +1,27 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +trait Tr

{ + const K: () + where + P: Copy + where + P: Eq; + //~^ ERROR cannot define duplicate `where` clauses on an item +} + +// Test that we error on the first where-clause but also that we don't suggest to swap it with the +// body as it would conflict with the second where-clause. +// FIXME(generic_const_items): We should provide a structured sugg to merge the 1st into the 2nd WC. + +impl

Tr

for () { + const K: () + where + P: Eq + = () + where + P: Copy; + //~^^^^^ ERROR where clauses are not allowed before const item bodies +} + +fn main() {} diff --git a/tests/ui/generic-const-items/duplicate-where-clause.stderr b/tests/ui/generic-const-items/duplicate-where-clause.stderr new file mode 100644 index 000000000..5fa61b01e --- /dev/null +++ b/tests/ui/generic-const-items/duplicate-where-clause.stderr @@ -0,0 +1,27 @@ +error: cannot define duplicate `where` clauses on an item + --> $DIR/duplicate-where-clause.rs:9:9 + | +LL | P: Copy + | - previous `where` clause starts here +LL | where +LL | P: Eq; + | ^ + | +help: consider joining the two `where` clauses into one + | +LL | P: Copy, + | ~ + +error: where clauses are not allowed before const item bodies + --> $DIR/duplicate-where-clause.rs:19:5 + | +LL | const K: () + | - while parsing this const item +LL | / where +LL | | P: Eq + | |_____________^ unexpected where clause +LL | = () + | -- the item body + +error: aborting due to 2 previous errors + diff --git a/tests/ui/generic-const-items/elided-lifetimes.rs b/tests/ui/generic-const-items/elided-lifetimes.rs new file mode 100644 index 000000000..cca73e2e8 --- /dev/null +++ b/tests/ui/generic-const-items/elided-lifetimes.rs @@ -0,0 +1,18 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Check that we forbid elided lifetimes inside the generics of const items. + +const K: () = () +where + &T: Copy; //~ ERROR `&` without an explicit lifetime name cannot be used here + +const I: &str = ""; +//~^ ERROR `&` without an explicit lifetime name cannot be used here +//~| ERROR `&str` is forbidden as the type of a const generic parameter + +const B>: () = (); //~ ERROR `'_` cannot be used here + +trait Trait<'a> {} + +fn main() {} diff --git a/tests/ui/generic-const-items/elided-lifetimes.stderr b/tests/ui/generic-const-items/elided-lifetimes.stderr new file mode 100644 index 000000000..8cd3f9ee7 --- /dev/null +++ b/tests/ui/generic-const-items/elided-lifetimes.stderr @@ -0,0 +1,35 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/elided-lifetimes.rs:8:5 + | +LL | &T: Copy; + | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here + | +LL | for<'a> &'a T: Copy; + | +++++++ ++ + +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/elided-lifetimes.rs:10:18 + | +LL | const I: &str = ""; + | ^ explicit lifetime name needed here + +error[E0637]: `'_` cannot be used here + --> $DIR/elided-lifetimes.rs:14:18 + | +LL | const B>: () = (); + | ^^ `'_` is a reserved lifetime name + +error: `&str` is forbidden as the type of a const generic parameter + --> $DIR/elided-lifetimes.rs:10:18 + | +LL | const I: &str = ""; + | ^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/generic-const-items/evaluatable-bounds.rs b/tests/ui/generic-const-items/evaluatable-bounds.rs new file mode 100644 index 000000000..cdcfcf918 --- /dev/null +++ b/tests/ui/generic-const-items/evaluatable-bounds.rs @@ -0,0 +1,31 @@ +// This is a regression test for issue #104400. + +// revisions: unconstrained constrained +//[constrained] check-pass + +// Test that we can constrain generic const items that appear inside associated consts by +// adding a (makeshift) "evaluatable"-bound to the item. + +#![feature(generic_const_items, generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const LEN: usize; + + #[cfg(unconstrained)] + const ARRAY: [i32; Self::LEN]; //[unconstrained]~ ERROR unconstrained generic constant + + #[cfg(constrained)] + const ARRAY: [i32; Self::LEN] + where + [(); Self::LEN]:; +} + +impl Trait for () { + const LEN: usize = 2; + const ARRAY: [i32; Self::LEN] = [360, 720]; +} + +fn main() { + let [_, _] = <() as Trait>::ARRAY; +} diff --git a/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr new file mode 100644 index 000000000..930080f7c --- /dev/null +++ b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/evaluatable-bounds.rs:16:5 + | +LL | const ARRAY: [i32; Self::LEN]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); Self::LEN]:` + +error: aborting due to previous error + diff --git a/tests/ui/generic-const-items/feature-gate-generic_const_items.rs b/tests/ui/generic-const-items/feature-gate-generic_const_items.rs new file mode 100644 index 000000000..5c241f256 --- /dev/null +++ b/tests/ui/generic-const-items/feature-gate-generic_const_items.rs @@ -0,0 +1,37 @@ +pub trait Trait { + const ONE: i32; + //~^ ERROR generic const items are experimental + + const TWO: () + where + A: Copy; + //~^^ ERROR generic const items are experimental +} + +const CONST: i32 = 0; +//~^ ERROR generic const items are experimental + +const EMPTY<>: i32 = 0; +//~^ ERROR generic const items are experimental + +const TRUE: () = () +where + String: Clone; +//~^^ ERROR generic const items are experimental + +// Ensure that we flag generic const items inside macro calls as well: + +macro_rules! discard { + ($item:item) => {} +} + +discard! { const FREE: () = (); } +//~^ ERROR generic const items are experimental + +discard! { impl () { const ASSOC: () = (); } } +//~^ ERROR generic const items are experimental + +discard! { impl () { const ASSOC: i32 = 0 where String: Copy; } } +//~^ ERROR generic const items are experimental + +fn main() {} diff --git a/tests/ui/generic-const-items/feature-gate-generic_const_items.stderr b/tests/ui/generic-const-items/feature-gate-generic_const_items.stderr new file mode 100644 index 000000000..a1fdf5f6e --- /dev/null +++ b/tests/ui/generic-const-items/feature-gate-generic_const_items.stderr @@ -0,0 +1,77 @@ +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:2:14 + | +LL | const ONE: i32; + | ^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:6:5 + | +LL | / where +LL | | A: Copy; + | |_______________^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:11:12 + | +LL | const CONST: i32 = 0; + | ^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:14:12 + | +LL | const EMPTY<>: i32 = 0; + | ^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:18:1 + | +LL | / where +LL | | String: Clone; + | |_________________^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:28:22 + | +LL | discard! { const FREE: () = (); } + | ^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:31:33 + | +LL | discard! { impl () { const ASSOC: () = (); } } + | ^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:34:43 + | +LL | discard! { impl () { const ASSOC: i32 = 0 where String: Copy; } } + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/generic-const-items/inference-failure.rs b/tests/ui/generic-const-items/inference-failure.rs new file mode 100644 index 000000000..fd4f424dd --- /dev/null +++ b/tests/ui/generic-const-items/inference-failure.rs @@ -0,0 +1,15 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +const NONE: Option = None::; +const IGNORE: () = (); + +fn none() { + let _ = NONE; //~ ERROR type annotations needed +} + +fn ignore() { + let _ = IGNORE; //~ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/generic-const-items/inference-failure.stderr b/tests/ui/generic-const-items/inference-failure.stderr new file mode 100644 index 000000000..22ff1b9ba --- /dev/null +++ b/tests/ui/generic-const-items/inference-failure.stderr @@ -0,0 +1,20 @@ +error[E0282]: type annotations needed for `Option` + --> $DIR/inference-failure.rs:8:9 + | +LL | let _ = NONE; + | ^ + | +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let _: Option = NONE; + | +++++++++++ + +error[E0282]: type annotations needed + --> $DIR/inference-failure.rs:12:13 + | +LL | let _ = IGNORE; + | ^^^^^^ cannot infer type for type parameter `T` declared on the constant `IGNORE` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/generic-const-items/misplaced-where-clause.fixed b/tests/ui/generic-const-items/misplaced-where-clause.fixed new file mode 100644 index 000000000..bff470c28 --- /dev/null +++ b/tests/ui/generic-const-items/misplaced-where-clause.fixed @@ -0,0 +1,18 @@ +// run-rustfix + +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +const K: u64 += T::K where + T: Tr<()>; +//~^^^ ERROR where clauses are not allowed before const item bodies + +trait Tr

{ + const K: u64 + = 0 where + P: Copy; + //~^^^ ERROR where clauses are not allowed before const item bodies +} + +fn main() {} diff --git a/tests/ui/generic-const-items/misplaced-where-clause.rs b/tests/ui/generic-const-items/misplaced-where-clause.rs new file mode 100644 index 000000000..b14c6d594 --- /dev/null +++ b/tests/ui/generic-const-items/misplaced-where-clause.rs @@ -0,0 +1,20 @@ +// run-rustfix + +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +const K: u64 +where + T: Tr<()> += T::K; +//~^^^ ERROR where clauses are not allowed before const item bodies + +trait Tr

{ + const K: u64 + where + P: Copy + = 0; + //~^^^ ERROR where clauses are not allowed before const item bodies +} + +fn main() {} diff --git a/tests/ui/generic-const-items/misplaced-where-clause.stderr b/tests/ui/generic-const-items/misplaced-where-clause.stderr new file mode 100644 index 000000000..431741d87 --- /dev/null +++ b/tests/ui/generic-const-items/misplaced-where-clause.stderr @@ -0,0 +1,36 @@ +error: where clauses are not allowed before const item bodies + --> $DIR/misplaced-where-clause.rs:7:1 + | +LL | const K: u64 + | - while parsing this const item +LL | / where +LL | | T: Tr<()> + | |_____________^ unexpected where clause +LL | = T::K; + | ---- the item body + | +help: move the body before the where clause + | +LL ~ = T::K where +LL ~ T: Tr<()>; + | + +error: where clauses are not allowed before const item bodies + --> $DIR/misplaced-where-clause.rs:14:5 + | +LL | const K: u64 + | - while parsing this const item +LL | / where +LL | | P: Copy + | |_______________^ unexpected where clause +LL | = 0; + | - the item body + | +help: move the body before the where clause + | +LL ~ = 0 where +LL ~ P: Copy; + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/generic-const-items/parameter-defaults.rs b/tests/ui/generic-const-items/parameter-defaults.rs new file mode 100644 index 000000000..a6f82c249 --- /dev/null +++ b/tests/ui/generic-const-items/parameter-defaults.rs @@ -0,0 +1,14 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Check that we emit a *hard* error (not just a lint warning or error for example) for generic +// parameter defaults on free const items since we are not limited by backward compatibility. +#![allow(invalid_type_param_default)] // Should have no effect here. + +// FIXME(default_type_parameter_fallback): Consider reallowing them once they work properly. + +const NONE: Option = None::; //~ ERROR defaults for type parameters are only allowed + +fn main() { + let _ = NONE; +} diff --git a/tests/ui/generic-const-items/parameter-defaults.stderr b/tests/ui/generic-const-items/parameter-defaults.stderr new file mode 100644 index 000000000..62da45e55 --- /dev/null +++ b/tests/ui/generic-const-items/parameter-defaults.stderr @@ -0,0 +1,8 @@ +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/parameter-defaults.rs:10:12 + | +LL | const NONE: Option = None::; + | ^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/generic-const-items/recursive.rs b/tests/ui/generic-const-items/recursive.rs new file mode 100644 index 000000000..3266b37d3 --- /dev/null +++ b/tests/ui/generic-const-items/recursive.rs @@ -0,0 +1,12 @@ +// FIXME(generic_const_items): This leads to a stack overflow in the compiler! +// known-bug: unknown +// ignore-test + +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +const RECUR: () = RECUR::<(T,)>; + +fn main() { + let _ = RECUR::<()>; +} diff --git a/tests/ui/generic-const-items/reference-outlives-referent.rs b/tests/ui/generic-const-items/reference-outlives-referent.rs new file mode 100644 index 000000000..13e4eaac3 --- /dev/null +++ b/tests/ui/generic-const-items/reference-outlives-referent.rs @@ -0,0 +1,9 @@ +// Test that we catch that the reference outlives the referent and we +// successfully emit a diagnostic. Regression test for issue #114714. + +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +const Q<'a, 'b>: &'a &'b () = &&(); //~ ERROR reference has a longer lifetime than the data it references + +fn main() {} diff --git a/tests/ui/generic-const-items/reference-outlives-referent.stderr b/tests/ui/generic-const-items/reference-outlives-referent.stderr new file mode 100644 index 000000000..2b57713b5 --- /dev/null +++ b/tests/ui/generic-const-items/reference-outlives-referent.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references + --> $DIR/reference-outlives-referent.rs:7:18 + | +LL | const Q<'a, 'b>: &'a &'b () = &&(); + | ^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/reference-outlives-referent.rs:7:9 + | +LL | const Q<'a, 'b>: &'a &'b () = &&(); + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/reference-outlives-referent.rs:7:13 + | +LL | const Q<'a, 'b>: &'a &'b () = &&(); + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs new file mode 100644 index 000000000..dd00b327d --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_items, trivial_bounds)] +#![allow(incomplete_features)] + +// Ensure that we check if trivial bounds on const items hold or not. + +const UNUSABLE: () = () +where + String: Copy; + +fn main() { + let _ = UNUSABLE; //~ ERROR the trait bound `String: Copy` is not satisfied +} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr new file mode 100644 index 000000000..c3ef94529 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/trivially-unsatisfied-bounds-0.rs:11:13 + | +LL | let _ = UNUSABLE; + | ^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `UNUSABLE` + --> $DIR/trivially-unsatisfied-bounds-0.rs:8:13 + | +LL | const UNUSABLE: () = () + | -------- required by a bound in this constant +LL | where +LL | String: Copy; + | ^^^^ required by this bound in `UNUSABLE` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs new file mode 100644 index 000000000..9243deac8 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_items, trivial_bounds)] +#![allow(incomplete_features, dead_code, trivial_bounds)] + +// FIXME(generic_const_items): This looks like a bug to me. I expected that we wouldn't emit any +// errors. I thought we'd skip the evaluation of consts whose bounds don't hold. + +const UNUSED: () = () +where + String: Copy; +//~^^^ ERROR evaluation of constant value failed + +fn main() {} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr new file mode 100644 index 000000000..a68400798 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr @@ -0,0 +1,11 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/trivially-unsatisfied-bounds-1.rs:7:1 + | +LL | / const UNUSED: () = () +LL | | where +LL | | String: Copy; + | |_________________^ entering unreachable code + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.rs b/tests/ui/generic-const-items/unsatisfied-bounds.rs new file mode 100644 index 000000000..058799001 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-bounds.rs @@ -0,0 +1,34 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Ensure that we check if bounds on const items hold or not. + +use std::convert::Infallible; + +const C: () = (); + +const K: () = () +where + Infallible: From; + +trait Trait

{ + const A: u32 + where + P: Copy; + + const B: u32 + where + Infallible: From; +} + +impl

Trait

for () { + const A: u32 = 0; + const B: u32 = 1; +} + +fn main() { + let () = C::; //~ ERROR the trait bound `String: Copy` is not satisfied + let () = K::<()>; //~ ERROR the trait bound `Infallible: From<()>` is not satisfied + let _ = <() as Trait>>::A; //~ ERROR the trait bound `Vec: Copy` is not satisfied + let _ = <() as Trait<&'static str>>::B::<()>; //~ ERROR the trait bound `Infallible: From<()>` is not satisfied +} diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-bounds.stderr new file mode 100644 index 000000000..1fda46037 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-bounds.stderr @@ -0,0 +1,62 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/unsatisfied-bounds.rs:30:18 + | +LL | let () = C::; + | ^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `C` + --> $DIR/unsatisfied-bounds.rs:8:12 + | +LL | const C: () = (); + | ^^^^ required by this bound in `C` + +error[E0277]: the trait bound `Infallible: From<()>` is not satisfied + --> $DIR/unsatisfied-bounds.rs:31:18 + | +LL | let () = K::<()>; + | ^^ the trait `From<()>` is not implemented for `Infallible` + | + = help: the trait `From` is implemented for `Infallible` +note: required by a bound in `K` + --> $DIR/unsatisfied-bounds.rs:12:17 + | +LL | const K: () = () + | - required by a bound in this constant +LL | where +LL | Infallible: From; + | ^^^^^^^ required by this bound in `K` + +error[E0277]: the trait bound `Vec: Copy` is not satisfied + --> $DIR/unsatisfied-bounds.rs:32:13 + | +LL | let _ = <() as Trait>>::A; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec` + | +note: required by a bound in `Trait::A` + --> $DIR/unsatisfied-bounds.rs:17:12 + | +LL | const A: u32 + | - required by a bound in this associated constant +LL | where +LL | P: Copy; + | ^^^^ required by this bound in `Trait::A` + +error[E0277]: the trait bound `Infallible: From<()>` is not satisfied + --> $DIR/unsatisfied-bounds.rs:33:46 + | +LL | let _ = <() as Trait<&'static str>>::B::<()>; + | ^^ the trait `From<()>` is not implemented for `Infallible` + | + = help: the trait `From` is implemented for `Infallible` +note: required by a bound in `Trait::B` + --> $DIR/unsatisfied-bounds.rs:21:21 + | +LL | const B: u32 + | - required by a bound in this associated constant +LL | where +LL | Infallible: From; + | ^^^^^^^ required by this bound in `Trait::B` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs new file mode 100644 index 000000000..961e5b4ae --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_items, generic_const_exprs)] +#![allow(incomplete_features)] + +// Ensure that we check if (makeshift) "evaluatable"-bounds on const items hold or not. + +const POSITIVE: usize = N +where + [(); N - 1]:; //~ ERROR evaluation of `POSITIVE::<0>::{constant#0}` failed + +fn main() { + let _ = POSITIVE::<0>; +} diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr new file mode 100644 index 000000000..bed213b0c --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of `POSITIVE::<0>::{constant#0}` failed + --> $DIR/unsatisfied-evaluatable-bounds.rs:8:10 + | +LL | [(); N - 1]:; + | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs new file mode 100644 index 000000000..204cf9def --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs @@ -0,0 +1,17 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Ensure that we check if outlives-bounds on const items hold or not. + +const C<'a, T: 'a>: () = (); +const K<'a, 'b: 'a>: () = (); + +fn parametrized0<'any>() { + let () = C::<'static, &'any ()>; //~ ERROR lifetime may not live long enough +} + +fn parametrized1<'any>() { + let () = K::<'static, 'any>; //~ ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr new file mode 100644 index 000000000..72e4265b3 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr @@ -0,0 +1,18 @@ +error: lifetime may not live long enough + --> $DIR/unsatisfied-outlives-bounds.rs:10:14 + | +LL | fn parametrized0<'any>() { + | ---- lifetime `'any` defined here +LL | let () = C::<'static, &'any ()>; + | ^^^^^^^^^^^^^^^^^^^^^^ requires that `'any` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/unsatisfied-outlives-bounds.rs:14:14 + | +LL | fn parametrized1<'any>() { + | ---- lifetime `'any` defined here +LL | let () = K::<'static, 'any>; + | ^^^^^^^^^^^^^^^^^^ requires that `'any` must outlive `'static` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/generics/issue-94923.rs b/tests/ui/generics/issue-94923.rs index d337a5dff..893bac0d5 100644 --- a/tests/ui/generics/issue-94923.rs +++ b/tests/ui/generics/issue-94923.rs @@ -1,6 +1,5 @@ // run-pass // regression test for issue #94923 -// min-llvm-version: 15.0.0 // compile-flags: -C opt-level=3 fn f0(mut x: usize) -> usize { diff --git a/tests/ui/hashmap/hashmap-iter-value-lifetime.stderr b/tests/ui/hashmap/hashmap-iter-value-lifetime.stderr index d6e7a1d45..de2591329 100644 --- a/tests/ui/hashmap/hashmap-iter-value-lifetime.stderr +++ b/tests/ui/hashmap/hashmap-iter-value-lifetime.stderr @@ -2,7 +2,7 @@ error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as --> $DIR/hashmap-iter-value-lifetime.rs:7:5 | LL | let (_, thing) = my_stuff.iter().next().unwrap(); - | --------------- immutable borrow occurs here + | -------- immutable borrow occurs here LL | LL | my_stuff.clear(); | ^^^^^^^^^^^^^^^^ mutable borrow occurs here diff --git a/tests/ui/hashmap/hashmap-lifetimes.stderr b/tests/ui/hashmap/hashmap-lifetimes.stderr index d1bcd53ae..497c7d121 100644 --- a/tests/ui/hashmap/hashmap-lifetimes.stderr +++ b/tests/ui/hashmap/hashmap-lifetimes.stderr @@ -2,7 +2,7 @@ error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as --> $DIR/hashmap-lifetimes.rs:6:5 | LL | let mut it = my_stuff.iter(); - | --------------- immutable borrow occurs here + | -------- immutable borrow occurs here LL | my_stuff.insert(1, 43); | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | it; diff --git a/tests/ui/hello_world/main.rs b/tests/ui/hello_world/main.rs index 22ce47414..39cb74b70 100644 --- a/tests/ui/hello_world/main.rs +++ b/tests/ui/hello_world/main.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// build-pass // Test that compiling hello world succeeds with no output of any kind. diff --git a/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr b/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr index 73b0a3173..5241b475d 100644 --- a/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr +++ b/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/placeholder-pattern-fail.rs:9:47 | LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; - | ^^^ one type is more general than the other + | -------------------------------- ^^^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)` found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` diff --git a/tests/ui/higher-ranked/trait-bounds/future.rs b/tests/ui/higher-ranked/trait-bounds/future.rs index da7ee0343..61d86a9cb 100644 --- a/tests/ui/higher-ranked/trait-bounds/future.rs +++ b/tests/ui/higher-ranked/trait-bounds/future.rs @@ -7,7 +7,7 @@ //[classic] build-fail //[classic] failure-status: 101 //[classic] normalize-stderr-test "note: .*\n\n" -> "" -//[classic] normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +//[classic] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" //[classic] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //[classic] rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.stderr b/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.stderr index a9d649b82..139c844d8 100644 --- a/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.stderr @@ -13,8 +13,7 @@ LL | | ) { LL | f | ^ expected `&dyn Fn(&dyn Fn(&dyn Fn(&...)))`, found `&dyn Fn(u32)` | - = note: expected reference `&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&...)))))))))))` - the full type name has been written to '$TEST_BUILD_DIR/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn/hang-on-deeply-nested-dyn.long-type-hash.txt' + = note: expected reference `&dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn Fn(u32) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a))` found reference `&dyn Fn(u32)` error: aborting due to previous error diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.stderr index fa391ecba..70d5b3c2e 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.stderr @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/hrtb-debruijn-in-receiver.rs:17:5 | LL | foo.insert(); - | ------------ first mutable borrow occurs here + | --- first mutable borrow occurs here LL | foo.insert(); - | ^^^^^^^^^^^^ + | ^^^ | | | second mutable borrow occurs here | first borrow later used here diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr index 9914783d9..db5fc4bf1 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/hrtb-exists-forall-fn.rs:17:34 | LL | let _: for<'b> fn(&'b u32) = foo(); - | ^^^^^ one type is more general than the other + | ------------------- ^^^^^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'b> fn(&'b u32)` found fn pointer `fn(&u32)` diff --git a/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr b/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr index f32ba5720..957082b60 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr @@ -31,7 +31,6 @@ LL | pub struct Filter { LL | let count = filter.countx(); | ^^^^^^ method cannot be called due to unsatisfied trait bounds | - = note: the full type name has been written to '$TEST_BUILD_DIR/higher-ranked/trait-bounds/issue-30786/issue-30786.long-type-hash.txt' note: the following trait bounds were not satisfied: `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs new file mode 100644 index 000000000..40c5eacee --- /dev/null +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.rs @@ -0,0 +1,29 @@ +// edition:2018 +#![feature(decl_macro)] + +macro a() { + extern crate core as my_core; + mod v { + // Early resolution. + use my_core; //~ ERROR unresolved import `my_core` + } + mod u { + // Late resolution. + fn f() { my_core::mem::drop(0); } + //~^ ERROR failed to resolve: use of undeclared crate or module `my_core` + } +} + +a!(); + +mod v { + // Early resolution. + use my_core; //~ ERROR unresolved import `my_core` +} +mod u { + // Late resolution. + fn f() { my_core::mem::drop(0); } + //~^ ERROR failed to resolve: use of undeclared crate or module `my_core` +} + +fn main() {} diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr new file mode 100644 index 000000000..7ed15e89c --- /dev/null +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr @@ -0,0 +1,53 @@ +error[E0432]: unresolved import `my_core` + --> $DIR/extern-prelude-from-opaque-fail-2018.rs:21:9 + | +LL | use my_core; + | ^^^^^^^ no external crate `my_core` + +error[E0432]: unresolved import `my_core` + --> $DIR/extern-prelude-from-opaque-fail-2018.rs:8:13 + | +LL | use my_core; + | ^^^^^^^ no external crate `my_core` +... +LL | a!(); + | ---- in this macro invocation + | + = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: use of undeclared crate or module `my_core` + --> $DIR/extern-prelude-from-opaque-fail-2018.rs:12:18 + | +LL | fn f() { my_core::mem::drop(0); } + | ^^^^^^^ use of undeclared crate or module `my_core` +... +LL | a!(); + | ---- in this macro invocation + | + = help: consider importing one of these items: + std::mem + core::mem + = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: use of undeclared crate or module `my_core` + --> $DIR/extern-prelude-from-opaque-fail-2018.rs:25:14 + | +LL | fn f() { my_core::mem::drop(0); } + | ^^^^^^^ use of undeclared crate or module `my_core` + | +help: consider importing one of these items + | +LL + use core::mem; + | +LL + use std::mem; + | +help: if you import `mem`, refer to it directly + | +LL - fn f() { my_core::mem::drop(0); } +LL + fn f() { mem::drop(0); } + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs b/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs index 571017df4..f3fa2ddda 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail.rs @@ -1,3 +1,4 @@ +// edition:2015 #![feature(decl_macro)] macro a() { diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr b/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr index f1f4caee3..13b2827ef 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr @@ -1,11 +1,11 @@ error[E0432]: unresolved import `my_core` - --> $DIR/extern-prelude-from-opaque-fail.rs:20:9 + --> $DIR/extern-prelude-from-opaque-fail.rs:21:9 | LL | use my_core; | ^^^^^^^ no `my_core` in the root error[E0432]: unresolved import `my_core` - --> $DIR/extern-prelude-from-opaque-fail.rs:7:13 + --> $DIR/extern-prelude-from-opaque-fail.rs:8:13 | LL | use my_core; | ^^^^^^^ no `my_core` in the root @@ -16,7 +16,7 @@ LL | a!(); = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: use of undeclared crate or module `my_core` - --> $DIR/extern-prelude-from-opaque-fail.rs:11:18 + --> $DIR/extern-prelude-from-opaque-fail.rs:12:18 | LL | fn f() { my_core::mem::drop(0); } | ^^^^^^^ use of undeclared crate or module `my_core` @@ -24,13 +24,25 @@ LL | fn f() { my_core::mem::drop(0); } LL | a!(); | ---- in this macro invocation | + = help: consider importing this module: + my_core::mem = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: use of undeclared crate or module `my_core` - --> $DIR/extern-prelude-from-opaque-fail.rs:24:14 + --> $DIR/extern-prelude-from-opaque-fail.rs:25:14 | LL | fn f() { my_core::mem::drop(0); } | ^^^^^^^ use of undeclared crate or module `my_core` + | +help: consider importing this module + | +LL + use my_core::mem; + | +help: if you import `mem`, refer to it directly + | +LL - fn f() { my_core::mem::drop(0); } +LL + fn f() { mem::drop(0); } + | error: aborting due to 4 previous errors diff --git a/tests/ui/hygiene/fields-numeric-borrowck.stderr b/tests/ui/hygiene/fields-numeric-borrowck.stderr index bc13aa62f..fb90825c0 100644 --- a/tests/ui/hygiene/fields-numeric-borrowck.stderr +++ b/tests/ui/hygiene/fields-numeric-borrowck.stderr @@ -7,7 +7,7 @@ LL | let S { 0: ref mut borrow2 } = s; | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | borrow1.use_mut(); - | ----------------- first borrow later used here + | ------- first borrow later used here error: aborting due to previous error diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index a7252a400..5ed0d9fcf 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:524:5 +thread 'main' panicked at library/alloc/src/raw_vec.rs:534:5: +capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr index 92a9763bc..a024cff0b 100644 --- a/tests/ui/impl-trait/auto-trait-leak.stderr +++ b/tests/ui/impl-trait/auto-trait-leak.stderr @@ -33,6 +33,7 @@ LL | | fn send(_: T) {} LL | | Rc::new(String::from("foo")) LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}` --> $DIR/auto-trait-leak.rs:11:16 @@ -68,6 +69,7 @@ LL | | fn send(_: T) {} LL | | Rc::new(String::from("foo")) LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: cannot check whether the hidden type of opaque type satisfies auto traits --> $DIR/auto-trait-leak.rs:21:10 diff --git a/tests/ui/impl-trait/autoderef.rs b/tests/ui/impl-trait/autoderef.rs index 0d07a5496..cd2cdd9e3 100644 --- a/tests/ui/impl-trait/autoderef.rs +++ b/tests/ui/impl-trait/autoderef.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flag: -Ztrait-solver=next +//[next] compile-flags: -Ztrait-solver=next // check-pass use std::path::Path; diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs new file mode 100644 index 000000000..57d688492 --- /dev/null +++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs @@ -0,0 +1,22 @@ +// edition:2015 +// check-pass +// issue: 114664 + +fn ice() -> impl AsRef { + //~^ WARN trait objects without an explicit `dyn` are deprecated + //~| WARN trait objects without an explicit `dyn` are deprecated + //~| WARN trait objects without an explicit `dyn` are deprecated + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + Foo +} + +struct Foo; +impl AsRef for Foo { + fn as_ref(&self) -> &(dyn for<'a> Fn(&'a ()) + 'static) { + todo!() + } +} + +pub fn main() {} diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr new file mode 100644 index 000000000..fad0b812d --- /dev/null +++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr @@ -0,0 +1,42 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 + | +LL | fn ice() -> impl AsRef { + | ^^^^^^^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see + = note: `#[warn(bare_trait_objects)]` on by default +help: use `dyn` + | +LL | fn ice() -> impl AsRef { + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 + | +LL | fn ice() -> impl AsRef { + | ^^^^^^^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +help: use `dyn` + | +LL | fn ice() -> impl AsRef { + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 + | +LL | fn ice() -> impl AsRef { + | ^^^^^^^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +help: use `dyn` + | +LL | fn ice() -> impl AsRef { + | +++ + +warning: 3 warnings emitted + diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs index 970d84120..212e7b108 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs @@ -6,7 +6,8 @@ fn reify_as() -> Thunk Continuation> { Thunk::new(|mut cont| { - cont.reify_as(); //~ ERROR type annotations needed + //~^ ERROR type annotations needed + cont.reify_as(); cont }) } @@ -15,7 +16,8 @@ type Tait = impl FnOnce(Continuation) -> Continuation; fn reify_as_tait() -> Thunk { Thunk::new(|mut cont| { - cont.reify_as(); //~ ERROR type annotations needed + //~^ ERROR type annotations needed + cont.reify_as(); cont }) } diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr index 957052feb..39bf22142 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr @@ -1,14 +1,30 @@ error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:9:9 + --> $DIR/hidden-type-is-opaque-2.rs:8:17 | +LL | Thunk::new(|mut cont| { + | ^^^^^^^^ +LL | LL | cont.reify_as(); - | ^^^^ cannot infer type + | ---- type must be known at this point + | +help: consider giving this closure parameter an explicit type + | +LL | Thunk::new(|mut cont: /* Type */| { + | ++++++++++++ error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:18:9 + --> $DIR/hidden-type-is-opaque-2.rs:18:17 | +LL | Thunk::new(|mut cont| { + | ^^^^^^^^ +LL | LL | cont.reify_as(); - | ^^^^ cannot infer type + | ---- type must be known at this point + | +help: consider giving this closure parameter an explicit type + | +LL | Thunk::new(|mut cont: /* Type */| { + | ++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs new file mode 100644 index 000000000..2a61c5cc8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs @@ -0,0 +1,29 @@ +// check-pass +// edition: 2021 +// issue: 113796 + +#![feature(async_fn_in_trait)] + +trait AsyncLendingIterator { + type Item<'a> + where + Self: 'a; + + async fn next(&mut self) -> Option>; +} + +struct Lend(I); +impl AsyncLendingIterator for Lend { + type Item<'a> = &'a I + where + Self: 'a; + + // Checking that the synthetic `::next()` GAT + // is well-formed requires being able to assume the WF types of `next`. + + async fn next(&mut self) -> Option> { + todo!() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs index 776006124..cfc2193f6 100644 --- a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs +++ b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs @@ -1,5 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty - #![feature(return_position_impl_trait_in_trait)] use std::ops::Deref; @@ -10,5 +8,7 @@ pub trait Foo { pub struct Foreign; impl Foo for Foreign { - fn bar(self) -> &'static () { &() } + fn bar(self) -> &'static () { + &() + } } diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs new file mode 100644 index 000000000..3a93dfee5 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs @@ -0,0 +1,11 @@ +// issue: 114146 + +#![feature(return_position_impl_trait_in_trait)] + +trait Foo { + fn bar<'other: 'a>() -> impl Sized + 'a {} + //~^ ERROR use of undeclared lifetime name `'a` + //~| ERROR use of undeclared lifetime name `'a` +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr new file mode 100644 index 000000000..3a1f8f908 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr @@ -0,0 +1,33 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/bad-item-bound-within-rpitit-2.rs:6:20 + | +LL | fn bar<'other: 'a>() -> impl Sized + 'a {} + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn bar<'a, 'other: 'a>() -> impl Sized + 'a {} + | +++ +help: consider introducing lifetime `'a` here + | +LL | trait Foo<'a> { + | ++++ + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/bad-item-bound-within-rpitit-2.rs:6:42 + | +LL | fn bar<'other: 'a>() -> impl Sized + 'a {} + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn bar<'a, 'other: 'a>() -> impl Sized + 'a {} + | +++ +help: consider introducing lifetime `'a` here + | +LL | trait Foo<'a> { + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs new file mode 100644 index 000000000..ff7ad4bf3 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs @@ -0,0 +1,24 @@ +// issue: 114145 + +#![feature(return_position_impl_trait_in_trait)] + +trait Iterable { + type Item<'a> + where + Self: 'a; + + fn iter(&self) -> impl '_ + Iterator>; +} + +impl<'a, I: 'a + Iterable> Iterable for &'a I { + type Item<'b> = I::Item<'a> + where + 'b: 'a; + //~^ ERROR impl has stricter requirements than trait + + fn iter(&self) -> impl 'a + Iterator> { + (*self).iter() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr new file mode 100644 index 000000000..106b8a7c8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr @@ -0,0 +1,17 @@ +error[E0276]: impl has stricter requirements than trait + --> $DIR/bad-item-bound-within-rpitit.rs:16:13 + | +LL | type Item<'a> + | ------------- definition of `Item` from trait +... +LL | 'b: 'a; + | ^^ impl has extra requirement `'b: 'a` + | +help: copy the `where` clause predicates from the trait + | +LL | where Self: 'b; + | ~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0276`. diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index f5290a5f4..f5ee4690f 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs new file mode 100644 index 000000000..742537ffc --- /dev/null +++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs @@ -0,0 +1,10 @@ +#![feature(return_position_impl_trait_in_trait)] + +struct Wrapper(G); + +trait Foo { + fn bar() -> Wrapper; + //~^ ERROR `impl Sized` cannot be sent between threads safely +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr new file mode 100644 index 000000000..dee87d082 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr @@ -0,0 +1,16 @@ +error[E0277]: `impl Sized` cannot be sent between threads safely + --> $DIR/check-wf-on-non-defaulted-rpitit.rs:6:17 + | +LL | fn bar() -> Wrapper; + | ^^^^^^^^^^^^^^^^^^^ `impl Sized` cannot be sent between threads safely + | + = help: the trait `Send` is not implemented for `impl Sized` +note: required by a bound in `Wrapper` + --> $DIR/check-wf-on-non-defaulted-rpitit.rs:3:19 + | +LL | struct Wrapper(G); + | ^^^^ required by this bound in `Wrapper` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/deep-match-works.rs b/tests/ui/impl-trait/in-trait/deep-match-works.rs index 5c9d2e356..78cff97c6 100644 --- a/tests/ui/impl-trait/in-trait/deep-match-works.rs +++ b/tests/ui/impl-trait/in-trait/deep-match-works.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/deep-match.current.stderr b/tests/ui/impl-trait/in-trait/deep-match.current.stderr deleted file mode 100644 index 400db20c7..000000000 --- a/tests/ui/impl-trait/in-trait/deep-match.current.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0053]: method `bar` has an incompatible return type for trait - --> $DIR/deep-match.rs:14:17 - | -LL | fn bar() -> i32 { - | ^^^ - | | - | expected `Wrapper<_>`, found `i32` - | return type in trait - | - = note: expected struct `Wrapper<_>` - found type `i32` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/deep-match.next.stderr b/tests/ui/impl-trait/in-trait/deep-match.next.stderr deleted file mode 100644 index 400db20c7..000000000 --- a/tests/ui/impl-trait/in-trait/deep-match.next.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0053]: method `bar` has an incompatible return type for trait - --> $DIR/deep-match.rs:14:17 - | -LL | fn bar() -> i32 { - | ^^^ - | | - | expected `Wrapper<_>`, found `i32` - | return type in trait - | - = note: expected struct `Wrapper<_>` - found type `i32` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/deep-match.rs b/tests/ui/impl-trait/in-trait/deep-match.rs index 413d054e1..0cae88f34 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.rs +++ b/tests/ui/impl-trait/in-trait/deep-match.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/deep-match.stderr b/tests/ui/impl-trait/in-trait/deep-match.stderr new file mode 100644 index 000000000..f0ad3c16e --- /dev/null +++ b/tests/ui/impl-trait/in-trait/deep-match.stderr @@ -0,0 +1,15 @@ +error[E0053]: method `bar` has an incompatible return type for trait + --> $DIR/deep-match.rs:11:17 + | +LL | fn bar() -> i32 { + | ^^^ + | | + | expected `Wrapper<_>`, found `i32` + | return type in trait + | + = note: expected struct `Wrapper<_>` + found type `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr deleted file mode 100644 index 85450e3b0..000000000 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/default-body-type-err-2.rs:10:9 - | -LL | 42 - | ^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found integer - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr deleted file mode 100644 index 85450e3b0..000000000 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/default-body-type-err-2.rs:10:9 - | -LL | 42 - | ^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found integer - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs index 623237763..45ae2b8ad 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![allow(incomplete_features)] #![feature(async_fn_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr new file mode 100644 index 000000000..cc3bdf0e5 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/default-body-type-err-2.rs:8:9 + | +LL | 42 + | ^^- help: try using a conversion method: `.to_string()` + | | + | expected `String`, found integer + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr deleted file mode 100644 index c949168a3..000000000 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` - --> $DIR/default-body-type-err.rs:10:22 - | -LL | fn lol(&self) -> impl Deref { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` -LL | -LL | &1i32 - | ----- return type was inferred to be `&i32` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr deleted file mode 100644 index c949168a3..000000000 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` - --> $DIR/default-body-type-err.rs:10:22 - | -LL | fn lol(&self) -> impl Deref { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` -LL | -LL | &1i32 - | ----- return type was inferred to be `&i32` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.rs b/tests/ui/impl-trait/in-trait/default-body-type-err.rs index 9bd5b7779..ac9baf91c 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![allow(incomplete_features)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr new file mode 100644 index 000000000..4742eb37d --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr @@ -0,0 +1,12 @@ +error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` + --> $DIR/default-body-type-err.rs:7:22 + | +LL | fn lol(&self) -> impl Deref { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` +LL | +LL | &1i32 + | ----- return type was inferred to be `&i32` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr deleted file mode 100644 index 3c24eff9a..000000000 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: concrete type differs from previous defining opaque type use - --> $DIR/default-body-with-rpit.rs:13:9 - | -LL | "" - | ^^ expected `impl Debug`, got `&'static str` - | -note: previous use here - --> $DIR/default-body-with-rpit.rs:12:39 - | -LL | async fn baz(&self) -> impl Debug { - | _______________________________________^ -LL | | "" -LL | | } - | |_____^ - -error[E0720]: cannot resolve opaque type - --> $DIR/default-body-with-rpit.rs:12:28 - | -LL | async fn baz(&self) -> impl Debug { - | ^^^^^^^^^^ cannot resolve opaque type - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr deleted file mode 100644 index 3c24eff9a..000000000 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: concrete type differs from previous defining opaque type use - --> $DIR/default-body-with-rpit.rs:13:9 - | -LL | "" - | ^^ expected `impl Debug`, got `&'static str` - | -note: previous use here - --> $DIR/default-body-with-rpit.rs:12:39 - | -LL | async fn baz(&self) -> impl Debug { - | _______________________________________^ -LL | | "" -LL | | } - | |_____^ - -error[E0720]: cannot resolve opaque type - --> $DIR/default-body-with-rpit.rs:12:28 - | -LL | async fn baz(&self) -> impl Debug { - | ^^^^^^^^^^ cannot resolve opaque type - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs index 6bcc7b9ef..25133214d 100644 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -1,7 +1,5 @@ // edition:2021 -// known-bug: #108304 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next +// check-pass #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs index ab6a51c6b..b0baf5bb1 100644 --- a/tests/ui/impl-trait/in-trait/default-body.rs +++ b/tests/ui/impl-trait/in-trait/default-body.rs @@ -1,7 +1,5 @@ // check-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs index 187039f44..817a4d7db 100644 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index 4f0bf2e7d..28d76241f 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next // This didn't work in the previous default RPITIT method hack attempt diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr deleted file mode 100644 index 653016cf0..000000000 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/doesnt-satisfy.rs:12:17 - | -LL | fn bar() -> () {} - | ^^ `()` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `Foo::bar::{opaque#0}` - --> $DIR/doesnt-satisfy.rs:8:22 - | -LL | fn bar() -> impl std::fmt::Display; - | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::bar::{opaque#0}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr deleted file mode 100644 index f0cd43bcf..000000000 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/doesnt-satisfy.rs:12:17 - | -LL | fn bar() -> () {} - | ^^ `()` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `Foo::{opaque#0}` - --> $DIR/doesnt-satisfy.rs:8:22 - | -LL | fn bar() -> impl std::fmt::Display; - | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs index fcd0b51ee..bb4e0d44f 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr new file mode 100644 index 000000000..7c56ffa10 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr @@ -0,0 +1,17 @@ +error[E0277]: `()` doesn't implement `std::fmt::Display` + --> $DIR/doesnt-satisfy.rs:9:17 + | +LL | fn bar() -> () {} + | ^^ `()` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `()` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Foo::{opaque#0}` + --> $DIR/doesnt-satisfy.rs:5:22 + | +LL | fn bar() -> impl std::fmt::Display; + | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr deleted file mode 100644 index d4d0124a6..000000000 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1 - | -LL | fn foo(&self) -> impl Sized; - | ---------------------------- `foo` from trait -... -LL | impl MyTrait for i32 { - | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr deleted file mode 100644 index d4d0124a6..000000000 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1 - | -LL | fn foo(&self) -> impl Sized; - | ---------------------------- `foo` from trait -... -LL | impl MyTrait for i32 { - | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs index 4d50b8c92..4719d5d3c 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] trait MyTrait { diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr new file mode 100644 index 000000000..66ee142cc --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/dont-project-to-rpitit-with-no-value.rs:8:1 + | +LL | fn foo(&self) -> impl Sized; + | ---------------------------- `foo` from trait +... +LL | impl MyTrait for i32 { + | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/early.rs b/tests/ui/impl-trait/in-trait/early.rs index 831033a58..9c1c2b503 100644 --- a/tests/ui/impl-trait/in-trait/early.rs +++ b/tests/ui/impl-trait/in-trait/early.rs @@ -1,7 +1,5 @@ // check-pass // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/encode.rs b/tests/ui/impl-trait/in-trait/encode.rs index 98aaf4a65..efb9f6498 100644 --- a/tests/ui/impl-trait/in-trait/encode.rs +++ b/tests/ui/impl-trait/in-trait/encode.rs @@ -1,7 +1,5 @@ // build-pass // compile-flags: --crate-type=lib -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr index 6eef392c0..bfb2be8cb 100644 --- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr @@ -5,7 +5,7 @@ LL | let _: &dyn rpitit::Foo = todo!(); | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/auxiliary/rpitit.rs:8:21 + --> $DIR/auxiliary/rpitit.rs:6:21 | LL | fn bar(self) -> impl Deref; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because method `bar` references an `impl Trait` type in its return type diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs index b0fbe3a3d..b0c93a029 100644 --- a/tests/ui/impl-trait/in-trait/foreign.rs +++ b/tests/ui/impl-trait/in-trait/foreign.rs @@ -1,7 +1,5 @@ // check-pass // aux-build: rpitit.rs -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next extern crate rpitit; @@ -11,7 +9,9 @@ use std::sync::Arc; // Implement an RPITIT from another crate. struct Local; impl Foo for Local { - fn bar(self) -> Arc { Arc::new(String::new()) } + fn bar(self) -> Arc { + Arc::new(String::new()) + } } fn generic(f: impl Foo) { diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr deleted file mode 100644 index 310edbcb6..000000000 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/generics-mismatch.rs:14:12 - | -LL | fn bar(&self) -> impl Sized; - | - expected 0 type parameters -... -LL | fn bar(&self) {} - | ^ found 1 type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr deleted file mode 100644 index 310edbcb6..000000000 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/generics-mismatch.rs:14:12 - | -LL | fn bar(&self) -> impl Sized; - | - expected 0 type parameters -... -LL | fn bar(&self) {} - | ^ found 1 type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.rs b/tests/ui/impl-trait/in-trait/generics-mismatch.rs index 9259ca193..cc0fc720e 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr new file mode 100644 index 000000000..cd42683e0 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/generics-mismatch.rs:11:12 + | +LL | fn bar(&self) -> impl Sized; + | - expected 0 type parameters +... +LL | fn bar(&self) {} + | ^ found 1 type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/issue-102140.current.stderr b/tests/ui/impl-trait/in-trait/issue-102140.current.stderr deleted file mode 100644 index 7aa7880e2..000000000 --- a/tests/ui/impl-trait/in-trait/issue-102140.current.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:26:22 - | -LL | MyTrait::foo(&self) - | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | | - | required by a bound introduced by this call - | -help: consider removing the leading `&`-reference - | -LL - MyTrait::foo(&self) -LL + MyTrait::foo(self) - | - -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:26:9 - | -LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | - = help: the trait `MyTrait` is implemented for `Outer` - -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:26:9 - | -LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | - = help: the trait `MyTrait` is implemented for `Outer` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr deleted file mode 100644 index 94893c9e7..000000000 --- a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:26:22 - | -LL | MyTrait::foo(&self) - | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | | - | required by a bound introduced by this call - | - = help: the trait `MyTrait` is implemented for `Outer` - -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:26:9 - | -LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | - = help: the trait `MyTrait` is implemented for `Outer` - -error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:26:9 - | -LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` - | - = help: the trait `MyTrait` is implemented for `Outer` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/issue-102140.rs b/tests/ui/impl-trait/in-trait/issue-102140.rs index 4dcac4f5b..be1e012ac 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.rs +++ b/tests/ui/impl-trait/in-trait/issue-102140.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102140.stderr b/tests/ui/impl-trait/in-trait/issue-102140.stderr new file mode 100644 index 000000000..5d55b9fa4 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102140.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/issue-102140.rs:23:22 + | +LL | MyTrait::foo(&self) + | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | | + | required by a bound introduced by this call + | + = help: the trait `MyTrait` is implemented for `Outer` + +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/issue-102140.rs:23:9 + | +LL | MyTrait::foo(&self) + | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | + = help: the trait `MyTrait` is implemented for `Outer` + +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/issue-102140.rs:23:9 + | +LL | MyTrait::foo(&self) + | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | + = help: the trait `MyTrait` is implemented for `Outer` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/issue-102301.rs b/tests/ui/impl-trait/in-trait/issue-102301.rs index 1329ca29d..a93714a65 100644 --- a/tests/ui/impl-trait/in-trait/issue-102301.rs +++ b/tests/ui/impl-trait/in-trait/issue-102301.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102571.current.stderr b/tests/ui/impl-trait/in-trait/issue-102571.current.stderr deleted file mode 100644 index cac9a29f6..000000000 --- a/tests/ui/impl-trait/in-trait/issue-102571.current.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-102571.rs:23:9 - | -LL | let () = t.bar(); - | ^^ ------- this expression has type `impl Deref` - | | - | expected associated type, found `()` - | - = note: expected associated type `impl Deref` - found unit type `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/issue-102571.next.stderr b/tests/ui/impl-trait/in-trait/issue-102571.next.stderr deleted file mode 100644 index cac9a29f6..000000000 --- a/tests/ui/impl-trait/in-trait/issue-102571.next.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-102571.rs:23:9 - | -LL | let () = t.bar(); - | ^^ ------- this expression has type `impl Deref` - | | - | expected associated type, found `()` - | - = note: expected associated type `impl Deref` - found unit type `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/issue-102571.rs b/tests/ui/impl-trait/in-trait/issue-102571.rs index f0ddab5e7..61c91e644 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.rs +++ b/tests/ui/impl-trait/in-trait/issue-102571.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102571.stderr b/tests/ui/impl-trait/in-trait/issue-102571.stderr new file mode 100644 index 000000000..87219941d --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102571.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-102571.rs:20:9 + | +LL | let () = t.bar(); + | ^^ ------- this expression has type `impl Deref` + | | + | expected associated type, found `()` + | + = note: expected associated type `impl Deref` + found unit type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs new file mode 100644 index 000000000..abc845d3a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs @@ -0,0 +1,12 @@ +#![feature(return_position_impl_trait_in_trait)] + +trait Iterable { + type Item<'a> + where + Self: 'a; + + fn iter(&self) -> impl Iterator>; + //~^ ERROR use of undeclared lifetime name `'missing` +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr new file mode 100644 index 000000000..0d74c0b69 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr @@ -0,0 +1,23 @@ +error[E0261]: use of undeclared lifetime name `'missing` + --> $DIR/missing-lt-outlives-in-rpitit-114274.rs:8:55 + | +LL | fn iter(&self) -> impl Iterator>; + | ^^^^^^^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'missing` lifetime + | +LL | fn iter(&self) -> impl for<'missing> Iterator>; + | +++++++++++++ +help: consider introducing lifetime `'missing` here + | +LL | fn iter<'missing>(&self) -> impl Iterator>; + | ++++++++++ +help: consider introducing lifetime `'missing` here + | +LL | trait Iterable<'missing> { + | ++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/impl-trait/in-trait/nested-rpitit.rs b/tests/ui/impl-trait/in-trait/nested-rpitit.rs index 360207537..65285e3a3 100644 --- a/tests/ui/impl-trait/in-trait/nested-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/nested-rpitit.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/object-safety.current.stderr b/tests/ui/impl-trait/in-trait/object-safety.current.stderr deleted file mode 100644 index 2c340a023..000000000 --- a/tests/ui/impl-trait/in-trait/object-safety.current.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:33 - | -LL | let i = Box::new(42_u32) as Box; - | ^^^^^^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:10:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:23:13 - | -LL | let s = i.baz(); - | ^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:10:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:13 - | -LL | let i = Box::new(42_u32) as Box; - | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:10:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = note: required for the cast from `Box` to `Box` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/object-safety.next.stderr b/tests/ui/impl-trait/in-trait/object-safety.next.stderr deleted file mode 100644 index 2c340a023..000000000 --- a/tests/ui/impl-trait/in-trait/object-safety.next.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:33 - | -LL | let i = Box::new(42_u32) as Box; - | ^^^^^^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:10:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:23:13 - | -LL | let s = i.baz(); - | ^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:10:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:13 - | -LL | let i = Box::new(42_u32) as Box; - | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:10:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = note: required for the cast from `Box` to `Box` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs index 016a0aaae..dd35b9a2d 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.rs +++ b/tests/ui/impl-trait/in-trait/object-safety.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr new file mode 100644 index 000000000..4a3b3b114 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -0,0 +1,49 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:17:33 + | +LL | let i = Box::new(42_u32) as Box; + | ^^^^^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-safety.rs:7:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:20:13 + | +LL | let s = i.baz(); + | ^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-safety.rs:7:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:17:13 + | +LL | let i = Box::new(42_u32) as Box; + | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-safety.rs:7:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + = note: required for the cast from `Box` to `Box` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr deleted file mode 100644 index a57653b2c..000000000 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/opaque-in-impl-is-opaque.rs:20:19 - | -LL | fn bar(&self) -> impl Display { - | ------------ the found opaque type -... -LL | let x: &str = ().bar(); - | ---- ^^^^^^^^ expected `&str`, found opaque type - | | - | expected due to this - | - = note: expected reference `&str` - found opaque type `impl std::fmt::Display` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr deleted file mode 100644 index a57653b2c..000000000 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/opaque-in-impl-is-opaque.rs:20:19 - | -LL | fn bar(&self) -> impl Display { - | ------------ the found opaque type -... -LL | let x: &str = ().bar(); - | ---- ^^^^^^^^ expected `&str`, found opaque type - | | - | expected due to this - | - = note: expected reference `&str` - found opaque type `impl std::fmt::Display` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs index c07ece15a..3ac264e8e 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr new file mode 100644 index 000000000..15edda483 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/opaque-in-impl-is-opaque.rs:17:19 + | +LL | fn bar(&self) -> impl Display { + | ------------ the found opaque type +... +LL | let x: &str = ().bar(); + | ---- ^^^^^^^^ expected `&str`, found opaque type + | | + | expected due to this + | + = note: expected reference `&str` + found opaque type `impl std::fmt::Display` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs index f48d9fa26..2e0662969 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs b/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs new file mode 100644 index 000000000..6330242ce --- /dev/null +++ b/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(return_position_impl_trait_in_trait)] + +trait Foo { + fn early<'a, T: 'a>(x: &'a T) -> impl Iterator>; + + fn late<'a, T>(x: &'a T) -> impl Iterator>; +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr deleted file mode 100644 index ff30103b7..000000000 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: the trait bound `impl Foo: Foo` is not satisfied - --> $DIR/return-dont-satisfy-bounds.rs:13:34 - | -LL | fn foo>(self) -> impl Foo { - | ^^^^^^^^^^^^ the trait `Foo` is not implemented for `impl Foo` - | - = help: the trait `Foo` is implemented for `Bar` -note: required by a bound in `Foo::foo::{opaque#0}` - --> $DIR/return-dont-satisfy-bounds.rs:7:30 - | -LL | fn foo(self) -> impl Foo; - | ^^^^^^ required by this bound in `Foo::foo::{opaque#0}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr deleted file mode 100644 index 7c7f7feaa..000000000 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: the trait bound `impl Foo: Foo` is not satisfied - --> $DIR/return-dont-satisfy-bounds.rs:13:34 - | -LL | fn foo>(self) -> impl Foo { - | ^^^^^^^^^^^^ the trait `Foo` is not implemented for `impl Foo` - | - = help: the trait `Foo` is implemented for `Bar` -note: required by a bound in `Foo::{opaque#0}` - --> $DIR/return-dont-satisfy-bounds.rs:7:30 - | -LL | fn foo(self) -> impl Foo; - | ^^^^^^ required by this bound in `Foo::{opaque#0}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs index 65528f212..5d9a224cc 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] trait Foo { diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr new file mode 100644 index 000000000..668fc6cbe --- /dev/null +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `impl Foo: Foo` is not satisfied + --> $DIR/return-dont-satisfy-bounds.rs:10:34 + | +LL | fn foo>(self) -> impl Foo { + | ^^^^^^^^^^^^ the trait `Foo` is not implemented for `impl Foo` + | + = help: the trait `Foo` is implemented for `Bar` +note: required by a bound in `Foo::{opaque#0}` + --> $DIR/return-dont-satisfy-bounds.rs:4:30 + | +LL | fn foo(self) -> impl Foo; + | ^^^^^^ required by this bound in `Foo::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/reveal.rs b/tests/ui/impl-trait/in-trait/reveal.rs index 1f42ec744..d6ede1cc4 100644 --- a/tests/ui/impl-trait/in-trait/reveal.rs +++ b/tests/ui/impl-trait/in-trait/reveal.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs new file mode 100644 index 000000000..7682884f8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs @@ -0,0 +1,18 @@ +// issue: 113903 + +#![feature(return_position_impl_trait_in_trait)] + +use std::ops::Deref; + +pub trait Tr { + fn w() -> impl Deref>; + //~^ ERROR cannot find type `Missing` in this scope +} + +impl Tr for () { + fn w() -> &'static () { + &() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr new file mode 100644 index 000000000..6e4a5bb5d --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/rpitit-shadowed-by-missing-adt.rs:8:35 + | +LL | fn w() -> impl Deref>; + | ^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr deleted file mode 100644 index 8c9dd4031..000000000 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: return type captures more lifetimes than trait definition - --> $DIR/signature-mismatch.rs:36:47 - | -LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: hidden type must only reference lifetimes captured by this impl trait - --> $DIR/signature-mismatch.rs:17:40 - | -LL | fn async_fn(&self, buff: &[u8]) -> impl Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: hidden type inferred to be `impl Future> + 'a` - -error: return type captures more lifetimes than trait definition - --> $DIR/signature-mismatch.rs:41:57 - | -LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: hidden type must only reference lifetimes captured by this impl trait - --> $DIR/signature-mismatch.rs:18:57 - | -LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: hidden type inferred to be `impl Future> + 'a` - -error: return type captures more lifetimes than trait definition - --> $DIR/signature-mismatch.rs:49:10 - | -LL | fn async_fn_multiple<'a, 'b>( - | -- this lifetime was captured -... -LL | ) -> impl Future> + Captures2<'a, 'b> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: hidden type must only reference lifetimes captured by this impl trait - --> $DIR/signature-mismatch.rs:20:12 - | -LL | -> impl Future> + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: hidden type inferred to be `impl Future> + Captures2<'a, 'b>` - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/signature-mismatch.rs:58:10 - | -LL | ) -> impl Future> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future>` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/signature-mismatch.rs:25:42 - | -LL | ) -> impl Future> + 'a; - | ^^ -help: consider adding an explicit lifetime bound... - | -LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>( - | ++++ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr deleted file mode 100644 index 8c9dd4031..000000000 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: return type captures more lifetimes than trait definition - --> $DIR/signature-mismatch.rs:36:47 - | -LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: hidden type must only reference lifetimes captured by this impl trait - --> $DIR/signature-mismatch.rs:17:40 - | -LL | fn async_fn(&self, buff: &[u8]) -> impl Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: hidden type inferred to be `impl Future> + 'a` - -error: return type captures more lifetimes than trait definition - --> $DIR/signature-mismatch.rs:41:57 - | -LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: hidden type must only reference lifetimes captured by this impl trait - --> $DIR/signature-mismatch.rs:18:57 - | -LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: hidden type inferred to be `impl Future> + 'a` - -error: return type captures more lifetimes than trait definition - --> $DIR/signature-mismatch.rs:49:10 - | -LL | fn async_fn_multiple<'a, 'b>( - | -- this lifetime was captured -... -LL | ) -> impl Future> + Captures2<'a, 'b> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: hidden type must only reference lifetimes captured by this impl trait - --> $DIR/signature-mismatch.rs:20:12 - | -LL | -> impl Future> + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: hidden type inferred to be `impl Future> + Captures2<'a, 'b>` - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/signature-mismatch.rs:58:10 - | -LL | ) -> impl Future> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future>` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/signature-mismatch.rs:25:42 - | -LL | ) -> impl Future> + 'a; - | ^^ -help: consider adding an explicit lifetime bound... - | -LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>( - | ++++ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.rs b/tests/ui/impl-trait/in-trait/signature-mismatch.rs index 23dd71ace..1d63a6f3c 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs @@ -1,6 +1,4 @@ // edition:2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.stderr new file mode 100644 index 000000000..616f1ac35 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.stderr @@ -0,0 +1,61 @@ +error: return type captures more lifetimes than trait definition + --> $DIR/signature-mismatch.rs:34:47 + | +LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { + | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: hidden type must only reference lifetimes captured by this impl trait + --> $DIR/signature-mismatch.rs:15:40 + | +LL | fn async_fn(&self, buff: &[u8]) -> impl Future>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: hidden type inferred to be `impl Future> + 'a` + +error: return type captures more lifetimes than trait definition + --> $DIR/signature-mismatch.rs:39:57 + | +LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { + | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: hidden type must only reference lifetimes captured by this impl trait + --> $DIR/signature-mismatch.rs:16:57 + | +LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: hidden type inferred to be `impl Future> + 'a` + +error: return type captures more lifetimes than trait definition + --> $DIR/signature-mismatch.rs:47:10 + | +LL | fn async_fn_multiple<'a, 'b>( + | -- this lifetime was captured +... +LL | ) -> impl Future> + Captures2<'a, 'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: hidden type must only reference lifetimes captured by this impl trait + --> $DIR/signature-mismatch.rs:18:12 + | +LL | -> impl Future> + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: hidden type inferred to be `impl Future> + Captures2<'a, 'b>` + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/signature-mismatch.rs:56:10 + | +LL | ) -> impl Future> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future>` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/signature-mismatch.rs:23:42 + | +LL | ) -> impl Future> + 'a; + | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>( + | ++++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr deleted file mode 100644 index f48e7a1ed..000000000 --- a/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/specialization-broken.rs:19:22 - | -LL | default impl Foo for U - | - this type parameter -... -LL | fn bar(&self) -> U { - | ^ - | | - | expected associated type, found type parameter `U` - | help: change the output type to match the trait: `impl Sized` - | -note: type in trait - --> $DIR/specialization-broken.rs:12:22 - | -LL | fn bar(&self) -> impl Sized; - | ^^^^^^^^^^ - = note: expected signature `fn(&U) -> impl Sized` - found signature `fn(&U) -> U` - -error: method with return-position `impl Trait` in trait cannot be specialized - --> $DIR/specialization-broken.rs:19:5 - | -LL | fn bar(&self) -> U { - | ^^^^^^^^^^^^^^^^^^ - | - = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr deleted file mode 100644 index f48e7a1ed..000000000 --- a/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/specialization-broken.rs:19:22 - | -LL | default impl Foo for U - | - this type parameter -... -LL | fn bar(&self) -> U { - | ^ - | | - | expected associated type, found type parameter `U` - | help: change the output type to match the trait: `impl Sized` - | -note: type in trait - --> $DIR/specialization-broken.rs:12:22 - | -LL | fn bar(&self) -> impl Sized; - | ^^^^^^^^^^ - = note: expected signature `fn(&U) -> impl Sized` - found signature `fn(&U) -> U` - -error: method with return-position `impl Trait` in trait cannot be specialized - --> $DIR/specialization-broken.rs:19:5 - | -LL | fn bar(&self) -> U { - | ^^^^^^^^^^^^^^^^^^ - | - = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs index 658d07097..2fcffdf3f 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.rs +++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - // FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not. // But we fixed an ICE anyways. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr new file mode 100644 index 000000000..dc621d6b8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -0,0 +1,31 @@ +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/specialization-broken.rs:16:22 + | +LL | default impl Foo for U + | - this type parameter +... +LL | fn bar(&self) -> U { + | ^ + | | + | expected associated type, found type parameter `U` + | help: change the output type to match the trait: `impl Sized` + | +note: type in trait + --> $DIR/specialization-broken.rs:9:22 + | +LL | fn bar(&self) -> impl Sized; + | ^^^^^^^^^^ + = note: expected signature `fn(&U) -> impl Sized` + found signature `fn(&U) -> U` + +error: method with return-position `impl Trait` in trait cannot be specialized + --> $DIR/specialization-broken.rs:16:5 + | +LL | fn bar(&self) -> U { + | ^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs index dbc5d38f1..c9ee877db 100644 --- a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs +++ b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(specialization)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/success.rs b/tests/ui/impl-trait/in-trait/success.rs index 0e69e0490..4cbe682b4 100644 --- a/tests/ui/impl-trait/in-trait/success.rs +++ b/tests/ui/impl-trait/in-trait/success.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr deleted file mode 100644 index 64c942705..000000000 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/trait-more-generics-than-impl.rs:14:11 - | -LL | fn bar() -> impl Sized; - | - expected 1 type parameter -... -LL | fn bar() -> impl Sized {} - | ^ found 0 type parameters - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr deleted file mode 100644 index 64c942705..000000000 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/trait-more-generics-than-impl.rs:14:11 - | -LL | fn bar() -> impl Sized; - | - expected 1 type parameter -... -LL | fn bar() -> impl Sized {} - | ^ found 0 type parameters - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs index c2e394a1f..0bbe50ea6 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr new file mode 100644 index 000000000..8ff54cad9 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr @@ -0,0 +1,12 @@ +error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/trait-more-generics-than-impl.rs:11:11 + | +LL | fn bar() -> impl Sized; + | - expected 1 type parameter +... +LL | fn bar() -> impl Sized {} + | ^ found 0 type parameters + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr deleted file mode 100644 index bf088ae8b..000000000 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/unconstrained-lt.rs:10:6 - | -LL | impl<'a, T> Foo for T { - | ^^ unconstrained lifetime parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr deleted file mode 100644 index bf088ae8b..000000000 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/unconstrained-lt.rs:10:6 - | -LL | impl<'a, T> Foo for T { - | ^^ unconstrained lifetime parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs index f966be43a..07c8606f9 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] trait Foo { @@ -10,7 +7,9 @@ trait Foo { impl<'a, T> Foo for T { //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - fn test() -> &'a () { &() } + fn test() -> &'a () { + &() + } } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr new file mode 100644 index 000000000..cfce35567 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr @@ -0,0 +1,9 @@ +error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-lt.rs:7:6 + | +LL | impl<'a, T> Foo for T { + | ^^ unconstrained lifetime parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/variances-of-gat.rs b/tests/ui/impl-trait/in-trait/variances-of-gat.rs index 4008ece94..0d19e1ff4 100644 --- a/tests/ui/impl-trait/in-trait/variances-of-gat.rs +++ b/tests/ui/impl-trait/in-trait/variances-of-gat.rs @@ -1,6 +1,4 @@ // check-pass -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr deleted file mode 100644 index 74c84c012..000000000 --- a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:17:22 - | -LL | fn nya() -> impl Wf>; - | ^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:20:23 - | -LL | fn nya2() -> impl Wf<[u8]>; - | ^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Wf` - --> $DIR/wf-bounds.rs:10:10 - | -LL | trait Wf { - | ^ required by this bound in `Wf` -help: consider relaxing the implicit `Sized` restriction - | -LL | trait Wf { - | ++++++++ - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:23:44 - | -LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; - | ^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/wf-bounds.rs:26:26 - | -LL | fn nya4() -> impl Wf>; - | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter - | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `NeedsDisplay` - --> $DIR/wf-bounds.rs:14:24 - | -LL | struct NeedsDisplay(T); - | ^^^^^^^ required by this bound in `NeedsDisplay` -help: consider restricting type parameter `T` - | -LL | fn nya4() -> impl Wf>; - | +++++++++++++++++++ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr deleted file mode 100644 index 74c84c012..000000000 --- a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:17:22 - | -LL | fn nya() -> impl Wf>; - | ^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:20:23 - | -LL | fn nya2() -> impl Wf<[u8]>; - | ^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Wf` - --> $DIR/wf-bounds.rs:10:10 - | -LL | trait Wf { - | ^ required by this bound in `Wf` -help: consider relaxing the implicit `Sized` restriction - | -LL | trait Wf { - | ++++++++ - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:23:44 - | -LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; - | ^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/wf-bounds.rs:26:26 - | -LL | fn nya4() -> impl Wf>; - | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter - | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `NeedsDisplay` - --> $DIR/wf-bounds.rs:14:24 - | -LL | struct NeedsDisplay(T); - | ^^^^^^^ required by this bound in `NeedsDisplay` -help: consider restricting type parameter `T` - | -LL | fn nya4() -> impl Wf>; - | +++++++++++++++++++ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs index f8c1e561d..ee873f94b 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.rs +++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs @@ -1,6 +1,4 @@ // issue #101663 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.stderr new file mode 100644 index 000000000..4d60b1330 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/wf-bounds.stderr @@ -0,0 +1,53 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:15:22 + | +LL | fn nya() -> impl Wf>; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:18:23 + | +LL | fn nya2() -> impl Wf<[u8]>; + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Wf` + --> $DIR/wf-bounds.rs:8:10 + | +LL | trait Wf { + | ^ required by this bound in `Wf` +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Wf { + | ++++++++ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:21:44 + | +LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: `T` doesn't implement `std::fmt::Display` + --> $DIR/wf-bounds.rs:24:26 + | +LL | fn nya4() -> impl Wf>; + | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter + | + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `NeedsDisplay` + --> $DIR/wf-bounds.rs:12:24 + | +LL | struct NeedsDisplay(T); + | ^^^^^^^ required by this bound in `NeedsDisplay` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/where-clause.rs b/tests/ui/impl-trait/in-trait/where-clause.rs index 88d86e2b5..87bac519c 100644 --- a/tests/ui/impl-trait/in-trait/where-clause.rs +++ b/tests/ui/impl-trait/in-trait/where-clause.rs @@ -1,7 +1,5 @@ // check-pass // edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/issue-102605.stderr b/tests/ui/impl-trait/issue-102605.stderr index dfe18e43e..dcb227971 100644 --- a/tests/ui/impl-trait/issue-102605.stderr +++ b/tests/ui/impl-trait/issue-102605.stderr @@ -1,3 +1,11 @@ +error[E0277]: `main` has invalid return type `Option<()>` + --> $DIR/issue-102605.rs:11:14 + | +LL | fn main() -> Option<()> { + | ^^^^^^^^^^ `main` can only return types that implement `Termination` + | + = help: consider using `()`, or a `Result` + error[E0308]: mismatched types --> $DIR/issue-102605.rs:13:20 | @@ -25,14 +33,6 @@ help: try wrapping the expression in `Err` LL | convert_result(Err(foo())) | ++++ + -error[E0277]: `main` has invalid return type `Option<()>` - --> $DIR/issue-102605.rs:11:14 - | -LL | fn main() -> Option<()> { - | ^^^^^^^^^^ `main` can only return types that implement `Termination` - | - = help: consider using `()`, or a `Result` - error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0308. diff --git a/tests/ui/impl-trait/issue-99073-2.rs b/tests/ui/impl-trait/issue-99073-2.rs index 14ac68880..37ea211be 100644 --- a/tests/ui/impl-trait/issue-99073-2.rs +++ b/tests/ui/impl-trait/issue-99073-2.rs @@ -8,6 +8,7 @@ fn test(t: T, recurse: bool) -> impl Display { let f = || { let i: u32 = test::(-1, false); //~^ ERROR concrete type differs from previous defining opaque type use + //~| ERROR expected generic type parameter, found `i32` println!("{i}"); }; if recurse { diff --git a/tests/ui/impl-trait/issue-99073-2.stderr b/tests/ui/impl-trait/issue-99073-2.stderr index 913bc8f56..06b2b8456 100644 --- a/tests/ui/impl-trait/issue-99073-2.stderr +++ b/tests/ui/impl-trait/issue-99073-2.stderr @@ -1,3 +1,12 @@ +error[E0792]: expected generic type parameter, found `i32` + --> $DIR/issue-99073-2.rs:9:22 + | +LL | fn test(t: T, recurse: bool) -> impl Display { + | - this generic parameter must be used with a generic type parameter +LL | let f = || { +LL | let i: u32 = test::(-1, false); + | ^^^^^^^^^^^^^^^^^^^^^^ + error: concrete type differs from previous defining opaque type use --> $DIR/issue-99073-2.rs:9:22 | @@ -5,10 +14,11 @@ LL | let i: u32 = test::(-1, false); | ^^^^^^^^^^^^^^^^^^^^^^ expected `T`, got `u32` | note: previous use here - --> $DIR/issue-99073-2.rs:16:5 + --> $DIR/issue-99073-2.rs:7:45 | -LL | t - | ^ +LL | fn test(t: T, recurse: bool) -> impl Display { + | ^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/issue-99073.rs b/tests/ui/impl-trait/issue-99073.rs index 7798e247d..b4ef3e66f 100644 --- a/tests/ui/impl-trait/issue-99073.rs +++ b/tests/ui/impl-trait/issue-99073.rs @@ -5,4 +5,5 @@ fn main() { fn fix(f: F) -> impl Fn() { move || f(fix(&f)) //~^ ERROR concrete type differs from previous defining opaque type use + //~| ERROR expected generic type parameter, found `&F` } diff --git a/tests/ui/impl-trait/issue-99073.stderr b/tests/ui/impl-trait/issue-99073.stderr index 546367953..a8400080e 100644 --- a/tests/ui/impl-trait/issue-99073.stderr +++ b/tests/ui/impl-trait/issue-99073.stderr @@ -1,14 +1,23 @@ -error: concrete type differs from previous defining opaque type use +error[E0792]: expected generic type parameter, found `&F` --> $DIR/issue-99073.rs:6:11 | +LL | fn fix(f: F) -> impl Fn() { + | - this generic parameter must be used with a generic type parameter +LL | move || f(fix(&f)) + | ^^^^^^^^^^ + +error: concrete type differs from previous defining opaque type use + --> $DIR/issue-99073.rs:6:13 + | LL | move || f(fix(&f)) - | ^^^^^^^^^^ expected `[closure@$DIR/issue-99073.rs:6:3: 6:10]`, got `G` + | ^^^^^^^ expected `[closure@$DIR/issue-99073.rs:6:3: 6:10]`, got `G` | note: previous use here - --> $DIR/issue-99073.rs:6:3 + --> $DIR/issue-99073.rs:5:36 | -LL | move || f(fix(&f)) - | ^^^^^^^^^^^^^^^^^^ +LL | fn fix(f: F) -> impl Fn() { + | ^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/issues/issue-86800.rs b/tests/ui/impl-trait/issues/issue-86800.rs index ec4fda322..df70b324c 100644 --- a/tests/ui/impl-trait/issues/issue-86800.rs +++ b/tests/ui/impl-trait/issues/issue-86800.rs @@ -5,7 +5,7 @@ // error-pattern: aborting due to `-Z treat-err-as-bug=1` // failure-status:101 // normalize-stderr-test ".*note: .*\n\n" -> "" -// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*:\n.*\n" -> "" // rustc-env:RUST_BACKTRACE=0 use std::future::Future; diff --git a/tests/ui/impl-trait/lifetime-ambiguity-regression.rs b/tests/ui/impl-trait/lifetime-ambiguity-regression.rs new file mode 100644 index 000000000..ce6ae3786 --- /dev/null +++ b/tests/ui/impl-trait/lifetime-ambiguity-regression.rs @@ -0,0 +1,13 @@ +//! This test shows a situation where through subtle compiler changes we can +//! suddenly infer a different lifetime in the hidden type, and thus not meet +//! the opaque type bounds anymore. In this case `'a` and `'b` are equal, so +//! picking either is fine, but then we'll fail an identity check of the hidden +//! type and the expected hidden type. + +// check-pass + +fn test<'a: 'b, 'b: 'a>() -> impl IntoIterator)> { + None::<(_, (_, _))> +} + +fn main() {} diff --git a/tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs b/tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs new file mode 100644 index 000000000..a2dd0a930 --- /dev/null +++ b/tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs @@ -0,0 +1,15 @@ +// check-pass +// issue: 114597 +// edition: 2021 + +struct A<'a> { + dat: &'a (), +} + +impl<'a> A<'a> { + async fn a(&self) -> impl Iterator> { + std::iter::repeat(()).map(|()| std::iter::repeat(())) + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/nested-rpit-hrtb-2.rs b/tests/ui/impl-trait/nested-rpit-hrtb-2.rs new file mode 100644 index 000000000..4d7296215 --- /dev/null +++ b/tests/ui/impl-trait/nested-rpit-hrtb-2.rs @@ -0,0 +1,9 @@ +// The nested impl Trait references a higher-ranked region + +trait Trait<'a> { type Assoc; } +impl<'a> Trait<'a> for () { type Assoc = &'a str; } + +fn test() -> impl for<'a> Trait<'a, Assoc = impl Sized> {} +//~^ ERROR captures lifetime that does not appear in bounds + +fn main() {} diff --git a/tests/ui/impl-trait/nested-rpit-hrtb-2.stderr b/tests/ui/impl-trait/nested-rpit-hrtb-2.stderr new file mode 100644 index 000000000..71d1d45f4 --- /dev/null +++ b/tests/ui/impl-trait/nested-rpit-hrtb-2.stderr @@ -0,0 +1,12 @@ +error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds + --> $DIR/nested-rpit-hrtb-2.rs:6:57 + | +LL | fn test() -> impl for<'a> Trait<'a, Assoc = impl Sized> {} + | -- ---------- ^^ + | | | + | | opaque type defined here + | hidden type `&'a str` captures the lifetime `'a` as defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs index d2e34c00b..dd03fd3f7 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.rs +++ b/tests/ui/impl-trait/normalize-tait-in-const.rs @@ -1,9 +1,4 @@ // known-bug: #103507 -// failure-status: 101 -// normalize-stderr-test "note: .*\n\n" -> "" -// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" -// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -// rustc-env:RUST_BACKTRACE=0 #![feature(type_alias_impl_trait)] #![feature(const_trait_impl)] diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 84b009187..5fbba9a85 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,8 +1,25 @@ -error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:LL:CC: Failed to normalize fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/normalize-tait-in-const.rs:26:5 + | +LL | fun(filter_positive()); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | const fn with_positive Fn(&'a Alias<'a>) + ~const Destruct + ~const std::ops::Fn<(&Alias<'_>,)>>(fun: F) { + | ++++++++++++++++++++++++++++++++++++ -query stack during panic: -#0 [eval_to_allocation_raw] const-evaluating + checking `BAR` -#1 [eval_to_const_value_raw] simplifying constant for the type system `BAR` -end of query stack -error: aborting due to previous error +error[E0493]: destructor of `F` cannot be evaluated at compile-time + --> $DIR/normalize-tait-in-const.rs:25:79 + | +LL | const fn with_positive Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { + | ^^^ the destructor for this type cannot be evaluated in constant functions +LL | fun(filter_positive()); +LL | } + | - value is dropped here +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0015, E0493. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs b/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs new file mode 100644 index 000000000..3e3bc09a6 --- /dev/null +++ b/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs @@ -0,0 +1,27 @@ +// edition: 2021 + +use std::future::Future; + +async fn bop() { + fold(run(), |mut foo| async move { + &mut foo.bar; + }) +} + +fn fold(_: Foo, f: F) +where + F: FnMut(Foo) -> Fut, +{ + loop {} +} + +struct Foo { + bar: Vec, +} + +fn run() -> Foo> { + //~^ ERROR type annotations needed + loop {} +} + +fn main() {} diff --git a/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr b/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr new file mode 100644 index 000000000..ee4343b11 --- /dev/null +++ b/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/opaque-cast-field-access-in-future.rs:22:17 + | +LL | fn run() -> Foo> { + | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/recursive-auto-trait.rs b/tests/ui/impl-trait/recursive-auto-trait.rs new file mode 100644 index 000000000..d7b68144f --- /dev/null +++ b/tests/ui/impl-trait/recursive-auto-trait.rs @@ -0,0 +1,10 @@ +// check-pass +fn is_send(_: T) {} +fn foo() -> impl Send { + if false { + is_send(foo()); + } + () +} + +fn main() {} diff --git a/tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs b/tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs new file mode 100644 index 000000000..6207381c7 --- /dev/null +++ b/tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs @@ -0,0 +1,19 @@ +// check-pass + +// related to #113916, check that using RPITs in functions with lifetime params +// which are constrained to be equal compiles. + +trait Trait<'a, 'b> {} +impl Trait<'_, '_> for () {} +fn pass<'a: 'b, 'b: 'a>() -> impl Trait<'a, 'b> { + (|| {})() +} + +struct Foo<'a>(&'a ()); +impl<'a> Foo<'a> { + fn bar<'b: 'a>(&'b self) -> impl Trait<'a, 'b> { + let _: &'a &'b &'a (); + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/rpit/non-defining-use.rs b/tests/ui/impl-trait/rpit/non-defining-use.rs new file mode 100644 index 000000000..255a8929a --- /dev/null +++ b/tests/ui/impl-trait/rpit/non-defining-use.rs @@ -0,0 +1,14 @@ +// Regression test for #111935 that non-defining uses of RPIT result in errors +#![allow(unconditional_recursion)] +fn foo() -> impl Sized { + let _: () = foo::(); //~ ERROR expected generic type parameter, found `u8` +} + +fn bar(val: T) -> impl Sized { + let _: u8 = bar(0u8); + //~^ ERROR concrete type differs from previous defining opaque type use + //~| ERROR expected generic type parameter, found `u8` + val +} + +fn main() {} diff --git a/tests/ui/impl-trait/rpit/non-defining-use.stderr b/tests/ui/impl-trait/rpit/non-defining-use.stderr new file mode 100644 index 000000000..19987d476 --- /dev/null +++ b/tests/ui/impl-trait/rpit/non-defining-use.stderr @@ -0,0 +1,31 @@ +error[E0792]: expected generic type parameter, found `u8` + --> $DIR/non-defining-use.rs:4:12 + | +LL | fn foo() -> impl Sized { + | - this generic parameter must be used with a generic type parameter +LL | let _: () = foo::(); + | ^^ + +error[E0792]: expected generic type parameter, found `u8` + --> $DIR/non-defining-use.rs:8:12 + | +LL | fn bar(val: T) -> impl Sized { + | - this generic parameter must be used with a generic type parameter +LL | let _: u8 = bar(0u8); + | ^^ + +error: concrete type differs from previous defining opaque type use + --> $DIR/non-defining-use.rs:8:17 + | +LL | let _: u8 = bar(0u8); + | ^^^^^^^^ expected `T`, got `u8` + | +note: previous use here + --> $DIR/non-defining-use.rs:7:22 + | +LL | fn bar(val: T) -> impl Sized { + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-1.rs b/tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-1.rs new file mode 100644 index 000000000..9b793642d --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-1.rs @@ -0,0 +1,26 @@ +// check-pass + +pub trait Foo { + type Error: Error; + + fn foo(&self, stream: &::Span); +} + +pub struct Wrapper(Inner); + +impl Foo for Wrapper +where + Inner: Foo, +{ + type Error = E; + + fn foo(&self, stream: &::Span) { + todo!() + } +} + +pub trait Error { + type Span; +} + +fn main() {} diff --git a/tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-2.rs b/tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-2.rs new file mode 100644 index 000000000..86b10a56c --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-entailment-wf-vars-issue-114783-2.rs @@ -0,0 +1,26 @@ +// check-pass + +trait AsBufferView { + type Device; +} + +trait Error { + type Span; +} + +trait Foo { + type Error: Error; + fn foo(&self) -> &::Span; +} + +impl Foo for VBuf0 +where + VBuf0: AsBufferView, +{ + type Error = D; + fn foo(&self) -> &::Span { + todo!() + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs b/tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs new file mode 100644 index 000000000..e0df96b0d --- /dev/null +++ b/tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs @@ -0,0 +1,32 @@ +// check-pass + +trait Data { + type Elem; +} + +impl> Data for ArrayBase { + type Elem = F; +} + +struct DatasetIter<'a, R: Data> { + data: &'a R::Elem, +} + +pub struct ArrayBase { + data: S, +} + +trait Trait { + type Item; + fn next() -> Option; +} + +impl<'a, D: Data> Trait for DatasetIter<'a, ArrayBase> { + type Item = (); + + fn next() -> Option { + None + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs b/tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs new file mode 100644 index 000000000..8dcc35a28 --- /dev/null +++ b/tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs @@ -0,0 +1,23 @@ +// check-pass +// See issue #109356. We don't want a false positive to the `implied_bounds_entailment` lint. + +use std::borrow::Cow; + +pub trait Trait { + fn method(self) -> Option> + where + Self: Sized; +} + +impl<'a> Trait for Cow<'a, str> { + // If we're not careful here, we'll check `WF(return-type)` using the trait + // and impl where clauses, requiring that `Cow<'a, str>: Sized`. This is + // obviously true, but if we pick the `Self: Sized` clause from the trait + // over the "inherent impl", we will require `'a == 'static`, which triggers + // the `implied_bounds_entailment` lint. + fn method(self) -> Option> { + None + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/trait-where-clause-implied.rs b/tests/ui/implied-bounds/trait-where-clause-implied.rs new file mode 100644 index 000000000..5f9ab66d3 --- /dev/null +++ b/tests/ui/implied-bounds/trait-where-clause-implied.rs @@ -0,0 +1,15 @@ +// check-pass + +pub trait Trait<'a, 'b> { + fn method(self, _: &'static &'static ()) + where + 'a: 'b; +} + +impl<'a> Trait<'a, 'static> for () { + // On first glance, this seems like we have the extra implied bound that + // `'a: 'static`, but we know this from the trait method where clause. + fn method(self, _: &'static &'a ()) {} +} + +fn main() {} diff --git a/tests/ui/imports/ambiguous-1.rs b/tests/ui/imports/ambiguous-1.rs new file mode 100644 index 000000000..2c9815864 --- /dev/null +++ b/tests/ui/imports/ambiguous-1.rs @@ -0,0 +1,30 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 + +macro_rules! m { + () => { + pub fn id() {} + }; +} + +mod openssl { + pub use self::evp::*; + //~^ WARNING ambiguous glob re-exports + pub use self::handwritten::*; + + mod evp { + m!(); + } + + mod handwritten { + m!(); + } +} + +pub use openssl::*; + +fn main() { + id(); + //~^ WARNING `id` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-1.stderr b/tests/ui/imports/ambiguous-1.stderr new file mode 100644 index 000000000..61b3077c3 --- /dev/null +++ b/tests/ui/imports/ambiguous-1.stderr @@ -0,0 +1,36 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-1.rs:11:13 + | +LL | pub use self::evp::*; + | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here +LL | +LL | pub use self::handwritten::*; + | -------------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `id` is ambiguous + --> $DIR/ambiguous-1.rs:27:5 + | +LL | id(); + | ^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `id` could refer to the function imported here + --> $DIR/ambiguous-1.rs:11:13 + | +LL | pub use self::evp::*; + | ^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate +note: `id` could also refer to the function imported here + --> $DIR/ambiguous-1.rs:13:13 + | +LL | pub use self::handwritten::*; + | ^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/imports/ambiguous-10.rs b/tests/ui/imports/ambiguous-10.rs new file mode 100644 index 000000000..5078b734b --- /dev/null +++ b/tests/ui/imports/ambiguous-10.rs @@ -0,0 +1,19 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +mod a { + pub enum Token {} +} + +mod b { + use crate::a::*; + #[derive(Debug)] + pub enum Token {} +} + +use crate::a::*; +use crate::b::*; +fn c(_: Token) {} +//~^ WARNING `Token` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +fn main() { } diff --git a/tests/ui/imports/ambiguous-10.stderr b/tests/ui/imports/ambiguous-10.stderr new file mode 100644 index 000000000..704af616b --- /dev/null +++ b/tests/ui/imports/ambiguous-10.stderr @@ -0,0 +1,25 @@ +warning: `Token` is ambiguous + --> $DIR/ambiguous-10.rs:16:9 + | +LL | fn c(_: Token) {} + | ^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Token` could refer to the enum imported here + --> $DIR/ambiguous-10.rs:14:5 + | +LL | use crate::a::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Token` to disambiguate +note: `Token` could also refer to the enum imported here + --> $DIR/ambiguous-10.rs:15:5 + | +LL | use crate::b::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Token` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-11.rs b/tests/ui/imports/ambiguous-11.rs new file mode 100644 index 000000000..0565b9d22 --- /dev/null +++ b/tests/ui/imports/ambiguous-11.rs @@ -0,0 +1,14 @@ +// aux-build: ambiguous-11-extern.rs + +extern crate ambiguous_11_extern; + +mod s { + pub trait Error {} +} + +use s::*; +use ambiguous_11_extern::*; +fn a(_: E) {} +//~^ ERROR `Error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/ambiguous-11.stderr b/tests/ui/imports/ambiguous-11.stderr new file mode 100644 index 000000000..765d6afa8 --- /dev/null +++ b/tests/ui/imports/ambiguous-11.stderr @@ -0,0 +1,23 @@ +error[E0659]: `Error` is ambiguous + --> $DIR/ambiguous-11.rs:11:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-11.rs:9:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-11.rs:10:5 + | +LL | use ambiguous_11_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-12.rs b/tests/ui/imports/ambiguous-12.rs new file mode 100644 index 000000000..6259c1357 --- /dev/null +++ b/tests/ui/imports/ambiguous-12.rs @@ -0,0 +1,25 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +macro_rules! m { + () => { + pub fn b() {} + }; +} + +pub mod ciphertext { + m!(); +} +pub mod public { + use crate::ciphertext::*; + m!(); +} + +use crate::ciphertext::*; +use crate::public::*; + +fn main() { + b(); + //~^ WARNING `b` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-12.stderr b/tests/ui/imports/ambiguous-12.stderr new file mode 100644 index 000000000..4725c3884 --- /dev/null +++ b/tests/ui/imports/ambiguous-12.stderr @@ -0,0 +1,25 @@ +warning: `b` is ambiguous + --> $DIR/ambiguous-12.rs:22:5 + | +LL | b(); + | ^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `b` could refer to the function imported here + --> $DIR/ambiguous-12.rs:18:5 + | +LL | use crate::ciphertext::*; + | ^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `b` to disambiguate +note: `b` could also refer to the function imported here + --> $DIR/ambiguous-12.rs:19:5 + | +LL | use crate::public::*; + | ^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `b` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-13.rs b/tests/ui/imports/ambiguous-13.rs new file mode 100644 index 000000000..82f933c49 --- /dev/null +++ b/tests/ui/imports/ambiguous-13.rs @@ -0,0 +1,22 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +pub mod object { + #[derive(Debug)] + pub struct Rect; +} + +pub mod content { + use crate::object::*; + + #[derive(Debug)] + pub struct Rect; +} + +use crate::object::*; +use crate::content::*; + +fn a(_: Rect) {} +//~^ WARNING `Rect` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +fn main() { } diff --git a/tests/ui/imports/ambiguous-13.stderr b/tests/ui/imports/ambiguous-13.stderr new file mode 100644 index 000000000..3e78100b6 --- /dev/null +++ b/tests/ui/imports/ambiguous-13.stderr @@ -0,0 +1,25 @@ +warning: `Rect` is ambiguous + --> $DIR/ambiguous-13.rs:19:9 + | +LL | fn a(_: Rect) {} + | ^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Rect` could refer to the struct imported here + --> $DIR/ambiguous-13.rs:16:5 + | +LL | use crate::object::*; + | ^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Rect` to disambiguate +note: `Rect` could also refer to the struct imported here + --> $DIR/ambiguous-13.rs:17:5 + | +LL | use crate::content::*; + | ^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Rect` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-14.rs b/tests/ui/imports/ambiguous-14.rs new file mode 100644 index 000000000..5e880b48c --- /dev/null +++ b/tests/ui/imports/ambiguous-14.rs @@ -0,0 +1,26 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/98467 + +mod a { + pub fn foo() {} +} + +mod b { + pub fn foo() {} +} + +mod f { + pub use a::*; + pub use b::*; +} + +mod g { + pub use a::*; + pub use f::*; +} + +fn main() { + g::foo(); + //~^ WARNING `foo` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-14.stderr b/tests/ui/imports/ambiguous-14.stderr new file mode 100644 index 000000000..bece58536 --- /dev/null +++ b/tests/ui/imports/ambiguous-14.stderr @@ -0,0 +1,25 @@ +warning: `foo` is ambiguous + --> $DIR/ambiguous-14.rs:23:8 + | +LL | g::foo(); + | ^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `foo` could refer to the function imported here + --> $DIR/ambiguous-14.rs:13:13 + | +LL | pub use a::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the function imported here + --> $DIR/ambiguous-14.rs:14:13 + | +LL | pub use b::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-15.rs b/tests/ui/imports/ambiguous-15.rs new file mode 100644 index 000000000..8c75c393a --- /dev/null +++ b/tests/ui/imports/ambiguous-15.rs @@ -0,0 +1,27 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +mod t2 { + #[derive(Debug)] + pub enum Error {} + + mod s { + pub use std::fmt::*; + pub trait Error: Sized {} + } + + use self::s::*; +} + +pub use t2::*; + +mod t3 { + pub trait Error {} +} + +use self::t3::*; +fn a(_: E) {} +//~^ WARNING `Error` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() {} diff --git a/tests/ui/imports/ambiguous-15.stderr b/tests/ui/imports/ambiguous-15.stderr new file mode 100644 index 000000000..838256752 --- /dev/null +++ b/tests/ui/imports/ambiguous-15.stderr @@ -0,0 +1,25 @@ +warning: `Error` is ambiguous + --> $DIR/ambiguous-15.rs:23:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-15.rs:22:5 + | +LL | use self::t3::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-15.rs:16:9 + | +LL | pub use t2::*; + | ^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-16.rs b/tests/ui/imports/ambiguous-16.rs new file mode 100644 index 000000000..e51e30e3e --- /dev/null +++ b/tests/ui/imports/ambiguous-16.rs @@ -0,0 +1,27 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099 + +mod framing { + mod public_message { + use super::*; + + #[derive(Debug)] + pub struct ConfirmedTranscriptHashInput; + } + + mod public_message_in { + use super::*; + + #[derive(Debug)] + pub struct ConfirmedTranscriptHashInput; + } + + pub use self::public_message::*; + pub use self::public_message_in::*; +} + +use crate::framing::ConfirmedTranscriptHashInput; +//~^ WARNING `ConfirmedTranscriptHashInput` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() { } diff --git a/tests/ui/imports/ambiguous-16.stderr b/tests/ui/imports/ambiguous-16.stderr new file mode 100644 index 000000000..7366cabc4 --- /dev/null +++ b/tests/ui/imports/ambiguous-16.stderr @@ -0,0 +1,25 @@ +warning: `ConfirmedTranscriptHashInput` is ambiguous + --> $DIR/ambiguous-16.rs:23:21 + | +LL | use crate::framing::ConfirmedTranscriptHashInput; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `ConfirmedTranscriptHashInput` could refer to the struct imported here + --> $DIR/ambiguous-16.rs:19:13 + | +LL | pub use self::public_message::*; + | ^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate +note: `ConfirmedTranscriptHashInput` could also refer to the struct imported here + --> $DIR/ambiguous-16.rs:20:13 + | +LL | pub use self::public_message_in::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-17.rs b/tests/ui/imports/ambiguous-17.rs new file mode 100644 index 000000000..7d01404ce --- /dev/null +++ b/tests/ui/imports/ambiguous-17.rs @@ -0,0 +1,29 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +pub use evp::*; //~ WARNING ambiguous glob re-exports +pub use handwritten::*; + +macro_rules! m { + () => { + pub fn id() {} + }; +} +mod evp { + use *; + m!(); +} + +mod handwritten { + pub use handwritten::evp::*; + mod evp { + use *; + m!(); + } +} + +fn main() { + id(); + //~^ WARNING `id` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-17.stderr b/tests/ui/imports/ambiguous-17.stderr new file mode 100644 index 000000000..55bc01095 --- /dev/null +++ b/tests/ui/imports/ambiguous-17.stderr @@ -0,0 +1,35 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-17.rs:4:9 + | +LL | pub use evp::*; + | ^^^^^^ the name `id` in the value namespace is first re-exported here +LL | pub use handwritten::*; + | -------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `id` is ambiguous + --> $DIR/ambiguous-17.rs:26:5 + | +LL | id(); + | ^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `id` could refer to the function imported here + --> $DIR/ambiguous-17.rs:4:9 + | +LL | pub use evp::*; + | ^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate +note: `id` could also refer to the function imported here + --> $DIR/ambiguous-17.rs:5:9 + | +LL | pub use handwritten::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/imports/ambiguous-2.rs b/tests/ui/imports/ambiguous-2.rs new file mode 100644 index 000000000..7b38f3006 --- /dev/null +++ b/tests/ui/imports/ambiguous-2.rs @@ -0,0 +1,9 @@ +// check-pass +// aux-build: ../ambiguous-1.rs +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 + +extern crate ambiguous_1; + +fn main() { + ambiguous_1::id(); +} diff --git a/tests/ui/imports/ambiguous-3.rs b/tests/ui/imports/ambiguous-3.rs new file mode 100644 index 000000000..61a5b6b83 --- /dev/null +++ b/tests/ui/imports/ambiguous-3.rs @@ -0,0 +1,21 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/47525 + +fn main() { + use a::*; + x(); + //~^ WARNING `x` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +mod a { + mod b { + pub fn x() { println!(module_path!()); } + } + mod c { + pub fn x() { println!(module_path!()); } + } + + pub use self::b::*; + pub use self::c::*; +} diff --git a/tests/ui/imports/ambiguous-3.stderr b/tests/ui/imports/ambiguous-3.stderr new file mode 100644 index 000000000..f019f6d89 --- /dev/null +++ b/tests/ui/imports/ambiguous-3.stderr @@ -0,0 +1,25 @@ +warning: `x` is ambiguous + --> $DIR/ambiguous-3.rs:6:5 + | +LL | x(); + | ^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `x` could refer to the function imported here + --> $DIR/ambiguous-3.rs:19:13 + | +LL | pub use self::b::*; + | ^^^^^^^^^^ + = help: consider adding an explicit import of `x` to disambiguate +note: `x` could also refer to the function imported here + --> $DIR/ambiguous-3.rs:20:13 + | +LL | pub use self::c::*; + | ^^^^^^^^^^ + = help: consider adding an explicit import of `x` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-4-extern.rs b/tests/ui/imports/ambiguous-4-extern.rs new file mode 100644 index 000000000..02546768e --- /dev/null +++ b/tests/ui/imports/ambiguous-4-extern.rs @@ -0,0 +1,26 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 + +macro_rules! m { + () => { + pub fn id() {} + }; +} + +pub use evp::*; //~ WARNING ambiguous glob re-exports +pub use handwritten::*; + +mod evp { + use *; + m! {} +} +mod handwritten { + use *; + m! {} +} + +fn main() { + id(); + //~^ WARNING `id` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-4-extern.stderr b/tests/ui/imports/ambiguous-4-extern.stderr new file mode 100644 index 000000000..001197321 --- /dev/null +++ b/tests/ui/imports/ambiguous-4-extern.stderr @@ -0,0 +1,35 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-4-extern.rs:10:9 + | +LL | pub use evp::*; + | ^^^^^^ the name `id` in the value namespace is first re-exported here +LL | pub use handwritten::*; + | -------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `id` is ambiguous + --> $DIR/ambiguous-4-extern.rs:23:5 + | +LL | id(); + | ^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `id` could refer to the function imported here + --> $DIR/ambiguous-4-extern.rs:10:9 + | +LL | pub use evp::*; + | ^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate +note: `id` could also refer to the function imported here + --> $DIR/ambiguous-4-extern.rs:11:9 + | +LL | pub use handwritten::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/imports/ambiguous-4.rs b/tests/ui/imports/ambiguous-4.rs new file mode 100644 index 000000000..24ae33784 --- /dev/null +++ b/tests/ui/imports/ambiguous-4.rs @@ -0,0 +1,9 @@ +// build-pass +// aux-build: ../ambiguous-4-extern.rs + +extern crate ambiguous_4_extern; + +fn main() { + ambiguous_4_extern::id(); + // `warning_ambiguous` had been lost at metadata. +} diff --git a/tests/ui/imports/ambiguous-5.rs b/tests/ui/imports/ambiguous-5.rs new file mode 100644 index 000000000..56092246a --- /dev/null +++ b/tests/ui/imports/ambiguous-5.rs @@ -0,0 +1,24 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +mod a { + pub struct Class(u16); +} + +use a::Class; + +mod gpos { + use super::gsubgpos::*; + use super::*; + struct MarkRecord(Class); + //~^ WARNING `Class` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +mod gsubgpos { + use super::*; + #[derive(Clone)] + pub struct Class; +} + +fn main() { } diff --git a/tests/ui/imports/ambiguous-5.stderr b/tests/ui/imports/ambiguous-5.stderr new file mode 100644 index 000000000..4bc35f86d --- /dev/null +++ b/tests/ui/imports/ambiguous-5.stderr @@ -0,0 +1,25 @@ +warning: `Class` is ambiguous + --> $DIR/ambiguous-5.rs:13:23 + | +LL | struct MarkRecord(Class); + | ^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Class` could refer to the struct imported here + --> $DIR/ambiguous-5.rs:12:9 + | +LL | use super::*; + | ^^^^^^^^ + = help: consider adding an explicit import of `Class` to disambiguate +note: `Class` could also refer to the struct imported here + --> $DIR/ambiguous-5.rs:11:9 + | +LL | use super::gsubgpos::*; + | ^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Class` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-6.rs b/tests/ui/imports/ambiguous-6.rs new file mode 100644 index 000000000..ba2623bf4 --- /dev/null +++ b/tests/ui/imports/ambiguous-6.rs @@ -0,0 +1,20 @@ +// check-pass +// edition: 2021 +// https://github.com/rust-lang/rust/issues/112713 + +pub fn foo() -> u32 { + use sub::*; + C + //~^ WARNING `C` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +mod sub { + mod mod1 { pub const C: u32 = 1; } + mod mod2 { pub const C: u32 = 2; } + + pub use mod1::*; + pub use mod2::*; +} + +fn main() {} diff --git a/tests/ui/imports/ambiguous-6.stderr b/tests/ui/imports/ambiguous-6.stderr new file mode 100644 index 000000000..d7871a0b8 --- /dev/null +++ b/tests/ui/imports/ambiguous-6.stderr @@ -0,0 +1,25 @@ +warning: `C` is ambiguous + --> $DIR/ambiguous-6.rs:7:5 + | +LL | C + | ^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `C` could refer to the constant imported here + --> $DIR/ambiguous-6.rs:16:13 + | +LL | pub use mod1::*; + | ^^^^^^^ + = help: consider adding an explicit import of `C` to disambiguate +note: `C` could also refer to the constant imported here + --> $DIR/ambiguous-6.rs:17:13 + | +LL | pub use mod2::*; + | ^^^^^^^ + = help: consider adding an explicit import of `C` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-7.rs b/tests/ui/imports/ambiguous-7.rs new file mode 100644 index 000000000..5148ff4cc --- /dev/null +++ b/tests/ui/imports/ambiguous-7.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +mod t2 { + #[derive(Debug)] + pub enum Error {} +} + +pub use t2::*; + +mod t3 { + pub trait Error {} +} + +use self::t3::*; +fn a(_: E) {} +//~^ ERROR `Error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/ambiguous-7.stderr b/tests/ui/imports/ambiguous-7.stderr new file mode 100644 index 000000000..2c6b56c61 --- /dev/null +++ b/tests/ui/imports/ambiguous-7.stderr @@ -0,0 +1,23 @@ +error[E0659]: `Error` is ambiguous + --> $DIR/ambiguous-7.rs:15:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-7.rs:14:5 + | +LL | use self::t3::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-7.rs:8:9 + | +LL | pub use t2::*; + | ^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-8.rs b/tests/ui/imports/ambiguous-8.rs new file mode 100644 index 000000000..d44cd9587 --- /dev/null +++ b/tests/ui/imports/ambiguous-8.rs @@ -0,0 +1,14 @@ +// aux-build: ambiguous-8-extern.rs + +extern crate ambiguous_8_extern; + +mod s { + pub trait Error {} +} + +use s::*; +use ambiguous_8_extern::*; +fn a(_: E) {} +//~^ ERROR `Error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/ambiguous-8.stderr b/tests/ui/imports/ambiguous-8.stderr new file mode 100644 index 000000000..32056fba6 --- /dev/null +++ b/tests/ui/imports/ambiguous-8.stderr @@ -0,0 +1,23 @@ +error[E0659]: `Error` is ambiguous + --> $DIR/ambiguous-8.rs:11:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-8.rs:9:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-8.rs:10:5 + | +LL | use ambiguous_8_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-9.rs b/tests/ui/imports/ambiguous-9.rs new file mode 100644 index 000000000..9da2467ad --- /dev/null +++ b/tests/ui/imports/ambiguous-9.rs @@ -0,0 +1,29 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +pub mod dsl { + mod range { + pub fn date_range() {} + } + pub use self::range::*; //~ WARNING ambiguous glob re-exports + use super::prelude::*; +} + +pub mod prelude { + mod t { + pub fn date_range() {} + } + pub use self::t::*; //~ WARNING ambiguous glob re-exports + pub use super::dsl::*; +} + +use dsl::*; +use prelude::*; + +fn main() { + date_range(); + //~^ WARNING `date_range` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| WARNING `date_range` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr new file mode 100644 index 000000000..6c7d79174 --- /dev/null +++ b/tests/ui/imports/ambiguous-9.stderr @@ -0,0 +1,65 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:8:13 + | +LL | pub use self::range::*; + | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | use super::prelude::*; + | ----------------- but the name `date_range` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `date_range` is ambiguous + --> $DIR/ambiguous-9.rs:24:5 + | +LL | date_range(); + | ^^^^^^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `date_range` could refer to the function imported here + --> $DIR/ambiguous-9.rs:8:13 + | +LL | pub use self::range::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate +note: `date_range` could also refer to the function imported here + --> $DIR/ambiguous-9.rs:9:9 + | +LL | use super::prelude::*; + | ^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:16:13 + | +LL | pub use self::t::*; + | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | pub use super::dsl::*; + | ------------- but the name `date_range` in the value namespace is also re-exported here + +warning: `date_range` is ambiguous + --> $DIR/ambiguous-9.rs:24:5 + | +LL | date_range(); + | ^^^^^^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `date_range` could refer to the function imported here + --> $DIR/ambiguous-9.rs:20:5 + | +LL | use dsl::*; + | ^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate +note: `date_range` could also refer to the function imported here + --> $DIR/ambiguous-9.rs:21:5 + | +LL | use prelude::*; + | ^^^^^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate + +warning: 4 warnings emitted + diff --git a/tests/ui/imports/auxiliary/ambiguous-11-extern.rs b/tests/ui/imports/auxiliary/ambiguous-11-extern.rs new file mode 100644 index 000000000..e679bc3dc --- /dev/null +++ b/tests/ui/imports/auxiliary/ambiguous-11-extern.rs @@ -0,0 +1,6 @@ +mod t2 { + #[derive(Debug)] + pub enum Error {} +} + +pub use t2::*; diff --git a/tests/ui/imports/auxiliary/ambiguous-8-extern.rs b/tests/ui/imports/auxiliary/ambiguous-8-extern.rs new file mode 100644 index 000000000..c7bf1bae0 --- /dev/null +++ b/tests/ui/imports/auxiliary/ambiguous-8-extern.rs @@ -0,0 +1,12 @@ +mod t2 { + #[derive(Debug)] + pub enum Error {} + + mod t { + pub trait Error: Sized {} + } + + use self::t::*; +} + +pub use t2::*; diff --git a/tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs b/tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs new file mode 100644 index 000000000..5cd102122 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs @@ -0,0 +1,4 @@ +mod a { + pub mod error {} +} +pub use a::*; diff --git a/tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs b/tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs new file mode 100644 index 000000000..378996768 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs @@ -0,0 +1,9 @@ +mod a { + pub mod error {} +} +pub use a::*; + +mod b { + pub mod error {} +} +pub use b::*; diff --git a/tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs b/tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs new file mode 100644 index 000000000..ad4e04804 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs @@ -0,0 +1,14 @@ +mod a { + pub mod error {} +} +pub use a::*; + +mod b { + pub mod error {} +} +pub use b::*; + +mod c { + pub mod error {} +} +pub use c::*; diff --git a/tests/ui/imports/duplicate.rs b/tests/ui/imports/duplicate.rs index db6538969..0c5a376da 100644 --- a/tests/ui/imports/duplicate.rs +++ b/tests/ui/imports/duplicate.rs @@ -34,6 +34,8 @@ fn main() { e::foo(); f::foo(); //~ ERROR `foo` is ambiguous g::foo(); + //~^ WARNING `foo` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod ambiguous_module_errors { diff --git a/tests/ui/imports/duplicate.stderr b/tests/ui/imports/duplicate.stderr index 997a2741b..d7a7dfce9 100644 --- a/tests/ui/imports/duplicate.stderr +++ b/tests/ui/imports/duplicate.stderr @@ -9,20 +9,20 @@ LL | use a::foo; = note: `foo` must be defined only once in the value namespace of this module error[E0659]: `foo` is ambiguous - --> $DIR/duplicate.rs:46:15 + --> $DIR/duplicate.rs:48:15 | LL | use self::foo::bar; | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the module imported here - --> $DIR/duplicate.rs:43:9 + --> $DIR/duplicate.rs:45:9 | LL | use self::m1::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the module imported here - --> $DIR/duplicate.rs:44:9 + --> $DIR/duplicate.rs:46:9 | LL | use self::m2::*; | ^^^^^^^^^^^ @@ -49,26 +49,49 @@ LL | pub use b::*; = help: consider adding an explicit import of `foo` to disambiguate error[E0659]: `foo` is ambiguous - --> $DIR/duplicate.rs:49:9 + --> $DIR/duplicate.rs:51:9 | LL | foo::bar(); | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the module imported here - --> $DIR/duplicate.rs:43:9 + --> $DIR/duplicate.rs:45:9 | LL | use self::m1::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the module imported here - --> $DIR/duplicate.rs:44:9 + --> $DIR/duplicate.rs:46:9 | LL | use self::m2::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate -error: aborting due to 4 previous errors +warning: `foo` is ambiguous + --> $DIR/duplicate.rs:36:8 + | +LL | g::foo(); + | ^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `foo` could refer to the function imported here + --> $DIR/duplicate.rs:24:13 + | +LL | pub use a::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the function imported here + --> $DIR/duplicate.rs:25:13 + | +LL | pub use b::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +error: aborting due to 4 previous errors; 1 warning emitted Some errors have detailed explanations: E0252, E0659. For more information about an error, try `rustc --explain E0252`. diff --git a/tests/ui/imports/extern-with-ambiguous-1.rs b/tests/ui/imports/extern-with-ambiguous-1.rs new file mode 100644 index 000000000..42c3c2068 --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-1.rs @@ -0,0 +1,19 @@ +// edition: 2021 +// aux-build: extern-with-ambiguous-1-extern.rs + +// `extern-with-ambiguous-1-extern.rs` doesn't has +// ambiguous, just for compare. + +extern crate extern_with_ambiguous_1_extern; + +mod s { + pub mod error { + use extern_with_ambiguous_1_extern::*; + } +} +use s::*; +use extern_with_ambiguous_1_extern::*; +use error::*; +//~^ ERROR `error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/extern-with-ambiguous-1.stderr b/tests/ui/imports/extern-with-ambiguous-1.stderr new file mode 100644 index 000000000..dca2b4ebe --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-1.stderr @@ -0,0 +1,23 @@ +error[E0659]: `error` is ambiguous + --> $DIR/extern-with-ambiguous-1.rs:16:5 + | +LL | use error::*; + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `error` could refer to the module imported here + --> $DIR/extern-with-ambiguous-1.rs:14:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `error` to disambiguate +note: `error` could also refer to the module imported here + --> $DIR/extern-with-ambiguous-1.rs:15:5 + | +LL | use extern_with_ambiguous_1_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/extern-with-ambiguous-2.rs b/tests/ui/imports/extern-with-ambiguous-2.rs new file mode 100644 index 000000000..68c623c1c --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-2.rs @@ -0,0 +1,16 @@ +// check-pass +// edition: 2021 +// aux-build: extern-with-ambiguous-2-extern.rs + +extern crate extern_with_ambiguous_2_extern; + +mod s { + pub mod error { + use extern_with_ambiguous_2_extern::*; + } +} +use s::*; +use extern_with_ambiguous_2_extern::*; +use error::*; + +fn main() {} diff --git a/tests/ui/imports/extern-with-ambiguous-3.rs b/tests/ui/imports/extern-with-ambiguous-3.rs new file mode 100644 index 000000000..282c1d569 --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-3.rs @@ -0,0 +1,17 @@ +// check-pass +// edition: 2021 +// aux-build: extern-with-ambiguous-3-extern.rs +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1643974121 + +extern crate extern_with_ambiguous_3_extern; + +mod s { + pub mod error { + use extern_with_ambiguous_3_extern::*; + } +} +use s::*; +use extern_with_ambiguous_3_extern::*; +use error::*; + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-1.rs b/tests/ui/imports/import-after-macro-expand-1.rs new file mode 100644 index 000000000..d7a8aaf2f --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-1.rs @@ -0,0 +1,19 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/56593#issue-388659456 + +struct Foo; + +mod foo { + use super::*; + + #[derive(Debug)] + pub struct Foo; +} + +mod bar { + use super::foo::*; + + fn bar(_: Foo) {} +} + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-2.rs b/tests/ui/imports/import-after-macro-expand-2.rs new file mode 100644 index 000000000..b3996d488 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-2.rs @@ -0,0 +1,27 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/56593#issuecomment-1133174514 + +use thing::*; + +#[derive(Debug)] +pub enum Thing { + Foo +} + +mod tests { + use super::*; + + fn test_thing() { + let thing: crate::thing::Thing = Thing::Bar; + // FIXME: `thing` should refer to `crate::Thing`, + // FIXME: but doesn't currently refer to it due to backward compatibility + } +} + +mod thing { + pub enum Thing { + Bar + } +} + +fn main() { } diff --git a/tests/ui/imports/import-after-macro-expand-3.rs b/tests/ui/imports/import-after-macro-expand-3.rs new file mode 100644 index 000000000..3babe1470 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-3.rs @@ -0,0 +1,24 @@ +// check-pass +// similar with `import-after-macro-expand-2.rs` + +use thing::*; + +pub enum Thing { + Foo +} + +mod tests { + use super::*; + + fn test_thing() { + let thing: crate::Thing = Thing::Foo; + } +} + +mod thing { + pub enum Thing { + Bar + } +} + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-4.rs b/tests/ui/imports/import-after-macro-expand-4.rs new file mode 100644 index 000000000..02cc3f01a --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-4.rs @@ -0,0 +1,30 @@ +// https://github.com/rust-lang/rust/pull/113242#issuecomment-1616034904 +// similar with `import-after-macro-expand-2.rs` + +mod a { + pub trait P {} +} + +pub use a::*; + +mod c { + use crate::*; + pub struct S(Vec

); + //~^ ERROR the size for values of type + //~| WARNING trait objects without an explicit + //~| WARNING this is accepted in the current edition + //~| WARNING trait objects without an explicit + //~| WARNING this is accepted in the current edition + //~| WARNING trait objects without an explicit + //~| WARNING this is accepted in the current edition + + // FIXME: should works, but doesn't currently refer + // to it due to backward compatibility +} + +#[derive(Clone)] +pub enum P { + A +} + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-4.stderr b/tests/ui/imports/import-after-macro-expand-4.stderr new file mode 100644 index 000000000..01f70cfc5 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-4.stderr @@ -0,0 +1,53 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/import-after-macro-expand-4.rs:12:22 + | +LL | pub struct S(Vec

); + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see + = note: `#[warn(bare_trait_objects)]` on by default +help: use `dyn` + | +LL | pub struct S(Vec); + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/import-after-macro-expand-4.rs:12:22 + | +LL | pub struct S(Vec

); + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +help: use `dyn` + | +LL | pub struct S(Vec); + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/import-after-macro-expand-4.rs:12:22 + | +LL | pub struct S(Vec

); + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +help: use `dyn` + | +LL | pub struct S(Vec); + | +++ + +error[E0277]: the size for values of type `(dyn a::P + 'static)` cannot be known at compilation time + --> $DIR/import-after-macro-expand-4.rs:12:18 + | +LL | pub struct S(Vec

); + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn a::P + 'static)` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to previous error; 3 warnings emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/imports/import-after-macro-expand-5.rs b/tests/ui/imports/import-after-macro-expand-5.rs new file mode 100644 index 000000000..ba28b6dea --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-5.rs @@ -0,0 +1,31 @@ +// edition: 2021 +// check-pass +// https://github.com/rust-lang/rust/issues/105235#issue-1474295873 + +mod abc { + pub struct Beeblebrox; + pub struct Zaphod; +} + +mod foo { + pub mod bar { + use crate::abc::*; + + #[derive(Debug)] + pub enum Zaphod { + Whale, + President, + } + } + pub use bar::*; +} + +mod baz { + pub fn do_something() { + println!("{:?}", crate::foo::Zaphod::Whale); + } +} + +fn main() { + baz::do_something(); +} diff --git a/tests/ui/imports/import-after-macro-expand-6.rs b/tests/ui/imports/import-after-macro-expand-6.rs new file mode 100644 index 000000000..ab5bb37a1 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-6.rs @@ -0,0 +1,24 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 + +pub mod a { + pub use crate::b::*; +} + +mod b { + pub mod http { + pub struct HeaderMap; + } + + pub use self::http::*; + #[derive(Debug)] + pub struct HeaderMap; +} + +use crate::a::HeaderMap; + +fn main() { + let h: crate::b::http::HeaderMap = HeaderMap; + // FIXME: should refer to `crate::b::HeaderMap`, + // FIXME: but doesn't currently refer to it due to backward compatibility +} diff --git a/tests/ui/imports/import-after-macro-expand-7.rs b/tests/ui/imports/import-after-macro-expand-7.rs new file mode 100644 index 000000000..0402dfdfd --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-7.rs @@ -0,0 +1,21 @@ +// check-pass +// a compared case for `import-after-macro-expand-6.rs` + +pub mod a { + pub use crate::b::*; +} + +mod b { + mod http { + pub struct HeaderMap; + } + + pub use self::http::*; + pub struct HeaderMap; +} + +use crate::a::HeaderMap; + +fn main() { + let h: crate::b::HeaderMap = HeaderMap; +} diff --git a/tests/ui/imports/import-after-macro-expand-8.rs b/tests/ui/imports/import-after-macro-expand-8.rs new file mode 100644 index 000000000..e11d65eff --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-8.rs @@ -0,0 +1,22 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113242#issuecomment-1616034904 + +mod a { + pub trait P {} +} +pub use a::*; + +mod b { + #[derive(Clone)] + pub enum P { + A + } +} +pub use b::P; + +mod c { + use crate::*; + pub struct S(Vec

); +} + +fn main() {} diff --git a/tests/ui/imports/issue-113953.rs b/tests/ui/imports/issue-113953.rs new file mode 100644 index 000000000..449a074f4 --- /dev/null +++ b/tests/ui/imports/issue-113953.rs @@ -0,0 +1,6 @@ +// edition: 2021 +use u8 as imported_u8; +use unresolved as u8; +//~^ ERROR unresolved import `unresolved` + +fn main() {} diff --git a/tests/ui/imports/issue-113953.stderr b/tests/ui/imports/issue-113953.stderr new file mode 100644 index 000000000..70f91bd3c --- /dev/null +++ b/tests/ui/imports/issue-113953.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `unresolved` + --> $DIR/issue-113953.rs:3:5 + | +LL | use unresolved as u8; + | ^^^^^^^^^^^^^^^^ no external crate `unresolved` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-81413.rs b/tests/ui/imports/issue-81413.rs new file mode 100644 index 000000000..f3fb8bfab --- /dev/null +++ b/tests/ui/imports/issue-81413.rs @@ -0,0 +1,23 @@ +pub const ITEM: Item = Item; + +pub struct Item; + +pub fn item() {} + +pub use doesnt_exist::*; +//~^ ERROR unresolved import `doesnt_exist` +mod a { + use crate::{item, Item, ITEM}; +} + +mod b { + use crate::item; + use crate::Item; + use crate::ITEM; +} + +mod c { + use crate::item; +} + +fn main() {} diff --git a/tests/ui/imports/issue-81413.stderr b/tests/ui/imports/issue-81413.stderr new file mode 100644 index 000000000..e2dfe02bc --- /dev/null +++ b/tests/ui/imports/issue-81413.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `doesnt_exist` + --> $DIR/issue-81413.rs:7:9 + | +LL | pub use doesnt_exist::*; + | ^^^^^^^^^^^^ maybe a missing crate `doesnt_exist`? + | + = help: consider adding `extern crate doesnt_exist` to use the `doesnt_exist` crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/resolve-other-libc.rs b/tests/ui/imports/resolve-other-libc.rs new file mode 100644 index 000000000..806d854ec --- /dev/null +++ b/tests/ui/imports/resolve-other-libc.rs @@ -0,0 +1,14 @@ +// Regression test for https://github.com/rust-lang/rust/issues/26043 + +// compile-flags: --extern libc=test.rlib + +// The error shall NOT be something similar to the following, because it +// indicates that `libc` was wrongly resolved to `libc` shipped with the +// compiler: +// +// error[E0658]: use of unstable library feature 'rustc_private': \ +// this crate is being loaded from the sysroot +// +extern crate libc; //~ ERROR: extern location for libc does not exist: test.rlib + +fn main() {} diff --git a/tests/ui/imports/resolve-other-libc.stderr b/tests/ui/imports/resolve-other-libc.stderr new file mode 100644 index 000000000..e57b88e50 --- /dev/null +++ b/tests/ui/imports/resolve-other-libc.stderr @@ -0,0 +1,8 @@ +error: extern location for libc does not exist: test.rlib + --> $DIR/resolve-other-libc.rs:12:1 + | +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/index-bot.rs b/tests/ui/index-bot.rs deleted file mode 100644 index e69c4019f..000000000 --- a/tests/ui/index-bot.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - (return)[0]; //~ ERROR cannot index into a value of type `!` -} diff --git a/tests/ui/index-bot.stderr b/tests/ui/index-bot.stderr deleted file mode 100644 index b5d782975..000000000 --- a/tests/ui/index-bot.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0608]: cannot index into a value of type `!` - --> $DIR/index-bot.rs:2:5 - | -LL | (return)[0]; - | ^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0608`. diff --git a/tests/ui/index-help.rs b/tests/ui/index-help.rs deleted file mode 100644 index 66571ec41..000000000 --- a/tests/ui/index-help.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let x = vec![1]; - x[0i32]; //~ ERROR E0277 -} diff --git a/tests/ui/index-help.stderr b/tests/ui/index-help.stderr deleted file mode 100644 index e020d0298..000000000 --- a/tests/ui/index-help.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0277]: the type `[{integer}]` cannot be indexed by `i32` - --> $DIR/index-help.rs:3:7 - | -LL | x[0i32]; - | ^^^^ slice indices are of type `usize` or ranges of `usize` - | - = help: the trait `SliceIndex<[{integer}]>` is not implemented for `i32` - = help: the trait `SliceIndex<[T]>` is implemented for `usize` - = note: required for `Vec<{integer}>` to implement `Index` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/index_message.rs b/tests/ui/index_message.rs deleted file mode 100644 index 88b848d6f..000000000 --- a/tests/ui/index_message.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let z = (10,); - let _ = z[0]; //~ ERROR cannot index into a value of type `({integer},)` -} diff --git a/tests/ui/index_message.stderr b/tests/ui/index_message.stderr deleted file mode 100644 index 56d1d7080..000000000 --- a/tests/ui/index_message.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0608]: cannot index into a value of type `({integer},)` - --> $DIR/index_message.rs:3:13 - | -LL | let _ = z[0]; - | ^^^^ help: to access tuple elements, use: `z.0` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0608`. diff --git a/tests/ui/indexing-requires-a-uint.rs b/tests/ui/indexing-requires-a-uint.rs deleted file mode 100644 index dbe9b44a1..000000000 --- a/tests/ui/indexing-requires-a-uint.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Make sure that indexing an array is only valid with a `usize`, not any other -// integral type. - -fn main() { - fn bar(_: T) {} - [0][0u8]; //~ ERROR: the type `[{integer}]` cannot be indexed by `u8` - - [0][0]; // should infer to be a usize - - let i = 0; // i is an IntVar - [0][i]; // i should be locked to usize - bar::(i); // i should not be re-coerced back to an isize - //~^ ERROR: mismatched types -} diff --git a/tests/ui/indexing-requires-a-uint.stderr b/tests/ui/indexing-requires-a-uint.stderr deleted file mode 100644 index 7a741cfc7..000000000 --- a/tests/ui/indexing-requires-a-uint.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0277]: the type `[{integer}]` cannot be indexed by `u8` - --> $DIR/indexing-requires-a-uint.rs:6:9 - | -LL | [0][0u8]; - | ^^^ slice indices are of type `usize` or ranges of `usize` - | - = help: the trait `SliceIndex<[{integer}]>` is not implemented for `u8` - = help: the trait `SliceIndex<[T]>` is implemented for `usize` - = note: required for `[{integer}]` to implement `Index` - -error[E0308]: mismatched types - --> $DIR/indexing-requires-a-uint.rs:12:18 - | -LL | bar::(i); // i should not be re-coerced back to an isize - | ------------ ^ expected `isize`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/indexing-requires-a-uint.rs:5:8 - | -LL | fn bar(_: T) {} - | ^^^ ---- -help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit - | -LL | bar::(i.try_into().unwrap()); // i should not be re-coerced back to an isize - | ++++++++++++++++++++ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/indexing/index-bot.rs b/tests/ui/indexing/index-bot.rs new file mode 100644 index 000000000..e69c4019f --- /dev/null +++ b/tests/ui/indexing/index-bot.rs @@ -0,0 +1,3 @@ +fn main() { + (return)[0]; //~ ERROR cannot index into a value of type `!` +} diff --git a/tests/ui/indexing/index-bot.stderr b/tests/ui/indexing/index-bot.stderr new file mode 100644 index 000000000..bf231c92c --- /dev/null +++ b/tests/ui/indexing/index-bot.stderr @@ -0,0 +1,9 @@ +error[E0608]: cannot index into a value of type `!` + --> $DIR/index-bot.rs:2:13 + | +LL | (return)[0]; + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0608`. diff --git a/tests/ui/indexing/index-help.rs b/tests/ui/indexing/index-help.rs new file mode 100644 index 000000000..66571ec41 --- /dev/null +++ b/tests/ui/indexing/index-help.rs @@ -0,0 +1,4 @@ +fn main() { + let x = vec![1]; + x[0i32]; //~ ERROR E0277 +} diff --git a/tests/ui/indexing/index-help.stderr b/tests/ui/indexing/index-help.stderr new file mode 100644 index 000000000..e020d0298 --- /dev/null +++ b/tests/ui/indexing/index-help.stderr @@ -0,0 +1,13 @@ +error[E0277]: the type `[{integer}]` cannot be indexed by `i32` + --> $DIR/index-help.rs:3:7 + | +LL | x[0i32]; + | ^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `SliceIndex<[{integer}]>` is not implemented for `i32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` + = note: required for `Vec<{integer}>` to implement `Index` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/indexing/index_message.rs b/tests/ui/indexing/index_message.rs new file mode 100644 index 000000000..88b848d6f --- /dev/null +++ b/tests/ui/indexing/index_message.rs @@ -0,0 +1,4 @@ +fn main() { + let z = (10,); + let _ = z[0]; //~ ERROR cannot index into a value of type `({integer},)` +} diff --git a/tests/ui/indexing/index_message.stderr b/tests/ui/indexing/index_message.stderr new file mode 100644 index 000000000..80f2bd523 --- /dev/null +++ b/tests/ui/indexing/index_message.stderr @@ -0,0 +1,9 @@ +error[E0608]: cannot index into a value of type `({integer},)` + --> $DIR/index_message.rs:3:14 + | +LL | let _ = z[0]; + | ^^^ help: to access tuple elements, use: `.0` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0608`. diff --git a/tests/ui/indexing/indexing-requires-a-uint.rs b/tests/ui/indexing/indexing-requires-a-uint.rs new file mode 100644 index 000000000..dbe9b44a1 --- /dev/null +++ b/tests/ui/indexing/indexing-requires-a-uint.rs @@ -0,0 +1,14 @@ +// Make sure that indexing an array is only valid with a `usize`, not any other +// integral type. + +fn main() { + fn bar(_: T) {} + [0][0u8]; //~ ERROR: the type `[{integer}]` cannot be indexed by `u8` + + [0][0]; // should infer to be a usize + + let i = 0; // i is an IntVar + [0][i]; // i should be locked to usize + bar::(i); // i should not be re-coerced back to an isize + //~^ ERROR: mismatched types +} diff --git a/tests/ui/indexing/indexing-requires-a-uint.stderr b/tests/ui/indexing/indexing-requires-a-uint.stderr new file mode 100644 index 000000000..7a741cfc7 --- /dev/null +++ b/tests/ui/indexing/indexing-requires-a-uint.stderr @@ -0,0 +1,32 @@ +error[E0277]: the type `[{integer}]` cannot be indexed by `u8` + --> $DIR/indexing-requires-a-uint.rs:6:9 + | +LL | [0][0u8]; + | ^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `SliceIndex<[{integer}]>` is not implemented for `u8` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` + = note: required for `[{integer}]` to implement `Index` + +error[E0308]: mismatched types + --> $DIR/indexing-requires-a-uint.rs:12:18 + | +LL | bar::(i); // i should not be re-coerced back to an isize + | ------------ ^ expected `isize`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/indexing-requires-a-uint.rs:5:8 + | +LL | fn bar(_: T) {} + | ^^^ ---- +help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit + | +LL | bar::(i.try_into().unwrap()); // i should not be re-coerced back to an isize + | ++++++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/indexing/indexing-spans-caller-location.rs b/tests/ui/indexing/indexing-spans-caller-location.rs new file mode 100644 index 000000000..2652f0021 --- /dev/null +++ b/tests/ui/indexing/indexing-spans-caller-location.rs @@ -0,0 +1,27 @@ +// run-pass + +// Regression test for https://github.com/rust-lang/rust/issues/114388 + +#[track_caller] +fn caller_line() -> u32 { + std::panic::Location::caller().line() +} + +fn main() { + let prev_line = caller_line(); // first line + (A { prev_line }) // second line + [0]; // third line +} + +struct A { + prev_line: u32, +} +impl std::ops::Index for A { + type Output = (); + + fn index(&self, _idx: usize) -> &() { + // Use the relative number to make it resistent to header changes. + assert_eq!(caller_line(), self.prev_line + 2); + &() + } +} diff --git a/tests/ui/inference/issue-113354.fixed b/tests/ui/inference/issue-113354.fixed new file mode 100644 index 000000000..804db985a --- /dev/null +++ b/tests/ui/inference/issue-113354.fixed @@ -0,0 +1,4 @@ +//run-rustfix +fn main() { + let _ = || { while let Some(_) = Some(1) { } }; //~ ERROR mismatched types +} diff --git a/tests/ui/inference/issue-113354.rs b/tests/ui/inference/issue-113354.rs new file mode 100644 index 000000000..ec33d1f8b --- /dev/null +++ b/tests/ui/inference/issue-113354.rs @@ -0,0 +1,4 @@ +//run-rustfix +fn main() { + let _ = || { while Some(_) = Some(1) { } }; //~ ERROR mismatched types +} diff --git a/tests/ui/inference/issue-113354.stderr b/tests/ui/inference/issue-113354.stderr new file mode 100644 index 000000000..045a5aa7b --- /dev/null +++ b/tests/ui/inference/issue-113354.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-113354.rs:3:24 + | +LL | let _ = || { while Some(_) = Some(1) { } }; + | ^^^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | let _ = || { while let Some(_) = Some(1) { } }; + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/need_type_info/infer-var-for-self-param.rs b/tests/ui/inference/need_type_info/infer-var-for-self-param.rs new file mode 100644 index 000000000..51ac7943f --- /dev/null +++ b/tests/ui/inference/need_type_info/infer-var-for-self-param.rs @@ -0,0 +1,7 @@ +// Regression test for #113610 where we ICEd when trying to print +// inference variables created by instantiating the self type parameter. + +fn main() { + let _ = (Default::default(),); + //~^ ERROR cannot call associated function on trait +} diff --git a/tests/ui/inference/need_type_info/infer-var-for-self-param.stderr b/tests/ui/inference/need_type_info/infer-var-for-self-param.stderr new file mode 100644 index 000000000..36d754693 --- /dev/null +++ b/tests/ui/inference/need_type_info/infer-var-for-self-param.stderr @@ -0,0 +1,14 @@ +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/infer-var-for-self-param.rs:5:14 + | +LL | let _ = (Default::default(),); + | ^^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use a fully-qualified path to a specific available implementation + | +LL | let _ = (::default(),); + | +++++++++++++++++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0790`. diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs new file mode 100644 index 000000000..5a893f2d8 --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs @@ -0,0 +1,12 @@ +trait T {} + +struct S {} + +impl S { + fn owo(&self, _: Option<&impl T>) {} +} + +fn main() { + (S {}).owo(None) + //~^ ERROR type annotations needed +} diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr new file mode 100644 index 000000000..0ec219415 --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:10:16 + | +LL | (S {}).owo(None) + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | (S {}).owo(None::<&_>) + | ++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/inference/str-as-char.fixed b/tests/ui/inference/str-as-char.fixed index 6aea809cb..911b067c4 100644 --- a/tests/ui/inference/str-as-char.fixed +++ b/tests/ui/inference/str-as-char.fixed @@ -7,4 +7,5 @@ fn main() { let _: &str = "a"; //~ ERROR mismatched types let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint + let _: &str = "\"\"\\\"\\\"\\\\\""; //~ ERROR character literal may only contain one codepoint } diff --git a/tests/ui/inference/str-as-char.rs b/tests/ui/inference/str-as-char.rs index eaa8d788c..832bc871a 100644 --- a/tests/ui/inference/str-as-char.rs +++ b/tests/ui/inference/str-as-char.rs @@ -7,4 +7,5 @@ fn main() { let _: &str = 'a'; //~ ERROR mismatched types let _: &str = '"""'; //~ ERROR character literal may only contain one codepoint let _: &str = '\"\"\"'; //~ ERROR character literal may only contain one codepoint + let _: &str = '"\"\\"\\\"\\\\"'; //~ ERROR character literal may only contain one codepoint } diff --git a/tests/ui/inference/str-as-char.stderr b/tests/ui/inference/str-as-char.stderr index 2c84dac8e..216f4cda6 100644 --- a/tests/ui/inference/str-as-char.stderr +++ b/tests/ui/inference/str-as-char.stderr @@ -20,6 +20,17 @@ help: if you meant to write a `str` literal, use double quotes LL | let _: &str = "\"\"\""; | ~~~~~~~~ +error: character literal may only contain one codepoint + --> $DIR/str-as-char.rs:10:19 + | +LL | let _: &str = '"\"\"\\"\\"'; + | ^^^^^^^^^^^^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let _: &str = "\"\"\\"\\"\\\""; + | ~~~~~~~~~~~~~~~~~~~~ + error[E0308]: mismatched types --> $DIR/str-as-char.rs:7:19 | @@ -33,6 +44,6 @@ help: if you meant to write a `str` literal, use double quotes LL | let _: &str = "a"; | ~~~ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/type-infer-generalize-ty-var.rs b/tests/ui/inference/type-infer-generalize-ty-var.rs index a3d6916cb..8b4a8c32b 100644 --- a/tests/ui/inference/type-infer-generalize-ty-var.rs +++ b/tests/ui/inference/type-infer-generalize-ty-var.rs @@ -1,4 +1,6 @@ -// run-pass +// check-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next #![allow(non_upper_case_globals)] #![allow(dead_code)] diff --git a/tests/ui/infinite/infinite-trait-alias-recursion.stderr b/tests/ui/infinite/infinite-trait-alias-recursion.stderr index 683987b49..39d7aa4c1 100644 --- a/tests/ui/infinite/infinite-trait-alias-recursion.stderr +++ b/tests/ui/infinite/infinite-trait-alias-recursion.stderr @@ -21,6 +21,7 @@ note: cycle used when collecting item types in top-level module | LL | trait T1 = T2; | ^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.stderr index 7f82b2944..bbdb1f70b 100644 --- a/tests/ui/infinite/infinite-type-alias-mutual-recursion.stderr +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.stderr @@ -28,6 +28,7 @@ LL | | type X3 = X1; LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/infinite/infinite-vec-type-recursion.stderr b/tests/ui/infinite/infinite-vec-type-recursion.stderr index 1e487a5b1..a21b033a9 100644 --- a/tests/ui/infinite/infinite-vec-type-recursion.stderr +++ b/tests/ui/infinite/infinite-vec-type-recursion.stderr @@ -16,6 +16,7 @@ LL | | LL | | LL | | fn main() { let b: X = Vec::new(); } | |____________________________________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/inline-const/instance-doesnt-depend-on-type.rs b/tests/ui/inline-const/instance-doesnt-depend-on-type.rs new file mode 100644 index 000000000..bc739785c --- /dev/null +++ b/tests/ui/inline-const/instance-doesnt-depend-on-type.rs @@ -0,0 +1,10 @@ +// check-pass +// issue: 114660 + +#![feature(inline_const)] + +fn main() { + const { core::mem::transmute:: }; + // Don't resolve the instance of this inline constant to be an intrinsic, + // even if the type of the constant is `extern "intrinsic" fn(u8) -> u8`. +} diff --git a/tests/ui/inline-const/interpolated.rs b/tests/ui/inline-const/interpolated.rs new file mode 100644 index 000000000..3fcc621c9 --- /dev/null +++ b/tests/ui/inline-const/interpolated.rs @@ -0,0 +1,32 @@ +// check-pass + +#![feature(inline_const)] + +// This used to be unsupported since the parser first tries to check if we have +// any nested items, and then checks for statements (and expressions). The heuristic +// that we were using to detect the beginning of a const item was incorrect, so +// this used to fail. +macro_rules! m { + ($b:block) => { + fn foo() { + const $b + } + } +} + +// This has worked since inline-consts were implemented, since the position that +// the const block is located at doesn't support nested items (e.g. because +// `let x = const X: u32 = 1;` is invalid), so there's no ambiguity parsing the +// inline const. +macro_rules! m2 { + ($b:block) => { + fn foo2() { + let _ = const $b; + } + } +} + +m!({}); +m2!({}); + +fn main() {} diff --git a/tests/ui/inline-const/pat-match-fndef.rs b/tests/ui/inline-const/pat-match-fndef.rs new file mode 100644 index 000000000..fbd4dc66c --- /dev/null +++ b/tests/ui/inline-const/pat-match-fndef.rs @@ -0,0 +1,13 @@ +#![feature(inline_const_pat)] +//~^ WARN the feature `inline_const_pat` is incomplete + +fn uwu() {} + +fn main() { + let x = []; + match x[123] { + const { uwu } => {} + //~^ ERROR `fn() {uwu}` cannot be used in patterns + _ => {} + } +} diff --git a/tests/ui/inline-const/pat-match-fndef.stderr b/tests/ui/inline-const/pat-match-fndef.stderr new file mode 100644 index 000000000..c94782b17 --- /dev/null +++ b/tests/ui/inline-const/pat-match-fndef.stderr @@ -0,0 +1,17 @@ +warning: the feature `inline_const_pat` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/pat-match-fndef.rs:1:12 + | +LL | #![feature(inline_const_pat)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #76001 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: `fn() {uwu}` cannot be used in patterns + --> $DIR/pat-match-fndef.rs:9:9 + | +LL | const { uwu } => {} + | ^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/inline-const/required-const.rs b/tests/ui/inline-const/required-const.rs new file mode 100644 index 000000000..048341066 --- /dev/null +++ b/tests/ui/inline-const/required-const.rs @@ -0,0 +1,13 @@ +// build-fail +// compile-flags: -Zmir-opt-level=3 +#![feature(inline_const)] + +fn foo() { + if false { + const { panic!() } //~ ERROR E0080 + } +} + +fn main() { + foo::(); +} diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr new file mode 100644 index 000000000..d6948e7ac --- /dev/null +++ b/tests/ui/inline-const/required-const.stderr @@ -0,0 +1,11 @@ +error[E0080]: evaluation of `foo::::{constant#0}` failed + --> $DIR/required-const.rs:7:17 + | +LL | const { panic!() } + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/required-const.rs:7:17 + | + = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/internal/internal-unstable.rs b/tests/ui/internal/internal-unstable.rs index b8987d3e1..1eb27fbdc 100644 --- a/tests/ui/internal/internal-unstable.rs +++ b/tests/ui/internal/internal-unstable.rs @@ -8,7 +8,6 @@ extern crate internal_unstable; struct Baz { #[allow_internal_unstable] - //^ WARN `#[allow_internal_unstable]` is ignored on struct fields and match arms baz: u8, } @@ -50,7 +49,6 @@ fn main() { match true { #[allow_internal_unstable] - //^ WARN `#[allow_internal_unstable]` is ignored on struct fields and match arms _ => {} } } diff --git a/tests/ui/internal/internal-unstable.stderr b/tests/ui/internal/internal-unstable.stderr index f0f9bfb8d..b7c47365c 100644 --- a/tests/ui/internal/internal-unstable.stderr +++ b/tests/ui/internal/internal-unstable.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'function' - --> $DIR/internal-unstable.rs:41:25 + --> $DIR/internal-unstable.rs:40:25 | LL | pass_through_allow!(internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | pass_through_allow!(internal_unstable::unstable()); = help: add `#![feature(function)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'function' - --> $DIR/internal-unstable.rs:43:27 + --> $DIR/internal-unstable.rs:42:27 | LL | pass_through_noallow!(internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | pass_through_noallow!(internal_unstable::unstable()); = help: add `#![feature(function)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'function' - --> $DIR/internal-unstable.rs:47:22 + --> $DIR/internal-unstable.rs:46:22 | LL | println!("{:?}", internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | println!("{:?}", internal_unstable::unstable()); = help: add `#![feature(function)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'function' - --> $DIR/internal-unstable.rs:49:10 + --> $DIR/internal-unstable.rs:48:10 | LL | bar!(internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | bar!(internal_unstable::unstable()); = help: add `#![feature(function)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'function' - --> $DIR/internal-unstable.rs:19:9 + --> $DIR/internal-unstable.rs:18:9 | LL | internal_unstable::unstable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr index 463cd52c5..a0024c092 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:6:6 +thread 'main' panicked at $DIR/const-eval-select-backtrace-std.rs:6:8: +byte index 1 is out of bounds of `` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr index 54e28db5e..3f196bd8a 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:17:9 +thread 'main' panicked at $DIR/const-eval-select-backtrace.rs:17:9: +Aaah! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs new file mode 100644 index 000000000..0e894ef58 --- /dev/null +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs @@ -0,0 +1,17 @@ +#![feature(core_intrinsics)] +#![feature(const_intrinsic_raw_eq)] + +const RAW_EQ_PADDING: bool = unsafe { + std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) +//~^ ERROR evaluation of constant value failed +//~| requires initialized memory +}; + +const RAW_EQ_PTR: bool = unsafe { + std::intrinsics::raw_eq(&(&0), &(&1)) +//~^ ERROR evaluation of constant value failed +//~| `raw_eq` on bytes with provenance +}; + +pub fn main() { +} diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr new file mode 100644 index 000000000..4fc304cda --- /dev/null +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -0,0 +1,15 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 + | +LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc3[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory + +error[E0080]: evaluation of constant value failed + --> $DIR/intrinsic-raw_eq-const-bad.rs:11:5 + | +LL | std::intrinsics::raw_eq(&(&0), &(&1)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `raw_eq` on bytes with provenance + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-padding.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-padding.rs deleted file mode 100644 index a93d777d2..000000000 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-padding.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(core_intrinsics)] -#![feature(const_intrinsic_raw_eq)] - -const BAD_RAW_EQ_CALL: bool = unsafe { - std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) -//~^ ERROR evaluation of constant value failed -}; - -pub fn main() { -} diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr deleted file mode 100644 index 56d5a4857..000000000 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/intrinsic-raw_eq-const-padding.rs:5:5 - | -LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc3[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/invalid/issue-114435-layout-type-err.rs b/tests/ui/invalid/issue-114435-layout-type-err.rs new file mode 100644 index 000000000..a2d405936 --- /dev/null +++ b/tests/ui/invalid/issue-114435-layout-type-err.rs @@ -0,0 +1,44 @@ +// build-fail +// compile-flags: --crate-type lib -Cdebuginfo=2 +// error-pattern: the type has an unknown layout + +#![recursion_limit = "10"] +macro_rules! link { + ($outer:ident, $inner:ident) => { + struct $outer($inner); + impl $outer { + fn new() -> $outer { + $outer($inner::new()) + } + } + impl std::ops::Deref for $outer { + type Target = $inner; + fn deref(&self) -> &$inner { + &self.0 + } + } + }; +} + +struct Bottom; + +impl Bottom { + fn new() -> Bottom { + Bottom + } +} + + +link!(A, B); +link!(B, C); +link!(C, D); +link!(D, E); +link!(E, F); +link!(F, G); +link!(G, H); +link!(H, I); +link!(I, J); +link!(J, K); +link!(K, Bottom); + +fn main() { } diff --git a/tests/ui/invalid/issue-114435-layout-type-err.stderr b/tests/ui/invalid/issue-114435-layout-type-err.stderr new file mode 100644 index 000000000..a2db74ff8 --- /dev/null +++ b/tests/ui/invalid/issue-114435-layout-type-err.stderr @@ -0,0 +1,8 @@ +error: reached the recursion limit finding the struct tail for `Bottom` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` + +error: the type has an unknown layout + +error: aborting due to 2 previous errors + diff --git a/tests/ui/issues/issue-100605.rs b/tests/ui/issues/issue-100605.rs deleted file mode 100644 index 917a45c15..000000000 --- a/tests/ui/issues/issue-100605.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn takes_option(_arg: Option<&String>) {} - -fn main() { - takes_option(&None); //~ ERROR 4:18: 4:23: mismatched types [E0308] - - let x = String::from("x"); - let res = Some(x); - takes_option(&res); //~ ERROR 8:18: 8:22: mismatched types [E0308] -} diff --git a/tests/ui/issues/issue-100605.stderr b/tests/ui/issues/issue-100605.stderr deleted file mode 100644 index 6f11f4475..000000000 --- a/tests/ui/issues/issue-100605.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-100605.rs:4:18 - | -LL | takes_option(&None); - | ------------ ^^^^^ expected `Option<&String>`, found `&Option<_>` - | | - | arguments to this function are incorrect - | - = note: expected enum `Option<&String>` - found reference `&Option<_>` -note: function defined here - --> $DIR/issue-100605.rs:1:4 - | -LL | fn takes_option(_arg: Option<&String>) {} - | ^^^^^^^^^^^^ --------------------- -help: consider removing the borrow - | -LL - takes_option(&None); -LL + takes_option(None); - | - -error[E0308]: mismatched types - --> $DIR/issue-100605.rs:8:18 - | -LL | takes_option(&res); - | ------------ ^^^^ expected `Option<&String>`, found `&Option` - | | - | arguments to this function are incorrect - | - = note: expected enum `Option<&String>` - found reference `&Option` -note: function defined here - --> $DIR/issue-100605.rs:1:4 - | -LL | fn takes_option(_arg: Option<&String>) {} - | ^^^^^^^^^^^^ --------------------- -help: try using `.as_ref()` to convert `&Option` to `Option<&String>` - | -LL - takes_option(&res); -LL + takes_option(res.as_ref()); - | - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-11515.rs b/tests/ui/issues/issue-11515.rs deleted file mode 100644 index b5c942f96..000000000 --- a/tests/ui/issues/issue-11515.rs +++ /dev/null @@ -1,10 +0,0 @@ -struct Test { - func: Box, -} - - - -fn main() { - let closure: Box = Box::new(|| ()); - let test = Box::new(Test { func: closure }); //~ ERROR trait upcasting coercion is experimental [E0658] -} diff --git a/tests/ui/issues/issue-11515.stderr b/tests/ui/issues/issue-11515.stderr deleted file mode 100644 index accd47f0f..000000000 --- a/tests/ui/issues/issue-11515.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental - --> $DIR/issue-11515.rs:9:38 - | -LL | let test = Box::new(Test { func: closure }); - | ^^^^^^^ - | - = note: see issue #65991 for more information - = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable - = note: required when coercing `Box<(dyn Fn() + 'static)>` into `Box<(dyn FnMut() + 'static)>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/issues/issue-11820.rs b/tests/ui/issues/issue-11820.rs index 7ffe96527..dc6349b10 100644 --- a/tests/ui/issues/issue-11820.rs +++ b/tests/ui/issues/issue-11820.rs @@ -1,6 +1,8 @@ // run-pass // pretty-expanded FIXME #23616 +#![allow(noop_method_call)] + struct NoClone; fn main() { diff --git a/tests/ui/issues/issue-13497-2.stderr b/tests/ui/issues/issue-13497-2.stderr index a365e24e2..8ad921027 100644 --- a/tests/ui/issues/issue-13497-2.stderr +++ b/tests/ui/issues/issue-13497-2.stderr @@ -1,11 +1,13 @@ error[E0515]: cannot return value referencing local variable `rawLines` --> $DIR/issue-13497-2.rs:3:5 | -LL | // rawLines -LL | || .iter().map(|l| l.trim()).collect() - | ||_______________-___________________________^ returns a value referencing data owned by the current function - | |_______________| - | `rawLines` is borrowed here +LL | rawLines + | ^------- + | | + | _____`rawLines` is borrowed here + | | +LL | | .iter().map(|l| l.trim()).collect() + | |___________________________________________^ returns a value referencing data owned by the current function error: aborting due to previous error diff --git a/tests/ui/issues/issue-17252.stderr b/tests/ui/issues/issue-17252.stderr index aca5242b2..daaf82e80 100644 --- a/tests/ui/issues/issue-17252.stderr +++ b/tests/ui/issues/issue-17252.stderr @@ -10,6 +10,7 @@ note: cycle used when const-evaluating + checking `main::{constant#0}` | LL | let _x: [u8; FOO]; // caused stack overflow prior to fix | ^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-20413.stderr b/tests/ui/issues/issue-20413.stderr index 8891a2678..8793029dd 100644 --- a/tests/ui/issues/issue-20413.stderr +++ b/tests/ui/issues/issue-20413.stderr @@ -14,12 +14,11 @@ LL | impl Foo for T where NoData: Foo { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `NoData>>>>>>>>>>>>` to implement `Foo` +note: required for `NoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` --> $DIR/issue-20413.rs:9:9 | LL | impl Foo for T where NoData: Foo { | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' = note: 126 redundant requirements hidden = note: required for `NoData` to implement `Foo` @@ -30,18 +29,16 @@ LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `EvenLessData>>>>>>` to implement `Baz` +note: required for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Baz` --> $DIR/issue-20413.rs:35:9 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' -note: required for `AlmostNoData>>>>>>` to implement `Bar` +note: required for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Bar` --> $DIR/issue-20413.rs:28:9 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' = note: 125 redundant requirements hidden = note: required for `EvenLessData` to implement `Baz` @@ -52,18 +49,16 @@ LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `AlmostNoData>>>>>>` to implement `Bar` +note: required for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Bar` --> $DIR/issue-20413.rs:28:9 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' -note: required for `EvenLessData>>>>>>` to implement `Baz` +note: required for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Baz` --> $DIR/issue-20413.rs:35:9 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' = note: 125 redundant requirements hidden = note: required for `AlmostNoData` to implement `Bar` diff --git a/tests/ui/issues/issue-20772.stderr b/tests/ui/issues/issue-20772.stderr index 416fd8c06..0c7e728c6 100644 --- a/tests/ui/issues/issue-20772.stderr +++ b/tests/ui/issues/issue-20772.stderr @@ -10,6 +10,7 @@ note: cycle used when computing the super predicates of `T` | LL | trait T : Iterator | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-21177.stderr b/tests/ui/issues/issue-21177.stderr index 6877a1846..8b749edcc 100644 --- a/tests/ui/issues/issue-21177.stderr +++ b/tests/ui/issues/issue-21177.stderr @@ -10,6 +10,7 @@ note: cycle used when computing explicit predicates of `foo` | LL | fn foo>() { } | ^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-21600.stderr b/tests/ui/issues/issue-21600.stderr index ea304f936..f79059344 100644 --- a/tests/ui/issues/issue-21600.stderr +++ b/tests/ui/issues/issue-21600.stderr @@ -5,7 +5,7 @@ LL | fn call_it(f: F) where F: Fn() { f(); } | - change this to accept `FnMut` instead of `Fn` ... LL | call_it(|| x.gen_mut()); - | ------- -- ^^^^^^^^^^^ cannot borrow as mutable + | ------- -- ^ cannot borrow as mutable | | | | | in this closure | expects `Fn` instead of `FnMut` diff --git a/tests/ui/issues/issue-23122-2.stderr b/tests/ui/issues/issue-23122-2.stderr index 06e5b711a..af77e4b1a 100644 --- a/tests/ui/issues/issue-23122-2.stderr +++ b/tests/ui/issues/issue-23122-2.stderr @@ -5,14 +5,13 @@ LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) -note: required for `GetNext<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` +note: required for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` --> $DIR/issue-23122-2.rs:10:15 | LL | impl Next for GetNext { | - ^^^^ ^^^^^^^^^^ | | | unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-hash.txt' error: aborting due to previous error diff --git a/tests/ui/issues/issue-23302-1.stderr b/tests/ui/issues/issue-23302-1.stderr index 9366050d7..d807e2440 100644 --- a/tests/ui/issues/issue-23302-1.stderr +++ b/tests/ui/issues/issue-23302-1.stderr @@ -10,6 +10,7 @@ note: cycle used when simplifying constant for the type system `X::A::{constant# | LL | A = X::A as isize, | ^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-23302-2.stderr b/tests/ui/issues/issue-23302-2.stderr index b97ae287a..91b39dba1 100644 --- a/tests/ui/issues/issue-23302-2.stderr +++ b/tests/ui/issues/issue-23302-2.stderr @@ -10,6 +10,7 @@ note: cycle used when simplifying constant for the type system `Y::A::{constant# | LL | A = Y::B as isize, | ^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-23302-3.stderr b/tests/ui/issues/issue-23302-3.stderr index c6cafe575..6b708d81f 100644 --- a/tests/ui/issues/issue-23302-3.stderr +++ b/tests/ui/issues/issue-23302-3.stderr @@ -15,6 +15,7 @@ note: cycle used when simplifying constant for the type system `A` | LL | const A: i32 = B; | ^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-27842.stderr b/tests/ui/issues/issue-27842.stderr index 83333aa0c..b18fe1512 100644 --- a/tests/ui/issues/issue-27842.stderr +++ b/tests/ui/issues/issue-27842.stderr @@ -1,24 +1,24 @@ error[E0608]: cannot index into a value of type `({integer}, {integer}, {integer})` - --> $DIR/issue-27842.rs:4:13 + --> $DIR/issue-27842.rs:4:16 | LL | let _ = tup[0]; - | ^^^^^^ help: to access tuple elements, use: `tup.0` + | ^^^ help: to access tuple elements, use: `.0` error[E0608]: cannot index into a value of type `({integer}, {integer}, {integer})` - --> $DIR/issue-27842.rs:9:13 + --> $DIR/issue-27842.rs:9:16 | LL | let _ = tup[i]; - | ^^^^-^ + | ^-^ | | | cannot access tuple elements at a variable index | = help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`) error[E0608]: cannot index into a value of type `({integer},)` - --> $DIR/issue-27842.rs:14:13 + --> $DIR/issue-27842.rs:14:16 | LL | let _ = tup[3]; - | ^^^^^^ + | ^^^ | = help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`) diff --git a/tests/ui/issues/issue-34373.stderr b/tests/ui/issues/issue-34373.stderr index 8be3cfa72..0f0821518 100644 --- a/tests/ui/issues/issue-34373.stderr +++ b/tests/ui/issues/issue-34373.stderr @@ -21,6 +21,7 @@ LL | | fn foo(_: T) {} LL | | fn main() { LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/issues/issue-40861.stderr b/tests/ui/issues/issue-40861.stderr index 84e38b9bb..9b6469d05 100644 --- a/tests/ui/issues/issue-40861.stderr +++ b/tests/ui/issues/issue-40861.stderr @@ -1,8 +1,8 @@ error[E0608]: cannot index into a value of type `()` - --> $DIR/issue-40861.rs:4:5 + --> $DIR/issue-40861.rs:4:7 | LL | ()[f(&[1.0])]; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`) diff --git a/tests/ui/issues/issue-41726.stderr b/tests/ui/issues/issue-41726.stderr index b05c1fb14..7c87fde54 100644 --- a/tests/ui/issues/issue-41726.stderr +++ b/tests/ui/issues/issue-41726.stderr @@ -2,13 +2,10 @@ error[E0596]: cannot borrow data in an index of `HashMap>` a --> $DIR/issue-41726.rs:5:9 | LL | things[src.as_str()].sort(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap>` -help: to modify a `HashMap>` use `.get_mut()` - | -LL | things.get_mut(src.as_str()).map(|val| val.sort()); - | ~~~~~~~~~ ~~~~~~~~~~~~~~~ + + = help: to modify a `HashMap>`, use `.get_mut()`, `.insert()` or the entry API error: aborting due to previous error diff --git a/tests/ui/issues/issue-42106.stderr b/tests/ui/issues/issue-42106.stderr index 73cf8652f..d5a9d233b 100644 --- a/tests/ui/issues/issue-42106.stderr +++ b/tests/ui/issues/issue-42106.stderr @@ -4,9 +4,9 @@ error[E0502]: cannot borrow `*collection` as mutable because it is also borrowed LL | let _a = &collection; | ----------- immutable borrow occurs here LL | collection.swap(1, 2); - | ^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^ mutable borrow occurs here LL | _a.use_ref(); - | ------------ immutable borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/tests/ui/issues/issue-44405.stderr b/tests/ui/issues/issue-44405.stderr index 626cb2999..1fd69f6e7 100644 --- a/tests/ui/issues/issue-44405.stderr +++ b/tests/ui/issues/issue-44405.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow data in an index of `Container` as mutable --> $DIR/issue-44405.rs:21:5 | LL | container[&mut val].test(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Container` diff --git a/tests/ui/issues/issue-48364.stderr b/tests/ui/issues/issue-48364.stderr index cac4af6a7..3f2e1b83a 100644 --- a/tests/ui/issues/issue-48364.stderr +++ b/tests/ui/issues/issue-48364.stderr @@ -10,7 +10,6 @@ LL | b"".starts_with(stringify!(foo)) found reference `&'static str` note: method defined here --> $SRC_DIR/core/src/slice/mod.rs:LL:COL - = note: this error originates in the macro `stringify` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/issues/issue-51632-try-desugar-incompatible-types.stderr b/tests/ui/issues/issue-51632-try-desugar-incompatible-types.stderr index 7180a3d24..c92da53db 100644 --- a/tests/ui/issues/issue-51632-try-desugar-incompatible-types.stderr +++ b/tests/ui/issues/issue-51632-try-desugar-incompatible-types.stderr @@ -1,6 +1,8 @@ error[E0308]: `?` operator has incompatible types --> $DIR/issue-51632-try-desugar-incompatible-types.rs:8:5 | +LL | fn forbidden_narratives() -> Result { + | ----------------- expected `Result` because of return type LL | missing_discourses()? | ^^^^^^^^^^^^^^^^^^^^^ expected `Result`, found `isize` | diff --git a/tests/ui/issues/issue-52126-assign-op-invariance.stderr b/tests/ui/issues/issue-52126-assign-op-invariance.stderr index 2d3b48832..316e755f4 100644 --- a/tests/ui/issues/issue-52126-assign-op-invariance.stderr +++ b/tests/ui/issues/issue-52126-assign-op-invariance.stderr @@ -4,7 +4,7 @@ error[E0597]: `line` does not live long enough LL | for line in vec!["123456789".to_string(), "12345678".to_string()] { | ---- binding `line` declared here LL | let v: Vec<&str> = line.split_whitespace().collect(); - | ^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^ borrowed value does not live long enough ... LL | acc += cnt2; | --- borrow later used here diff --git a/tests/ui/issues/issue-61108.stderr b/tests/ui/issues/issue-61108.stderr index 3aaf5fb3f..dd87b6266 100644 --- a/tests/ui/issues/issue-61108.stderr +++ b/tests/ui/issues/issue-61108.stderr @@ -7,7 +7,7 @@ LL | for l in bad_letters { | ----------- `bad_letters` moved due to this implicit call to `.into_iter()` ... LL | bad_letters.push('s'); - | ^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move + | ^^^^^^^^^^^ value borrowed here after move | note: `into_iter` takes ownership of the receiver `self`, which moves `bad_letters` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL diff --git a/tests/ui/issues/issue-81584.stderr b/tests/ui/issues/issue-81584.stderr index 54973cfa3..d57f1b778 100644 --- a/tests/ui/issues/issue-81584.stderr +++ b/tests/ui/issues/issue-81584.stderr @@ -2,7 +2,7 @@ error[E0515]: cannot return value referencing function parameter `y` --> $DIR/issue-81584.rs:5:22 | LL | .map(|y| y.iter().map(|x| x + 1)) - | --------^^^^^^^^^^^^^^^ + | -^^^^^^^^^^^^^^^^^^^^^^ | | | returns a value referencing data owned by the current function | `y` is borrowed here diff --git a/tests/ui/issues/issue-83190.rs b/tests/ui/issues/issue-83190.rs deleted file mode 100644 index da931c3ed..000000000 --- a/tests/ui/issues/issue-83190.rs +++ /dev/null @@ -1,49 +0,0 @@ -// check-pass - -// Regression test for issue #83190, triggering an ICE in borrowck. - -pub trait Any {} -impl Any for T {} - -pub trait StreamOnce { - type Range; -} - -pub trait Parser: Sized { - type Output; - type PartialState; - fn map(self) -> Map { - todo!() - } -} - -pub struct Map

(P); -impl> Parser for Map

{ - type Output = (); - type PartialState = P::PartialState; -} - -struct TakeWhile1(Input); -impl Parser for TakeWhile1 { - type Output = I::Range; - type PartialState = (); -} -impl TakeWhile1 { - fn new() -> Self { - todo!() - } -} - -impl> Parser for (A,) { - type Output = (); - type PartialState = Map; -} - -pub fn metric_stream_parser<'a, I>() -> impl Parser -where - I: StreamOnce, -{ - (TakeWhile1::new(),).map() -} - -fn main() {} diff --git a/tests/ui/issues/issue-87707.run.stderr b/tests/ui/issues/issue-87707.run.stderr index 527c78ba8..255a77a6a 100644 --- a/tests/ui/issues/issue-87707.run.stderr +++ b/tests/ui/issues/issue-87707.run.stderr @@ -1,3 +1,5 @@ -thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:14:24 +thread 'main' panicked at $DIR/issue-87707.rs:14:24: +Here Once instance is poisoned. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:16:7 +thread 'main' panicked at $DIR/issue-87707.rs:16:7: +Once instance has previously been poisoned diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index b9fa1b299..eeffb3c5f 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -53,6 +53,8 @@ error: layout_of(E) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(12 bytes), @@ -77,9 +79,13 @@ error: layout_of(E) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/debug.rs:7:1 | @@ -124,6 +130,8 @@ error: layout_of(S) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/debug.rs:10:1 | @@ -146,6 +154,8 @@ error: layout_of(U) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/debug.rs:13:1 | @@ -237,6 +247,8 @@ error: layout_of(std::result::Result) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, Layout { size: Size(8 bytes), @@ -272,9 +284,13 @@ error: layout_of(std::result::Result) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/debug.rs:16:1 | @@ -301,6 +317,8 @@ error: layout_of(i32) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/debug.rs:19:1 | @@ -323,6 +341,8 @@ error: layout_of(V) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), } --> $DIR/debug.rs:22:1 | @@ -345,6 +365,8 @@ error: layout_of(W) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), } --> $DIR/debug.rs:28:1 | @@ -367,6 +389,8 @@ error: layout_of(Y) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), } --> $DIR/debug.rs:34:1 | @@ -389,6 +413,8 @@ error: layout_of(P1) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/debug.rs:41:1 | @@ -411,6 +437,8 @@ error: layout_of(P2) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/debug.rs:45:1 | @@ -433,6 +461,8 @@ error: layout_of(P3) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/debug.rs:53:1 | @@ -455,6 +485,8 @@ error: layout_of(P4) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/debug.rs:57:1 | @@ -482,6 +514,8 @@ error: layout_of(P5) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/debug.rs:61:1 | @@ -509,6 +543,8 @@ error: layout_of(std::mem::MaybeUninit) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/debug.rs:64:1 | diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index d850dd69c..a2ad4a1ab 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -59,9 +59,13 @@ error: layout_of(A) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/hexagon-enum.rs:16:1 | @@ -129,9 +133,13 @@ error: layout_of(B) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/hexagon-enum.rs:20:1 | @@ -199,9 +207,13 @@ error: layout_of(C) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), } --> $DIR/hexagon-enum.rs:24:1 | @@ -269,9 +281,13 @@ error: layout_of(P) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/hexagon-enum.rs:28:1 | @@ -339,9 +355,13 @@ error: layout_of(T) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/hexagon-enum.rs:34:1 | diff --git a/tests/ui/layout/issue-113941.rs b/tests/ui/layout/issue-113941.rs new file mode 100644 index 000000000..7a54e28b3 --- /dev/null +++ b/tests/ui/layout/issue-113941.rs @@ -0,0 +1,13 @@ +// build-pass +// revisions: normal randomize-layout +// [randomize-layout]compile-flags: -Zrandomize-layout + +enum Void {} + +pub struct Struct([*const (); 0], Void); + +pub enum Enum { + Variant(Struct), +} + +fn main() {} diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 8c7c91535..d3ba1a295 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -81,6 +81,8 @@ error: layout_of(MissingPayloadField) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(1 bytes), @@ -99,9 +101,13 @@ error: layout_of(MissingPayloadField) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:16:1 | @@ -193,6 +199,8 @@ error: layout_of(CommonPayloadField) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(2 bytes), @@ -228,9 +236,13 @@ error: layout_of(CommonPayloadField) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:25:1 | @@ -320,6 +332,8 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(2 bytes), @@ -354,9 +368,13 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:33:1 | @@ -462,6 +480,8 @@ error: layout_of(NicheFirst) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(0 bytes), @@ -480,6 +500,8 @@ error: layout_of(NicheFirst) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(0 bytes), @@ -498,9 +520,13 @@ error: layout_of(NicheFirst) = Layout { variants: Single { index: 2, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:41:1 | @@ -606,6 +632,8 @@ error: layout_of(NicheSecond) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(0 bytes), @@ -624,6 +652,8 @@ error: layout_of(NicheSecond) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(0 bytes), @@ -642,9 +672,13 @@ error: layout_of(NicheSecond) = Layout { variants: Single { index: 2, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:50:1 | diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index de6177c8d..c539eb453 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -53,6 +53,10 @@ error: layout_of(Aligned1) = Layout { variants: Single { index: 0, }, + max_repr_align: Some( + Align(8 bytes), + ), + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(8 bytes), @@ -71,9 +75,17 @@ error: layout_of(Aligned1) = Layout { variants: Single { index: 1, }, + max_repr_align: Some( + Align(8 bytes), + ), + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: Some( + Align(8 bytes), + ), + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96185-overaligned-enum.rs:8:1 | @@ -141,6 +153,10 @@ error: layout_of(Aligned2) = Layout { variants: Single { index: 0, }, + max_repr_align: Some( + Align(1 bytes), + ), + unadjusted_abi_align: Align(1 bytes), }, Layout { size: Size(1 bytes), @@ -159,9 +175,17 @@ error: layout_of(Aligned2) = Layout { variants: Single { index: 1, }, + max_repr_align: Some( + Align(1 bytes), + ), + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: Some( + Align(1 bytes), + ), + unadjusted_abi_align: Align(1 bytes), } --> $DIR/issue-96185-overaligned-enum.rs:16:1 | diff --git a/tests/ui/layout/malformed-unsized-type-in-union.rs b/tests/ui/layout/malformed-unsized-type-in-union.rs new file mode 100644 index 000000000..5d8ec576c --- /dev/null +++ b/tests/ui/layout/malformed-unsized-type-in-union.rs @@ -0,0 +1,8 @@ +// issue: 113760 + +union W { s: dyn Iterator } +//~^ ERROR cannot find type `Missing` in this scope + +static ONCE: W = todo!(); + +fn main() {} diff --git a/tests/ui/layout/malformed-unsized-type-in-union.stderr b/tests/ui/layout/malformed-unsized-type-in-union.stderr new file mode 100644 index 000000000..cbb8d6af3 --- /dev/null +++ b/tests/ui/layout/malformed-unsized-type-in-union.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/malformed-unsized-type-in-union.rs:3:34 + | +LL | union W { s: dyn Iterator } + | ^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 227bd950b..6f6ab4982 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -59,9 +59,13 @@ error: layout_of(A) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/thumb-enum.rs:16:1 | @@ -129,9 +133,13 @@ error: layout_of(B) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), } --> $DIR/thumb-enum.rs:20:1 | @@ -199,9 +207,13 @@ error: layout_of(C) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), } --> $DIR/thumb-enum.rs:24:1 | @@ -269,9 +281,13 @@ error: layout_of(P) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/thumb-enum.rs:28:1 | @@ -339,9 +355,13 @@ error: layout_of(T) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/thumb-enum.rs:34:1 | diff --git a/tests/ui/layout/valid_range_oob.stderr b/tests/ui/layout/valid_range_oob.stderr index a3a514fb8..d56804a35 100644 --- a/tests/ui/layout/valid_range_oob.stderr +++ b/tests/ui/layout/valid_range_oob.stderr @@ -1,3 +1,4 @@ +257 > 255 error: the compiler unexpectedly panicked. this is a bug. query stack during panic: diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index a3e82070e..df9f1cc8d 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -57,6 +57,8 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, Layout { size: Size(2 bytes), @@ -88,9 +90,13 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:13:1 | @@ -156,6 +162,8 @@ error: layout_of(MultipleAlignments) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(2 bytes), }, Layout { size: Size(4 bytes), @@ -178,6 +186,8 @@ error: layout_of(MultipleAlignments) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, Layout { size: Size(2 bytes), @@ -209,9 +219,13 @@ error: layout_of(MultipleAlignments) = Layout { variants: Single { index: 2, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:21:1 | @@ -277,6 +291,8 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, Layout { size: Size(3 bytes), @@ -308,9 +324,13 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:37:1 | @@ -380,6 +400,8 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { variants: Single { index: 0, }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), }, Layout { size: Size(2 bytes), @@ -411,9 +433,13 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { variants: Single { index: 1, }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), }, ], }, + max_repr_align: None, + unadjusted_abi_align: Align(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:44:1 | diff --git a/tests/ui/lazy-type-alias/auxiliary/eager.rs b/tests/ui/lazy-type-alias/auxiliary/eager.rs new file mode 100644 index 000000000..8793a1701 --- /dev/null +++ b/tests/ui/lazy-type-alias/auxiliary/eager.rs @@ -0,0 +1,6 @@ +// This crate does *not* have lazy type aliases enabled. + +#![allow(type_alias_bounds)] + +// The `Copy` bound is ignored both locally and externally for backward compatibility. +pub type Alias = Option; diff --git a/tests/ui/lazy-type-alias/auxiliary/lazy.rs b/tests/ui/lazy-type-alias/auxiliary/lazy.rs new file mode 100644 index 000000000..caa7999b4 --- /dev/null +++ b/tests/ui/lazy-type-alias/auxiliary/lazy.rs @@ -0,0 +1,4 @@ +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +pub type Alias = Option; diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr b/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr new file mode 100644 index 000000000..98b3921de --- /dev/null +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr @@ -0,0 +1,11 @@ +warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/coerce-behind-lazy.rs:5:12 + | +LL | #![feature(lazy_type_alias)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr b/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr new file mode 100644 index 000000000..98b3921de --- /dev/null +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/coerce-behind-lazy.rs:5:12 + | +LL | #![feature(lazy_type_alias)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.rs b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs new file mode 100644 index 000000000..745eadb96 --- /dev/null +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs @@ -0,0 +1,16 @@ +// check-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +#![feature(lazy_type_alias)] +//~^ WARN the feature `lazy_type_alias` is incomplete + +use std::any::Any; + +type Coerce = Box; + +fn test() -> Coerce { + Box::new(1) +} + +fn main() {} diff --git a/tests/ui/lazy-type-alias/enum-variant.rs b/tests/ui/lazy-type-alias/enum-variant.rs new file mode 100644 index 000000000..6d18e9eca --- /dev/null +++ b/tests/ui/lazy-type-alias/enum-variant.rs @@ -0,0 +1,18 @@ +// Regression test for issue #113736. +// check-pass + +#![feature(lazy_type_alias)] +//~^ WARN the feature `lazy_type_alias` is incomplete and may not be safe to use + +enum Enum { + Unit, + Tuple(), + Struct {}, +} + +fn main() { + type Alias = Enum; + let _ = Alias::Unit; + let _ = Alias::Tuple(); + let _ = Alias::Struct {}; +} diff --git a/tests/ui/lazy-type-alias/enum-variant.stderr b/tests/ui/lazy-type-alias/enum-variant.stderr new file mode 100644 index 000000000..4360db917 --- /dev/null +++ b/tests/ui/lazy-type-alias/enum-variant.stderr @@ -0,0 +1,11 @@ +warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/enum-variant.rs:4:12 + | +LL | #![feature(lazy_type_alias)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs b/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs new file mode 100644 index 000000000..07389961c --- /dev/null +++ b/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs @@ -0,0 +1,23 @@ +// This test serves as a regression test for issue #114468 and it also ensures that we consider +// type aliases from external crates that don't have `lazy_type_alias` enabled to be eager. + +// aux-crate:eager=eager.rs +// edition: 2021 +// check-pass + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// This used to crash when we were computing the variances of `Struct` since we would convert +// `eager::Alias` to a weak projection due to the presence of `#![feature(lazy_type_alias)]` in +// this (!) crate and subsequently attempt to obtain the variances of the type alias associated with +// the weak projection which would panic because we don't compute this information for eager type +// aliases at all. +struct Struct(eager::Alias); + +fn main() { + // We want to ignore (or rather “end up ignoring”) the bound `T: Copy` since `Alias` should be + // treated as an eager type alias not just inside the crate it is defined in but also in + // dependent crates (like this one). + let _: eager::Alias; +} diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr new file mode 100644 index 000000000..9e0e2bfa8 --- /dev/null +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12 + | +LL | let _: lazy::Alias; + | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound on the type alias `Alias` + --> $DIR/auxiliary/lazy.rs:4:19 + | +LL | pub type Alias = Option; + | ^^^^ required by this bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr new file mode 100644 index 000000000..9e0e2bfa8 --- /dev/null +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12 + | +LL | let _: lazy::Alias; + | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound on the type alias `Alias` + --> $DIR/auxiliary/lazy.rs:4:19 + | +LL | pub type Alias = Option; + | ^^^^ required by this bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs new file mode 100644 index 000000000..31a19161b --- /dev/null +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs @@ -0,0 +1,16 @@ +// revisions: locally_eager locally_lazy +// aux-crate:lazy=lazy.rs +// edition: 2021 + +// Test that we treat lazy type aliases from external crates as lazy independently of whether the +// local crate enables `lazy_type_alias` or not. + +#![cfg_attr( + locally_lazy, + feature(lazy_type_alias), + allow(incomplete_features) +)] + +fn main() { + let _: lazy::Alias; //~ ERROR the trait bound `String: Copy` is not satisfied +} diff --git a/tests/ui/lazy-type-alias/leading-where-clause.fixed b/tests/ui/lazy-type-alias/leading-where-clause.fixed new file mode 100644 index 000000000..07ebc09b3 --- /dev/null +++ b/tests/ui/lazy-type-alias/leading-where-clause.fixed @@ -0,0 +1,15 @@ +// run-rustfix + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// Check that we *reject* leading where-clauses on lazy type aliases. + +type Alias + += T where String: From; +//~^^^ ERROR where clauses are not allowed before the type for type aliases + +fn main() { + let _: Alias<&str>; +} diff --git a/tests/ui/lazy-type-alias/leading-where-clause.rs b/tests/ui/lazy-type-alias/leading-where-clause.rs new file mode 100644 index 000000000..4a6542934 --- /dev/null +++ b/tests/ui/lazy-type-alias/leading-where-clause.rs @@ -0,0 +1,16 @@ +// run-rustfix + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// Check that we *reject* leading where-clauses on lazy type aliases. + +type Alias +where + String: From, += T; +//~^^^ ERROR where clauses are not allowed before the type for type aliases + +fn main() { + let _: Alias<&str>; +} diff --git a/tests/ui/lazy-type-alias/leading-where-clause.stderr b/tests/ui/lazy-type-alias/leading-where-clause.stderr new file mode 100644 index 000000000..8ddf0ce6c --- /dev/null +++ b/tests/ui/lazy-type-alias/leading-where-clause.stderr @@ -0,0 +1,16 @@ +error: where clauses are not allowed before the type for type aliases + --> $DIR/leading-where-clause.rs:9:1 + | +LL | / where +LL | | String: From, + | |____________________^ + | + = note: see issue #89122 for more information +help: move it to the end of the type declaration + | +LL + +LL ~ = T where String: From; + | + +error: aborting due to previous error + diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.rs b/tests/ui/lazy-type-alias/trailing-where-clause.rs new file mode 100644 index 000000000..ac9598fe5 --- /dev/null +++ b/tests/ui/lazy-type-alias/trailing-where-clause.rs @@ -0,0 +1,13 @@ +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// Check that we allow & respect trailing where-clauses on lazy type aliases. + +type Alias = T +where + String: From; + +fn main() { + let _: Alias<&str>; + let _: Alias<()>; //~ ERROR the trait bound `String: From<()>` is not satisfied +} diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.stderr b/tests/ui/lazy-type-alias/trailing-where-clause.stderr new file mode 100644 index 000000000..d7606ba6b --- /dev/null +++ b/tests/ui/lazy-type-alias/trailing-where-clause.stderr @@ -0,0 +1,22 @@ +error[E0277]: the trait bound `String: From<()>` is not satisfied + --> $DIR/trailing-where-clause.rs:12:12 + | +LL | let _: Alias<()>; + | ^^^^^^^^^ the trait `From<()>` is not implemented for `String` + | + = help: the following other types implement trait `From`: + > + >> + >> + > + > + > +note: required by a bound on the type alias `Alias` + --> $DIR/trailing-where-clause.rs:8:13 + | +LL | String: From; + | ^^^^^^^ required by this bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs b/tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs new file mode 100644 index 000000000..d0abd3ebf --- /dev/null +++ b/tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs @@ -0,0 +1,14 @@ +// Check that we don't issue the lint `type_alias_bounds` for +// lazy type aliases since the bounds are indeed enforced. + +// check-pass + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] +#![deny(type_alias_bounds)] + +use std::ops::Mul; + +type Alias = ::Output; + +fn main() {} diff --git a/tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.rs b/tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.rs new file mode 100644 index 000000000..c798e4e43 --- /dev/null +++ b/tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.rs @@ -0,0 +1,8 @@ +// Test that we check lazy type aliases for well-formedness. + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +type Alias = ::Output; //~ ERROR cannot multiply `T` by `T` + +fn main() {} diff --git a/tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.stderr b/tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.stderr new file mode 100644 index 000000000..d022f8251 --- /dev/null +++ b/tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.stderr @@ -0,0 +1,14 @@ +error[E0277]: cannot multiply `T` by `T` + --> $DIR/unsatisfied-bounds-type-alias-body.rs:6:17 + | +LL | type Alias = ::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T * T` + | +help: consider restricting type parameter `T` + | +LL | type Alias = ::Output; + | +++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lazy-type-alias/variance.rs b/tests/ui/lazy-type-alias/variance.rs new file mode 100644 index 000000000..f83215856 --- /dev/null +++ b/tests/ui/lazy-type-alias/variance.rs @@ -0,0 +1,38 @@ +// This is a regression test for issue #114221. +// Check that we compute variances for lazy type aliases. + +// check-pass + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// [+] `A` is covariant over `'a`. +struct A<'a>(Co<'a>); + +// [+] `Co` is covariant over `'a`. +type Co<'a> = &'a (); + +fn co<'a>(x: A<'static>) { + let _: A<'a> = x; +} + +// [-] `B` is contravariant over `'a`. +struct B<'a>(Contra<'a>); + +// [-] `Contra` is contravariant over `'a`. +type Contra<'a> = fn(&'a ()); + +fn contra<'a>(x: B<'a>) { + let _: B<'static> = x; +} + +struct C(CoContra); + +// [+, -] `CoContra` is covariant over `T` and contravariant over `U`. +type CoContra = Option<(T, fn(U))>; + +fn co_contra<'a>(x: C<&'static (), &'a ()>) -> C<&'a (), &'static ()> { + x +} + +fn main() {} diff --git a/tests/ui/lexer/lex-emoji-identifiers.rs b/tests/ui/lexer/lex-emoji-identifiers.rs index 91b5929c0..decf2f005 100644 --- a/tests/ui/lexer/lex-emoji-identifiers.rs +++ b/tests/ui/lexer/lex-emoji-identifiers.rs @@ -1,9 +1,7 @@ fn invalid_emoji_usages() { let arrow↔️ = "basic emoji"; //~ ERROR: identifiers cannot contain emoji - // FIXME - let planet🪐 = "basic emoji"; //~ ERROR: unknown start of token - // FIXME - let wireless🛜 = "basic emoji"; //~ ERROR: unknown start of token + let planet🪐 = "basic emoji"; //~ ERROR: identifiers cannot contain emoji + let wireless🛜 = "basic emoji"; //~ ERROR: identifiers cannot contain emoji // FIXME let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token //~^ WARN: identifier contains uncommon Unicode codepoints diff --git a/tests/ui/lexer/lex-emoji-identifiers.stderr b/tests/ui/lexer/lex-emoji-identifiers.stderr index 6237c5d02..747825fa2 100644 --- a/tests/ui/lexer/lex-emoji-identifiers.stderr +++ b/tests/ui/lexer/lex-emoji-identifiers.stderr @@ -1,17 +1,5 @@ -error: unknown start of token: \u{1fa90} - --> $DIR/lex-emoji-identifiers.rs:4:15 - | -LL | let planet🪐 = "basic emoji"; - | ^^ - -error: unknown start of token: \u{1f6dc} - --> $DIR/lex-emoji-identifiers.rs:6:17 - | -LL | let wireless🛜 = "basic emoji"; - | ^^ - error: unknown start of token: \u{20e3} - --> $DIR/lex-emoji-identifiers.rs:8:14 + --> $DIR/lex-emoji-identifiers.rs:6:14 | LL | let key1️⃣ = "keycap sequence"; | ^ @@ -22,26 +10,38 @@ error: identifiers cannot contain emoji: `arrow↔️` LL | let arrow↔️ = "basic emoji"; | ^^^^^^ +error: identifiers cannot contain emoji: `planet🪐` + --> $DIR/lex-emoji-identifiers.rs:3:9 + | +LL | let planet🪐 = "basic emoji"; + | ^^^^^^^^ + +error: identifiers cannot contain emoji: `wireless🛜` + --> $DIR/lex-emoji-identifiers.rs:4:9 + | +LL | let wireless🛜 = "basic emoji"; + | ^^^^^^^^^^ + error: identifiers cannot contain emoji: `flag🇺🇳` - --> $DIR/lex-emoji-identifiers.rs:10:9 + --> $DIR/lex-emoji-identifiers.rs:8:9 | LL | let flag🇺🇳 = "flag sequence"; | ^^^^^^ error: identifiers cannot contain emoji: `wales🏴` - --> $DIR/lex-emoji-identifiers.rs:11:9 + --> $DIR/lex-emoji-identifiers.rs:9:9 | LL | let wales🏴 = "tag sequence"; | ^^^^^^^ error: identifiers cannot contain emoji: `folded🙏🏿` - --> $DIR/lex-emoji-identifiers.rs:12:9 + --> $DIR/lex-emoji-identifiers.rs:10:9 | LL | let folded🙏🏿 = "modifier sequence"; | ^^^^^^^^^^ warning: identifier contains uncommon Unicode codepoints - --> $DIR/lex-emoji-identifiers.rs:8:9 + --> $DIR/lex-emoji-identifiers.rs:6:9 | LL | let key1️⃣ = "keycap sequence"; | ^^^^ diff --git a/tests/ui/lifetimes/borrowck-let-suggestion.stderr b/tests/ui/lifetimes/borrowck-let-suggestion.stderr index 987b051b1..da0078698 100644 --- a/tests/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/tests/ui/lifetimes/borrowck-let-suggestion.stderr @@ -7,10 +7,14 @@ LL | let mut x = vec![1].iter(); | creates a temporary value which is freed while still in use LL | LL | x.use_mut(); - | ----------- borrow later used here + | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = vec![1]; +LL ~ let mut x = binding.iter(); + | error: aborting due to previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr index cc2447b18..cb629d2e3 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr @@ -1,3 +1,14 @@ +error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 + | +LL | y.push(z); + | ^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | fn foo(x:fn(&u8, &u8), mut y: Vec<&u8>, z: &u8) { + | +++ + error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 | @@ -13,17 +24,6 @@ help: consider introducing a named lifetime parameter LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) { | ++++ ++ ++ -error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 - | -LL | y.push(z); - | ^^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to be mutable - | -LL | fn foo(x:fn(&u8, &u8), mut y: Vec<&u8>, z: &u8) { - | +++ - error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr index 2ba5afa80..05f930812 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr @@ -1,3 +1,14 @@ +error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 + | +LL | y.push(z); + | ^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | fn foo(x:Box , mut y: Vec<&u8>, z: &u8) { + | +++ + error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 | @@ -13,17 +24,6 @@ help: consider introducing a named lifetime parameter LL | fn foo<'a>(x:Box , y: Vec<&'a u8>, z: &'a u8) { | ++++ ++ ++ -error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 - | -LL | y.push(z); - | ^^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to be mutable - | -LL | fn foo(x:Box , mut y: Vec<&u8>, z: &u8) { - | +++ - error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index 4994e4dc4..01ec69a61 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -3,11 +3,6 @@ error[E0106]: missing lifetime specifier | LL | fn d() {} | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | fn d<'a, const C: S<'a>>() {} - | +++ ++++ error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/unusual-rib-combinations.rs:29:22 diff --git a/tests/ui/limits/issue-17913.stderr b/tests/ui/limits/issue-17913.stderr index 684db53a9..0d21a4288 100644 --- a/tests/ui/limits/issue-17913.stderr +++ b/tests/ui/limits/issue-17913.stderr @@ -1,4 +1,5 @@ error: values of the type `[&usize; usize::MAX]` are too big for the current architecture + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL error: aborting due to previous error diff --git a/tests/ui/lint/clashing-extern-fn.stderr b/tests/ui/lint/clashing-extern-fn.stderr index 5d457ba0e..0d269e599 100644 --- a/tests/ui/lint/clashing-extern-fn.stderr +++ b/tests/ui/lint/clashing-extern-fn.stderr @@ -1,11 +1,30 @@ +warning: `extern` block uses type `Option`, which is not FFI-safe + --> $DIR/clashing-extern-fn.rs:433:55 + | +LL | fn hidden_niche_transparent_no_niche() -> Option; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum + = note: enum has no representation hint + = note: `#[warn(improper_ctypes)]` on by default + +warning: `extern` block uses type `Option>`, which is not FFI-safe + --> $DIR/clashing-extern-fn.rs:437:46 + | +LL | fn hidden_niche_unsafe_cell() -> Option>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum + = note: enum has no representation hint + warning: `clash` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:14:13 | LL | fn clash(x: u8); - | ---------------- `clash` previously declared here + | --------------- `clash` previously declared here ... LL | fn clash(x: u64); - | ^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(u8)` found `unsafe extern "C" fn(u64)` @@ -18,12 +37,11 @@ LL | #![warn(clashing_extern_declarations)] warning: `extern_link_name` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:52:9 | -LL | / #[link_name = "extern_link_name"] -LL | | fn some_new_name(x: i16); - | |_____________________________- `extern_link_name` previously declared here +LL | #[link_name = "extern_link_name"] + | --------------------------------- `extern_link_name` previously declared here ... -LL | fn extern_link_name(x: u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration +LL | fn extern_link_name(x: u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(i16)` found `unsafe extern "C" fn(u32)` @@ -31,13 +49,11 @@ LL | fn extern_link_name(x: u32); warning: `some_other_extern_link_name` redeclares `some_other_new_name` with a different signature --> $DIR/clashing-extern-fn.rs:55:9 | -LL | fn some_other_new_name(x: i16); - | ------------------------------- `some_other_new_name` previously declared here +LL | fn some_other_new_name(x: i16); + | ------------------------------ `some_other_new_name` previously declared here ... -LL | / #[link_name = "some_other_new_name"] -LL | | -LL | | fn some_other_extern_link_name(x: u32); - | |_______________________________________________^ this signature doesn't match the previous declaration +LL | #[link_name = "some_other_new_name"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(i16)` found `unsafe extern "C" fn(u32)` @@ -45,14 +61,11 @@ LL | | fn some_other_extern_link_name(x: u32); warning: `other_both_names_different` redeclares `link_name_same` with a different signature --> $DIR/clashing-extern-fn.rs:59:9 | -LL | / #[link_name = "link_name_same"] -LL | | fn both_names_different(x: i16); - | |____________________________________- `link_name_same` previously declared here +LL | #[link_name = "link_name_same"] + | ------------------------------- `link_name_same` previously declared here ... -LL | / #[link_name = "link_name_same"] -LL | | -LL | | fn other_both_names_different(x: u32); - | |______________________________________________^ this signature doesn't match the previous declaration +LL | #[link_name = "link_name_same"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(i16)` found `unsafe extern "C" fn(u32)` @@ -61,10 +74,10 @@ warning: `different_mod` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:72:9 | LL | fn different_mod(x: u8); - | ------------------------ `different_mod` previously declared here + | ----------------------- `different_mod` previously declared here ... LL | fn different_mod(x: u64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(u8)` found `unsafe extern "C" fn(u64)` @@ -73,10 +86,10 @@ warning: `variadic_decl` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:82:9 | LL | fn variadic_decl(x: u8, ...); - | ----------------------------- `variadic_decl` previously declared here + | ---------------------------- `variadic_decl` previously declared here ... LL | fn variadic_decl(x: u8); - | ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(u8, ...)` found `unsafe extern "C" fn(u8)` @@ -85,10 +98,10 @@ warning: `weigh_banana` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:142:13 | LL | fn weigh_banana(count: *const Banana) -> u64; - | --------------------------------------------- `weigh_banana` previously declared here + | -------------------------------------------- `weigh_banana` previously declared here ... LL | fn weigh_banana(count: *const Banana) -> u64; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(*const one::Banana) -> u64` found `unsafe extern "C" fn(*const three::Banana) -> u64` @@ -97,10 +110,10 @@ warning: `draw_point` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:171:13 | LL | fn draw_point(p: Point); - | ------------------------ `draw_point` previously declared here + | ----------------------- `draw_point` previously declared here ... LL | fn draw_point(p: Point); - | ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(sameish_members::a::Point)` found `unsafe extern "C" fn(sameish_members::b::Point)` @@ -109,10 +122,10 @@ warning: `origin` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:197:13 | LL | fn origin() -> Point3; - | ---------------------- `origin` previously declared here + | --------------------- `origin` previously declared here ... LL | fn origin() -> Point3; - | ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> same_sized_members_clash::a::Point3` found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3` @@ -121,10 +134,10 @@ warning: `transparent_incorrect` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:220:13 | LL | fn transparent_incorrect() -> T; - | -------------------------------- `transparent_incorrect` previously declared here + | ------------------------------- `transparent_incorrect` previously declared here ... LL | fn transparent_incorrect() -> isize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> T` found `unsafe extern "C" fn() -> isize` @@ -133,10 +146,10 @@ warning: `missing_return_type` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:259:13 | LL | fn missing_return_type() -> usize; - | ---------------------------------- `missing_return_type` previously declared here + | --------------------------------- `missing_return_type` previously declared here ... LL | fn missing_return_type(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn()` @@ -145,10 +158,10 @@ warning: `non_zero_usize` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:277:13 | LL | fn non_zero_usize() -> core::num::NonZeroUsize; - | ----------------------------------------------- `non_zero_usize` previously declared here + | ---------------------------------------------- `non_zero_usize` previously declared here ... LL | fn non_zero_usize() -> usize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> NonZeroUsize` found `unsafe extern "C" fn() -> usize` @@ -157,10 +170,10 @@ warning: `non_null_ptr` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:279:13 | LL | fn non_null_ptr() -> core::ptr::NonNull; - | ----------------------------------------------- `non_null_ptr` previously declared here + | ---------------------------------------------- `non_null_ptr` previously declared here ... LL | fn non_null_ptr() -> *const usize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> NonNull` found `unsafe extern "C" fn() -> *const usize` @@ -169,10 +182,10 @@ warning: `option_non_zero_usize_incorrect` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:377:13 | LL | fn option_non_zero_usize_incorrect() -> usize; - | ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here + | --------------------------------------------- `option_non_zero_usize_incorrect` previously declared here ... LL | fn option_non_zero_usize_incorrect() -> isize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn() -> isize` @@ -181,10 +194,10 @@ warning: `option_non_null_ptr_incorrect` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:379:13 | LL | fn option_non_null_ptr_incorrect() -> *const usize; - | --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here + | -------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here ... LL | fn option_non_null_ptr_incorrect() -> *const isize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> *const usize` found `unsafe extern "C" fn() -> *const isize` @@ -193,10 +206,10 @@ warning: `hidden_niche_transparent_no_niche` redeclared with a different signatu --> $DIR/clashing-extern-fn.rs:433:13 | LL | fn hidden_niche_transparent_no_niche() -> usize; - | ------------------------------------------------ `hidden_niche_transparent_no_niche` previously declared here + | ----------------------------------------------- `hidden_niche_transparent_no_niche` previously declared here ... LL | fn hidden_niche_transparent_no_niche() -> Option; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn() -> Option` @@ -205,32 +218,13 @@ warning: `hidden_niche_unsafe_cell` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:437:13 | LL | fn hidden_niche_unsafe_cell() -> usize; - | --------------------------------------- `hidden_niche_unsafe_cell` previously declared here + | -------------------------------------- `hidden_niche_unsafe_cell` previously declared here ... LL | fn hidden_niche_unsafe_cell() -> Option>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn() -> Option>` -warning: `extern` block uses type `Option`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:433:55 - | -LL | fn hidden_niche_transparent_no_niche() -> Option; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum - = note: enum has no representation hint - = note: `#[warn(improper_ctypes)]` on by default - -warning: `extern` block uses type `Option>`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:437:46 - | -LL | fn hidden_niche_unsafe_cell() -> Option>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum - = note: enum has no representation hint - warning: 19 warnings emitted diff --git a/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.rs b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.rs new file mode 100644 index 000000000..b71bcd0fa --- /dev/null +++ b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.rs @@ -0,0 +1,19 @@ +// check-pass + +// this test checks that the `dead_code` lint is *NOT* being emited +// for `foo` as `foo` is being used by `main`, and so the `#[expect]` +// is unfulfilled +// +// it also checks that the `dead_code` lint is also *NOT* emited +// for `bar` as it's suppresed by the `#[expect]` on `bar` + +#![feature(lint_reasons)] +#![warn(dead_code)] // to override compiletest + +fn bar() {} + +#[expect(dead_code)] +//~^ WARN this lint expectation is unfulfilled +fn foo() { bar() } + +fn main() { foo() } diff --git a/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.stderr b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.stderr new file mode 100644 index 000000000..d5c4dabed --- /dev/null +++ b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-2.stderr @@ -0,0 +1,10 @@ +warning: this lint expectation is unfulfilled + --> $DIR/allow-or-expect-dead_code-114557-2.rs:15:10 + | +LL | #[expect(dead_code)] + | ^^^^^^^^^ + | + = note: `#[warn(unfulfilled_lint_expectations)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.rs b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.rs new file mode 100644 index 000000000..f8a5d31a0 --- /dev/null +++ b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.rs @@ -0,0 +1,13 @@ +// check-pass + +// this test makes sure that the `unfulfilled_lint_expectations` lint +// is being emited for `foo` as foo is not dead code, it's pub + +#![feature(lint_reasons)] +#![warn(dead_code)] // to override compiletest + +#[expect(dead_code)] +//~^ WARN this lint expectation is unfulfilled +pub fn foo() {} + +fn main() {} diff --git a/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.stderr b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.stderr new file mode 100644 index 000000000..c954a75b3 --- /dev/null +++ b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557-3.stderr @@ -0,0 +1,10 @@ +warning: this lint expectation is unfulfilled + --> $DIR/allow-or-expect-dead_code-114557-3.rs:9:10 + | +LL | #[expect(dead_code)] + | ^^^^^^^^^ + | + = note: `#[warn(unfulfilled_lint_expectations)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557.rs b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557.rs new file mode 100644 index 000000000..24fafa3d1 --- /dev/null +++ b/tests/ui/lint/dead-code/allow-or-expect-dead_code-114557.rs @@ -0,0 +1,18 @@ +// check-pass +// revisions: allow expect + +// this test checks that no matter if we put #[allow(dead_code)] +// or #[expect(dead_code)], no warning is being emited + +#![feature(lint_reasons)] +#![warn(dead_code)] // to override compiletest + +fn f() {} + +#[cfg_attr(allow, allow(dead_code))] +#[cfg_attr(expect, expect(dead_code))] +fn g() { + f(); +} + +fn main() {} diff --git a/tests/ui/lint/invalid-nan-comparison.stderr b/tests/ui/lint/invalid-nan-comparison.stderr index 054c06d38..f2d55c107 100644 --- a/tests/ui/lint/invalid-nan-comparison.stderr +++ b/tests/ui/lint/invalid-nan-comparison.stderr @@ -5,11 +5,6 @@ LL | const TEST: bool = 5f32 == f32::NAN; | ^^^^^^^^^^^^^^^^ | = note: `#[warn(invalid_nan_comparisons)]` on by default -help: use `f32::is_nan()` or `f64::is_nan()` instead - | -LL - const TEST: bool = 5f32 == f32::NAN; -LL + const TEST: bool = 5f32.is_nan(); - | warning: incorrect NaN comparison, NaN cannot be directly compared to itself --> $DIR/invalid-nan-comparison.rs:14:5 diff --git a/tests/ui/lint/issue-111359.stderr b/tests/ui/lint/issue-111359.stderr index 2296d8413..0aef5007a 100644 --- a/tests/ui/lint/issue-111359.stderr +++ b/tests/ui/lint/issue-111359.stderr @@ -1,26 +1,26 @@ -error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation +error: type could implement `Copy`; consider adding `impl Copy` --> $DIR/issue-111359.rs:7:5 | LL | pub struct BarPub; | ^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-111359.rs:1:8 + --> $DIR/issue-111359.rs:2:8 | -LL | #[deny(missing_debug_implementations)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deny(missing_copy_implementations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type could implement `Copy`; consider adding `impl Copy` +error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation --> $DIR/issue-111359.rs:7:5 | LL | pub struct BarPub; | ^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-111359.rs:2:8 + --> $DIR/issue-111359.rs:1:8 | -LL | #[deny(missing_copy_implementations)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deny(missing_debug_implementations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lint/issue-1866.stderr b/tests/ui/lint/issue-1866.stderr index d19a13496..36d323825 100644 --- a/tests/ui/lint/issue-1866.stderr +++ b/tests/ui/lint/issue-1866.stderr @@ -2,10 +2,10 @@ warning: `rust_task_is_unwinding` redeclared with a different signature --> $DIR/issue-1866.rs:23:13 | LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool; - | ------------------------------------------------------------ `rust_task_is_unwinding` previously declared here + | ----------------------------------------------------------- `rust_task_is_unwinding` previously declared here ... LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn(*const usize) -> bool` found `unsafe extern "C" fn(*const bool) -> bool` diff --git a/tests/ui/lint/lint-attr-everywhere-late.stderr b/tests/ui/lint/lint-attr-everywhere-late.stderr index 9587556b0..7fe078068 100644 --- a/tests/ui/lint/lint-attr-everywhere-late.stderr +++ b/tests/ui/lint/lint-attr-everywhere-late.stderr @@ -34,12 +34,6 @@ note: the lint level is defined here LL | #![deny(missing_docs)] | ^^^^^^^^^^^^ -error: missing documentation for a function - --> $DIR/lint-attr-everywhere-late.rs:47:5 - | -LL | pub fn missing_inner() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - error: missing documentation for an associated function --> $DIR/lint-attr-everywhere-late.rs:54:5 | @@ -142,52 +136,6 @@ note: the lint level is defined here LL | #[deny(missing_docs)] | ^^^^^^^^^^^^ -error: missing documentation for a variant - --> $DIR/lint-attr-everywhere-late.rs:112:5 - | -LL | Variant1, - | ^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:111:12 - | -LL | #[deny(missing_docs)] - | ^^^^^^^^^^^^ - -error: `clashing1` redeclared with a different signature - --> $DIR/lint-attr-everywhere-late.rs:123:5 - | -LL | fn clashing1(); - | --------------- `clashing1` previously declared here -... -LL | fn clashing1(_: i32); - | ^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration - | - = note: expected `unsafe extern "C" fn()` - found `unsafe extern "C" fn(i32)` -note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:122:13 - | -LL | #![deny(clashing_extern_declarations)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `clashing2` redeclared with a different signature - --> $DIR/lint-attr-everywhere-late.rs:128:5 - | -LL | fn clashing2(); - | --------------- `clashing2` previously declared here -... -LL | fn clashing2(_: i32); - | ^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration - | - = note: expected `unsafe extern "C" fn()` - found `unsafe extern "C" fn(i32)` -note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:127:12 - | -LL | #[deny(clashing_extern_declarations)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped --> $DIR/lint-attr-everywhere-late.rs:93:38 | @@ -230,6 +178,18 @@ note: the lint level is defined here LL | #[deny(overflowing_literals)] const ASSOC_CONST: u8 = 1000; | ^^^^^^^^^^^^^^^^^^^^ +error: missing documentation for a variant + --> $DIR/lint-attr-everywhere-late.rs:112:5 + | +LL | Variant1, + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/lint-attr-everywhere-late.rs:111:12 + | +LL | #[deny(missing_docs)] + | ^^^^^^^^^^^^ + error: variable `PARAM` should have a snake case name --> $DIR/lint-attr-everywhere-late.rs:131:37 | @@ -436,5 +396,45 @@ note: the lint level is defined here LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::(&123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ +error: missing documentation for a function + --> $DIR/lint-attr-everywhere-late.rs:47:5 + | +LL | pub fn missing_inner() {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `clashing1` redeclared with a different signature + --> $DIR/lint-attr-everywhere-late.rs:123:5 + | +LL | fn clashing1(); + | -------------- `clashing1` previously declared here +... +LL | fn clashing1(_: i32); + | ^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | + = note: expected `unsafe extern "C" fn()` + found `unsafe extern "C" fn(i32)` +note: the lint level is defined here + --> $DIR/lint-attr-everywhere-late.rs:122:13 + | +LL | #![deny(clashing_extern_declarations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `clashing2` redeclared with a different signature + --> $DIR/lint-attr-everywhere-late.rs:128:5 + | +LL | fn clashing2(); + | -------------- `clashing2` previously declared here +... +LL | fn clashing2(_: i32); + | ^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | + = note: expected `unsafe extern "C" fn()` + found `unsafe extern "C" fn(i32)` +note: the lint level is defined here + --> $DIR/lint-attr-everywhere-late.rs:127:12 + | +LL | #[deny(clashing_extern_declarations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: aborting due to 32 previous errors diff --git a/tests/ui/lint/lint-cap-trait-bounds.rs b/tests/ui/lint/lint-cap-trait-bounds.rs new file mode 100644 index 000000000..d9c28dd0a --- /dev/null +++ b/tests/ui/lint/lint-cap-trait-bounds.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/43134 + +// check-pass +// compile-flags: --cap-lints allow + +type Foo = Option; + +fn main() {} diff --git a/tests/ui/lint/lint-missing-doc.stderr b/tests/ui/lint/lint-missing-doc.stderr index adcc21c44..4e9ee4f27 100644 --- a/tests/ui/lint/lint-missing-doc.stderr +++ b/tests/ui/lint/lint-missing-doc.stderr @@ -112,24 +112,6 @@ error: missing documentation for a static LL | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:174:5 - | -LL | pub fn undocumented1() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:175:5 - | -LL | pub fn undocumented2() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:181:9 - | -LL | pub fn also_undocumented1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: missing documentation for a function --> $DIR/lint-missing-doc.rs:196:5 | @@ -154,5 +136,23 @@ error: missing documentation for a trait alias LL | pub trait T = Sync; | ^^^^^^^^^^^ +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:174:5 + | +LL | pub fn undocumented1() {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:175:5 + | +LL | pub fn undocumented2() {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:181:9 + | +LL | pub fn also_undocumented1() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: aborting due to 25 previous errors diff --git a/tests/ui/lint/lint-qualification.fixed b/tests/ui/lint/lint-qualification.fixed new file mode 100644 index 000000000..c14493013 --- /dev/null +++ b/tests/ui/lint/lint-qualification.fixed @@ -0,0 +1,21 @@ +// run-rustfix +#![deny(unused_qualifications)] +#![allow(deprecated)] + +mod foo { + pub fn bar() {} +} + +fn main() { + use foo::bar; + bar(); //~ ERROR: unnecessary qualification + bar(); + + let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345 + + macro_rules! m { () => { + $crate::foo::bar(); // issue #37357 + ::foo::bar(); // issue #38682 + } } + m!(); +} diff --git a/tests/ui/lint/lint-qualification.rs b/tests/ui/lint/lint-qualification.rs index 0cace0ca0..809043035 100644 --- a/tests/ui/lint/lint-qualification.rs +++ b/tests/ui/lint/lint-qualification.rs @@ -1,3 +1,4 @@ +// run-rustfix #![deny(unused_qualifications)] #![allow(deprecated)] diff --git a/tests/ui/lint/lint-qualification.stderr b/tests/ui/lint/lint-qualification.stderr index 149a782d9..90a06bc6c 100644 --- a/tests/ui/lint/lint-qualification.stderr +++ b/tests/ui/lint/lint-qualification.stderr @@ -1,14 +1,19 @@ error: unnecessary qualification - --> $DIR/lint-qualification.rs:10:5 + --> $DIR/lint-qualification.rs:11:5 | LL | foo::bar(); | ^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-qualification.rs:1:9 + --> $DIR/lint-qualification.rs:2:9 | LL | #![deny(unused_qualifications)] | ^^^^^^^^^^^^^^^^^^^^^ +help: remove the unnecessary path segments + | +LL - foo::bar(); +LL + bar(); + | error: aborting due to previous error diff --git a/tests/ui/lint/lint-struct-necessary.rs b/tests/ui/lint/lint-struct-necessary.rs new file mode 100644 index 000000000..8bc3c1205 --- /dev/null +++ b/tests/ui/lint/lint-struct-necessary.rs @@ -0,0 +1,31 @@ +#![allow(dead_code)] +#![deny(unused_parens)] + +enum State { + Waiting { start_at: u64 } +} +struct Foo {} + +fn main() { + let e = &mut State::Waiting { start_at: 0u64 }; + match (&mut State::Waiting { start_at: 0u64 }) { + _ => {} + } + + match (e) { + //~^ ERROR unnecessary parentheses around `match` scrutinee expression + _ => {} + } + + match &(State::Waiting { start_at: 0u64 }) { + _ => {} + } + + match (State::Waiting { start_at: 0u64 }) { + _ => {} + } + + match (&&Foo {}) { + _ => {} + } +} diff --git a/tests/ui/lint/lint-struct-necessary.stderr b/tests/ui/lint/lint-struct-necessary.stderr new file mode 100644 index 000000000..eb65a9e98 --- /dev/null +++ b/tests/ui/lint/lint-struct-necessary.stderr @@ -0,0 +1,19 @@ +error: unnecessary parentheses around `match` scrutinee expression + --> $DIR/lint-struct-necessary.rs:15:11 + | +LL | match (e) { + | ^ ^ + | +note: the lint level is defined here + --> $DIR/lint-struct-necessary.rs:2:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - match (e) { +LL + match e { + | + +error: aborting due to previous error + diff --git a/tests/ui/lint/lint-unconditional-drop-recursion.rs b/tests/ui/lint/lint-unconditional-drop-recursion.rs new file mode 100644 index 000000000..348cd2801 --- /dev/null +++ b/tests/ui/lint/lint-unconditional-drop-recursion.rs @@ -0,0 +1,38 @@ +// Because drop recursion can only be detected after drop elaboration which +// happens for codegen: +// build-fail + +#![deny(unconditional_recursion)] +#![allow(dead_code)] + +pub struct RecursiveDrop; + +impl Drop for RecursiveDrop { + fn drop(&mut self) { //~ ERROR function cannot return without recursing + let _ = RecursiveDrop; + } +} + +#[derive(Default)] +struct NotRecursiveDrop1; + +impl Drop for NotRecursiveDrop1 { + fn drop(&mut self) { + // Before drop elaboration, the MIR can look like a recursive drop will + // occur. But it will not, since forget() prevents drop() from running. + let taken = std::mem::take(self); + std::mem::forget(taken); + } +} + +struct NotRecursiveDrop2; + +impl Drop for NotRecursiveDrop2 { + fn drop(&mut self) { + // Before drop elaboration, the MIR can look like a recursive drop will + // occur. But it will not, since this will panic. + std::panic::panic_any(NotRecursiveDrop2); + } +} + +fn main() {} diff --git a/tests/ui/lint/lint-unconditional-drop-recursion.stderr b/tests/ui/lint/lint-unconditional-drop-recursion.stderr new file mode 100644 index 000000000..76f954816 --- /dev/null +++ b/tests/ui/lint/lint-unconditional-drop-recursion.stderr @@ -0,0 +1,17 @@ +error: function cannot return without recursing + --> $DIR/lint-unconditional-drop-recursion.rs:11:5 + | +LL | fn drop(&mut self) { + | ^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | let _ = RecursiveDrop; + | - recursive call site + | + = help: a `loop` may express intention better if this is on purpose +note: the lint level is defined here + --> $DIR/lint-unconditional-drop-recursion.rs:5:9 + | +LL | #![deny(unconditional_recursion)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/lint/lint-unconditional-recursion.stderr b/tests/ui/lint/lint-unconditional-recursion.stderr index 9d200a789..d75754bf9 100644 --- a/tests/ui/lint/lint-unconditional-recursion.stderr +++ b/tests/ui/lint/lint-unconditional-recursion.stderr @@ -139,7 +139,7 @@ error: function cannot return without recursing LL | fn index(&self, x: usize) -> &Baz { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing LL | &self[x] - | ------- recursive call site + | --- recursive call site | = help: a `loop` may express intention better if this is on purpose diff --git a/tests/ui/lint/missing-copy-implementations-negative-copy.rs b/tests/ui/lint/missing-copy-implementations-negative-copy.rs new file mode 100644 index 000000000..b29d2209f --- /dev/null +++ b/tests/ui/lint/missing-copy-implementations-negative-copy.rs @@ -0,0 +1,15 @@ +// Regression test for issue #101980. +// Ensure that we don't suggest impl'ing `Copy` for a type if it already impl's `!Copy`. + +// check-pass + +#![feature(negative_impls)] +#![deny(missing_copy_implementations)] + +pub struct Struct { + pub field: i32, +} + +impl !Copy for Struct {} + +fn main() {} diff --git a/tests/ui/lint/missing-doc-private-macro.stderr b/tests/ui/lint/missing-doc-private-macro.stderr index 979b007d0..18c8ad2de 100644 --- a/tests/ui/lint/missing-doc-private-macro.stderr +++ b/tests/ui/lint/missing-doc-private-macro.stderr @@ -1,8 +1,8 @@ error: missing documentation for a macro - --> $DIR/missing-doc-private-macro.rs:31:5 + --> $DIR/missing-doc-private-macro.rs:37:1 | -LL | macro_rules! exported_to_top_level { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub macro top_level_pub_macro { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/missing-doc-private-macro.rs:5:9 @@ -11,10 +11,10 @@ LL | #![deny(missing_docs)] | ^^^^^^^^^^^^ error: missing documentation for a macro - --> $DIR/missing-doc-private-macro.rs:37:1 + --> $DIR/missing-doc-private-macro.rs:31:5 | -LL | pub macro top_level_pub_macro { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | macro_rules! exported_to_top_level { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lint/noop-method-call.fixed b/tests/ui/lint/noop-method-call.fixed new file mode 100644 index 000000000..eeb80279f --- /dev/null +++ b/tests/ui/lint/noop-method-call.fixed @@ -0,0 +1,51 @@ +// check-pass +// run-rustfix + +#![allow(unused)] + +use std::borrow::Borrow; +use std::ops::Deref; + +struct PlainType(T); + +#[derive(Clone)] +struct CloneType(T); + +fn check(mut encoded: &[u8]) { + let _ = &mut encoded; + //~^ WARN call to `.clone()` on a reference in this situation does nothing + let _ = &encoded; + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} + +fn main() { + let non_clone_type_ref = &PlainType(1u32); + let non_clone_type_ref_clone: &PlainType = non_clone_type_ref; + //~^ WARN call to `.clone()` on a reference in this situation does nothing + + let clone_type_ref = &CloneType(1u32); + let clone_type_ref_clone: CloneType = clone_type_ref.clone(); + + + let non_deref_type = &PlainType(1u32); + let non_deref_type_deref: &PlainType = non_deref_type; + //~^ WARN call to `.deref()` on a reference in this situation does nothing + + let non_borrow_type = &PlainType(1u32); + let non_borrow_type_borrow: &PlainType = non_borrow_type; + //~^ WARN call to `.borrow()` on a reference in this situation does nothing + + // Borrowing a &&T does not warn since it has collapsed the double reference + let non_borrow_type = &&PlainType(1u32); + let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); +} + +fn generic(non_clone_type: &PlainType) { + non_clone_type; + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} + +fn non_generic(non_clone_type: &PlainType) { + non_clone_type; + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs index dbcf2a513..9569a0dfc 100644 --- a/tests/ui/lint/noop-method-call.rs +++ b/tests/ui/lint/noop-method-call.rs @@ -1,7 +1,7 @@ // check-pass +// run-rustfix #![allow(unused)] -#![warn(noop_method_call)] use std::borrow::Borrow; use std::ops::Deref; @@ -11,45 +11,41 @@ struct PlainType(T); #[derive(Clone)] struct CloneType(T); +fn check(mut encoded: &[u8]) { + let _ = &mut encoded.clone(); + //~^ WARN call to `.clone()` on a reference in this situation does nothing + let _ = &encoded.clone(); + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} + fn main() { let non_clone_type_ref = &PlainType(1u32); let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); - //~^ WARNING call to `.clone()` on a reference in this situation does nothing + //~^ WARN call to `.clone()` on a reference in this situation does nothing let clone_type_ref = &CloneType(1u32); let clone_type_ref_clone: CloneType = clone_type_ref.clone(); - let clone_type_ref = &&CloneType(1u32); - let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); - //~^ WARNING using `.clone()` on a double reference, which returns `&CloneType` let non_deref_type = &PlainType(1u32); let non_deref_type_deref: &PlainType = non_deref_type.deref(); - //~^ WARNING call to `.deref()` on a reference in this situation does nothing - - let non_deref_type = &&PlainType(1u32); - let non_deref_type_deref: &PlainType = non_deref_type.deref(); - //~^ WARNING using `.deref()` on a double reference, which returns `&PlainType` + //~^ WARN call to `.deref()` on a reference in this situation does nothing let non_borrow_type = &PlainType(1u32); let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); - //~^ WARNING call to `.borrow()` on a reference in this situation does nothing + //~^ WARN call to `.borrow()` on a reference in this situation does nothing // Borrowing a &&T does not warn since it has collapsed the double reference let non_borrow_type = &&PlainType(1u32); let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); - - let xs = ["a", "b", "c"]; - let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead - //~^ WARNING using `.clone()` on a double reference, which returns `&str` } fn generic(non_clone_type: &PlainType) { non_clone_type.clone(); - //~^ WARNING call to `.clone()` on a reference in this situation does nothing + //~^ WARN call to `.clone()` on a reference in this situation does nothing } fn non_generic(non_clone_type: &PlainType) { non_clone_type.clone(); - //~^ WARNING call to `.clone()` on a reference in this situation does nothing + //~^ WARN call to `.clone()` on a reference in this situation does nothing } diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr index 37cd1a0fc..aefc2706f 100644 --- a/tests/ui/lint/noop-method-call.stderr +++ b/tests/ui/lint/noop-method-call.stderr @@ -1,67 +1,59 @@ warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:16:71 + --> $DIR/noop-method-call.rs:15:25 | -LL | let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); - | ^^^^^^^^ unnecessary method call - | - = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed -note: the lint level is defined here - --> $DIR/noop-method-call.rs:4:9 +LL | let _ = &mut encoded.clone(); + | ^^^^^^^^ help: remove this redundant call | -LL | #![warn(noop_method_call)] - | ^^^^^^^^^^^^^^^^ + = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed + = note: `#[warn(noop_method_call)]` on by default -warning: using `.clone()` on a double reference, which returns `&CloneType` instead of cloning the inner type - --> $DIR/noop-method-call.rs:23:63 +warning: call to `.clone()` on a reference in this situation does nothing + --> $DIR/noop-method-call.rs:17:21 | -LL | let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); - | ^^^^^^^^ +LL | let _ = &encoded.clone(); + | ^^^^^^^^ help: remove this redundant call | - = note: `#[warn(suspicious_double_ref_op)]` on by default + = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed -warning: call to `.deref()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:27:63 +warning: call to `.clone()` on a reference in this situation does nothing + --> $DIR/noop-method-call.rs:23:71 | -LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); - | ^^^^^^^^ unnecessary method call +LL | let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); + | ^^^^^^^^ help: remove this redundant call | - = note: the type `&PlainType` which `deref` is being called on is the same as the type returned from `deref`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed -warning: using `.deref()` on a double reference, which returns `&PlainType` instead of dereferencing the inner type +warning: call to `.deref()` on a reference in this situation does nothing --> $DIR/noop-method-call.rs:31:63 | LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); - | ^^^^^^^^ + | ^^^^^^^^ help: remove this redundant call + | + = note: the type `PlainType` does not implement `Deref`, so calling `deref` on `&PlainType` copies the reference, which does not do anything and can be removed warning: call to `.borrow()` on a reference in this situation does nothing --> $DIR/noop-method-call.rs:35:66 | LL | let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); - | ^^^^^^^^^ unnecessary method call - | - = note: the type `&PlainType` which `borrow` is being called on is the same as the type returned from `borrow`, so the method call does not do anything and can be removed - -warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type - --> $DIR/noop-method-call.rs:43:44 + | ^^^^^^^^^ help: remove this redundant call | -LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead - | ^^^^^^^^ + = note: the type `PlainType` does not implement `Borrow`, so calling `borrow` on `&PlainType` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:48:19 + --> $DIR/noop-method-call.rs:44:19 | LL | non_clone_type.clone(); - | ^^^^^^^^ unnecessary method call + | ^^^^^^^^ help: remove this redundant call | - = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:53:19 + --> $DIR/noop-method-call.rs:49:19 | LL | non_clone_type.clone(); - | ^^^^^^^^ unnecessary method call + | ^^^^^^^^ help: remove this redundant call | - = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed -warning: 8 warnings emitted +warning: 7 warnings emitted diff --git a/tests/ui/lint/ptr_null_checks.rs b/tests/ui/lint/ptr_null_checks.rs new file mode 100644 index 000000000..e677ea309 --- /dev/null +++ b/tests/ui/lint/ptr_null_checks.rs @@ -0,0 +1,76 @@ +// check-pass + +#![feature(ptr_from_ref)] + +use std::ptr; + +extern "C" fn c_fn() {} +fn static_i32() -> &'static i32 { &1 } + +fn main() { + let fn_ptr = main; + + // ------------- Function pointers --------------- + if (fn_ptr as *mut ()).is_null() {} + //~^ WARN function pointers are not nullable + if (fn_ptr as *const u8).is_null() {} + //~^ WARN function pointers are not nullable + if (fn_ptr as *const ()) == std::ptr::null() {} + //~^ WARN function pointers are not nullable + if (fn_ptr as *mut ()) == std::ptr::null_mut() {} + //~^ WARN function pointers are not nullable + if (fn_ptr as *const ()) == (0 as *const ()) {} + //~^ WARN function pointers are not nullable + if <*const _>::is_null(fn_ptr as *const ()) {} + //~^ WARN function pointers are not nullable + if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {} + //~^ WARN function pointers are not nullable + if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {} + //~^ WARN function pointers are not nullable + if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {} + //~^ WARN function pointers are not nullable + if (fn_ptr as fn() as *const ()).is_null() {} + //~^ WARN function pointers are not nullable + if (c_fn as *const fn()).is_null() {} + //~^ WARN function pointers are not nullable + + // ---------------- References ------------------ + if (&mut 8 as *mut i32).is_null() {} + //~^ WARN references are not nullable + if ptr::from_mut(&mut 8).is_null() {} + //~^ WARN references are not nullable + if (&8 as *const i32).is_null() {} + //~^ WARN references are not nullable + if ptr::from_ref(&8).is_null() {} + //~^ WARN references are not nullable + if ptr::from_ref(&8).cast_mut().is_null() {} + //~^ WARN references are not nullable + if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {} + //~^ WARN references are not nullable + if (&8 as *const i32) == std::ptr::null() {} + //~^ WARN references are not nullable + let ref_num = &8; + if (ref_num as *const i32) == std::ptr::null() {} + //~^ WARN references are not nullable + if (b"\0" as *const u8).is_null() {} + //~^ WARN references are not nullable + if ("aa" as *const str).is_null() {} + //~^ WARN references are not nullable + if (&[1, 2] as *const i32).is_null() {} + //~^ WARN references are not nullable + if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {} + //~^ WARN references are not nullable + if (static_i32() as *const i32).is_null() {} + //~^ WARN references are not nullable + if (&*{ static_i32() } as *const i32).is_null() {} + //~^ WARN references are not nullable + + // ---------------------------------------------- + const ZPTR: *const () = 0 as *const _; + const NOT_ZPTR: *const () = 1 as *const _; + + // unlike the uplifted clippy::fn_null_check lint we do + // not lint on them + if (fn_ptr as *const ()) == ZPTR {} + if (fn_ptr as *const ()) == NOT_ZPTR {} +} diff --git a/tests/ui/lint/ptr_null_checks.stderr b/tests/ui/lint/ptr_null_checks.stderr new file mode 100644 index 000000000..3cee1804b --- /dev/null +++ b/tests/ui/lint/ptr_null_checks.stderr @@ -0,0 +1,225 @@ +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:14:8 + | +LL | if (fn_ptr as *mut ()).is_null() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + = note: `#[warn(useless_ptr_null_checks)]` on by default + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:16:8 + | +LL | if (fn_ptr as *const u8).is_null() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:18:8 + | +LL | if (fn_ptr as *const ()) == std::ptr::null() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:20:8 + | +LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:22:8 + | +LL | if (fn_ptr as *const ()) == (0 as *const ()) {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:24:8 + | +LL | if <*const _>::is_null(fn_ptr as *const ()) {} + | ^^^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:26:8 + | +LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:28:8 + | +LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:30:8 + | +LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {} + | ^^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn() {main}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:32:8 + | +LL | if (fn_ptr as fn() as *const ()).is_null() {} + | ^--------------^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `fn()` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: function pointers are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:34:8 + | +LL | if (c_fn as *const fn()).is_null() {} + | ^----^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `extern "C" fn() {c_fn}` + | + = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:38:8 + | +LL | if (&mut 8 as *mut i32).is_null() {} + | ^------^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&mut i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:40:8 + | +LL | if ptr::from_mut(&mut 8).is_null() {} + | ^^^^^^^^^^^^^^------^^^^^^^^^^^ + | | + | expression has type `&mut i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:42:8 + | +LL | if (&8 as *const i32).is_null() {} + | ^--^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:44:8 + | +LL | if ptr::from_ref(&8).is_null() {} + | ^^^^^^^^^^^^^^--^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:46:8 + | +LL | if ptr::from_ref(&8).cast_mut().is_null() {} + | ^^^^^^^^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:48:8 + | +LL | if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {} + | ^^^^^^^^^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:50:8 + | +LL | if (&8 as *const i32) == std::ptr::null() {} + | ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:53:8 + | +LL | if (ref_num as *const i32) == std::ptr::null() {} + | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:55:8 + | +LL | if (b"\0" as *const u8).is_null() {} + | ^-----^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&[u8; 1]` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:57:8 + | +LL | if ("aa" as *const str).is_null() {} + | ^----^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&str` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:59:8 + | +LL | if (&[1, 2] as *const i32).is_null() {} + | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&[i32; 2]` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:61:8 + | +LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {} + | ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&mut [i32; 2]` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:63:8 + | +LL | if (static_i32() as *const i32).is_null() {} + | ^------------^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: references are not nullable, so checking them for null will always return false + --> $DIR/ptr_null_checks.rs:65:8 + | +LL | if (&*{ static_i32() } as *const i32).is_null() {} + | ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expression has type `&i32` + +warning: 25 warnings emitted + diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs index 996382049..6c38bca3d 100644 --- a/tests/ui/lint/reference_casting.rs +++ b/tests/ui/lint/reference_casting.rs @@ -1,7 +1,6 @@ // check-fail #![feature(ptr_from_ref)] -#![deny(invalid_reference_casting)] extern "C" { // N.B., mutability can be easily incorrect in FFI calls -- as @@ -10,42 +9,97 @@ extern "C" { fn int_ffi(c: *mut i32); } -fn main() { +fn static_u8() -> &'static u8 { + &8 +} + +unsafe fn ref_to_mut() { + let num = &3i32; + + let _num = &mut *(num as *const i32 as *mut i32); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(num as *const i32).cast_mut(); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *std::ptr::from_ref(num).cast_mut(); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *std::ptr::from_ref({ num }).cast_mut(); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *{ std::ptr::from_ref(num) }.cast_mut(); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(num as *const i32).cast::().cast_mut(); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(num as *const i32).cast::().cast_mut().cast_const().cast_mut(); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *std::mem::transmute::<_, *mut i32>(num); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + + let deferred = num as *const i32 as *mut i32; + let _num = &mut *deferred; + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; + let _num = &mut *deferred; + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(num as *const _ as usize as *mut i32); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + + unsafe fn generic_ref_cast_mut(this: &T) -> &mut T { + &mut *((this as *const _) as *mut _) + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + } +} + +unsafe fn assign_to_ref() { let s = String::from("Hello"); let a = &s; - unsafe { - let num = &3i32; - let mut_num = &mut 3i32; + let num = &3i32; - (*(a as *const _ as *mut String)).push_str(" world"); - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - *(a as *const _ as *mut _) = String::from("Replaced"); - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - *(a as *const _ as *mut String) += " world"; - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - let _num = &mut *(num as *const i32 as *mut i32); - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - let _num = &mut *(num as *const i32).cast_mut(); - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - let _num = *{ num as *const i32 }.cast_mut(); - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - *std::ptr::from_ref(num).cast_mut() += 1; - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - *std::ptr::from_ref({ num }).cast_mut() += 1; - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - *{ std::ptr::from_ref(num) }.cast_mut() += 1; - //~^ ERROR casting `&T` to `&mut T` is undefined behavior - *(std::ptr::from_ref({ num }) as *mut i32) += 1; - //~^ ERROR casting `&T` to `&mut T` is undefined behavior + *(a as *const _ as *mut _) = String::from("Replaced"); + //~^ ERROR assigning to `&T` is undefined behavior + *(a as *const _ as *mut String) += " world"; + //~^ ERROR assigning to `&T` is undefined behavior + *std::ptr::from_ref(num).cast_mut() += 1; + //~^ ERROR assigning to `&T` is undefined behavior + *std::ptr::from_ref({ num }).cast_mut() += 1; + //~^ ERROR assigning to `&T` is undefined behavior + *{ std::ptr::from_ref(num) }.cast_mut() += 1; + //~^ ERROR assigning to `&T` is undefined behavior + *(std::ptr::from_ref({ num }) as *mut i32) += 1; + //~^ ERROR assigning to `&T` is undefined behavior + *std::mem::transmute::<_, *mut i32>(num) += 1; + //~^ ERROR assigning to `&T` is undefined behavior + + let value = num as *const i32 as *mut i32; + *value = 1; + //~^ ERROR assigning to `&T` is undefined behavior + *(num as *const i32).cast::().cast_mut() = 2; + //~^ ERROR assigning to `&T` is undefined behavior + *(num as *const _ as usize as *mut i32) = 2; + //~^ ERROR assigning to `&T` is undefined behavior - // Shouldn't be warned against - println!("{}", *(num as *const _ as *const i16)); - println!("{}", *(mut_num as *mut _ as *mut i16)); - ffi(a.as_ptr() as *mut _); - int_ffi(num as *const _ as *mut _); - int_ffi(&3 as *const _ as *mut _); - let mut value = 3; - let value: *const i32 = &mut value; - *(value as *const i16 as *mut i16) = 42; + unsafe fn generic_assign_to_ref(this: &T, a: T) { + *(this as *const _ as *mut _) = a; + //~^ ERROR assigning to `&T` is undefined behavior } } + +unsafe fn no_warn() { + let num = &3i32; + let mut_num = &mut 3i32; + let a = &String::from("ffi"); + + *(num as *const i32 as *mut i32); + println!("{}", *(num as *const _ as *const i16)); + println!("{}", *(mut_num as *mut _ as *mut i16)); + ffi(a.as_ptr() as *mut _); + int_ffi(num as *const _ as *mut _); + int_ffi(&3 as *const _ as *mut _); + let mut value = 3; + let value: *const i32 = &mut value; + *(value as *const i16 as *mut i16) = 42; +} + +fn main() {} diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr index d5b9bbef6..7ff9b76a8 100644 --- a/tests/ui/lint/reference_casting.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -1,68 +1,160 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:20:9 + --> $DIR/reference_casting.rs:19:16 | -LL | (*(a as *const _ as *mut String)).push_str(" world"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(num as *const i32 as *mut i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[deny(invalid_reference_casting)]` on by default + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:21:16 + | +LL | let _num = &mut *(num as *const i32).cast_mut(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:23:16 + | +LL | let _num = &mut *std::ptr::from_ref(num).cast_mut(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:25:16 | -note: the lint level is defined here - --> $DIR/reference_casting.rs:4:9 +LL | let _num = &mut *std::ptr::from_ref({ num }).cast_mut(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:27:16 | -LL | #![deny(invalid_reference_casting)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *{ std::ptr::from_ref(num) }.cast_mut(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:22:9 + --> $DIR/reference_casting.rs:29:16 | -LL | *(a as *const _ as *mut _) = String::from("Replaced"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:24:9 + --> $DIR/reference_casting.rs:31:16 | -LL | *(a as *const _ as *mut String) += " world"; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(num as *const i32).cast::().cast_mut(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:26:25 + --> $DIR/reference_casting.rs:33:16 | -LL | let _num = &mut *(num as *const i32 as *mut i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(num as *const i32).cast::().cast_mut().cast_const().cast_mut(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:28:25 + --> $DIR/reference_casting.rs:35:16 | -LL | let _num = &mut *(num as *const i32).cast_mut(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:30:20 + --> $DIR/reference_casting.rs:37:16 | -LL | let _num = *{ num as *const i32 }.cast_mut(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:32:9 + --> $DIR/reference_casting.rs:41:16 | -LL | *std::ptr::from_ref(num).cast_mut() += 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let deferred = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +LL | let _num = &mut *deferred; + | ^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:34:9 + --> $DIR/reference_casting.rs:44:16 | -LL | *std::ptr::from_ref({ num }).cast_mut() += 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; + | ---------------------------------------------------------------------------- casting happend here +LL | let _num = &mut *deferred; + | ^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:36:9 + --> $DIR/reference_casting.rs:46:16 | -LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(num as *const _ as usize as *mut i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:38:9 + --> $DIR/reference_casting.rs:50:9 + | +LL | &mut *((this as *const _) as *mut _) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:60:5 + | +LL | *(a as *const _ as *mut _) = String::from("Replaced"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:62:5 + | +LL | *(a as *const _ as *mut String) += " world"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:64:5 | -LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | *std::ptr::from_ref(num).cast_mut() += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:66:5 + | +LL | *std::ptr::from_ref({ num }).cast_mut() += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:68:5 + | +LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:70:5 + | +LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:72:5 + | +LL | *std::mem::transmute::<_, *mut i32>(num) += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:76:5 + | +LL | let value = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +LL | *value = 1; + | ^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:78:5 + | +LL | *(num as *const i32).cast::().cast_mut() = 2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:80:5 + | +LL | *(num as *const _ as usize as *mut i32) = 2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:84:9 + | +LL | *(this as *const _ as *mut _) = a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 10 previous errors +error: aborting due to 25 previous errors diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs index e7da825ae..b2d8a28d3 100644 --- a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs +++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs @@ -5,8 +5,8 @@ const s: usize = 42; const s_s: usize = 42; fn main() { - let s = "rust"; //~ ERROR identifier pair considered confusable - let s_s = "rust2"; //~ ERROR identifier pair considered confusable + let s = "rust"; //~ ERROR found both + let s_s = "rust2"; //~ ERROR found both not_affected(); } diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr index e9906c83d..d1920f215 100644 --- a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr +++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr @@ -1,11 +1,11 @@ -error: identifier pair considered confusable between `s` and `s` +error: found both `s` and `s` as identifiers, which look alike --> $DIR/lint-confusable-idents.rs:8:9 | LL | const s: usize = 42; - | -- this is where the previous identifier occurred + | -- other identifier used here ... LL | let s = "rust"; - | ^ + | ^ this identifier can be confused with `s` | note: the lint level is defined here --> $DIR/lint-confusable-idents.rs:1:9 @@ -13,14 +13,14 @@ note: the lint level is defined here LL | #![deny(confusable_idents)] | ^^^^^^^^^^^^^^^^^ -error: identifier pair considered confusable between `s_s` and `s_s` +error: found both `s_s` and `s_s` as identifiers, which look alike --> $DIR/lint-confusable-idents.rs:9:9 | LL | const s_s: usize = 42; - | --- this is where the previous identifier occurred + | --- other identifier used here ... LL | let s_s = "rust2"; - | ^^^^^ + | ^^^^^ this identifier can be confused with `s_s` error: aborting due to 2 previous errors diff --git a/tests/ui/lint/suspicious-double-ref-op.rs b/tests/ui/lint/suspicious-double-ref-op.rs index b9bcd31c2..bc8c23c7b 100644 --- a/tests/ui/lint/suspicious-double-ref-op.rs +++ b/tests/ui/lint/suspicious-double-ref-op.rs @@ -1,6 +1,14 @@ #![feature(lazy_cell)] #![deny(suspicious_double_ref_op, noop_method_call)] +use std::borrow::Borrow; +use std::ops::Deref; + +struct PlainType(T); + +#[derive(Clone)] +struct CloneType(T); + pub fn clone_on_double_ref() { let x = vec![1]; let y = &&x; @@ -20,11 +28,16 @@ fn rust_clippy_issue_9272() { println!("{str}") } -fn check(mut encoded: &[u8]) { - let _ = &mut encoded.clone(); - //~^ ERROR call to `.clone()` on a reference in this situation does nothing - let _ = &encoded.clone(); - //~^ ERROR call to `.clone()` on a reference in this situation does nothing -} +fn main() { + let clone_type_ref = &&CloneType(1u32); + let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); + //~^ ERROR using `.clone()` on a double reference, which returns `&CloneType` + + let non_deref_type = &&PlainType(1u32); + let non_deref_type_deref: &PlainType = non_deref_type.deref(); + //~^ ERROR using `.deref()` on a double reference, which returns `&PlainType` -fn main() {} + let xs = ["a", "b", "c"]; + let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead + //~^ ERROR using `.clone()` on a double reference, which returns `&str` +} diff --git a/tests/ui/lint/suspicious-double-ref-op.stderr b/tests/ui/lint/suspicious-double-ref-op.stderr index d15487ca2..f5a71d40f 100644 --- a/tests/ui/lint/suspicious-double-ref-op.stderr +++ b/tests/ui/lint/suspicious-double-ref-op.stderr @@ -1,5 +1,5 @@ error: using `.clone()` on a double reference, which returns `&Vec` instead of cloning the inner type - --> $DIR/suspicious-double-ref-op.rs:7:23 + --> $DIR/suspicious-double-ref-op.rs:15:23 | LL | let z: &Vec<_> = y.clone(); | ^^^^^^^^ @@ -10,26 +10,23 @@ note: the lint level is defined here LL | #![deny(suspicious_double_ref_op, noop_method_call)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: call to `.clone()` on a reference in this situation does nothing - --> $DIR/suspicious-double-ref-op.rs:24:25 +error: using `.clone()` on a double reference, which returns `&CloneType` instead of cloning the inner type + --> $DIR/suspicious-double-ref-op.rs:33:63 | -LL | let _ = &mut encoded.clone(); - | ^^^^^^^^ unnecessary method call - | - = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed -note: the lint level is defined here - --> $DIR/suspicious-double-ref-op.rs:2:35 - | -LL | #![deny(suspicious_double_ref_op, noop_method_call)] - | ^^^^^^^^^^^^^^^^ +LL | let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); + | ^^^^^^^^ -error: call to `.clone()` on a reference in this situation does nothing - --> $DIR/suspicious-double-ref-op.rs:26:21 +error: using `.deref()` on a double reference, which returns `&PlainType` instead of dereferencing the inner type + --> $DIR/suspicious-double-ref-op.rs:37:63 | -LL | let _ = &encoded.clone(); - | ^^^^^^^^ unnecessary method call +LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); + | ^^^^^^^^ + +error: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type + --> $DIR/suspicious-double-ref-op.rs:41:44 | - = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed +LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead + | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/lint/unaligned_references.stderr b/tests/ui/lint/unaligned_references.stderr index 5f9cecadb..d3abc3766 100644 --- a/tests/ui/lint/unaligned_references.stderr +++ b/tests/ui/lint/unaligned_references.stderr @@ -52,7 +52,7 @@ error[E0793]: reference to packed field is unaligned --> $DIR/unaligned_references.rs:40:17 | LL | let _ = good.data.clone(); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) diff --git a/tests/ui/lint/unknown-lints/allow-in-other-module.rs b/tests/ui/lint/unknown-lints/allow-in-other-module.rs new file mode 100644 index 000000000..20bf0d7af --- /dev/null +++ b/tests/ui/lint/unknown-lints/allow-in-other-module.rs @@ -0,0 +1,26 @@ +// check-pass + +// Tests that the unknown_lints lint doesn't fire for an unknown lint loaded from a separate file. +// The key part is that the stderr output should be empty. +// Reported in https://github.com/rust-lang/rust/issues/84936 +// Fixed incidentally by https://github.com/rust-lang/rust/pull/97266 + +// This `allow` should apply to submodules, whether they are inline or loaded from a file. +#![allow(unknown_lints)] +#![allow(dead_code)] +// no warning +#![allow(not_a_real_lint)] + +mod other; + +// no warning +#[allow(not_a_real_lint)] +fn m() {} + +mod mm { + // no warning + #[allow(not_a_real_lint)] + fn m() {} +} + +fn main() {} diff --git a/tests/ui/lint/unknown-lints/other.rs b/tests/ui/lint/unknown-lints/other.rs new file mode 100644 index 000000000..a5111c00a --- /dev/null +++ b/tests/ui/lint/unknown-lints/other.rs @@ -0,0 +1,10 @@ +// ignore-test + +// Companion to allow-in-other-module.rs + +// This should not warn. +#![allow(not_a_real_lint)] + +// This should not warn, either. +#[allow(not_a_real_lint)] +fn m() {} diff --git a/tests/ui/lint/unused/const-local-var.rs b/tests/ui/lint/unused/const-local-var.rs new file mode 100644 index 000000000..89ca16fe0 --- /dev/null +++ b/tests/ui/lint/unused/const-local-var.rs @@ -0,0 +1,23 @@ +// regression test for https://github.com/rust-lang/rust/issues/69016 +// check-pass + +#![warn(unused)] +#![deny(warnings)] + +fn _unused1(x: i32) -> i32 { + const F: i32 = 2; + let g = 1; + x * F + g +} + +pub struct Foo {} + +impl Foo { + fn _unused2(x: i32) -> i32 { + const F: i32 = 2; + let g = 1; + x * F + g + } +} + +fn main() {} diff --git a/tests/ui/liveness/liveness-move-call-arg-2.rs b/tests/ui/liveness/liveness-move-call-arg-2.rs new file mode 100644 index 000000000..b93535c89 --- /dev/null +++ b/tests/ui/liveness/liveness-move-call-arg-2.rs @@ -0,0 +1,12 @@ +fn take(_x: Box) {} + + +fn main() { + let _ = || { + let x: Box = Box::new(25); + + loop { + take(x); //~ ERROR use of moved value: `x` + } + }; +} diff --git a/tests/ui/liveness/liveness-move-call-arg-2.stderr b/tests/ui/liveness/liveness-move-call-arg-2.stderr new file mode 100644 index 000000000..479a086a8 --- /dev/null +++ b/tests/ui/liveness/liveness-move-call-arg-2.stderr @@ -0,0 +1,26 @@ +error[E0382]: use of moved value: `x` + --> $DIR/liveness-move-call-arg-2.rs:9:18 + | +LL | let x: Box = Box::new(25); + | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait +LL | +LL | loop { + | ---- inside of this loop +LL | take(x); + | ^ value moved here, in previous iteration of loop + | +note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary + --> $DIR/liveness-move-call-arg-2.rs:1:13 + | +LL | fn take(_x: Box) {} + | ---- ^^^^^^^^^^ this parameter takes ownership of the value + | | + | in this function +help: consider cloning the value if the performance cost is acceptable + | +LL | take(x.clone()); + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/lto/issue-100772.rs b/tests/ui/lto/issue-100772.rs index d6b067192..eeb511962 100644 --- a/tests/ui/lto/issue-100772.rs +++ b/tests/ui/lto/issue-100772.rs @@ -1,6 +1,6 @@ -// run-pass +// build-pass // needs-sanitizer-cfi -// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +// compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi // no-prefer-dynamic // only-x86_64-unknown-linux-gnu diff --git a/tests/ui/macros/assert-eq-macro-msg.rs b/tests/ui/macros/assert-eq-macro-msg.rs index accbd2d1e..3d921f400 100644 --- a/tests/ui/macros/assert-eq-macro-msg.rs +++ b/tests/ui/macros/assert-eq-macro-msg.rs @@ -1,7 +1,7 @@ // run-fail -// error-pattern:panicked at 'assertion failed: `(left == right)` -// error-pattern: left: `2` -// error-pattern:right: `3`: 1 + 1 definitely should be 3' +// error-pattern:assertion `left == right` failed: 1 + 1 definitely should be 3 +// error-pattern: left: 2 +// error-pattern: right: 3 // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-eq-macro-panic.rs b/tests/ui/macros/assert-eq-macro-panic.rs index 5e505c30b..6745290cb 100644 --- a/tests/ui/macros/assert-eq-macro-panic.rs +++ b/tests/ui/macros/assert-eq-macro-panic.rs @@ -1,7 +1,7 @@ // run-fail -// error-pattern:assertion failed: `(left == right)` -// error-pattern: left: `14` -// error-pattern:right: `15` +// error-pattern:assertion `left == right` failed +// error-pattern: left: 14 +// error-pattern: right: 15 // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-macro-explicit.rs b/tests/ui/macros/assert-macro-explicit.rs index 578ef5632..3d1a9a6b1 100644 --- a/tests/ui/macros/assert-macro-explicit.rs +++ b/tests/ui/macros/assert-macro-explicit.rs @@ -1,5 +1,5 @@ // run-fail -// error-pattern:panicked at 'assertion failed: false' +// error-pattern:assertion failed: false // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-macro-fmt.rs b/tests/ui/macros/assert-macro-fmt.rs index b8d319d85..ceec53ceb 100644 --- a/tests/ui/macros/assert-macro-fmt.rs +++ b/tests/ui/macros/assert-macro-fmt.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'test-assert-fmt 42 rust' +// error-pattern: panicked +// error-pattern: test-assert-fmt 42 rust // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-macro-owned.rs b/tests/ui/macros/assert-macro-owned.rs index 753675872..fb4b389b8 100644 --- a/tests/ui/macros/assert-macro-owned.rs +++ b/tests/ui/macros/assert-macro-owned.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'test-assert-owned' +// error-pattern:panicked +// error-pattern:test-assert-owned // ignore-emscripten no processes #![allow(non_fmt_panics)] diff --git a/tests/ui/macros/assert-macro-static.rs b/tests/ui/macros/assert-macro-static.rs index dc5274a7e..fccc32592 100644 --- a/tests/ui/macros/assert-macro-static.rs +++ b/tests/ui/macros/assert-macro-static.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'test-assert-static' +// error-pattern:panicked +// error-pattern:test-assert-static // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-matches-macro-msg.rs b/tests/ui/macros/assert-matches-macro-msg.rs index fd8cd5a1a..7af6a0778 100644 --- a/tests/ui/macros/assert-matches-macro-msg.rs +++ b/tests/ui/macros/assert-matches-macro-msg.rs @@ -1,7 +1,7 @@ // run-fail -// error-pattern:panicked at 'assertion failed: `(left matches right)` -// error-pattern: left: `2` -// error-pattern:right: `3`: 1 + 1 definitely should be 3' +// error-pattern:assertion `left matches right` failed: 1 + 1 definitely should be 3 +// error-pattern: left: 2 +// error-pattern: right: 3 // ignore-emscripten no processes #![feature(assert_matches)] diff --git a/tests/ui/macros/assert-ne-macro-msg.rs b/tests/ui/macros/assert-ne-macro-msg.rs index fc0472b99..adda0af88 100644 --- a/tests/ui/macros/assert-ne-macro-msg.rs +++ b/tests/ui/macros/assert-ne-macro-msg.rs @@ -1,7 +1,7 @@ // run-fail -// error-pattern:panicked at 'assertion failed: `(left != right)` -// error-pattern: left: `2` -// error-pattern:right: `2`: 1 + 1 definitely should not be 2' +// error-pattern:assertion `left != right` failed: 1 + 1 definitely should not be 2 +// error-pattern: left: 2 +// error-pattern: right: 2 // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-ne-macro-panic.rs b/tests/ui/macros/assert-ne-macro-panic.rs index 4f507d7b5..d977473a2 100644 --- a/tests/ui/macros/assert-ne-macro-panic.rs +++ b/tests/ui/macros/assert-ne-macro-panic.rs @@ -1,7 +1,7 @@ // run-fail -// error-pattern:assertion failed: `(left != right)` -// error-pattern: left: `14` -// error-pattern:right: `14` +// error-pattern:assertion `left != right` failed +// error-pattern: left: 14 +// error-pattern: right: 14 // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/builtin-env-issue-114010.rs b/tests/ui/macros/builtin-env-issue-114010.rs new file mode 100644 index 000000000..819b8b1e8 --- /dev/null +++ b/tests/ui/macros/builtin-env-issue-114010.rs @@ -0,0 +1,10 @@ +// unset-rustc-env:oopsie +// unset-rustc-env:a""a + +env![r#"oopsie"#]; +//~^ ERROR environment variable `oopsie` not defined at compile time + +env![r#"a""a"#]; +//~^ ERROR environment variable `a""a` not defined at compile time + +fn main() {} diff --git a/tests/ui/macros/builtin-env-issue-114010.stderr b/tests/ui/macros/builtin-env-issue-114010.stderr new file mode 100644 index 000000000..0da42089c --- /dev/null +++ b/tests/ui/macros/builtin-env-issue-114010.stderr @@ -0,0 +1,20 @@ +error: environment variable `oopsie` not defined at compile time + --> $DIR/builtin-env-issue-114010.rs:4:1 + | +LL | env![r#"oopsie"#]; + | ^^^^^^^^^^^^^^^^^ + | + = help: use `std::env::var(r#"oopsie"#)` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: environment variable `a""a` not defined at compile time + --> $DIR/builtin-env-issue-114010.rs:7:1 + | +LL | env![r#"a""a"#]; + | ^^^^^^^^^^^^^^^ + | + = help: use `std::env::var(r#"a""a"#)` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index b726e1862..c1054230b 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -26,10 +26,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `vec` LL | type B = vec::Vec; | ^^^ use of undeclared crate or module `vec` | -help: a struct with a similar name exists - | -LL | type B = Vec::Vec; - | ~~~ help: consider importing this module | LL + use std::vec; diff --git a/tests/ui/macros/format-args-temporaries-in-write.stderr b/tests/ui/macros/format-args-temporaries-in-write.stderr index 520b2ce50..e05246cfb 100644 --- a/tests/ui/macros/format-args-temporaries-in-write.stderr +++ b/tests/ui/macros/format-args-temporaries-in-write.stderr @@ -4,7 +4,7 @@ error[E0597]: `mutex` does not live long enough LL | let mutex = Mutex; | ----- binding `mutex` declared here LL | write!(Out, "{}", mutex.lock()) /* no semicolon */ - | ^^^^^^^^^^^^ + | ^^^^^------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... @@ -21,7 +21,7 @@ error[E0597]: `mutex` does not live long enough LL | let mutex = Mutex; | ----- binding `mutex` declared here LL | writeln!(Out, "{}", mutex.lock()) /* no semicolon */ - | ^^^^^^^^^^^^ + | ^^^^^------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... diff --git a/tests/ui/macros/issue-19163.stderr b/tests/ui/macros/issue-19163.stderr index ae1ae1426..af509aa59 100644 --- a/tests/ui/macros/issue-19163.stderr +++ b/tests/ui/macros/issue-19163.stderr @@ -1,10 +1,8 @@ error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-19163.rs:9:5 + --> $DIR/issue-19163.rs:9:14 | LL | mywrite!(&v, "Hello world"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = note: this error originates in the macro `mywrite` (in Nightly builds, run with -Z macro-backtrace for more info) + | ^^ cannot borrow as mutable error: aborting due to previous error diff --git a/tests/ui/macros/macro-interpolation.rs b/tests/ui/macros/macro-interpolation.rs index 35003a79a..48c1f19e7 100644 --- a/tests/ui/macros/macro-interpolation.rs +++ b/tests/ui/macros/macro-interpolation.rs @@ -1,5 +1,3 @@ -// run-pass - macro_rules! overly_complicated { ($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) => ({ @@ -21,12 +19,14 @@ macro_rules! qpath { (ty, <$type:ty as $trait:ty>::$name:ident) => { <$type as $trait>::$name + //~^ ERROR expected identifier, found `!` }; } pub fn main() { let _: qpath!(path, ::Owned); let _: qpath!(ty, ::Owned); + let _: qpath!(ty, ::Owned); assert!(overly_complicated!(f, x, Option, { return Some(x); }, Some(8), Some(y), y) == 8) diff --git a/tests/ui/macros/macro-interpolation.stderr b/tests/ui/macros/macro-interpolation.stderr new file mode 100644 index 000000000..7ef1fcbbc --- /dev/null +++ b/tests/ui/macros/macro-interpolation.stderr @@ -0,0 +1,16 @@ +error: expected identifier, found `!` + --> $DIR/macro-interpolation.rs:21:19 + | +LL | <$type as $trait>::$name + | ^^^^^^ expected identifier +... +LL | let _: qpath!(ty, ::Owned); + | ----------------------------- + | | + | this macro call doesn't expand to a type + | in this macro invocation + | + = note: this error originates in the macro `qpath` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs new file mode 100644 index 000000000..9cc572c23 --- /dev/null +++ b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs @@ -0,0 +1,14 @@ +#![feature(macro_metavar_expr)] + +macro_rules! foo { + ( $( $($t:ident),* );* ) => { ${count(t,)} } + //~^ ERROR `count` followed by a comma must have an associated + //~| ERROR expected expression, found `$` +} + +fn test() { + foo!(a, a; b, b); +} + +fn main() { +} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr new file mode 100644 index 000000000..e9317a5c3 --- /dev/null +++ b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr @@ -0,0 +1,19 @@ +error: `count` followed by a comma must have an associated index indicating its depth + --> $DIR/issue-111904.rs:4:37 + | +LL | ( $( $($t:ident),* );* ) => { ${count(t,)} } + | ^^^^^ + +error: expected expression, found `$` + --> $DIR/issue-111904.rs:4:35 + | +LL | ( $( $($t:ident),* );* ) => { ${count(t,)} } + | ^ expected expression +... +LL | foo!(a, a; b, b); + | ---------------- in this macro invocation + | + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/match/issue-114691.rs b/tests/ui/match/issue-114691.rs new file mode 100644 index 000000000..cc17d9ecf --- /dev/null +++ b/tests/ui/match/issue-114691.rs @@ -0,0 +1,39 @@ +// run-pass + +// This test used to be miscompiled by LLVM 17. +#![allow(dead_code)] + +enum Pass { + Opaque { + clear_color: [f32; 4], + with_depth_pre_pass: bool, + }, + Transparent, +} + +enum LoadOp { + Clear, + Load, +} + +#[inline(never)] +fn check(x: Option) { + assert!(x.is_none()); +} + +#[inline(never)] +fn test(mode: Pass) { + check(match mode { + Pass::Opaque { + with_depth_pre_pass: true, + .. + } + | Pass::Transparent => None, + _ => Some(LoadOp::Clear), + }); +} + +fn main() { + println!("Hello, world!"); + test(Pass::Transparent); +} diff --git a/tests/ui/match/issue-115681.rs b/tests/ui/match/issue-115681.rs new file mode 100644 index 000000000..c41e808e1 --- /dev/null +++ b/tests/ui/match/issue-115681.rs @@ -0,0 +1,32 @@ +// run-pass +// compile-flags: -C opt-level=1 + +// Make sure LLVM does not miscompile this match. +fn main() { + enum Bits { + None = 0x00, + Low = 0x40, + High = 0x80, + Both = 0xC0, + } + + let value = Box::new(0x40u8); + let mut out = Box::new(0u8); + + let bits = match *value { + 0x00 => Bits::None, + 0x40 => Bits::Low, + 0x80 => Bits::High, + 0xC0 => Bits::Both, + _ => return, + }; + + match bits { + Bits::None | Bits::Low => { + *out = 1; + } + _ => (), + } + + assert_eq!(*out, 1); +} diff --git a/tests/ui/match/issue-74050-end-span.stderr b/tests/ui/match/issue-74050-end-span.stderr index 0b3425f2b..0dafeae87 100644 --- a/tests/ui/match/issue-74050-end-span.stderr +++ b/tests/ui/match/issue-74050-end-span.stderr @@ -6,7 +6,7 @@ LL | let _arg = match args.next() { LL | Some(arg) => { | --- binding `arg` declared here LL | match arg.to_str() { - | ^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } | - `arg` dropped here while still borrowed diff --git a/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs b/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs new file mode 100644 index 000000000..85b1ef755 --- /dev/null +++ b/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs @@ -0,0 +1,21 @@ +#![allow(unused)] + +fn test(shouldwe: Option, shouldwe2: Option) -> u32 { + //~^ NOTE expected `u32` because of return type + match shouldwe { + Some(val) => { + match shouldwe2 { + Some(val) => { + return val; + } + None => (), //~ ERROR mismatched types + //~^ NOTE expected `u32`, found `()` + } + } + None => return 12, + } +} + +fn main() { + println!("returned {}", test(None, Some(5))); +} diff --git a/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.stderr b/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.stderr new file mode 100644 index 000000000..e6d93b8b5 --- /dev/null +++ b/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/non-first-arm-doesnt-match-expected-return-type.rs:11:25 + | +LL | fn test(shouldwe: Option, shouldwe2: Option) -> u32 { + | --- expected `u32` because of return type +... +LL | None => (), + | ^^ expected `u32`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/methods/inherent-bound-in-probe.stderr b/tests/ui/methods/inherent-bound-in-probe.stderr index ff03a7edb..8d7cc4622 100644 --- a/tests/ui/methods/inherent-bound-in-probe.stderr +++ b/tests/ui/methods/inherent-bound-in-probe.stderr @@ -24,8 +24,7 @@ LL | where LL | &'a T: IntoIterator, | ------------- unsatisfied trait bound introduced here = note: 126 redundant requirements hidden - = note: required for `&BitReaderWrapper>>>>` to implement `IntoIterator` - = note: the full type name has been written to '$TEST_BUILD_DIR/methods/inherent-bound-in-probe/inherent-bound-in-probe.long-type-hash.txt' + = note: required for `&BitReaderWrapper>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `IntoIterator` note: required by a bound in `Helper<'a, T>` --> $DIR/inherent-bound-in-probe.rs:25:25 | diff --git a/tests/ui/methods/method-self-arg-2.stderr b/tests/ui/methods/method-self-arg-2.stderr index b98f7a786..946e71ee5 100644 --- a/tests/ui/methods/method-self-arg-2.stderr +++ b/tests/ui/methods/method-self-arg-2.stderr @@ -6,7 +6,7 @@ LL | let y = &mut x; LL | Foo::bar(&x); | ^^ immutable borrow occurs here LL | y.use_mut(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/method-self-arg-2.rs:20:14 @@ -16,7 +16,7 @@ LL | let y = &mut x; LL | Foo::baz(&mut x); | ^^^^^^ second mutable borrow occurs here LL | y.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs new file mode 100644 index 000000000..93b7ddf5e --- /dev/null +++ b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs @@ -0,0 +1,6 @@ +// issue: 114131 + +fn main() { + let hello = len(vec![]); + //~^ ERROR cannot find function `len` in this scope +} diff --git a/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr new file mode 100644 index 000000000..9694f80ab --- /dev/null +++ b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr @@ -0,0 +1,15 @@ +error[E0425]: cannot find function `len` in this scope + --> $DIR/suggest-method-on-call-with-macro-rcvr.rs:4:17 + | +LL | let hello = len(vec![]); + | ^^^ not found in this scope + | +help: use the `.` operator to call the method `len` on `&Vec<_>` + | +LL - let hello = len(vec![]); +LL + let hello = vec![].len(); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/mir/debug-ref-undef.rs b/tests/ui/mir/debug-ref-undef.rs new file mode 100644 index 000000000..37fd22a9d --- /dev/null +++ b/tests/ui/mir/debug-ref-undef.rs @@ -0,0 +1,57 @@ +// run-pass +// compile-flags: -g -O -Zmir-opt-level=0 -Zinline-mir=y -Zmir-enable-passes=+ReferencePropagation + +#![allow(dead_code)] + +use std::marker::PhantomData; + +struct RawTable { + marker: PhantomData, +} + +impl RawTable { + fn iter(&self) -> RawIter { + RawIter { marker: PhantomData } + } +} + +struct RawIter { + marker: PhantomData, +} + +impl Iterator for RawIter { + type Item = (); + fn next(&mut self) -> Option<()> { + None + } +} + +struct HashMap { + table: RawTable, +} + +struct Iter { + inner: RawIter, // Removing this breaks the reproducer +} + +impl IntoIterator for &HashMap { + type Item = T; + type IntoIter = Iter; + fn into_iter(self) -> Iter { + Iter { inner: self.table.iter() } + } +} + +impl Iterator for Iter { + type Item = T; + fn next(&mut self) -> Option { + None + } +} + +pub fn main() { + let maybe_hash_set: Option> = None; + for _ in maybe_hash_set.as_ref().unwrap_or(&HashMap { table: RawTable { marker: PhantomData } }) + { + } +} diff --git a/tests/ui/mir/validate/storage-live.stderr b/tests/ui/mir/validate/storage-live.stderr index 720fb0a90..1037ddc88 100644 --- a/tests/ui/mir/validate/storage-live.stderr +++ b/tests/ui/mir/validate/storage-live.stderr @@ -5,6 +5,7 @@ error: internal compiler error: broken MIR in Item(DefId(0:8 ~ storage_live[HASH LL | StorageLive(a); | ^^^^^^^^^^^^^^ +aborting due to `-Z treat-err-as-bug=1` error: the compiler unexpectedly panicked. this is a bug. query stack during panic: diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr index fb8af4bb7..452cba6b4 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr @@ -10,7 +10,7 @@ LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); found closure signature `fn(i32) -> _` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | let _ = (-10..=10).find(|x: &i32| x.signum() == 0); | + @@ -27,7 +27,7 @@ LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); found closure signature `for<'a, 'b, 'c> fn(&'a &'b &'c i32) -> _` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -help: do not borrow the argument +help: consider adjusting the signature so it does not borrow its argument | LL - let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); LL + let _ = (-10..=10).find(|x: &i32| x.signum() == 0); diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr index 811ff0533..760e3327b 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -10,7 +10,7 @@ LL | a.iter().map(|_: (u32, u32)| 45); found closure signature `fn((u32, u32)) -> _` note: required by a bound in `map` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | a.iter().map(|_: &(u32, u32)| 45); | + diff --git a/tests/ui/mismatched_types/closure-ref-114180.rs b/tests/ui/mismatched_types/closure-ref-114180.rs new file mode 100644 index 000000000..d84bdbeda --- /dev/null +++ b/tests/ui/mismatched_types/closure-ref-114180.rs @@ -0,0 +1,8 @@ +// check-fail + +fn main() { + let mut v = vec![(1,)]; + let compare = |(a,), (e,)| todo!(); + v.sort_by(compare); + //~^ ERROR type mismatch in closure arguments +} diff --git a/tests/ui/mismatched_types/closure-ref-114180.stderr b/tests/ui/mismatched_types/closure-ref-114180.stderr new file mode 100644 index 000000000..8a146d784 --- /dev/null +++ b/tests/ui/mismatched_types/closure-ref-114180.stderr @@ -0,0 +1,22 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/closure-ref-114180.rs:6:15 + | +LL | let compare = |(a,), (e,)| todo!(); + | ------------ found signature defined here +LL | v.sort_by(compare); + | ------- ^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected closure signature `for<'a, 'b> fn(&'a ({integer},), &'b ({integer},)) -> _` + found closure signature `fn((_,), (_,)) -> _` +note: required by a bound in `slice::::sort_by` + --> $SRC_DIR/alloc/src/slice.rs:LL:COL +help: consider adjusting the signature so it borrows its arguments + | +LL | let compare = |&(a,), &(e,)| todo!(); + | + + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/mismatched_types/issue-36053-2.stderr b/tests/ui/mismatched_types/issue-36053-2.stderr index a6764a1dc..4d230ce9a 100644 --- a/tests/ui/mismatched_types/issue-36053-2.stderr +++ b/tests/ui/mismatched_types/issue-36053-2.stderr @@ -10,7 +10,7 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); found closure signature `for<'a> fn(&'a str) -> _` note: required by a bound in `filter` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | once::<&str>("str").fuse().filter(|a: &&str| true).count(); | + diff --git a/tests/ui/mismatched_types/ref-pat-suggestions.stderr b/tests/ui/mismatched_types/ref-pat-suggestions.stderr index 62824004d..148ed00b0 100644 --- a/tests/ui/mismatched_types/ref-pat-suggestions.stderr +++ b/tests/ui/mismatched_types/ref-pat-suggestions.stderr @@ -103,10 +103,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:11:23 | LL | let _: fn(u32) = |&_a| (); - | ^-- - | || - | |expected due to this + | ^^^ + | | | expected `u32`, found `&_` + | expected due to this | = note: expected type `u32` found reference `&_` @@ -120,10 +120,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:12:23 | LL | let _: fn(u32) = |&mut _a| (); - | ^^^^^-- - | | | - | | expected due to this + | ^^^^^^^ + | | | expected `u32`, found `&mut _` + | expected due to this | = note: expected type `u32` found mutable reference `&mut _` @@ -142,10 +142,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:13:25 | LL | let _: fn(&u32) = |&&_a| (); - | ^-- - | || - | |expected due to this - | expected `u32`, found `&_` + | -^^^ + | || + | |expected `u32`, found `&_` + | expected due to this | = note: expected type `u32` found reference `&_` @@ -159,10 +159,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:14:33 | LL | let _: fn(&mut u32) = |&mut &_a| (); - | ^-- - | || - | |expected due to this - | expected `u32`, found `&_` + | -----^^^ + | | | + | | expected `u32`, found `&_` + | expected due to this | = note: expected type `u32` found reference `&_` @@ -176,10 +176,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:15:25 | LL | let _: fn(&u32) = |&&mut _a| (); - | ^^^^^-- - | | | - | | expected due to this - | expected `u32`, found `&mut _` + | -^^^^^^^ + | || + | |expected `u32`, found `&mut _` + | expected due to this | = note: expected type `u32` found mutable reference `&mut _` @@ -193,10 +193,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:16:33 | LL | let _: fn(&mut u32) = |&mut &mut _a| (); - | ^^^^^-- - | | | - | | expected due to this - | expected `u32`, found `&mut _` + | -----^^^^^^^ + | | | + | | expected `u32`, found `&mut _` + | expected due to this | = note: expected type `u32` found mutable reference `&mut _` diff --git a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr index 71c4729e3..5c4c13266 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr +++ b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr @@ -13,7 +13,7 @@ LL | let _has_inference_vars: Option = Some(0).map(deref_int); found function signature `for<'a> fn(&'a i32) -> _` note: required by a bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL -help: do not borrow the argument +help: consider adjusting the signature so it does not borrow its argument | LL - fn deref_int(a: &i32) -> i32 { LL + fn deref_int(a: i32) -> i32 { diff --git a/tests/ui/mismatched_types/suggest-option-asderef.fixed b/tests/ui/mismatched_types/suggest-option-asderef.fixed index 5c42ece3c..fc488b790 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef.fixed +++ b/tests/ui/mismatched_types/suggest-option-asderef.fixed @@ -17,7 +17,7 @@ fn generic(_: T) -> Option<()> { } fn generic_ref(_: T) -> Option<()> { - //~^ HELP do not borrow the argument + //~^ HELP consider adjusting the signature so it does not borrow its argument Some(()) } diff --git a/tests/ui/mismatched_types/suggest-option-asderef.rs b/tests/ui/mismatched_types/suggest-option-asderef.rs index a5278b8fb..28f46808a 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef.rs +++ b/tests/ui/mismatched_types/suggest-option-asderef.rs @@ -17,7 +17,7 @@ fn generic(_: T) -> Option<()> { } fn generic_ref(_: &T) -> Option<()> { - //~^ HELP do not borrow the argument + //~^ HELP consider adjusting the signature so it does not borrow its argument Some(()) } diff --git a/tests/ui/mismatched_types/suggest-option-asderef.stderr b/tests/ui/mismatched_types/suggest-option-asderef.stderr index 01341603d..bfea08673 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef.stderr +++ b/tests/ui/mismatched_types/suggest-option-asderef.stderr @@ -73,7 +73,7 @@ LL | let _ = produces_string().and_then(generic_ref); found function signature `for<'a> fn(&'a _) -> _` note: required by a bound in `Option::::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL -help: do not borrow the argument +help: consider adjusting the signature so it does not borrow its argument | LL - fn generic_ref(_: &T) -> Option<()> { LL + fn generic_ref(_: T) -> Option<()> { diff --git a/tests/ui/missing_debug_impls.rs b/tests/ui/missing_debug_impls.rs index dc4dacfc4..ccad861c0 100644 --- a/tests/ui/missing_debug_impls.rs +++ b/tests/ui/missing_debug_impls.rs @@ -35,4 +35,4 @@ struct PrivateStruct; enum PrivateEnum {} #[derive(Debug)] -struct GenericType(T); +pub struct GenericType(T); diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr index 38a910b57..5705e84e0 100644 --- a/tests/ui/modules/issue-107649.stderr +++ b/tests/ui/modules/issue-107649.stderr @@ -11,7 +11,7 @@ help: consider annotating `Dummy` with `#[derive(Debug)]` --> $DIR/auxiliary/dummy_lib.rs:2:1 | 2 + #[derive(Debug)] -3 | #[path = "auxiliary/dummy_lib.rs"] +3 | pub struct Dummy; | error: aborting due to previous error diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index 91d237b1d..c91a8b5ef 100644 --- a/tests/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -12,7 +12,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves `val.0` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | val.0.clone().into_iter().next(); - | ++++++++ + | ++++++++ error[E0382]: use of moved value: `foo` --> $DIR/move-fn-self-receiver.rs:34:5 @@ -78,7 +78,7 @@ error[E0505]: cannot move out of `mut_foo` because it is borrowed LL | let mut mut_foo = Foo; | ----------- binding `mut_foo` declared here LL | let ret = mut_foo.use_mut_self(); - | ---------------------- borrow of `mut_foo` occurs here + | ------- borrow of `mut_foo` occurs here LL | mut_foo; | ^^^^^^^ move out of `mut_foo` occurs here LL | ret; @@ -102,7 +102,7 @@ LL | fn use_rc_self(self: Rc) {} help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | rc_foo.clone().use_rc_self(); - | ++++++++ + | ++++++++ error[E0382]: use of moved value: `foo_add` --> $DIR/move-fn-self-receiver.rs:59:5 @@ -145,7 +145,7 @@ LL | explicit_into_iter; help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | for _val in explicit_into_iter.clone().into_iter() {} - | ++++++++ + | ++++++++ error[E0382]: use of moved value: `container` --> $DIR/move-fn-self-receiver.rs:71:5 diff --git a/tests/ui/moves/moves-based-on-type-access-to-field.stderr b/tests/ui/moves/moves-based-on-type-access-to-field.stderr index a28f324aa..739018663 100644 --- a/tests/ui/moves/moves-based-on-type-access-to-field.stderr +++ b/tests/ui/moves/moves-based-on-type-access-to-field.stderr @@ -13,7 +13,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves `x` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | consume(x.clone().into_iter().next().unwrap()); - | ++++++++ + | ++++++++ error: aborting due to previous error diff --git a/tests/ui/moves/moves-based-on-type-exprs.stderr b/tests/ui/moves/moves-based-on-type-exprs.stderr index ab7c27456..45f7d4063 100644 --- a/tests/ui/moves/moves-based-on-type-exprs.stderr +++ b/tests/ui/moves/moves-based-on-type-exprs.stderr @@ -165,7 +165,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves `x` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | let _y = x.clone().into_iter().next().unwrap(); - | ++++++++ + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:83:11 @@ -182,7 +182,7 @@ note: `into_iter` takes ownership of the receiver `self`, which moves `x` help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | let _y = [x.clone().into_iter().next().unwrap(); 1]; - | ++++++++ + | ++++++++ error: aborting due to 11 previous errors diff --git a/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr index 7e513b73c..a184482a4 100644 --- a/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr +++ b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr @@ -13,7 +13,7 @@ note: `Pin::<&'a mut T>::get_mut` takes ownership of the receiver `self`, which help: consider reborrowing the `Pin` instead of moving it | LL | foo(r.as_mut().get_mut()); - | +++++++++ + | +++++++++ error: aborting due to previous error diff --git a/tests/ui/moves/pin-mut-reborrow.stderr b/tests/ui/moves/pin-mut-reborrow.stderr index 16fa4bacc..4bf207e7e 100644 --- a/tests/ui/moves/pin-mut-reborrow.stderr +++ b/tests/ui/moves/pin-mut-reborrow.stderr @@ -16,7 +16,7 @@ LL | fn foo(self: Pin<&mut Self>) {} help: consider reborrowing the `Pin` instead of moving it | LL | foo.as_mut().foo(); - | +++++++++ + | +++++++++ error: aborting due to previous error diff --git a/tests/ui/moves/suggest-clone.stderr b/tests/ui/moves/suggest-clone.stderr index cbb3dfea3..065acf904 100644 --- a/tests/ui/moves/suggest-clone.stderr +++ b/tests/ui/moves/suggest-clone.stderr @@ -2,9 +2,8 @@ error[E0507]: cannot move out of `*foo` which is behind a shared reference --> $DIR/suggest-clone.rs:10:5 | LL | foo.foo(); - | ^^^^----- - | | | - | | `*foo` moved due to this method call + | ^^^ ----- `*foo` moved due to this method call + | | | move occurs because `*foo` has type `Foo`, which does not implement the `Copy` trait | note: `Foo::foo` takes ownership of the receiver `self`, which moves `*foo` @@ -15,7 +14,7 @@ LL | fn foo(self) {} help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | foo.clone().foo(); - | ++++++++ + | ++++++++ error: aborting due to previous error diff --git a/tests/ui/moves/use_of_moved_value_clone_suggestions.stderr b/tests/ui/moves/use_of_moved_value_clone_suggestions.stderr index 22e7951db..0bb486a88 100644 --- a/tests/ui/moves/use_of_moved_value_clone_suggestions.stderr +++ b/tests/ui/moves/use_of_moved_value_clone_suggestions.stderr @@ -8,7 +8,7 @@ LL | (t, t) | | | value moved here | -help: consider cloning the value if the performance cost is acceptable +help: clone the value to increment its reference count | LL | (t.clone(), t) | ++++++++ diff --git a/tests/ui/mut/mut-cant-alias.stderr b/tests/ui/mut/mut-cant-alias.stderr index 6046c076f..d56e45db1 100644 --- a/tests/ui/mut/mut-cant-alias.stderr +++ b/tests/ui/mut/mut-cant-alias.stderr @@ -6,7 +6,7 @@ LL | let b1 = &mut *b; LL | let b2 = &mut *b; | ^ second mutable borrow occurs here LL | b1.use_mut(); - | ------------ first borrow later used here + | -- first borrow later used here error: aborting due to previous error diff --git a/tests/ui/mut/mut-suggestion.stderr b/tests/ui/mut/mut-suggestion.stderr index d89c8b413..1521ae4c5 100644 --- a/tests/ui/mut/mut-suggestion.stderr +++ b/tests/ui/mut/mut-suggestion.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/mut-suggestion.rs:12:5 | LL | arg.mutate(); - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable --> $DIR/mut-suggestion.rs:20:5 | LL | local.mutate(); - | ^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/nll/closure-access-spans.stderr b/tests/ui/nll/closure-access-spans.stderr index 035dd5a56..3e98fbd5e 100644 --- a/tests/ui/nll/closure-access-spans.stderr +++ b/tests/ui/nll/closure-access-spans.stderr @@ -8,7 +8,7 @@ LL | || x; | | | immutable borrow occurs here LL | r.use_mut(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closure-access-spans.rs:11:5 @@ -20,7 +20,7 @@ LL | || x = 2; | | | second mutable borrow occurs here LL | r.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/closure-access-spans.rs:17:5 @@ -32,7 +32,7 @@ LL | || *x = 2; | | | closure construction occurs here LL | r.use_mut(); - | ----------- first borrow later used here + | - first borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/closure-access-spans.rs:23:13 @@ -42,7 +42,7 @@ LL | let r = &mut x; LL | move || x; | ^ use of borrowed `x` LL | r.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/closure-access-spans.rs:29:5 @@ -56,7 +56,7 @@ LL | || x; | | | move out of `x` occurs here LL | r.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0382]: borrow of moved value: `x` --> $DIR/closure-access-spans.rs:35:5 diff --git a/tests/ui/nll/closure-borrow-spans.stderr b/tests/ui/nll/closure-borrow-spans.stderr index cf0df5834..cac22c2ec 100644 --- a/tests/ui/nll/closure-borrow-spans.stderr +++ b/tests/ui/nll/closure-borrow-spans.stderr @@ -8,7 +8,7 @@ LL | let f = || x.len(); LL | let y = x; | ^ move out of `x` occurs here LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/closure-borrow-spans.rs:11:13 @@ -20,7 +20,7 @@ LL | let f = || x; LL | let y = &mut x; | ^^^^^^ mutable borrow occurs here LL | f.use_ref(); - | ----------- immutable borrow later used here + | - immutable borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:19:16 @@ -32,7 +32,7 @@ LL | f = || x; LL | } | - `x` dropped here while still borrowed LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/closure-borrow-spans.rs:26:5 @@ -44,7 +44,7 @@ LL | let f = || x; LL | x = 1; | ^^^^^ `x` is assigned to here but it was already borrowed LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/closure-borrow-spans.rs:32:13 @@ -56,7 +56,7 @@ LL | let f = || x = 0; LL | let y = x; | ^ use of borrowed `x` LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/closure-borrow-spans.rs:38:13 @@ -68,7 +68,7 @@ LL | let f = || x = 0; LL | let y = &x; | ^^ immutable borrow occurs here LL | f.use_ref(); - | ----------- mutable borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closure-borrow-spans.rs:44:13 @@ -80,7 +80,7 @@ LL | let f = || x = 0; LL | let y = &mut x; | ^^^^^^ second mutable borrow occurs here LL | f.use_ref(); - | ----------- first borrow later used here + | - first borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:52:16 @@ -92,7 +92,7 @@ LL | f = || x = 0; LL | } | - `x` dropped here while still borrowed LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/closure-borrow-spans.rs:59:5 @@ -104,7 +104,7 @@ LL | let f = || x = 0; LL | x = 1; | ^^^^^ `x` is assigned to here but it was already borrowed LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/closure-borrow-spans.rs:65:13 @@ -116,7 +116,7 @@ LL | let f = || *x = 0; LL | let y = x; | ^ move out of `x` occurs here LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access --> $DIR/closure-borrow-spans.rs:71:13 @@ -128,7 +128,7 @@ LL | let f = || *x = 0; LL | let y = &x; | ^^ second borrow occurs here LL | f.use_ref(); - | ----------- first borrow later used here + | - first borrow later used here error[E0501]: cannot borrow `x` as mutable because previous closure requires unique access --> $DIR/closure-borrow-spans.rs:77:13 @@ -140,7 +140,7 @@ LL | let f = || *x = 0; LL | let y = &mut x; | ^^^^^^ second borrow occurs here LL | f.use_ref(); - | ----------- first borrow later used here + | - first borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:86:16 @@ -152,7 +152,7 @@ LL | f = || *x = 0; LL | } | - `x` dropped here while still borrowed LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/closure-borrow-spans.rs:93:5 @@ -164,7 +164,7 @@ LL | let f = || *x = 0; LL | *x = 1; | ^^^^^^ `*x` is assigned to here but it was already borrowed LL | f.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to 14 previous errors diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr index 61233fd84..1e3a5328d 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | let mut closure = expect_sig(|p, y| *p = y); | ^^^^^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) i32)), (), diff --git a/tests/ui/nll/closure-requirements/escape-argument.stderr b/tests/ui/nll/closure-requirements/escape-argument.stderr index 61e2a1ea6..bc4ba93f8 100644 --- a/tests/ui/nll/closure-requirements/escape-argument.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | let mut closure = expect_sig(|p, y| *p = y); | ^^^^^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32)), (), diff --git a/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr b/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr index c00a31ef8..727df1cf8 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -4,7 +4,7 @@ note: external requirements LL | let mut closure1 = || p = &y; | ^^ | - = note: defining type: test::{closure#0}::{closure#0} with closure substs [ + = note: defining type: test::{closure#0}::{closure#0} with closure args [ i16, extern "rust-call" fn(()), (&'?1 mut &'?2 i32, &'?3 i32), @@ -18,7 +18,7 @@ note: external requirements LL | let mut closure = || { | ^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::{closure#0} with closure args [ i16, extern "rust-call" fn(()), (&'?1 mut &'?2 i32, &'?3 i32), diff --git a/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr b/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr index 2d67e6e7d..ff638f2a1 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -4,7 +4,7 @@ note: external requirements LL | let mut closure = || p = &y; | ^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::{closure#0} with closure args [ i16, extern "rust-call" fn(()), (&'?1 mut &'?2 i32, &'?3 i32), diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index ba42576d4..f8383cc42 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | |_outlives1, _outlives2, _outlives3, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?3 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr index 9dd6e0208..113173d8f 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -4,7 +4,7 @@ note: external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index e2f5576d3..ba15199ab 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | foo(cell, |cell_a, cell_x| { | ^^^^^^^^^^^^^^^^ | - = note: defining type: case1::{closure#0} with closure substs [ + = note: defining type: case1::{closure#0} with closure args [ i32, for extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), (), @@ -34,7 +34,7 @@ note: external requirements LL | foo(cell, |cell_a, cell_x| { | ^^^^^^^^^^^^^^^^ | - = note: defining type: case2::{closure#0} with closure substs [ + = note: defining type: case2::{closure#0} with closure args [ i32, for extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index 383fb471a..f2bf83c6c 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -4,7 +4,7 @@ note: external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | ^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index ac346c0b1..2734326ed 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -4,7 +4,7 @@ note: external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr index b217ae197..5ab321eb6 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -4,7 +4,7 @@ note: external requirements LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::{closure#0} with closure args [ i16, for extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index f31478b6d..595fd5ff5 100644 --- a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -4,7 +4,7 @@ note: external requirements LL | |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 1509ade87..62b0e3eed 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | ^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index c85a9872e..6f2044d62 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), diff --git a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 05e274ab2..1aa7de1e1 100644 --- a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -4,7 +4,7 @@ note: external requirements LL | establish_relationships(value, |value| { | ^^^^^^^ | - = note: defining type: supply::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: supply::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((T,)), (), diff --git a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 4e34ba516..7635f2ede 100644 --- a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | expect_sig(|a, b| b); // ought to return `a` | ^^^^^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::{closure#0} with closure args [ i16, for extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) i32, (), diff --git a/tests/ui/nll/closures-in-loops.stderr b/tests/ui/nll/closures-in-loops.stderr index 1c1a31d35..2c1008c51 100644 --- a/tests/ui/nll/closures-in-loops.stderr +++ b/tests/ui/nll/closures-in-loops.stderr @@ -13,9 +13,8 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closures-in-loops.rs:13:16 | LL | v.push(|| x = String::new()); - | -------^^------------------- - | | | | - | | | borrows occur due to use of `x` in closure + | - ^^ - borrows occur due to use of `x` in closure + | | | | | `x` was mutably borrowed here in the previous iteration of the loop | first borrow used here, in later iteration of loop @@ -23,9 +22,8 @@ error[E0524]: two closures require unique access to `x` at the same time --> $DIR/closures-in-loops.rs:20:16 | LL | v.push(|| *x = String::new()); - | -------^^-------------------- - | | | | - | | | borrows occur due to use of `x` in closure + | - ^^ -- borrows occur due to use of `x` in closure + | | | | | closures are constructed here in different iterations of loop | first borrow used here, in later iteration of loop diff --git a/tests/ui/nll/get_default.stderr b/tests/ui/nll/get_default.stderr index 6998c0433..af79771e7 100644 --- a/tests/ui/nll/get_default.stderr +++ b/tests/ui/nll/get_default.stderr @@ -5,7 +5,7 @@ LL | fn ok(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` LL | loop { LL | match map.get() { - | --------- immutable borrow occurs here + | --- immutable borrow occurs here LL | Some(v) => { LL | return v; | - returning this value requires that `*map` is borrowed for `'1` @@ -20,7 +20,7 @@ LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` LL | loop { LL | match map.get() { - | --------- immutable borrow occurs here + | --- immutable borrow occurs here LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here @@ -35,7 +35,7 @@ LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` LL | loop { LL | match map.get() { - | --------- immutable borrow occurs here + | --- immutable borrow occurs here ... LL | return v; | - returning this value requires that `*map` is borrowed for `'1` diff --git a/tests/ui/nll/guarantor-issue-46974.rs b/tests/ui/nll/guarantor-issue-46974.rs index 96af4bf5c..93fdf7b46 100644 --- a/tests/ui/nll/guarantor-issue-46974.rs +++ b/tests/ui/nll/guarantor-issue-46974.rs @@ -9,7 +9,6 @@ fn foo(s: &mut (i32,)) -> i32 { } fn bar(s: &Box<(i32,)>) -> &'static i32 { - // FIXME(#46983): error message should be better &s.0 //~ ERROR lifetime may not live long enough } diff --git a/tests/ui/nll/guarantor-issue-46974.stderr b/tests/ui/nll/guarantor-issue-46974.stderr index 7edc3dcc5..f09faf163 100644 --- a/tests/ui/nll/guarantor-issue-46974.stderr +++ b/tests/ui/nll/guarantor-issue-46974.stderr @@ -10,11 +10,10 @@ LL | *x | -- borrow later used here error: lifetime may not live long enough - --> $DIR/guarantor-issue-46974.rs:13:5 + --> $DIR/guarantor-issue-46974.rs:12:5 | LL | fn bar(s: &Box<(i32,)>) -> &'static i32 { | - let's call the lifetime of this reference `'1` -LL | // FIXME(#46983): error message should be better LL | &s.0 | ^^^^ returning this value requires that `'1` must outlive `'static` diff --git a/tests/ui/nll/issue-46589.stderr b/tests/ui/nll/issue-46589.stderr index 60ef3f7b8..82cd364ee 100644 --- a/tests/ui/nll/issue-46589.stderr +++ b/tests/ui/nll/issue-46589.stderr @@ -2,10 +2,10 @@ error[E0499]: cannot borrow `**other` as mutable more than once at a time --> $DIR/issue-46589.rs:23:21 | LL | *other = match (*other).get_self() { - | ------------------- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | Some(s) => s, LL | None => (*other).new_self() - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | | | second mutable borrow occurs here | first borrow later used here diff --git a/tests/ui/nll/issue-51191.stderr b/tests/ui/nll/issue-51191.stderr index 27b1f8705..c14056c3a 100644 --- a/tests/ui/nll/issue-51191.stderr +++ b/tests/ui/nll/issue-51191.stderr @@ -48,7 +48,7 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-51191.rs:22:9 | LL | (&mut self).bar(); - | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable --> $DIR/issue-51191.rs:28:9 diff --git a/tests/ui/nll/issue-51345-2.rs b/tests/ui/nll/issue-51345-2.rs index 52f342a85..77a944a7b 100644 --- a/tests/ui/nll/issue-51345-2.rs +++ b/tests/ui/nll/issue-51345-2.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern: thread 'main' panicked at 'explicit panic' +// error-pattern:thread 'main' panicked +// error-pattern:explicit panic // ignore-emscripten no processes fn main() { diff --git a/tests/ui/nll/issue-52669.stderr b/tests/ui/nll/issue-52669.stderr index 807b95f7e..db53e444b 100644 --- a/tests/ui/nll/issue-52669.stderr +++ b/tests/ui/nll/issue-52669.stderr @@ -7,7 +7,7 @@ LL | a.b = B; LL | foo(a); | - value moved here LL | a.b.clone() - | ^^^^^^^^^^^ value borrowed here after move + | ^^^ value borrowed here after move error: aborting due to previous error diff --git a/tests/ui/nll/issue-53773.stderr b/tests/ui/nll/issue-53773.stderr index 90cba2a14..fc185d42d 100644 --- a/tests/ui/nll/issue-53773.stderr +++ b/tests/ui/nll/issue-53773.stderr @@ -2,7 +2,9 @@ error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-53773.rs:41:22 | LL | members.push(child.raw); - | -------------^^^^^^^^^- borrow later used here + | ------- ^^^^^^^^^ + | | + | borrow later used here LL | LL | } | - here, drop of `child` needs exclusive access to `*child.raw`, because the type `C<'_>` implements the `Drop` trait diff --git a/tests/ui/nll/issue-54556-niconii.stderr b/tests/ui/nll/issue-54556-niconii.stderr index d41d462f2..ad0a2d1e3 100644 --- a/tests/ui/nll/issue-54556-niconii.stderr +++ b/tests/ui/nll/issue-54556-niconii.stderr @@ -5,7 +5,7 @@ LL | let counter = Mutex; | ------- binding `counter` declared here LL | LL | if let Ok(_) = counter.lock() { } - | ^^^^^^^^^^^^^^ + | ^^^^^^^------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... diff --git a/tests/ui/nll/issue-62007-assign-const-index.stderr b/tests/ui/nll/issue-62007-assign-const-index.stderr index 12e28aa3f..0db9fe62c 100644 --- a/tests/ui/nll/issue-62007-assign-const-index.stderr +++ b/tests/ui/nll/issue-62007-assign-const-index.stderr @@ -17,7 +17,7 @@ LL | fn to_refs(mut list: [&mut List; 2]) -> Vec<&mut T> { | - let's call the lifetime of this reference `'1` ... LL | if let Some(n) = list[0].next.as_mut() { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | `list[_].next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list[_].next` is borrowed for `'1` diff --git a/tests/ui/nll/issue-62007-assign-differing-fields.stderr b/tests/ui/nll/issue-62007-assign-differing-fields.stderr index 4488431fc..f1af2e855 100644 --- a/tests/ui/nll/issue-62007-assign-differing-fields.stderr +++ b/tests/ui/nll/issue-62007-assign-differing-fields.stderr @@ -17,7 +17,7 @@ LL | fn to_refs<'a, T>(mut list: (&'a mut List, &'a mut List)) -> Vec<&'a | -- lifetime `'a` defined here ... LL | if let Some(n) = (list.0).next.as_mut() { - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^--------- | | | `list.0.next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list.0.next` is borrowed for `'a` diff --git a/tests/ui/nll/loan_ends_mid_block_vec.stderr b/tests/ui/nll/loan_ends_mid_block_vec.stderr index 22c72af61..c0b97bea3 100644 --- a/tests/ui/nll/loan_ends_mid_block_vec.stderr +++ b/tests/ui/nll/loan_ends_mid_block_vec.stderr @@ -5,7 +5,7 @@ LL | let slice = &mut data; | --------- first mutable borrow occurs here LL | capitalize(slice); LL | data.push('d'); - | ^^^^^^^^^^^^^^ second mutable borrow occurs here + | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); | ----- first borrow later used here @@ -17,7 +17,7 @@ LL | let slice = &mut data; | --------- first mutable borrow occurs here ... LL | data.push('e'); - | ^^^^^^^^^^^^^^ second mutable borrow occurs here + | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); | ----- first borrow later used here @@ -29,7 +29,7 @@ LL | let slice = &mut data; | --------- first mutable borrow occurs here ... LL | data.push('f'); - | ^^^^^^^^^^^^^^ second mutable borrow occurs here + | ^^^^ second mutable borrow occurs here LL | LL | capitalize(slice); | ----- first borrow later used here diff --git a/tests/ui/nll/polonius/assignment-to-differing-field.stderr b/tests/ui/nll/polonius/assignment-to-differing-field.stderr index afa1b9344..acac47eac 100644 --- a/tests/ui/nll/polonius/assignment-to-differing-field.stderr +++ b/tests/ui/nll/polonius/assignment-to-differing-field.stderr @@ -17,7 +17,7 @@ LL | fn assignment_to_field_projection<'a, T>( | -- lifetime `'a` defined here ... LL | if let Some(n) = (list.0).next.as_mut() { - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^--------- | | | `list.0.next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list.0.next` is borrowed for `'a` @@ -41,7 +41,7 @@ LL | fn assignment_through_projection_chain<'a, T>( | -- lifetime `'a` defined here ... LL | if let Some(n) = ((((list.0).0).0).0).0.next.as_mut() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^--------- | | | `list.0.0.0.0.0.next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list.0.0.0.0.0.next` is borrowed for `'a` diff --git a/tests/ui/nll/return_from_loop.stderr b/tests/ui/nll/return_from_loop.stderr index bd2b8b158..efd56ea2d 100644 --- a/tests/ui/nll/return_from_loop.stderr +++ b/tests/ui/nll/return_from_loop.stderr @@ -5,10 +5,10 @@ LL | let value = &mut my_struct.field; | -------------------- first mutable borrow occurs here LL | loop { LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^^^ second mutable borrow occurs here LL | LL | value.len(); - | ----------- first borrow later used here + | ----- first borrow later used here error: aborting due to previous error diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 4eefb180e..433024c30 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -4,7 +4,7 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: no_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: no_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '?2)>, (), @@ -37,7 +37,7 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: correct_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: correct_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '?2)>, (), @@ -61,7 +61,7 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: wrong_region::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: wrong_region::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '?3)>, (), @@ -94,7 +94,7 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '?3)>, (), diff --git a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr index 986c2bd21..ebdce7bc1 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -4,7 +4,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), @@ -54,7 +54,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -104,7 +104,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -129,7 +129,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 25cc60d81..52040663e 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -4,7 +4,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), @@ -42,7 +42,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -80,7 +80,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -105,7 +105,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -130,7 +130,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: one_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: one_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index 5a092d7b8..97be61b77 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -4,7 +4,7 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), @@ -27,7 +27,7 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -50,7 +50,7 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -73,7 +73,7 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -96,7 +96,7 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: one_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: one_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), diff --git a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 51283aa88..dbad8e478 100644 --- a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -4,7 +4,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -38,7 +38,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), @@ -72,7 +72,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), @@ -97,7 +97,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive1::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive1::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), @@ -122,7 +122,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive2::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive2::<'?1, '?2, '?3, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), @@ -147,7 +147,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: two_regions::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: two_regions::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), @@ -188,7 +188,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: two_regions_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: two_regions_outlive::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), @@ -213,7 +213,7 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: one_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: one_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 04616f9b7..660211fe2 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -4,7 +4,7 @@ note: external requirements LL | twice(cell, value, |a, b| invoke(a, b)); | ^^^^^^ | - = note: defining type: generic::::{closure#0} with closure substs [ + = note: defining type: generic::::{closure#0} with closure args [ i16, for extern "rust-call" fn((std::option::Option>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), (), @@ -26,7 +26,7 @@ note: external requirements LL | twice(cell, value, |a, b| invoke(a, b)); | ^^^^^^ | - = note: defining type: generic_fail::::{closure#0} with closure substs [ + = note: defining type: generic_fail::::{closure#0} with closure args [ i16, for extern "rust-call" fn((std::option::Option>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), (), diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index d580774ff..ddad1d205 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -4,7 +4,7 @@ note: external requirements LL | with_signature(x, |y| y) | ^^^ | - = note: defining type: no_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: no_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn std::fmt::Debug + '?2)>, (), diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 3d4c11a3c..bb455e9ae 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -4,7 +4,7 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: no_region::::{closure#0} with closure substs [ + = note: defining type: no_region::::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?1 ()>, T)), (), @@ -38,7 +38,7 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: correct_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: correct_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), @@ -62,7 +62,7 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: wrong_region::<'?1, T>::{closure#0} with closure substs [ + = note: defining type: wrong_region::<'?1, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), @@ -98,7 +98,7 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure substs [ + = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure args [ i32, extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), diff --git a/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs b/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs index ccda9129d..1d0b0d55a 100644 --- a/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs +++ b/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs @@ -8,7 +8,7 @@ struct SomeStruct { t: T } -#[rustc_dump_user_substs] +#[rustc_dump_user_args] fn main() { SomeStruct { t: 22 }; // Nothing given, no annotation. diff --git a/tests/ui/nll/user-annotations/dump-adt-brace-struct.stderr b/tests/ui/nll/user-annotations/dump-adt-brace-struct.stderr index 586062190..7809b2470 100644 --- a/tests/ui/nll/user-annotations/dump-adt-brace-struct.stderr +++ b/tests/ui/nll/user-annotations/dump-adt-brace-struct.stderr @@ -1,4 +1,4 @@ -error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None } +error: user args: UserArgs { args: [&ReStatic u32], user_self_ty: None } --> $DIR/dump-adt-brace-struct.rs:19:5 | LL | SomeStruct::<&'static u32> { t: &22 }; diff --git a/tests/ui/nll/user-annotations/dump-fn-method.rs b/tests/ui/nll/user-annotations/dump-fn-method.rs index 148d63d84..9bdbbc37c 100644 --- a/tests/ui/nll/user-annotations/dump-fn-method.rs +++ b/tests/ui/nll/user-annotations/dump-fn-method.rs @@ -15,7 +15,7 @@ impl Bazoom for S { fn foo<'a, T>(_: T) { } -#[rustc_dump_user_substs] +#[rustc_dump_user_args] fn main() { // Here: nothing is given, so we don't have any annotation. let x = foo; diff --git a/tests/ui/nll/user-annotations/dump-fn-method.stderr b/tests/ui/nll/user-annotations/dump-fn-method.stderr index d139efa88..1daf49825 100644 --- a/tests/ui/nll/user-annotations/dump-fn-method.stderr +++ b/tests/ui/nll/user-annotations/dump-fn-method.stderr @@ -1,22 +1,22 @@ -error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None } +error: user args: UserArgs { args: [&ReStatic u32], user_self_ty: None } --> $DIR/dump-fn-method.rs:29:13 | LL | let x = foo::<&'static u32>; | ^^^^^^^^^^^^^^^^^^^ -error: user substs: UserSubsts { substs: [^0, u32, ^1], user_self_ty: None } +error: user args: UserArgs { args: [^0, u32, ^1], user_self_ty: None } --> $DIR/dump-fn-method.rs:35:13 | LL | let x = <_ as Bazoom>::method::<_>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: UserSubsts { substs: [u8, &ReStatic u16, u32], user_self_ty: None } +error: user args: UserArgs { args: [u8, &ReStatic u16, u32], user_self_ty: None } --> $DIR/dump-fn-method.rs:44:13 | LL | let x = >::method::; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: UserSubsts { substs: [^0, ^1, u32], user_self_ty: None } +error: user args: UserArgs { args: [^0, ^1, u32], user_self_ty: None } --> $DIR/dump-fn-method.rs:52:5 | LL | y.method::(44, 66); diff --git a/tests/ui/numbers-arithmetic/apfloat-modulo-wrong.rs b/tests/ui/numbers-arithmetic/apfloat-modulo-wrong.rs new file mode 100644 index 000000000..64ff1f8b1 --- /dev/null +++ b/tests/ui/numbers-arithmetic/apfloat-modulo-wrong.rs @@ -0,0 +1,15 @@ +// run-pass +// check-run-results +// regression test for issue #109567 + +fn f() -> f64 { + std::hint::black_box(-1.0) % std::hint::black_box(-1.0) +} + +const G: f64 = -1.0 % -1.0; + +pub fn main() { + assert_eq!(-1, G.signum() as i32); + assert_eq!((-0.0_f64).to_bits(), G.to_bits()); + assert_eq!(f().signum(), G.signum()); +} diff --git a/tests/ui/numbers-arithmetic/overflowing-add.rs b/tests/ui/numbers-arithmetic/overflowing-add.rs index b0f22a74b..c45b44966 100644 --- a/tests/ui/numbers-arithmetic/overflowing-add.rs +++ b/tests/ui/numbers-arithmetic/overflowing-add.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to add with overflow' +// error-pattern:thread 'main' panicked +// error-pattern:attempt to add with overflow // compile-flags: -C debug-assertions // ignore-emscripten no processes diff --git a/tests/ui/numbers-arithmetic/overflowing-mul.rs b/tests/ui/numbers-arithmetic/overflowing-mul.rs index 34ab5d8fa..ec5279d32 100644 --- a/tests/ui/numbers-arithmetic/overflowing-mul.rs +++ b/tests/ui/numbers-arithmetic/overflowing-mul.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' +// error-pattern:thread 'main' panicked +// error-pattern:attempt to multiply with overflow // ignore-emscripten no processes // compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs index 565b7e86f..dabb0d50c 100644 --- a/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs +++ b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs @@ -1,5 +1,5 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to negate with overflow' +// error-pattern:attempt to negate with overflow // ignore-emscripten no processes // compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-neg.rs b/tests/ui/numbers-arithmetic/overflowing-neg.rs index df1198053..530243753 100644 --- a/tests/ui/numbers-arithmetic/overflowing-neg.rs +++ b/tests/ui/numbers-arithmetic/overflowing-neg.rs @@ -1,5 +1,5 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to negate with overflow' +// error-pattern:attempt to negate with overflow // ignore-emscripten no processes // compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs b/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs index b59efe6f2..c2c8cad5f 100644 --- a/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs +++ b/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' +// error-pattern:thread 'main' panicked +// error-pattern:attempt to multiply with overflow // ignore-emscripten no processes // compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs b/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs index f2643c164..4a0f9abd9 100644 --- a/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs +++ b/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' +// error-pattern:thread 'main' panicked +// error-pattern:attempt to multiply with overflow // ignore-emscripten no processes // compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-sub.rs b/tests/ui/numbers-arithmetic/overflowing-sub.rs index 66685ac96..119d80748 100644 --- a/tests/ui/numbers-arithmetic/overflowing-sub.rs +++ b/tests/ui/numbers-arithmetic/overflowing-sub.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'attempt to subtract with overflow' +// error-pattern:thread 'main' panicked +// error-pattern:attempt to subtract with overflow // ignore-emscripten no processes // compile-flags: -C debug-assertions diff --git a/tests/ui/object-safety/assoc_const_bounds.rs b/tests/ui/object-safety/assoc_const_bounds.rs index 94b1f6316..bfa21fd9a 100644 --- a/tests/ui/object-safety/assoc_const_bounds.rs +++ b/tests/ui/object-safety/assoc_const_bounds.rs @@ -1,7 +1,12 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +// check-pass + trait Foo { const BAR: bool - where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - Self: Sized; + where + Self: Sized; } trait Cake {} diff --git a/tests/ui/object-safety/assoc_const_bounds.stderr b/tests/ui/object-safety/assoc_const_bounds.stderr deleted file mode 100644 index 09bc11e17..000000000 --- a/tests/ui/object-safety/assoc_const_bounds.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - --> $DIR/assoc_const_bounds.rs:3:9 - | -LL | trait Foo { - | - while parsing this item list starting here -LL | const BAR: bool - | - expected one of 7 possible tokens -LL | where - | ^^^^^ unexpected token -LL | Self: Sized; -LL | } - | - the item list ends here - -error: aborting due to previous error - diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.rs b/tests/ui/object-safety/assoc_const_bounds_sized.rs index 2a76e5dce..87d1f06f0 100644 --- a/tests/ui/object-safety/assoc_const_bounds_sized.rs +++ b/tests/ui/object-safety/assoc_const_bounds_sized.rs @@ -1,7 +1,12 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +// check-pass + trait Foo { const BAR: bool - where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - Self: Sized; + where + Self: Sized; } fn foo(_: &dyn Foo) {} diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.stderr b/tests/ui/object-safety/assoc_const_bounds_sized.stderr deleted file mode 100644 index e1f57f677..000000000 --- a/tests/ui/object-safety/assoc_const_bounds_sized.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - --> $DIR/assoc_const_bounds_sized.rs:3:9 - | -LL | trait Foo { - | - while parsing this item list starting here -LL | const BAR: bool - | - expected one of 7 possible tokens -LL | where - | ^^^^^ unexpected token -LL | Self: Sized; -LL | } - | - the item list ends here - -error: aborting due to previous error - diff --git a/tests/ui/object-safety/object-safety-by-value-self-use.stderr b/tests/ui/object-safety/object-safety-by-value-self-use.stderr index 94fdcdf26..17f4cb4d4 100644 --- a/tests/ui/object-safety/object-safety-by-value-self-use.stderr +++ b/tests/ui/object-safety/object-safety-by-value-self-use.stderr @@ -2,7 +2,7 @@ error[E0161]: cannot move a value of type `dyn Bar` --> $DIR/object-safety-by-value-self-use.rs:15:5 | LL | t.bar() - | ^^^^^^^ the size of `dyn Bar` cannot be statically determined + | ^ the size of `dyn Bar` cannot be statically determined error: aborting due to previous error diff --git a/tests/ui/or-patterns/missing-bindings.stderr b/tests/ui/or-patterns/missing-bindings.stderr index 8fafa275b..4457b7893 100644 --- a/tests/ui/or-patterns/missing-bindings.stderr +++ b/tests/ui/or-patterns/missing-bindings.stderr @@ -79,6 +79,14 @@ LL | let (A(A(..) | B(a), _) | B(A(a, _) | B(a))) = Y; | | | pattern doesn't bind `a` +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/missing-bindings.rs:45:12 + | +LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; + | ^^^^^^^ - variable not in all patterns + | | + | pattern doesn't bind `c` + error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:45:22 | @@ -96,12 +104,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | variable not in all patterns error[E0408]: variable `c` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:12 + --> $DIR/missing-bindings.rs:45:33 | LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | ^^^^^^^ - variable not in all patterns - | | - | pattern doesn't bind `c` + | - ^^^^ pattern doesn't bind `c` + | | + | variable not in all patterns error[E0408]: variable `d` is not bound in all patterns --> $DIR/missing-bindings.rs:45:33 @@ -135,14 +143,6 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | | | variable not in all patterns -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:33 - | -LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | - ^^^^ pattern doesn't bind `c` - | | - | variable not in all patterns - error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:61:29 | @@ -185,6 +185,28 @@ LL | B(b), LL | B(_) | ^^^^ pattern doesn't bind `b` +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/missing-bindings.rs:57:13 + | +LL | / V1( +LL | | +LL | | +LL | | A( +... | +LL | | B(Ok(a) | Err(a)) +LL | | ) | + | |_____________^ pattern doesn't bind `c` +LL | / V2( +LL | | A( +LL | | A(_, a) | +LL | | B(b), +... | +LL | | +LL | | ) | + | |_____________^ pattern doesn't bind `c` +LL | V3(c), + | - variable not in all patterns + error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:76:13 | @@ -215,28 +237,6 @@ LL | B(b), LL | V3(c), | ^^^^^ pattern doesn't bind `b` -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/missing-bindings.rs:57:13 - | -LL | / V1( -LL | | -LL | | -LL | | A( -... | -LL | | B(Ok(a) | Err(a)) -LL | | ) | - | |_____________^ pattern doesn't bind `c` -LL | / V2( -LL | | A( -LL | | A(_, a) | -LL | | B(b), -... | -LL | | -LL | | ) | - | |_____________^ pattern doesn't bind `c` -LL | V3(c), - | - variable not in all patterns - error: aborting due to 26 previous errors For more information about this error, try `rustc --explain E0408`. diff --git a/tests/ui/panic-handler/weak-lang-item-2.rs b/tests/ui/panic-handler/weak-lang-item-2.rs index a429d8fab..2cc5f23b4 100644 --- a/tests/ui/panic-handler/weak-lang-item-2.rs +++ b/tests/ui/panic-handler/weak-lang-item-2.rs @@ -1,15 +1,15 @@ // run-pass // aux-build:weak-lang-items.rs -// ignore-emscripten no threads support // pretty-expanded FIXME #23616 extern crate weak_lang_items as other; -use std::thread; - fn main() { - let _ = thread::spawn(move|| { - other::foo() - }); + // The goal of the test is just to make sure other::foo() is referenced at link time. Since + // the function panics, to prevent it from running we gate it behind an always-false `if` that + // is not going to be optimized away. + if std::hint::black_box(false) { + other::foo(); + } } diff --git a/tests/ui/panics/abort-on-panic.rs b/tests/ui/panics/abort-on-panic.rs index 1f6ad64c0..7fbee85ff 100644 --- a/tests/ui/panics/abort-on-panic.rs +++ b/tests/ui/panics/abort-on-panic.rs @@ -1,4 +1,6 @@ // run-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next #![allow(unused_must_use)] #![feature(c_unwind)] diff --git a/tests/ui/panics/default-backtrace-ice.stderr b/tests/ui/panics/default-backtrace-ice.stderr index 815ce4dd0..4b00f1350 100644 --- a/tests/ui/panics/default-backtrace-ice.stderr +++ b/tests/ui/panics/default-backtrace-ice.stderr @@ -5,6 +5,7 @@ LL | fn main() { missing_ident; } | ^^^^^^^^^^^^^ not found in this scope +aborting due to `-Z treat-err-as-bug=1` stack backtrace: (end_short_backtrace) (begin_short_backtrace) diff --git a/tests/ui/panics/fmt-only-once.run.stderr b/tests/ui/panics/fmt-only-once.run.stderr index 39bd06881..a991706d3 100644 --- a/tests/ui/panics/fmt-only-once.run.stderr +++ b/tests/ui/panics/fmt-only-once.run.stderr @@ -1,3 +1,4 @@ fmt -thread 'main' panicked at 'PrintOnFmt', $DIR/fmt-only-once.rs:20:5 +thread 'main' panicked at $DIR/fmt-only-once.rs:20:5: +PrintOnFmt note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/issue-47429-short-backtraces.legacy.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.legacy.run.stderr index ac4ed8225..dce91ce59 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.legacy.run.stderr +++ b/tests/ui/panics/issue-47429-short-backtraces.legacy.run.stderr @@ -1,4 +1,5 @@ -thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5 +thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:23:5: +explicit panic stack backtrace: 0: std::panicking::begin_panic 1: issue_47429_short_backtraces::main diff --git a/tests/ui/panics/issue-47429-short-backtraces.v0.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.v0.run.stderr index 65401fe1c..f458c7acb 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.v0.run.stderr +++ b/tests/ui/panics/issue-47429-short-backtraces.v0.run.stderr @@ -1,4 +1,5 @@ -thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5 +thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:23:5: +explicit panic stack backtrace: 0: std::panicking::begin_panic::<&str> 1: issue_47429_short_backtraces::main diff --git a/tests/ui/panics/location-detail-panic-no-column.run.stderr b/tests/ui/panics/location-detail-panic-no-column.run.stderr index 46c9b8448..6d8d02a3a 100644 --- a/tests/ui/panics/location-detail-panic-no-column.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-column.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'column-redacted', $DIR/location-detail-panic-no-column.rs:7:0 +thread 'main' panicked at $DIR/location-detail-panic-no-column.rs:7:0: +column-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-file.run.stderr b/tests/ui/panics/location-detail-panic-no-file.run.stderr index 811f93bf3..492ad37f5 100644 --- a/tests/ui/panics/location-detail-panic-no-file.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-file.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'file-redacted', :7:5 +thread 'main' panicked at :7:5: +file-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-line.run.stderr b/tests/ui/panics/location-detail-panic-no-line.run.stderr index cc3f1624c..fdbc43c43 100644 --- a/tests/ui/panics/location-detail-panic-no-line.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-line.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'line-redacted', $DIR/location-detail-panic-no-line.rs:0:5 +thread 'main' panicked at $DIR/location-detail-panic-no-line.rs:0:5: +line-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-location-info.run.stderr b/tests/ui/panics/location-detail-panic-no-location-info.run.stderr index d1c310864..1e9002df9 100644 --- a/tests/ui/panics/location-detail-panic-no-location-info.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-location-info.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'no location info', :0:0 +thread 'main' panicked at :0:0: +no location info note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-unwrap-no-file.run.stderr b/tests/ui/panics/location-detail-unwrap-no-file.run.stderr index 7d8e1d930..52019f622 100644 --- a/tests/ui/panics/location-detail-unwrap-no-file.run.stderr +++ b/tests/ui/panics/location-detail-unwrap-no-file.run.stderr @@ -1,2 +1,3 @@ -thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', :8:9 +thread 'main' panicked at :8:9: +called `Option::unwrap()` on a `None` value note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/panic-macro-any-wrapped.rs b/tests/ui/panics/panic-macro-any-wrapped.rs index 663bf6713..1815a0d2c 100644 --- a/tests/ui/panics/panic-macro-any-wrapped.rs +++ b/tests/ui/panics/panic-macro-any-wrapped.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'Box' +// error-pattern:panicked +// error-pattern:Box // ignore-emscripten no processes #![allow(non_fmt_panics)] diff --git a/tests/ui/panics/panic-macro-any.rs b/tests/ui/panics/panic-macro-any.rs index c7df53654..1bc3c336c 100644 --- a/tests/ui/panics/panic-macro-any.rs +++ b/tests/ui/panics/panic-macro-any.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'Box' +// error-pattern:panicked +// error-pattern:Box // ignore-emscripten no processes #![allow(non_fmt_panics)] diff --git a/tests/ui/panics/panic-macro-explicit.rs b/tests/ui/panics/panic-macro-explicit.rs index ac4d6f812..b5b6c7675 100644 --- a/tests/ui/panics/panic-macro-explicit.rs +++ b/tests/ui/panics/panic-macro-explicit.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'explicit panic' +// error-pattern:panicked +// error-pattern:explicit panic // ignore-emscripten no processes fn main() { diff --git a/tests/ui/panics/panic-macro-fmt.rs b/tests/ui/panics/panic-macro-fmt.rs index a755ebc0f..0796d33ea 100644 --- a/tests/ui/panics/panic-macro-fmt.rs +++ b/tests/ui/panics/panic-macro-fmt.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'test-fail-fmt 42 rust' +// error-pattern:panicked +// error-pattern:test-fail-fmt 42 rust // ignore-emscripten no processes fn main() { diff --git a/tests/ui/panics/panic-macro-owned.rs b/tests/ui/panics/panic-macro-owned.rs index b898fde77..522c87e1c 100644 --- a/tests/ui/panics/panic-macro-owned.rs +++ b/tests/ui/panics/panic-macro-owned.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'test-fail-owned' +// error-pattern:panicked +// error-pattern:test-fail-owned // ignore-emscripten no processes fn main() { diff --git a/tests/ui/panics/panic-macro-static.rs b/tests/ui/panics/panic-macro-static.rs index a1d467cbf..06ec5b0ad 100644 --- a/tests/ui/panics/panic-macro-static.rs +++ b/tests/ui/panics/panic-macro-static.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:panicked at 'test-fail-static' +// error-pattern:panicked +// error-pattern:test-fail-static // ignore-emscripten no processes fn main() { diff --git a/tests/ui/panics/panic-set-unset-handler.rs b/tests/ui/panics/panic-set-unset-handler.rs index dde0c72f7..91f69f0a6 100644 --- a/tests/ui/panics/panic-set-unset-handler.rs +++ b/tests/ui/panics/panic-set-unset-handler.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'foobar' +// error-pattern:thread 'main' panicked +// error-pattern:foobar // ignore-emscripten no processes use std::panic; diff --git a/tests/ui/panics/panic-take-handler-nop.rs b/tests/ui/panics/panic-take-handler-nop.rs index 41cbac97c..d14a3244e 100644 --- a/tests/ui/panics/panic-take-handler-nop.rs +++ b/tests/ui/panics/panic-take-handler-nop.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'main' panicked at 'foobar' +// error-pattern:thread 'main' panicked +// error-pattern:foobar // ignore-emscripten no processes use std::panic; diff --git a/tests/ui/panics/panic-task-name-none.rs b/tests/ui/panics/panic-task-name-none.rs index 4e95fb5bd..3fb0f3412 100644 --- a/tests/ui/panics/panic-task-name-none.rs +++ b/tests/ui/panics/panic-task-name-none.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread '' panicked at 'test' +// error-pattern:thread '' panicked +// error-pattern:test // ignore-emscripten Needs threads use std::thread; diff --git a/tests/ui/panics/panic-task-name-owned.rs b/tests/ui/panics/panic-task-name-owned.rs index f85be7bb8..d5274ebbc 100644 --- a/tests/ui/panics/panic-task-name-owned.rs +++ b/tests/ui/panics/panic-task-name-owned.rs @@ -1,5 +1,6 @@ // run-fail -// error-pattern:thread 'owned name' panicked at 'test' +// error-pattern:thread 'owned name' panicked +// error-pattern:test // ignore-emscripten Needs threads. use std::thread::Builder; diff --git a/tests/ui/panics/runtime-switch.legacy.run.stderr b/tests/ui/panics/runtime-switch.legacy.run.stderr index 0f7655163..bd05b6cc0 100644 --- a/tests/ui/panics/runtime-switch.legacy.run.stderr +++ b/tests/ui/panics/runtime-switch.legacy.run.stderr @@ -1,4 +1,5 @@ -thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5 +thread 'main' panicked at $DIR/runtime-switch.rs:26:5: +explicit panic stack backtrace: 0: std::panicking::begin_panic 1: runtime_switch::main diff --git a/tests/ui/panics/runtime-switch.v0.run.stderr b/tests/ui/panics/runtime-switch.v0.run.stderr index a4ae44131..2078c356d 100644 --- a/tests/ui/panics/runtime-switch.v0.run.stderr +++ b/tests/ui/panics/runtime-switch.v0.run.stderr @@ -1,4 +1,5 @@ -thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5 +thread 'main' panicked at $DIR/runtime-switch.rs:26:5: +explicit panic stack backtrace: 0: std::panicking::begin_panic::<&str> 1: runtime_switch::main diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr index 2592b7479..2b648a0ca 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -1,10 +1,13 @@ -thread 'main' panicked at 'debug!!!', $DIR/short-ice-remove-middle-frames-2.rs:56:5 +thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:56:5: +debug!!! stack backtrace: 0: std::panicking::begin_panic 1: short_ice_remove_middle_frames_2::eight 2: short_ice_remove_middle_frames_2::seven::{{closure}} + [... omitted 3 frames ...] 3: short_ice_remove_middle_frames_2::fifth 4: short_ice_remove_middle_frames_2::fourth::{{closure}} + [... omitted 4 frames ...] 5: short_ice_remove_middle_frames_2::first 6: short_ice_remove_middle_frames_2::main 7: core::ops::function::FnOnce::call_once diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr index 9c15f2e08..5b3726840 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -1,9 +1,11 @@ -thread 'main' panicked at 'debug!!!', $DIR/short-ice-remove-middle-frames.rs:52:5 +thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:52:5: +debug!!! stack backtrace: 0: std::panicking::begin_panic 1: short_ice_remove_middle_frames::seven 2: short_ice_remove_middle_frames::sixth 3: short_ice_remove_middle_frames::fifth::{{closure}} + [... omitted 4 frames ...] 4: short_ice_remove_middle_frames::second 5: short_ice_remove_middle_frames::first::{{closure}} 6: short_ice_remove_middle_frames::first diff --git a/tests/ui/parser/async-with-nonterminal-block.rs b/tests/ui/parser/async-with-nonterminal-block.rs new file mode 100644 index 000000000..96015fd5d --- /dev/null +++ b/tests/ui/parser/async-with-nonterminal-block.rs @@ -0,0 +1,16 @@ +// check-pass +// edition:2021 + +macro_rules! create_async { + ($body:block) => { + async $body + }; +} + +async fn other() {} + +fn main() { + let y = create_async! {{ + other().await; + }}; +} diff --git a/tests/ui/parser/generic-statics.rs b/tests/ui/parser/generic-statics.rs new file mode 100644 index 000000000..2fb8781fd --- /dev/null +++ b/tests/ui/parser/generic-statics.rs @@ -0,0 +1,4 @@ +static S: i32 = 0; +//~^ ERROR static items may not have generic parameters + +fn main() {} diff --git a/tests/ui/parser/generic-statics.stderr b/tests/ui/parser/generic-statics.stderr new file mode 100644 index 000000000..c757232b0 --- /dev/null +++ b/tests/ui/parser/generic-statics.stderr @@ -0,0 +1,8 @@ +error: static items may not have generic parameters + --> $DIR/generic-statics.rs:1:9 + | +LL | static S: i32 = 0; + | ^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-113203.rs b/tests/ui/parser/issues/issue-113203.rs new file mode 100644 index 000000000..1103251c1 --- /dev/null +++ b/tests/ui/parser/issues/issue-113203.rs @@ -0,0 +1,7 @@ +// Checks what happens when we attempt to use the await keyword as a prefix. Span +// incorrectly emitted an `.await` in E0277 which does not exist +// edition:2018 +fn main() { + await {}() + //~^ ERROR incorrect use of `await` +} diff --git a/tests/ui/parser/issues/issue-113203.stderr b/tests/ui/parser/issues/issue-113203.stderr new file mode 100644 index 000000000..97304a89c --- /dev/null +++ b/tests/ui/parser/issues/issue-113203.stderr @@ -0,0 +1,8 @@ +error: incorrect use of `await` + --> $DIR/issue-113203.rs:5:5 + | +LL | await {}() + | ^^^^^^^^ help: `await` is a postfix operation: `{}.await` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-114219.rs b/tests/ui/parser/issues/issue-114219.rs new file mode 100644 index 000000000..332258b62 --- /dev/null +++ b/tests/ui/parser/issues/issue-114219.rs @@ -0,0 +1,4 @@ +fn main() { + async move {}; + //~^ ERROR `async move` blocks are only allowed in Rust 2018 or later +} diff --git a/tests/ui/parser/issues/issue-114219.stderr b/tests/ui/parser/issues/issue-114219.stderr new file mode 100644 index 000000000..90dcdc427 --- /dev/null +++ b/tests/ui/parser/issues/issue-114219.stderr @@ -0,0 +1,8 @@ +error: `async move` blocks are only allowed in Rust 2018 or later + --> $DIR/issue-114219.rs:2:5 + | +LL | async move {}; + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs b/tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs new file mode 100644 index 000000000..3421333b8 --- /dev/null +++ b/tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs @@ -0,0 +1,21 @@ +// Regression test for issue #115780. +// Ensure that we don't emit a parse error for the token sequence `Ident "<" Ty` in pattern position +// if we are inside a macro call since it can be valid input for a subsequent macro rule. +// See also #103534. + +// check-pass + +macro_rules! mdo { + ($p: pat =<< $e: expr ; $( $t: tt )*) => { + $e.and_then(|$p| mdo! { $( $t )* }) + }; + (ret<$ty: ty> $e: expr;) => { Some::<$ty>($e) }; +} + +fn main() { + mdo! { + x_val =<< Some(0); + y_val =<< Some(1); + ret<(i32, i32)> (x_val, y_val); + }; +} diff --git a/tests/ui/parser/issues/issue-22647.rs b/tests/ui/parser/issues/issue-22647.rs index a68614106..163cbc69d 100644 --- a/tests/ui/parser/issues/issue-22647.rs +++ b/tests/ui/parser/issues/issue-22647.rs @@ -1,5 +1,5 @@ fn main() { - let caller = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + let caller = |f: F| //~ ERROR generic args in patterns require the turbofish syntax where F: Fn() -> i32 { let x = f(); diff --git a/tests/ui/parser/issues/issue-22647.stderr b/tests/ui/parser/issues/issue-22647.stderr index 89b454d19..585e70266 100644 --- a/tests/ui/parser/issues/issue-22647.stderr +++ b/tests/ui/parser/issues/issue-22647.stderr @@ -1,8 +1,13 @@ -error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/issue-22647.rs:2:15 | LL | let caller = |f: F| - | ^ expected one of `:`, `;`, `=`, `@`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | let caller:: = |f: F| + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-22712.rs b/tests/ui/parser/issues/issue-22712.rs index 774de9c7e..92b12b8e1 100644 --- a/tests/ui/parser/issues/issue-22712.rs +++ b/tests/ui/parser/issues/issue-22712.rs @@ -3,7 +3,7 @@ struct Foo { } fn bar() { - let Foo> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + let Foo> //~ ERROR generic args in patterns require the turbofish syntax } fn main() {} diff --git a/tests/ui/parser/issues/issue-22712.stderr b/tests/ui/parser/issues/issue-22712.stderr index 30fabac65..7f9d99d8e 100644 --- a/tests/ui/parser/issues/issue-22712.stderr +++ b/tests/ui/parser/issues/issue-22712.stderr @@ -1,8 +1,13 @@ -error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/issue-22712.rs:6:12 | LL | let Foo> - | ^ expected one of `:`, `;`, `=`, `@`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | let Foo::> + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs b/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs index 80f53338a..92ff0ef64 100644 --- a/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs +++ b/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs @@ -6,9 +6,13 @@ pub enum ErrorHandled { impl ErrorHandled { pub fn assert_reported(self) { match self { + //~^ NOTE this delimiter might not be properly closed... ErrorHandled::Reported => {}} - //^~ ERROR block is empty, you might have not meant to close it + //~^ NOTE block is empty, you might have not meant to close it + //~| NOTE as it matches this but it has different indentation ErrorHandled::TooGeneric => panic!(), } } -} //~ ERROR unexpected closing delimiter: `}` +} +//~^ ERROR unexpected closing delimiter: `}` +//~| NOTE unexpected closing delimiter diff --git a/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr b/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr index 9ae94c701..c590e04bb 100644 --- a/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr +++ b/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr @@ -1,8 +1,9 @@ error: unexpected closing delimiter: `}` - --> $DIR/issue-70583-block-is-empty-2.rs:14:1 + --> $DIR/issue-70583-block-is-empty-2.rs:16:1 | LL | match self { | - this delimiter might not be properly closed... +LL | LL | ErrorHandled::Reported => {}} | --- ...as it matches this but it has different indentation | | diff --git a/tests/ui/parser/macro/macro-expand-to-field.rs b/tests/ui/parser/macro/macro-expand-to-field.rs new file mode 100644 index 000000000..155872f7a --- /dev/null +++ b/tests/ui/parser/macro/macro-expand-to-field.rs @@ -0,0 +1,70 @@ +// compile-flags: --crate-type=lib + +macro_rules! field { + ($name:ident:$type:ty) => { + $name:$type + }; +} + +macro_rules! variant { + ($name:ident) => { + $name + } +} + +struct Struct { + field!(bar:u128), + //~^ NOTE macros cannot expand to struct fields + //~| ERROR unexpected token: `!` + //~| NOTE unexpected token after this + a: u32, + b: u32, + field!(recovers:()), //~ NOTE macros cannot expand to struct fields + //~^ ERROR unexpected token: `!` + //~^^ NOTE unexpected token after this +} + +enum EnumVariant { + variant!(whoops), + //~^ NOTE macros cannot expand to enum variants + //~| ERROR unexpected token: `!` + //~| NOTE unexpected token after this + U32, + F64, + variant!(recovers), + //~^ NOTE macros cannot expand to enum variants + //~| ERROR unexpected token: `!` + //~| NOTE unexpected token after this + Data { + field!(x:u32), + //~^ NOTE macros cannot expand to struct fields + //~| ERROR unexpected token: `!` + //~| NOTE unexpected token after this + } +} + +enum EnumVariantField { + Named { + field!(oopsies:()), + //~^ NOTE macros cannot expand to struct fields + //~| ERROR unexpected token: `!` + //~| unexpected token after this + field!(oopsies2:()), + //~^ NOTE macros cannot expand to struct fields + //~| ERROR unexpected token: `!` + //~| unexpected token after this + }, +} + +union Union { + A: u32, + field!(oopsies:()), + //~^ NOTE macros cannot expand to union fields + //~| ERROR unexpected token: `!` + //~| unexpected token after this + B: u32, + field!(recovers:()), + //~^ NOTE macros cannot expand to union fields + //~| ERROR unexpected token: `!` + //~| unexpected token after this +} diff --git a/tests/ui/parser/macro/macro-expand-to-field.stderr b/tests/ui/parser/macro/macro-expand-to-field.stderr new file mode 100644 index 000000000..adcd032f5 --- /dev/null +++ b/tests/ui/parser/macro/macro-expand-to-field.stderr @@ -0,0 +1,74 @@ +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:16:10 + | +LL | field!(bar:u128), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:22:10 + | +LL | field!(recovers:()), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:28:12 + | +LL | variant!(whoops), + | ^ unexpected token after this + | + = note: macros cannot expand to enum variants + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:34:12 + | +LL | variant!(recovers), + | ^ unexpected token after this + | + = note: macros cannot expand to enum variants + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:39:14 + | +LL | field!(x:u32), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:48:14 + | +LL | field!(oopsies:()), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:52:14 + | +LL | field!(oopsies2:()), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:61:10 + | +LL | field!(oopsies:()), + | ^ unexpected token after this + | + = note: macros cannot expand to union fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:66:10 + | +LL | field!(recovers:()), + | ^ unexpected token after this + | + = note: macros cannot expand to union fields + +error: aborting due to 9 previous errors + diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.rs b/tests/ui/parser/macro/macro-expand-to-match-arm.rs new file mode 100644 index 000000000..39d1d065e --- /dev/null +++ b/tests/ui/parser/macro/macro-expand-to-match-arm.rs @@ -0,0 +1,18 @@ +macro_rules! arm { + ($pattern:pat => $block:block) => { + $pattern => $block + }; +} + +fn main() { + let x = Some(1); + match x { + Some(1) => {}, + arm!(None => {}), + //~^ NOTE macros cannot expand to match arms + //~| ERROR unexpected `,` in pattern + // doesn't recover + Some(2) => {}, + _ => {}, + }; +} diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr new file mode 100644 index 000000000..1a5f46968 --- /dev/null +++ b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr @@ -0,0 +1,10 @@ +error: unexpected `,` in pattern + --> $DIR/macro-expand-to-match-arm.rs:11:25 + | +LL | arm!(None => {}), + | ^ + | + = note: macros cannot expand to match arms + +error: aborting due to previous error + diff --git a/tests/ui/parser/pat-lt-bracket-3.rs b/tests/ui/parser/pat-lt-bracket-3.rs index a8bdfd3fa..bd83fe8db 100644 --- a/tests/ui/parser/pat-lt-bracket-3.rs +++ b/tests/ui/parser/pat-lt-bracket-3.rs @@ -3,8 +3,7 @@ struct Foo(T, T); impl Foo { fn foo(&self) { match *self { - Foo(x, y) => { - //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo(x, y) => { //~ ERROR generic args in patterns require the turbofish syntax println!("Goodbye, World!") } } diff --git a/tests/ui/parser/pat-lt-bracket-3.stderr b/tests/ui/parser/pat-lt-bracket-3.stderr index bacf868e3..afdf1e9a5 100644 --- a/tests/ui/parser/pat-lt-bracket-3.stderr +++ b/tests/ui/parser/pat-lt-bracket-3.stderr @@ -1,8 +1,13 @@ -error: expected one of `=>`, `@`, `if`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/pat-lt-bracket-3.rs:6:16 | LL | Foo(x, y) => { - | ^ expected one of `=>`, `@`, `if`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | Foo::(x, y) => { + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/pat-lt-bracket-4.rs b/tests/ui/parser/pat-lt-bracket-4.rs index de314f6c6..6d348b68c 100644 --- a/tests/ui/parser/pat-lt-bracket-4.rs +++ b/tests/ui/parser/pat-lt-bracket-4.rs @@ -5,7 +5,7 @@ enum BtNode { fn main() { let y = match 10 { - Foo::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo::A(value) => value, //~ ERROR generic args in patterns require the turbofish syntax Foo::B => 7, }; } diff --git a/tests/ui/parser/pat-lt-bracket-4.stderr b/tests/ui/parser/pat-lt-bracket-4.stderr index 911c276b9..b71a5ad93 100644 --- a/tests/ui/parser/pat-lt-bracket-4.stderr +++ b/tests/ui/parser/pat-lt-bracket-4.stderr @@ -1,8 +1,13 @@ -error: expected one of `=>`, `@`, `if`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/pat-lt-bracket-4.rs:8:12 | LL | Foo::A(value) => value, - | ^ expected one of `=>`, `@`, `if`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | Foo::::A(value) => value, + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/ternary_operator.rs b/tests/ui/parser/ternary_operator.rs new file mode 100644 index 000000000..23d537e77 --- /dev/null +++ b/tests/ui/parser/ternary_operator.rs @@ -0,0 +1,69 @@ +// A good chunk of these errors aren't shown to the user, but are still +// required in the test for it to pass. + +fn a() { //~ NOTE this function should return `Result` or `Option` to accept `?` + let x = 5 > 2 ? true : false; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` +} + +fn b() { //~ NOTE this function should return `Result` or `Option` to accept `?` + let x = 5 > 2 ? { true } : { false }; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` +} + +fn c() { //~ NOTE this function should return `Result` or `Option` to accept `?` + let x = 5 > 2 ? f32::MAX : f32::MIN; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` +} + +fn main() { //~ NOTE this function should return `Result` or `Option` to accept `?` + let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + //~| NOTE expected one of `.`, `;`, `?`, `else`, or an operator + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE type ascription syntax has been removed, see issue #101728 + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` +} diff --git a/tests/ui/parser/ternary_operator.stderr b/tests/ui/parser/ternary_operator.stderr new file mode 100644 index 000000000..af9565bbe --- /dev/null +++ b/tests/ui/parser/ternary_operator.stderr @@ -0,0 +1,115 @@ +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:5:19 + | +LL | let x = 5 > 2 ? true : false; + | ^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:21:19 + | +LL | let x = 5 > 2 ? { true } : { false }; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:37:19 + | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/ternary_operator.rs:53:37 + | +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^ expected one of `.`, `;`, `?`, `else`, or an operator + | + = note: type ascription syntax has been removed, see issue #101728 + +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:53:19 + | +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:5:17 + | +LL | let x = 5 > 2 ? true : false; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:5:19 + | +LL | fn a() { + | ------ this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? true : false; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:21:17 + | +LL | let x = 5 > 2 ? { true } : { false }; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:21:19 + | +LL | fn b() { + | ------ this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? { true } : { false }; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:37:17 + | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:37:19 + | +LL | fn c() { + | ------ this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:53:17 + | +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:53:19 + | +LL | fn main() { + | --------- this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/parser/trait-object-delimiters.rs b/tests/ui/parser/trait-object-delimiters.rs index c41cda187..e9b13defe 100644 --- a/tests/ui/parser/trait-object-delimiters.rs +++ b/tests/ui/parser/trait-object-delimiters.rs @@ -3,9 +3,9 @@ fn foo1(_: &dyn Drop + AsRef) {} //~ ERROR ambiguous `+` in a type //~^ ERROR only auto traits can be used as additional traits in a trait object -fn foo2(_: &dyn (Drop + AsRef)) {} //~ ERROR incorrect braces around trait bounds +fn foo2(_: &dyn (Drop + AsRef)) {} //~ ERROR incorrect parentheses around trait bounds -fn foo2_no_space(_: &dyn(Drop + AsRef)) {} //~ ERROR incorrect braces around trait bounds +fn foo2_no_space(_: &dyn(Drop + AsRef)) {} //~ ERROR incorrect parentheses around trait bounds fn foo3(_: &dyn {Drop + AsRef}) {} //~ ERROR expected parameter name, found `{` //~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `for`, `~`, lifetime, or path, found `{` diff --git a/tests/ui/parser/trait-object-delimiters.stderr b/tests/ui/parser/trait-object-delimiters.stderr index ccce3a805..519546750 100644 --- a/tests/ui/parser/trait-object-delimiters.stderr +++ b/tests/ui/parser/trait-object-delimiters.stderr @@ -4,28 +4,28 @@ error: ambiguous `+` in a type LL | fn foo1(_: &dyn Drop + AsRef) {} | ^^^^^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(dyn Drop + AsRef)` -error: incorrect braces around trait bounds +error: incorrect parentheses around trait bounds --> $DIR/trait-object-delimiters.rs:6:17 | LL | fn foo2(_: &dyn (Drop + AsRef)) {} | ^ ^ | -help: remove the parentheses +help: fix the parentheses | LL - fn foo2(_: &dyn (Drop + AsRef)) {} -LL + fn foo2(_: &dyn Drop + AsRef) {} +LL + fn foo2(_: &(dyn Drop + AsRef)) {} | -error: incorrect braces around trait bounds +error: incorrect parentheses around trait bounds --> $DIR/trait-object-delimiters.rs:8:25 | LL | fn foo2_no_space(_: &dyn(Drop + AsRef)) {} | ^ ^ | -help: remove the parentheses +help: fix the parentheses | LL - fn foo2_no_space(_: &dyn(Drop + AsRef)) {} -LL + fn foo2_no_space(_: &dyn Drop + AsRef) {} +LL + fn foo2_no_space(_: &(dyn Drop + AsRef)) {} | error: expected parameter name, found `{` diff --git a/tests/ui/parser/try-with-nonterminal-block.rs b/tests/ui/parser/try-with-nonterminal-block.rs new file mode 100644 index 000000000..2a9652f2e --- /dev/null +++ b/tests/ui/parser/try-with-nonterminal-block.rs @@ -0,0 +1,19 @@ +// check-pass +// edition:2021 + +#![feature(try_blocks)] + +macro_rules! create_try { + ($body:block) => { + try $body + }; +} + +fn main() { + let x: Option<&str> = create_try! {{ + None?; + "Hello world" + }}; + + println!("{x:?}"); +} diff --git a/tests/ui/parser/type-alias-where-fixable.fixed b/tests/ui/parser/type-alias-where-fixable.fixed deleted file mode 100644 index 2f47c0d91..000000000 --- a/tests/ui/parser/type-alias-where-fixable.fixed +++ /dev/null @@ -1,28 +0,0 @@ -// check-pass -// run-rustfix - -trait Trait { - // Fine. - type Assoc where u32: Copy; - // Fine. - type Assoc2 where u32: Copy, i32: Copy; -} - -impl Trait for u32 { - // Not fine, suggests moving. - type Assoc = () where u32: Copy; - //~^ WARNING where clause not allowed here - // Not fine, suggests moving `u32: Copy` - type Assoc2 = () where i32: Copy, u32: Copy; - //~^ WARNING where clause not allowed here -} - -impl Trait for i32 { - // Fine. - type Assoc = () where u32: Copy; - // Not fine, suggests moving both. - type Assoc2 = () where u32: Copy, i32: Copy; - //~^ WARNING where clause not allowed here -} - -fn main() {} diff --git a/tests/ui/parser/type-alias-where-fixable.rs b/tests/ui/parser/type-alias-where-fixable.rs deleted file mode 100644 index b20aa9398..000000000 --- a/tests/ui/parser/type-alias-where-fixable.rs +++ /dev/null @@ -1,28 +0,0 @@ -// check-pass -// run-rustfix - -trait Trait { - // Fine. - type Assoc where u32: Copy; - // Fine. - type Assoc2 where u32: Copy, i32: Copy; -} - -impl Trait for u32 { - // Not fine, suggests moving. - type Assoc where u32: Copy = (); - //~^ WARNING where clause not allowed here - // Not fine, suggests moving `u32: Copy` - type Assoc2 where u32: Copy = () where i32: Copy; - //~^ WARNING where clause not allowed here -} - -impl Trait for i32 { - // Fine. - type Assoc = () where u32: Copy; - // Not fine, suggests moving both. - type Assoc2 where u32: Copy, i32: Copy = (); - //~^ WARNING where clause not allowed here -} - -fn main() {} diff --git a/tests/ui/parser/type-alias-where-fixable.stderr b/tests/ui/parser/type-alias-where-fixable.stderr deleted file mode 100644 index f0acb388b..000000000 --- a/tests/ui/parser/type-alias-where-fixable.stderr +++ /dev/null @@ -1,42 +0,0 @@ -warning: where clause not allowed here - --> $DIR/type-alias-where-fixable.rs:13:16 - | -LL | type Assoc where u32: Copy = (); - | ^^^^^^^^^^^^^^^ - | - = note: see issue #89122 for more information - = note: `#[warn(deprecated_where_clause_location)]` on by default -help: move it to the end of the type declaration - | -LL - type Assoc where u32: Copy = (); -LL + type Assoc = () where u32: Copy; - | - -warning: where clause not allowed here - --> $DIR/type-alias-where-fixable.rs:16:17 - | -LL | type Assoc2 where u32: Copy = () where i32: Copy; - | ^^^^^^^^^^^^^^^ - | - = note: see issue #89122 for more information -help: move it to the end of the type declaration - | -LL - type Assoc2 where u32: Copy = () where i32: Copy; -LL + type Assoc2 = () where i32: Copy, u32: Copy; - | - -warning: where clause not allowed here - --> $DIR/type-alias-where-fixable.rs:24:17 - | -LL | type Assoc2 where u32: Copy, i32: Copy = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #89122 for more information -help: move it to the end of the type declaration - | -LL - type Assoc2 where u32: Copy, i32: Copy = (); -LL + type Assoc2 = () where u32: Copy, i32: Copy; - | - -warning: 3 warnings emitted - diff --git a/tests/ui/parser/type-alias-where.rs b/tests/ui/parser/type-alias-where.rs deleted file mode 100644 index 62e301cb4..000000000 --- a/tests/ui/parser/type-alias-where.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-fail - -// Fine, but lints as unused -type Foo where u32: Copy = (); -// Not fine. -type Bar = () where u32: Copy; -//~^ ERROR where clauses are not allowed -type Baz = () where; -//~^ ERROR where clauses are not allowed - -fn main() {} diff --git a/tests/ui/parser/type-alias-where.stderr b/tests/ui/parser/type-alias-where.stderr deleted file mode 100644 index fb8381792..000000000 --- a/tests/ui/parser/type-alias-where.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: where clauses are not allowed after the type for type aliases - --> $DIR/type-alias-where.rs:6:15 - | -LL | type Bar = () where u32: Copy; - | ^^^^^^^^^^^^^^^ - | - = note: see issue #89122 for more information - -error: where clauses are not allowed after the type for type aliases - --> $DIR/type-alias-where.rs:8:15 - | -LL | type Baz = () where; - | ^^^^^ - | - = note: see issue #89122 for more information - -error: aborting due to 2 previous errors - diff --git a/tests/ui/pattern/slice-array-infer.rs b/tests/ui/pattern/slice-array-infer.rs new file mode 100644 index 000000000..f94a3dcfe --- /dev/null +++ b/tests/ui/pattern/slice-array-infer.rs @@ -0,0 +1,27 @@ +// check-pass + +#![allow(unused_variables)] +#![feature(generic_arg_infer)] + +struct Zeroes; +impl Into<&'static [usize; 3]> for Zeroes { + fn into(self) -> &'static [usize; 3] { + &[0; 3] + } +} +impl Into<[usize; 3]> for Zeroes { + fn into(self) -> [usize; 3] { + [0; 3] + } +} +fn main() { + let [a, b, c] = Zeroes.into(); + let [d, e, f] = >::into(Zeroes); + let &[g, h, i] = Zeroes.into(); + let [j, k, l]: [usize; _] = Zeroes.into(); + let [m, n, o]: &[usize; _] = Zeroes.into(); + + // check the binding mode of these patterns: + let _: &[usize] = &[a, b, c, g, h, i, j, k, l]; + let _: &[&usize] = &[d, e, f, m, n, o]; +} diff --git a/tests/ui/pattern/slice-pattern-refutable.rs b/tests/ui/pattern/slice-pattern-refutable.rs new file mode 100644 index 000000000..1be3c6ef8 --- /dev/null +++ b/tests/ui/pattern/slice-pattern-refutable.rs @@ -0,0 +1,36 @@ +// Test that we do not infer the expected types of patterns to an array +// if we're in a refutable pattern. +#![allow(unused_variables)] + +struct Zeroes; + +impl Into<[usize; 3]> for Zeroes { + fn into(self) -> [usize; 3] { + [0; 3] + } +} + +fn let_else() { + let [a, b, c] = Zeroes.into() else { + //~^ ERROR type annotations needed + unreachable!(); + }; +} + +fn if_let() { + if let [a, b, c] = Zeroes.into() { + //~^ ERROR type annotations needed + unreachable!(); + } +} + +fn if_let_else() { + if let [a, b, c] = Zeroes.into() { + //~^ ERROR type annotations needed + unreachable!(); + } else { + unreachable!(); + } +} + +fn main() {} diff --git a/tests/ui/pattern/slice-pattern-refutable.stderr b/tests/ui/pattern/slice-pattern-refutable.stderr new file mode 100644 index 000000000..df5b58d3e --- /dev/null +++ b/tests/ui/pattern/slice-pattern-refutable.stderr @@ -0,0 +1,40 @@ +error[E0282]: type annotations needed + --> $DIR/slice-pattern-refutable.rs:14:9 + | +LL | let [a, b, c] = Zeroes.into() else { + | ^^^^^^^^^ + | +help: consider giving this pattern a type + | +LL | let [a, b, c]: /* Type */ = Zeroes.into() else { + | ++++++++++++ + +error[E0282]: type annotations needed + --> $DIR/slice-pattern-refutable.rs:21:31 + | +LL | if let [a, b, c] = Zeroes.into() { + | --------- ^^^^ + | | + | type must be known at this point + | +help: try using a fully qualified path to specify the expected types + | +LL | if let [a, b, c] = >::into(Zeroes) { + | ++++++++++++++++++++++++++ ~ + +error[E0282]: type annotations needed + --> $DIR/slice-pattern-refutable.rs:28:31 + | +LL | if let [a, b, c] = Zeroes.into() { + | --------- ^^^^ + | | + | type must be known at this point + | +help: try using a fully qualified path to specify the expected types + | +LL | if let [a, b, c] = >::into(Zeroes) { + | ++++++++++++++++++++++++++ ~ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/pattern/slice-patterns-ambiguity.rs b/tests/ui/pattern/slice-patterns-ambiguity.rs new file mode 100644 index 000000000..0fe24b0e5 --- /dev/null +++ b/tests/ui/pattern/slice-patterns-ambiguity.rs @@ -0,0 +1,47 @@ +#![allow(unused_variables)] + +struct Zeroes; + +const ARR: [usize; 2] = [0; 2]; +const ARR2: [usize; 2] = [2; 2]; + +impl Into<&'static [usize; 2]> for Zeroes { + fn into(self) -> &'static [usize; 2] { + &ARR + } +} + +impl Into<&'static [usize]> for Zeroes { + fn into(self) -> &'static [usize] { + &ARR2 + } +} + +fn let_decl() { + let &[a, b] = Zeroes.into(); +} + +fn let_else() { + let &[a, b] = Zeroes.into() else { + //~^ ERROR type annotations needed + unreachable!(); + }; +} + +fn if_let() { + if let &[a, b] = Zeroes.into() { + //~^ ERROR type annotations needed + unreachable!(); + } +} + +fn if_let_else() { + if let &[a, b] = Zeroes.into() { + //~^ ERROR type annotations needed + unreachable!(); + } else { + unreachable!(); + } +} + +fn main() {} diff --git a/tests/ui/pattern/slice-patterns-ambiguity.stderr b/tests/ui/pattern/slice-patterns-ambiguity.stderr new file mode 100644 index 000000000..3ef99d0e2 --- /dev/null +++ b/tests/ui/pattern/slice-patterns-ambiguity.stderr @@ -0,0 +1,40 @@ +error[E0282]: type annotations needed for `&_` + --> $DIR/slice-patterns-ambiguity.rs:25:9 + | +LL | let &[a, b] = Zeroes.into() else { + | ^^^^^^^ + | +help: consider giving this pattern a type, where the placeholders `_` are specified + | +LL | let &[a, b]: &_ = Zeroes.into() else { + | ++++ + +error[E0282]: type annotations needed + --> $DIR/slice-patterns-ambiguity.rs:32:29 + | +LL | if let &[a, b] = Zeroes.into() { + | ------ ^^^^ + | | + | type must be known at this point + | +help: try using a fully qualified path to specify the expected types + | +LL | if let &[a, b] = >::into(Zeroes) { + | +++++++++++++++++++++++++++ ~ + +error[E0282]: type annotations needed + --> $DIR/slice-patterns-ambiguity.rs:39:29 + | +LL | if let &[a, b] = Zeroes.into() { + | ------ ^^^^ + | | + | type must be known at this point + | +help: try using a fully qualified path to specify the expected types + | +LL | if let &[a, b] = >::into(Zeroes) { + | +++++++++++++++++++++++++++ ~ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/pattern/slice-patterns-irrefutable.rs b/tests/ui/pattern/slice-patterns-irrefutable.rs new file mode 100644 index 000000000..bd230608e --- /dev/null +++ b/tests/ui/pattern/slice-patterns-irrefutable.rs @@ -0,0 +1,74 @@ +// Test that we infer the expected type of a pattern to an array of the given length. + +#![allow(unused_variables)] + +use std::array::TryFromSliceError; +use std::convert::TryInto; + +struct Zeroes; +impl Into<[usize; 2]> for Zeroes { + fn into(self) -> [usize; 2] { + [0; 2] + } +} +impl Into<[usize; 3]> for Zeroes { + fn into(self) -> [usize; 3] { + [0; 3] + } +} +impl Into<[usize; 4]> for Zeroes { + fn into(self) -> [usize; 4] { + [0; 4] + } +} + +fn zeroes_into() { + let [a, b, c] = Zeroes.into(); + let [d, e, f]: [_; 3] = Zeroes.into(); +} + +fn array_try_from(x: &[usize]) -> Result { + let [a, b] = x.try_into()?; + Ok(a + b) +} + +fn destructuring_assignment() { + let a: i32; + let b; + [a, b] = Default::default(); +} + +fn test_nested_array() { + let a: [_; 3]; + let b; + //~^ ERROR type annotations needed + [a, b] = Default::default(); +} + +fn test_nested_array_type_hint() { + let a: [_; 3]; + let b; + [a, b] = Default::default(); + let _: i32 = b[1]; +} + +fn test_working_nested_array() { + let a: i32; + [[a, _, _], _, _] = Default::default(); +} + +struct Foo([T; 2]); + +impl Default for Foo { + fn default() -> Self { + Foo([Default::default(); 2]) + } +} + +fn field_array() { + let a: i32; + let b; + Foo([a, b]) = Default::default(); +} + +fn main() {} diff --git a/tests/ui/pattern/slice-patterns-irrefutable.stderr b/tests/ui/pattern/slice-patterns-irrefutable.stderr new file mode 100644 index 000000000..fac99534f --- /dev/null +++ b/tests/ui/pattern/slice-patterns-irrefutable.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed for `[_; 3]` + --> $DIR/slice-patterns-irrefutable.rs:43:9 + | +LL | let b; + | ^ + | +help: consider giving `b` an explicit type, where the placeholders `_` are specified + | +LL | let b: [_; 3]; + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/pattern/slice-patterns-nested.rs b/tests/ui/pattern/slice-patterns-nested.rs new file mode 100644 index 000000000..077e0a139 --- /dev/null +++ b/tests/ui/pattern/slice-patterns-nested.rs @@ -0,0 +1,15 @@ +// check-pass +#![allow(unused_variables)] + +struct Zeroes; +struct Foo(T); + +impl Into<[usize; 3]> for Zeroes { + fn into(self) -> [usize; 3] { + [0; 3] + } +} + +fn main() { + let Foo([a, b, c]) = Foo(Zeroes.into()); +} diff --git a/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr b/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr index 4ecc6370d..9df7f0ffd 100644 --- a/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr +++ b/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr @@ -9,8 +9,12 @@ LL | LL | stuff(phantom_pinned) | -------------- borrow later used here | - = note: consider using a `let` binding to create a longer lived value = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = pin!(PhantomPinned); +LL ~ let phantom_pinned = identity(binding); + | error[E0716]: temporary value dropped while borrowed --> $DIR/lifetime_errors_on_promotion_misusage.rs:18:30 diff --git a/tests/ui/privacy/issue-113860-1.rs b/tests/ui/privacy/issue-113860-1.rs new file mode 100644 index 000000000..86ccca41f --- /dev/null +++ b/tests/ui/privacy/issue-113860-1.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +pub trait Trait { + //~^ ERROR trait has missing stability attribute + fn fun() {} + //~^ ERROR associated function has missing stability attribute +} + +impl Trait for u8 { + //~^ ERROR implementation has missing stability attribute + pub(self) fn fun() {} + //~^ ERROR visibility qualifiers are not permitted here [E0449] +} + +fn main() {} diff --git a/tests/ui/privacy/issue-113860-1.stderr b/tests/ui/privacy/issue-113860-1.stderr new file mode 100644 index 000000000..c33ce26f0 --- /dev/null +++ b/tests/ui/privacy/issue-113860-1.stderr @@ -0,0 +1,49 @@ +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/issue-113860-1.rs:12:5 + | +LL | pub(self) fn fun() {} + | ^^^^^^^^^ + | + = note: trait items always share the visibility of their trait + +error: module has missing stability attribute + --> $DIR/issue-113860-1.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | pub trait Trait { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: trait has missing stability attribute + --> $DIR/issue-113860-1.rs:4:1 + | +LL | / pub trait Trait { +LL | | +LL | | fn fun() {} +LL | | +LL | | } + | |_^ + +error: implementation has missing stability attribute + --> $DIR/issue-113860-1.rs:10:1 + | +LL | / impl Trait for u8 { +LL | | +LL | | pub(self) fn fun() {} +LL | | +LL | | } + | |_^ + +error: associated function has missing stability attribute + --> $DIR/issue-113860-1.rs:6:5 + | +LL | fn fun() {} + | ^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/privacy/issue-113860-2.rs b/tests/ui/privacy/issue-113860-2.rs new file mode 100644 index 000000000..59be19d88 --- /dev/null +++ b/tests/ui/privacy/issue-113860-2.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +pub trait Trait { + //~^ ERROR trait has missing stability attribute + type X; + //~^ ERROR associated type has missing stability attribute +} + +impl Trait for u8 { + //~^ ERROR implementation has missing stability attribute + pub(self) type X = Self; + //~^ ERROR visibility qualifiers are not permitted here [E0449] +} + +fn main() {} diff --git a/tests/ui/privacy/issue-113860-2.stderr b/tests/ui/privacy/issue-113860-2.stderr new file mode 100644 index 000000000..6748bc276 --- /dev/null +++ b/tests/ui/privacy/issue-113860-2.stderr @@ -0,0 +1,49 @@ +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/issue-113860-2.rs:12:5 + | +LL | pub(self) type X = Self; + | ^^^^^^^^^ + | + = note: trait items always share the visibility of their trait + +error: module has missing stability attribute + --> $DIR/issue-113860-2.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | pub trait Trait { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: trait has missing stability attribute + --> $DIR/issue-113860-2.rs:4:1 + | +LL | / pub trait Trait { +LL | | +LL | | type X; +LL | | +LL | | } + | |_^ + +error: implementation has missing stability attribute + --> $DIR/issue-113860-2.rs:10:1 + | +LL | / impl Trait for u8 { +LL | | +LL | | pub(self) type X = Self; +LL | | +LL | | } + | |_^ + +error: associated type has missing stability attribute + --> $DIR/issue-113860-2.rs:6:5 + | +LL | type X; + | ^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/privacy/issue-113860.rs b/tests/ui/privacy/issue-113860.rs new file mode 100644 index 000000000..b94c14fac --- /dev/null +++ b/tests/ui/privacy/issue-113860.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +pub trait Trait { + //~^ ERROR trait has missing stability attribute + const X: u32; + //~^ ERROR associated constant has missing stability attribute +} + +impl Trait for u8 { + //~^ ERROR implementation has missing stability attribute + pub(self) const X: u32 = 3; + //~^ ERROR visibility qualifiers are not permitted here [E0449] +} + +fn main() {} diff --git a/tests/ui/privacy/issue-113860.stderr b/tests/ui/privacy/issue-113860.stderr new file mode 100644 index 000000000..3204f4ff9 --- /dev/null +++ b/tests/ui/privacy/issue-113860.stderr @@ -0,0 +1,49 @@ +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/issue-113860.rs:12:5 + | +LL | pub(self) const X: u32 = 3; + | ^^^^^^^^^ + | + = note: trait items always share the visibility of their trait + +error: module has missing stability attribute + --> $DIR/issue-113860.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | pub trait Trait { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: trait has missing stability attribute + --> $DIR/issue-113860.rs:4:1 + | +LL | / pub trait Trait { +LL | | +LL | | const X: u32; +LL | | +LL | | } + | |_^ + +error: implementation has missing stability attribute + --> $DIR/issue-113860.rs:10:1 + | +LL | / impl Trait for u8 { +LL | | +LL | | pub(self) const X: u32 = 3; +LL | | +LL | | } + | |_^ + +error: associated constant has missing stability attribute + --> $DIR/issue-113860.rs:6:5 + | +LL | const X: u32; + | ^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/privacy/privacy2.rs b/tests/ui/privacy/privacy2.rs index c8fa436bd..212bc003e 100644 --- a/tests/ui/privacy/privacy2.rs +++ b/tests/ui/privacy/privacy2.rs @@ -1,3 +1,5 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes + #![feature(start, no_core)] #![no_core] // makes debugging this test *a lot* easier (during resolve) diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index c2a33ce1f..e7135d3fd 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -1,22 +1,22 @@ error[E0432]: unresolved import `bar::foo` - --> $DIR/privacy2.rs:17:9 + --> $DIR/privacy2.rs:19:9 | LL | use bar::foo; | ^^^^^^^^ no `foo` in `bar` error[E0603]: function import `foo` is private - --> $DIR/privacy2.rs:23:20 + --> $DIR/privacy2.rs:25:20 | LL | use bar::glob::foo; | ^^^ private function import | note: the function import `foo` is defined here... - --> $DIR/privacy2.rs:10:13 + --> $DIR/privacy2.rs:12:13 | LL | use foo; | ^^^ note: ...and refers to the function `foo` which is defined here - --> $DIR/privacy2.rs:14:1 + --> $DIR/privacy2.rs:16:1 | LL | pub fn foo() {} | ^^^^^^^^^^^^ consider importing it directly diff --git a/tests/ui/privacy/privacy3.rs b/tests/ui/privacy/privacy3.rs index 5a7cd76a9..3466f5bb1 100644 --- a/tests/ui/privacy/privacy3.rs +++ b/tests/ui/privacy/privacy3.rs @@ -1,3 +1,5 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes + #![feature(start, no_core)] #![no_core] // makes debugging this test *a lot* easier (during resolve) diff --git a/tests/ui/privacy/privacy3.stderr b/tests/ui/privacy/privacy3.stderr index 22c1e48b0..df66c8475 100644 --- a/tests/ui/privacy/privacy3.stderr +++ b/tests/ui/privacy/privacy3.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `bar::gpriv` - --> $DIR/privacy3.rs:18:9 + --> $DIR/privacy3.rs:20:9 | LL | use bar::gpriv; | ^^^^^^^^^^ no `gpriv` in `bar` diff --git a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr index d1052ce35..5f8076fc8 100644 --- a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr +++ b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr @@ -9,7 +9,7 @@ note: required by a bound in `Sealed` | LL | pub trait Sealed: self::b::Hidden { | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` - = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a::b::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it + = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `a::b::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it error: aborting due to previous error diff --git a/tests/ui/privacy/unnameable_types.rs b/tests/ui/privacy/unnameable_types.rs index eae20dd9d..46e249152 100644 --- a/tests/ui/privacy/unnameable_types.rs +++ b/tests/ui/privacy/unnameable_types.rs @@ -11,12 +11,12 @@ mod m { pub trait PubTr { //~ ERROR trait `PubTr` is reachable but cannot be named const C : i32 = 0; - type Alias; //~ ERROR associated type `PubTr::Alias` is reachable but cannot be named + type Alias; fn f() {} } impl PubTr for PubStruct { - type Alias = i32; //~ ERROR associated type `::Alias` is reachable but cannot be named + type Alias = i32; fn f() {} } } diff --git a/tests/ui/privacy/unnameable_types.stderr b/tests/ui/privacy/unnameable_types.stderr index 25eb5c943..904127525 100644 --- a/tests/ui/privacy/unnameable_types.stderr +++ b/tests/ui/privacy/unnameable_types.stderr @@ -22,17 +22,5 @@ error: trait `PubTr` is reachable but cannot be named LL | pub trait PubTr { | ^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` -error: associated type `PubTr::Alias` is reachable but cannot be named - --> $DIR/unnameable_types.rs:14:9 - | -LL | type Alias; - | ^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` - -error: associated type `::Alias` is reachable but cannot be named - --> $DIR/unnameable_types.rs:19:9 - | -LL | type Alias = i32; - | ^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout b/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout index 091862de3..4f8730053 100644 --- a/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout +++ b/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout @@ -19,17 +19,17 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#11), + span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#10), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#11), + span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#10), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#11), + span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#10), }, Ident { ident: "struct", @@ -206,17 +206,17 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#32), + span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#31), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#32), + span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#31), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#32), + span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#31), }, Punct { ch: '#', diff --git a/tests/ui/proc-macro/attr-stmt-expr.stdout b/tests/ui/proc-macro/attr-stmt-expr.stdout index f9b2305c7..c6d77e0ed 100644 --- a/tests/ui/proc-macro/attr-stmt-expr.stdout +++ b/tests/ui/proc-macro/attr-stmt-expr.stdout @@ -3,17 +3,17 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#8), + span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#7), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#8), + span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#7), }, ], - span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#8), + span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#7), }, Ident { ident: "struct", @@ -190,17 +190,17 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#29), + span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#28), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#29), + span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#28), }, ], - span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#29), + span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#28), }, Punct { ch: '#', diff --git a/tests/ui/proc-macro/auxiliary/issue-107113.rs b/tests/ui/proc-macro/auxiliary/issue-107113.rs new file mode 100644 index 000000000..b27d3fd2f --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/issue-107113.rs @@ -0,0 +1,13 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn main(_: TokenStream, item: TokenStream) -> TokenStream { + "fn main() -> std::io::Result<()> { () } ".parse().unwrap() +} diff --git a/tests/ui/proc-macro/capture-macro-rules-invoke.stdout b/tests/ui/proc-macro/capture-macro-rules-invoke.stdout index b88fbd3e8..01d71ff98 100644 --- a/tests/ui/proc-macro/capture-macro-rules-invoke.stdout +++ b/tests/ui/proc-macro/capture-macro-rules-invoke.stdout @@ -8,7 +8,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:36:24: 36:28 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:21:21: 21:26 (#4), + span: $DIR/capture-macro-rules-invoke.rs:21:21: 21:26 (#3), }, ] PRINT-BANG INPUT (DISPLAY): 1 + 1, { "a" }, let a = 1;, String, my_name, 'a, my_val = 30, @@ -37,12 +37,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:38:17: 38:18 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:14:29: 14:34 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:29: 14:34 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:14:34: 14:35 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:34: 14:35 (#7), }, Group { delimiter: None, @@ -60,12 +60,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:39:13: 39:20 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:14:36: 14:42 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:36: 14:42 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:14:42: 14:43 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:42: 14:43 (#7), }, Group { delimiter: None, @@ -90,12 +90,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:40:21: 40:22 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:14:44: 14:49 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:44: 14:49 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:14:49: 14:50 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:49: 14:50 (#7), }, Group { delimiter: None, @@ -105,12 +105,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:41:13: 41:19 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:14:51: 14:54 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:51: 14:54 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:14:54: 14:55 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:54: 14:55 (#7), }, Ident { ident: "my_name", @@ -119,7 +119,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:14:62: 14:63 (#8), + span: $DIR/capture-macro-rules-invoke.rs:14:62: 14:63 (#7), }, Group { delimiter: None, @@ -134,12 +134,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:43:13: 43:15 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:15:29: 15:38 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:29: 15:38 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:15:38: 15:39 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:38: 15:39 (#7), }, Group { delimiter: None, @@ -160,12 +160,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:44:22: 44:24 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:15:40: 15:45 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:40: 15:45 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:15:45: 15:46 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:45: 15:46 (#7), }, Group { delimiter: None, @@ -203,12 +203,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:45:26: 45:32 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:15:47: 15:52 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:47: 15:52 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:15:52: 15:53 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:52: 15:53 (#7), }, Group { delimiter: None, @@ -246,12 +246,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:46:16: 46:31 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:15:54: 15:58 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:54: 15:58 (#7), }, Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:15:58: 15:59 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:58: 15:59 (#7), }, Group { delimiter: Bracket, @@ -274,7 +274,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ Punct { ch: ',', spacing: Alone, - span: $DIR/capture-macro-rules-invoke.rs:15:63: 15:64 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:63: 15:64 (#7), }, Group { delimiter: None, @@ -291,7 +291,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:48:14: 48:16 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:15:65: 15:69 (#8), + span: $DIR/capture-macro-rules-invoke.rs:15:65: 15:69 (#7), }, ] PRINT-BANG INPUT (DISPLAY): (a, b) @@ -319,6 +319,6 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-macro-rules-invoke.rs:52:26: 52:32 (#0), }, ], - span: $DIR/capture-macro-rules-invoke.rs:27:21: 27:25 (#12), + span: $DIR/capture-macro-rules-invoke.rs:27:21: 27:25 (#11), }, ] diff --git a/tests/ui/proc-macro/capture-unglued-token.stdout b/tests/ui/proc-macro/capture-unglued-token.stdout index 7e6b54033..a0d2178f0 100644 --- a/tests/ui/proc-macro/capture-unglued-token.stdout +++ b/tests/ui/proc-macro/capture-unglued-token.stdout @@ -23,6 +23,6 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/capture-unglued-token.rs:19:30: 19:31 (#0), }, ], - span: $DIR/capture-unglued-token.rs:15:42: 15:48 (#4), + span: $DIR/capture-unglued-token.rs:15:42: 15:48 (#3), }, ] diff --git a/tests/ui/proc-macro/derive-helper-shadowed.rs b/tests/ui/proc-macro/derive-helper-shadowed.rs index e299454e0..ac14ece69 100644 --- a/tests/ui/proc-macro/derive-helper-shadowed.rs +++ b/tests/ui/proc-macro/derive-helper-shadowed.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs // aux-build:derive-helper-shadowed-2.rs diff --git a/tests/ui/proc-macro/derive-in-mod.rs b/tests/ui/proc-macro/derive-in-mod.rs index 8b5d4e9d0..96e9d93fe 100644 --- a/tests/ui/proc-macro/derive-in-mod.rs +++ b/tests/ui/proc-macro/derive-in-mod.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs extern crate test_macros; diff --git a/tests/ui/proc-macro/dollar-crate-issue-57089.stdout b/tests/ui/proc-macro/dollar-crate-issue-57089.stdout index 2622c005d..de4f0c000 100644 --- a/tests/ui/proc-macro/dollar-crate-issue-57089.stdout +++ b/tests/ui/proc-macro/dollar-crate-issue-57089.stdout @@ -2,79 +2,79 @@ PRINT-BANG INPUT (DISPLAY): struct M($crate :: S) ; PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/dollar-crate-issue-57089.rs:17:13: 17:19 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:13: 17:19 (#3), }, Ident { ident: "M", - span: $DIR/dollar-crate-issue-57089.rs:17:20: 17:21 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:20: 17:21 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/dollar-crate-issue-57089.rs:17:22: 17:28 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:22: 17:28 (#3), }, Punct { ch: ':', spacing: Joint, - span: $DIR/dollar-crate-issue-57089.rs:17:28: 17:29 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:28: 17:29 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/dollar-crate-issue-57089.rs:17:29: 17:30 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:29: 17:30 (#3), }, Ident { ident: "S", - span: $DIR/dollar-crate-issue-57089.rs:17:30: 17:31 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:30: 17:31 (#3), }, ], - span: $DIR/dollar-crate-issue-57089.rs:17:21: 17:32 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:21: 17:32 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/dollar-crate-issue-57089.rs:17:32: 17:33 (#4), + span: $DIR/dollar-crate-issue-57089.rs:17:32: 17:33 (#3), }, ] PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/dollar-crate-issue-57089.rs:21:9: 21:15 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:9: 21:15 (#3), }, Ident { ident: "A", - span: $DIR/dollar-crate-issue-57089.rs:21:16: 21:17 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:16: 21:17 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/dollar-crate-issue-57089.rs:21:18: 21:24 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:18: 21:24 (#3), }, Punct { ch: ':', spacing: Joint, - span: $DIR/dollar-crate-issue-57089.rs:21:24: 21:25 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:24: 21:25 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/dollar-crate-issue-57089.rs:21:25: 21:26 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:25: 21:26 (#3), }, Ident { ident: "S", - span: $DIR/dollar-crate-issue-57089.rs:21:26: 21:27 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:26: 21:27 (#3), }, ], - span: $DIR/dollar-crate-issue-57089.rs:21:17: 21:28 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:17: 21:28 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/dollar-crate-issue-57089.rs:21:28: 21:29 (#4), + span: $DIR/dollar-crate-issue-57089.rs:21:28: 21:29 (#3), }, ] diff --git a/tests/ui/proc-macro/dollar-crate-issue-62325.stdout b/tests/ui/proc-macro/dollar-crate-issue-62325.stdout index a91908239..c7e72bf4f 100644 --- a/tests/ui/proc-macro/dollar-crate-issue-62325.stdout +++ b/tests/ui/proc-macro/dollar-crate-issue-62325.stdout @@ -2,109 +2,109 @@ PRINT-ATTR INPUT (DISPLAY): struct A(identity! ($crate :: S)) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/dollar-crate-issue-62325.rs:19:5: 19:11 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:5: 19:11 (#3), }, Ident { ident: "A", - span: $DIR/dollar-crate-issue-62325.rs:19:12: 19:13 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:12: 19:13 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "identity", - span: $DIR/dollar-crate-issue-62325.rs:19:14: 19:22 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:14: 19:22 (#3), }, Punct { ch: '!', spacing: Alone, - span: $DIR/dollar-crate-issue-62325.rs:19:22: 19:23 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:22: 19:23 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/dollar-crate-issue-62325.rs:19:24: 19:30 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:24: 19:30 (#3), }, Punct { ch: ':', spacing: Joint, - span: $DIR/dollar-crate-issue-62325.rs:19:30: 19:31 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:30: 19:31 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/dollar-crate-issue-62325.rs:19:31: 19:32 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:31: 19:32 (#3), }, Ident { ident: "S", - span: $DIR/dollar-crate-issue-62325.rs:19:32: 19:33 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:32: 19:33 (#3), }, ], - span: $DIR/dollar-crate-issue-62325.rs:19:23: 19:34 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:23: 19:34 (#3), }, ], - span: $DIR/dollar-crate-issue-62325.rs:19:13: 19:35 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:13: 19:35 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/dollar-crate-issue-62325.rs:19:35: 19:36 (#4), + span: $DIR/dollar-crate-issue-62325.rs:19:35: 19:36 (#3), }, ] PRINT-ATTR INPUT (DISPLAY): struct B(identity! ($crate :: S)) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:21:5: 21:11 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:5: 21:11 (#11), }, Ident { ident: "B", - span: $DIR/auxiliary/dollar-crate-external.rs:21:12: 21:13 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:12: 21:13 (#11), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "identity", - span: $DIR/auxiliary/dollar-crate-external.rs:21:14: 21:22 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:14: 21:22 (#11), }, Punct { ch: '!', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:21:22: 21:23 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:22: 21:23 (#11), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:21:24: 21:30 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:24: 21:30 (#11), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:21:30: 21:31 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:30: 21:31 (#11), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:21:31: 21:32 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:31: 21:32 (#11), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:21:32: 21:33 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:32: 21:33 (#11), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:21:23: 21:34 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:23: 21:34 (#11), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:21:13: 21:35 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:13: 21:35 (#11), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:21:35: 21:36 (#12), + span: $DIR/auxiliary/dollar-crate-external.rs:21:35: 21:36 (#11), }, ] diff --git a/tests/ui/proc-macro/dollar-crate.stdout b/tests/ui/proc-macro/dollar-crate.stdout index 4e169d47e..0f5f87cec 100644 --- a/tests/ui/proc-macro/dollar-crate.stdout +++ b/tests/ui/proc-macro/dollar-crate.stdout @@ -2,239 +2,239 @@ PRINT-BANG INPUT (DISPLAY): struct M($crate :: S) ; PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/dollar-crate.rs:20:17: 20:23 (#4), + span: $DIR/dollar-crate.rs:20:17: 20:23 (#3), }, Ident { ident: "M", - span: $DIR/dollar-crate.rs:20:24: 20:25 (#4), + span: $DIR/dollar-crate.rs:20:24: 20:25 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/dollar-crate.rs:20:26: 20:32 (#4), + span: $DIR/dollar-crate.rs:20:26: 20:32 (#3), }, Punct { ch: ':', spacing: Joint, - span: $DIR/dollar-crate.rs:20:32: 20:33 (#4), + span: $DIR/dollar-crate.rs:20:32: 20:33 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/dollar-crate.rs:20:33: 20:34 (#4), + span: $DIR/dollar-crate.rs:20:33: 20:34 (#3), }, Ident { ident: "S", - span: $DIR/dollar-crate.rs:20:34: 20:35 (#4), + span: $DIR/dollar-crate.rs:20:34: 20:35 (#3), }, ], - span: $DIR/dollar-crate.rs:20:25: 20:36 (#4), + span: $DIR/dollar-crate.rs:20:25: 20:36 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/dollar-crate.rs:20:36: 20:37 (#4), + span: $DIR/dollar-crate.rs:20:36: 20:37 (#3), }, ] PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/dollar-crate.rs:24:13: 24:19 (#4), + span: $DIR/dollar-crate.rs:24:13: 24:19 (#3), }, Ident { ident: "A", - span: $DIR/dollar-crate.rs:24:20: 24:21 (#4), + span: $DIR/dollar-crate.rs:24:20: 24:21 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/dollar-crate.rs:24:22: 24:28 (#4), + span: $DIR/dollar-crate.rs:24:22: 24:28 (#3), }, Punct { ch: ':', spacing: Joint, - span: $DIR/dollar-crate.rs:24:28: 24:29 (#4), + span: $DIR/dollar-crate.rs:24:28: 24:29 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/dollar-crate.rs:24:29: 24:30 (#4), + span: $DIR/dollar-crate.rs:24:29: 24:30 (#3), }, Ident { ident: "S", - span: $DIR/dollar-crate.rs:24:30: 24:31 (#4), + span: $DIR/dollar-crate.rs:24:30: 24:31 (#3), }, ], - span: $DIR/dollar-crate.rs:24:21: 24:32 (#4), + span: $DIR/dollar-crate.rs:24:21: 24:32 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/dollar-crate.rs:24:32: 24:33 (#4), + span: $DIR/dollar-crate.rs:24:32: 24:33 (#3), }, ] PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S) ; PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/dollar-crate.rs:27:13: 27:19 (#4), + span: $DIR/dollar-crate.rs:27:13: 27:19 (#3), }, Ident { ident: "D", - span: $DIR/dollar-crate.rs:27:20: 27:21 (#4), + span: $DIR/dollar-crate.rs:27:20: 27:21 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/dollar-crate.rs:27:22: 27:28 (#4), + span: $DIR/dollar-crate.rs:27:22: 27:28 (#3), }, Punct { ch: ':', spacing: Joint, - span: $DIR/dollar-crate.rs:27:28: 27:29 (#4), + span: $DIR/dollar-crate.rs:27:28: 27:29 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/dollar-crate.rs:27:29: 27:30 (#4), + span: $DIR/dollar-crate.rs:27:29: 27:30 (#3), }, Ident { ident: "S", - span: $DIR/dollar-crate.rs:27:30: 27:31 (#4), + span: $DIR/dollar-crate.rs:27:30: 27:31 (#3), }, ], - span: $DIR/dollar-crate.rs:27:21: 27:32 (#4), + span: $DIR/dollar-crate.rs:27:21: 27:32 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/dollar-crate.rs:27:32: 27:33 (#4), + span: $DIR/dollar-crate.rs:27:32: 27:33 (#3), }, ] PRINT-BANG INPUT (DISPLAY): struct M($crate :: S) ; PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:7:13: 7:19 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:13: 7:19 (#14), }, Ident { ident: "M", - span: $DIR/auxiliary/dollar-crate-external.rs:7:20: 7:21 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:20: 7:21 (#14), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:7:22: 7:28 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:22: 7:28 (#14), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:7:28: 7:29 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:28: 7:29 (#14), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:7:29: 7:30 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:29: 7:30 (#14), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:7:30: 7:31 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:30: 7:31 (#14), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:7:21: 7:32 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:21: 7:32 (#14), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:7:32: 7:33 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:7:32: 7:33 (#14), }, ] PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:11:9: 11:15 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:9: 11:15 (#14), }, Ident { ident: "A", - span: $DIR/auxiliary/dollar-crate-external.rs:11:16: 11:17 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:16: 11:17 (#14), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:11:18: 11:24 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:18: 11:24 (#14), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:11:24: 11:25 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:24: 11:25 (#14), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:11:25: 11:26 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:25: 11:26 (#14), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:11:26: 11:27 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:26: 11:27 (#14), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:11:17: 11:28 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:17: 11:28 (#14), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:11:28: 11:29 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:11:28: 11:29 (#14), }, ] PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S) ; PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/dollar-crate-external.rs:14:9: 14:15 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:9: 14:15 (#14), }, Ident { ident: "D", - span: $DIR/auxiliary/dollar-crate-external.rs:14:16: 14:17 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:16: 14:17 (#14), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "$crate", - span: $DIR/auxiliary/dollar-crate-external.rs:14:18: 14:24 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:18: 14:24 (#14), }, Punct { ch: ':', spacing: Joint, - span: $DIR/auxiliary/dollar-crate-external.rs:14:24: 14:25 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:24: 14:25 (#14), }, Punct { ch: ':', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:14:25: 14:26 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:25: 14:26 (#14), }, Ident { ident: "S", - span: $DIR/auxiliary/dollar-crate-external.rs:14:26: 14:27 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:26: 14:27 (#14), }, ], - span: $DIR/auxiliary/dollar-crate-external.rs:14:17: 14:28 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:17: 14:28 (#14), }, Punct { ch: ';', spacing: Alone, - span: $DIR/auxiliary/dollar-crate-external.rs:14:28: 14:29 (#15), + span: $DIR/auxiliary/dollar-crate-external.rs:14:28: 14:29 (#14), }, ] diff --git a/tests/ui/proc-macro/edition-imports-2018.rs b/tests/ui/proc-macro/edition-imports-2018.rs index 5a77cd4ef..765673531 100644 --- a/tests/ui/proc-macro/edition-imports-2018.rs +++ b/tests/ui/proc-macro/edition-imports-2018.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // edition:2018 // aux-build:edition-imports-2015.rs diff --git a/tests/ui/proc-macro/expand-to-derive.stdout b/tests/ui/proc-macro/expand-to-derive.stdout index a6437982a..39f009183 100644 --- a/tests/ui/proc-macro/expand-to-derive.stdout +++ b/tests/ui/proc-macro/expand-to-derive.stdout @@ -6,35 +6,35 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/expand-to-derive.rs:16:9: 16:15 (#4), + span: $DIR/expand-to-derive.rs:16:9: 16:15 (#3), }, Ident { ident: "Foo", - span: $DIR/expand-to-derive.rs:16:16: 16:19 (#4), + span: $DIR/expand-to-derive.rs:16:16: 16:19 (#3), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "field", - span: $DIR/expand-to-derive.rs:18:13: 18:18 (#4), + span: $DIR/expand-to-derive.rs:18:13: 18:18 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/expand-to-derive.rs:18:18: 18:19 (#4), + span: $DIR/expand-to-derive.rs:18:18: 18:19 (#3), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "bool", - span: $DIR/expand-to-derive.rs:18:21: 18:25 (#4), + span: $DIR/expand-to-derive.rs:18:21: 18:25 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/expand-to-derive.rs:18:25: 18:26 (#4), + span: $DIR/expand-to-derive.rs:18:25: 18:26 (#3), }, Group { delimiter: Brace, @@ -90,15 +90,15 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ kind: Integer, symbol: "0", suffix: None, - span: $DIR/expand-to-derive.rs:20:17: 20:18 (#4), + span: $DIR/expand-to-derive.rs:20:17: 20:18 (#3), }, ], - span: $DIR/expand-to-derive.rs:18:27: 21:14 (#4), + span: $DIR/expand-to-derive.rs:18:27: 21:14 (#3), }, ], - span: $DIR/expand-to-derive.rs:18:20: 21:15 (#4), + span: $DIR/expand-to-derive.rs:18:20: 21:15 (#3), }, ], - span: $DIR/expand-to-derive.rs:16:20: 22:10 (#4), + span: $DIR/expand-to-derive.rs:16:20: 22:10 (#3), }, ] diff --git a/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout b/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout index 686d53e88..40181efc0 100644 --- a/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout +++ b/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout @@ -3,39 +3,39 @@ PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = #[allow(warning PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #4 bytes(299..303), + span: #3 bytes(299..303), }, Ident { ident: "E", - span: #4 bytes(304..305), + span: #3 bytes(304..305), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "V", - span: #4 bytes(320..321), + span: #3 bytes(320..321), }, Punct { ch: '=', spacing: Alone, - span: #4 bytes(322..323), + span: #3 bytes(322..323), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: #4 bytes(326..329), + span: #3 bytes(326..329), }, Ident { ident: "_", - span: #4 bytes(330..331), + span: #3 bytes(330..331), }, Punct { ch: '=', spacing: Alone, - span: #4 bytes(332..333), + span: #3 bytes(332..333), }, Group { delimiter: None, @@ -97,29 +97,29 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #0 bytes(560..561), }, ], - span: #4 bytes(334..339), + span: #3 bytes(334..339), }, Punct { ch: ';', spacing: Alone, - span: #4 bytes(339..340), + span: #3 bytes(339..340), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #4 bytes(341..342), + span: #3 bytes(341..342), }, ], - span: #4 bytes(324..344), + span: #3 bytes(324..344), }, Punct { ch: ',', spacing: Alone, - span: #4 bytes(344..345), + span: #3 bytes(344..345), }, ], - span: #4 bytes(306..355), + span: #3 bytes(306..355), }, ] PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { 0; } ; 0 }, } @@ -127,39 +127,39 @@ PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { 0 } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #8 bytes(423..427), + span: #7 bytes(423..427), }, Ident { ident: "E", - span: #8 bytes(428..429), + span: #7 bytes(428..429), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "V", - span: #8 bytes(444..445), + span: #7 bytes(444..445), }, Punct { ch: '=', spacing: Alone, - span: #8 bytes(446..447), + span: #7 bytes(446..447), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: #8 bytes(450..453), + span: #7 bytes(450..453), }, Ident { ident: "_", - span: #8 bytes(454..455), + span: #7 bytes(454..455), }, Punct { ch: '=', spacing: Alone, - span: #8 bytes(456..457), + span: #7 bytes(456..457), }, Group { delimiter: Brace, @@ -174,71 +174,71 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #0 bytes(578..579), }, ], - span: #8 bytes(460..465), + span: #7 bytes(460..465), }, ], - span: #8 bytes(458..467), + span: #7 bytes(458..467), }, Punct { ch: ';', spacing: Alone, - span: #8 bytes(467..468), + span: #7 bytes(467..468), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #8 bytes(469..470), + span: #7 bytes(469..470), }, ], - span: #8 bytes(448..472), + span: #7 bytes(448..472), }, Punct { ch: ',', spacing: Alone, - span: #8 bytes(472..473), + span: #7 bytes(472..473), }, ], - span: #8 bytes(430..483), + span: #7 bytes(430..483), }, ] PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { {} } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #12 bytes(423..427), + span: #11 bytes(423..427), }, Ident { ident: "E", - span: #12 bytes(428..429), + span: #11 bytes(428..429), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "V", - span: #12 bytes(444..445), + span: #11 bytes(444..445), }, Punct { ch: '=', spacing: Alone, - span: #12 bytes(446..447), + span: #11 bytes(446..447), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: #12 bytes(450..453), + span: #11 bytes(450..453), }, Ident { ident: "_", - span: #12 bytes(454..455), + span: #11 bytes(454..455), }, Punct { ch: '=', spacing: Alone, - span: #12 bytes(456..457), + span: #11 bytes(456..457), }, Group { delimiter: Brace, @@ -252,32 +252,32 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #0 bytes(596..598), }, ], - span: #12 bytes(460..465), + span: #11 bytes(460..465), }, ], - span: #12 bytes(458..467), + span: #11 bytes(458..467), }, Punct { ch: ';', spacing: Alone, - span: #12 bytes(467..468), + span: #11 bytes(467..468), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #12 bytes(469..470), + span: #11 bytes(469..470), }, ], - span: #12 bytes(448..472), + span: #11 bytes(448..472), }, Punct { ch: ',', spacing: Alone, - span: #12 bytes(472..473), + span: #11 bytes(472..473), }, ], - span: #12 bytes(430..483), + span: #11 bytes(430..483), }, ] PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { PATH; } ; 0 }, } @@ -285,39 +285,39 @@ PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { PATH } ; 0 }, PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #16 bytes(423..427), + span: #15 bytes(423..427), }, Ident { ident: "E", - span: #16 bytes(428..429), + span: #15 bytes(428..429), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "V", - span: #16 bytes(444..445), + span: #15 bytes(444..445), }, Punct { ch: '=', spacing: Alone, - span: #16 bytes(446..447), + span: #15 bytes(446..447), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: #16 bytes(450..453), + span: #15 bytes(450..453), }, Ident { ident: "_", - span: #16 bytes(454..455), + span: #15 bytes(454..455), }, Punct { ch: '=', spacing: Alone, - span: #16 bytes(456..457), + span: #15 bytes(456..457), }, Group { delimiter: Brace, @@ -330,32 +330,32 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #0 bytes(615..619), }, ], - span: #16 bytes(460..465), + span: #15 bytes(460..465), }, ], - span: #16 bytes(458..467), + span: #15 bytes(458..467), }, Punct { ch: ';', spacing: Alone, - span: #16 bytes(467..468), + span: #15 bytes(467..468), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #16 bytes(469..470), + span: #15 bytes(469..470), }, ], - span: #16 bytes(448..472), + span: #15 bytes(448..472), }, Punct { ch: ',', spacing: Alone, - span: #16 bytes(472..473), + span: #15 bytes(472..473), }, ], - span: #16 bytes(430..483), + span: #15 bytes(430..483), }, ] PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { 0 + 1; } ; 0 }, } @@ -363,39 +363,39 @@ PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { 0 + 1 } ; 0 } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #20 bytes(423..427), + span: #19 bytes(423..427), }, Ident { ident: "E", - span: #20 bytes(428..429), + span: #19 bytes(428..429), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "V", - span: #20 bytes(444..445), + span: #19 bytes(444..445), }, Punct { ch: '=', spacing: Alone, - span: #20 bytes(446..447), + span: #19 bytes(446..447), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: #20 bytes(450..453), + span: #19 bytes(450..453), }, Ident { ident: "_", - span: #20 bytes(454..455), + span: #19 bytes(454..455), }, Punct { ch: '=', spacing: Alone, - span: #20 bytes(456..457), + span: #19 bytes(456..457), }, Group { delimiter: Brace, @@ -421,32 +421,32 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #0 bytes(640..641), }, ], - span: #20 bytes(460..465), + span: #19 bytes(460..465), }, ], - span: #20 bytes(458..467), + span: #19 bytes(458..467), }, Punct { ch: ';', spacing: Alone, - span: #20 bytes(467..468), + span: #19 bytes(467..468), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #20 bytes(469..470), + span: #19 bytes(469..470), }, ], - span: #20 bytes(448..472), + span: #19 bytes(448..472), }, Punct { ch: ',', spacing: Alone, - span: #20 bytes(472..473), + span: #19 bytes(472..473), }, ], - span: #20 bytes(430..483), + span: #19 bytes(430..483), }, ] PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { PATH + 1; } ; 0 }, } @@ -454,39 +454,39 @@ PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { PATH + 1 } ; PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #24 bytes(423..427), + span: #23 bytes(423..427), }, Ident { ident: "E", - span: #24 bytes(428..429), + span: #23 bytes(428..429), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "V", - span: #24 bytes(444..445), + span: #23 bytes(444..445), }, Punct { ch: '=', spacing: Alone, - span: #24 bytes(446..447), + span: #23 bytes(446..447), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: #24 bytes(450..453), + span: #23 bytes(450..453), }, Ident { ident: "_", - span: #24 bytes(454..455), + span: #23 bytes(454..455), }, Punct { ch: '=', spacing: Alone, - span: #24 bytes(456..457), + span: #23 bytes(456..457), }, Group { delimiter: Brace, @@ -510,31 +510,31 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #0 bytes(665..666), }, ], - span: #24 bytes(460..465), + span: #23 bytes(460..465), }, ], - span: #24 bytes(458..467), + span: #23 bytes(458..467), }, Punct { ch: ';', spacing: Alone, - span: #24 bytes(467..468), + span: #23 bytes(467..468), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #24 bytes(469..470), + span: #23 bytes(469..470), }, ], - span: #24 bytes(448..472), + span: #23 bytes(448..472), }, Punct { ch: ',', spacing: Alone, - span: #24 bytes(472..473), + span: #23 bytes(472..473), }, ], - span: #24 bytes(430..483), + span: #23 bytes(430..483), }, ] diff --git a/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs b/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs index a6e64e1b1..38f61c36c 100644 --- a/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs +++ b/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // edition:2018 extern crate proc_macro; diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import.rs b/tests/ui/proc-macro/helper-attr-blocked-by-import.rs index 2e20a3de6..344323122 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import.rs +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use(Empty)] diff --git a/tests/ui/proc-macro/input-interpolated.stdout b/tests/ui/proc-macro/input-interpolated.stdout index 34566c780..6a8789b2c 100644 --- a/tests/ui/proc-macro/input-interpolated.stdout +++ b/tests/ui/proc-macro/input-interpolated.stdout @@ -9,7 +9,7 @@ PRINT-ATTR INPUT (DISPLAY): const A : u8 = 0 ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "const", - span: #4 bytes(416..421), + span: #3 bytes(416..421), }, Ident { ident: "A", @@ -18,34 +18,34 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: ':', spacing: Alone, - span: #4 bytes(424..425), + span: #3 bytes(424..425), }, Ident { ident: "u8", - span: #4 bytes(426..428), + span: #3 bytes(426..428), }, Punct { ch: '=', spacing: Alone, - span: #4 bytes(429..430), + span: #3 bytes(429..430), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: #4 bytes(431..432), + span: #3 bytes(431..432), }, Punct { ch: ';', spacing: Alone, - span: #4 bytes(432..433), + span: #3 bytes(432..433), }, ] PRINT-DERIVE INPUT (DISPLAY): struct A {} PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: #4 bytes(468..474), + span: #3 bytes(468..474), }, Ident { ident: "A", @@ -54,6 +54,6 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Group { delimiter: Brace, stream: TokenStream [], - span: #4 bytes(478..480), + span: #3 bytes(478..480), }, ] diff --git a/tests/ui/proc-macro/issue-107113-wrap.rs b/tests/ui/proc-macro/issue-107113-wrap.rs new file mode 100644 index 000000000..bc5b44963 --- /dev/null +++ b/tests/ui/proc-macro/issue-107113-wrap.rs @@ -0,0 +1,8 @@ +// edition:2021 +// aux-build:issue-107113.rs + +#[macro_use] +extern crate issue_107113; + +#[issue_107113::main] //~ ERROR mismatched types [E0308] +async fn main() -> std::io::Result<()> {} diff --git a/tests/ui/proc-macro/issue-107113-wrap.stderr b/tests/ui/proc-macro/issue-107113-wrap.stderr new file mode 100644 index 000000000..4122253d2 --- /dev/null +++ b/tests/ui/proc-macro/issue-107113-wrap.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/issue-107113-wrap.rs:7:1 + | +LL | #[issue_107113::main] + | ^^^^^^^^^^^^^^^^^^^^^ + | | + | expected `Result<(), Error>`, found `()` + | expected `Result<(), std::io::Error>` because of return type + | + = note: expected enum `Result<(), std::io::Error>` + found unit type `()` + = note: this error originates in the attribute macro `issue_107113::main` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/proc-macro/issue-53481.rs b/tests/ui/proc-macro/issue-53481.rs index ae10a3baa..922e60a4c 100644 --- a/tests/ui/proc-macro/issue-53481.rs +++ b/tests/ui/proc-macro/issue-53481.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use] diff --git a/tests/ui/proc-macro/issue-75734-pp-paren.stdout b/tests/ui/proc-macro/issue-75734-pp-paren.stdout index 0fda6654f..2f7c013e9 100644 --- a/tests/ui/proc-macro/issue-75734-pp-paren.stdout +++ b/tests/ui/proc-macro/issue-75734-pp-paren.stdout @@ -118,17 +118,17 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/issue-75734-pp-paren.rs:25:16: 25:17 (#0), }, ], - span: $DIR/issue-75734-pp-paren.rs:17:21: 17:25 (#7), + span: $DIR/issue-75734-pp-paren.rs:17:21: 17:25 (#6), }, Punct { ch: '*', spacing: Alone, - span: $DIR/issue-75734-pp-paren.rs:17:26: 17:27 (#7), + span: $DIR/issue-75734-pp-paren.rs:17:26: 17:27 (#6), }, Literal { kind: Integer, symbol: "2", suffix: None, - span: $DIR/issue-75734-pp-paren.rs:17:28: 17:29 (#7), + span: $DIR/issue-75734-pp-paren.rs:17:28: 17:29 (#6), }, ] diff --git a/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout b/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout index 60a400a5d..ae5e94008 100644 --- a/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout +++ b/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout @@ -5,12 +5,12 @@ PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): foo! { #[fake_attr] mod bar { #! [doc = PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "foo", - span: $DIR/issue-78675-captured-inner-attrs.rs:20:9: 20:12 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:20:9: 20:12 (#3), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-78675-captured-inner-attrs.rs:20:12: 20:13 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:20:12: 20:13 (#3), }, Group { delimiter: Brace, @@ -18,17 +18,17 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-78675-captured-inner-attrs.rs:21:13: 21:14 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:21:13: 21:14 (#3), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "fake_attr", - span: $DIR/issue-78675-captured-inner-attrs.rs:21:15: 21:24 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:21:15: 21:24 (#3), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:21:14: 21:25 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:21:14: 21:25 (#3), }, Group { delimiter: None, @@ -79,9 +79,9 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/issue-78675-captured-inner-attrs.rs:27:13: 29:6 (#0), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#3), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:20:14: 23:10 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:20:14: 23:10 (#3), }, ] diff --git a/tests/ui/proc-macro/issue-80760-empty-stmt.stdout b/tests/ui/proc-macro/issue-80760-empty-stmt.stdout index 4b7ed8743..82f52e4bc 100644 --- a/tests/ui/proc-macro/issue-80760-empty-stmt.stdout +++ b/tests/ui/proc-macro/issue-80760-empty-stmt.stdout @@ -9,6 +9,6 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/issue-80760-empty-stmt.rs:25:17: 25:18 (#0), }, ], - span: $DIR/issue-80760-empty-stmt.rs:13:21: 13:23 (#4), + span: $DIR/issue-80760-empty-stmt.rs:13:21: 13:23 (#3), }, ] diff --git a/tests/ui/proc-macro/load-panic-backtrace.stderr b/tests/ui/proc-macro/load-panic-backtrace.stderr index 45d4fd1c9..c1a642713 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.stderr +++ b/tests/ui/proc-macro/load-panic-backtrace.stderr @@ -1,4 +1,5 @@ -at 'panic-derive', $DIR/auxiliary/test-macros.rs:43:5 +at $DIR/auxiliary/test-macros.rs:43:5: +panic-derive error: proc-macro derive panicked --> $DIR/load-panic-backtrace.rs:11:10 | diff --git a/tests/ui/proc-macro/macro-rules-derive-cfg.stdout b/tests/ui/proc-macro/macro-rules-derive-cfg.stdout index 74641058e..aee0f966d 100644 --- a/tests/ui/proc-macro/macro-rules-derive-cfg.stdout +++ b/tests/ui/proc-macro/macro-rules-derive-cfg.stdout @@ -10,76 +10,76 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/macro-rules-derive-cfg.rs:17:9: 17:15 (#4), + span: $DIR/macro-rules-derive-cfg.rs:17:9: 17:15 (#3), }, Ident { ident: "Foo", - span: $DIR/macro-rules-derive-cfg.rs:17:16: 17:19 (#4), + span: $DIR/macro-rules-derive-cfg.rs:17:16: 17:19 (#3), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "val", - span: $DIR/macro-rules-derive-cfg.rs:18:13: 18:16 (#4), + span: $DIR/macro-rules-derive-cfg.rs:18:13: 18:16 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:18:16: 18:17 (#4), + span: $DIR/macro-rules-derive-cfg.rs:18:16: 18:17 (#3), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "bool", - span: $DIR/macro-rules-derive-cfg.rs:18:19: 18:23 (#4), + span: $DIR/macro-rules-derive-cfg.rs:18:19: 18:23 (#3), }, Punct { ch: ';', spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:18:23: 18:24 (#4), + span: $DIR/macro-rules-derive-cfg.rs:18:23: 18:24 (#3), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "let", - span: $DIR/macro-rules-derive-cfg.rs:19:17: 19:20 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:17: 19:20 (#3), }, Ident { ident: "a", - span: $DIR/macro-rules-derive-cfg.rs:19:21: 19:22 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:21: 19:22 (#3), }, Punct { ch: '=', spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:19:23: 19:24 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:23: 19:24 (#3), }, Punct { ch: '#', spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#3), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/macro-rules-derive-cfg.rs:19:48: 19:59 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:48: 19:59 (#3), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "first", - span: $DIR/macro-rules-derive-cfg.rs:19:60: 19:65 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:60: 19:65 (#3), }, ], - span: $DIR/macro-rules-derive-cfg.rs:19:59: 19:66 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:59: 19:66 (#3), }, ], - span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#3), }, Punct { ch: '#', @@ -151,21 +151,21 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: ';', spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:19:74: 19:75 (#4), + span: $DIR/macro-rules-derive-cfg.rs:19:74: 19:75 (#3), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: $DIR/macro-rules-derive-cfg.rs:20:17: 20:18 (#4), + span: $DIR/macro-rules-derive-cfg.rs:20:17: 20:18 (#3), }, ], - span: $DIR/macro-rules-derive-cfg.rs:18:25: 21:14 (#4), + span: $DIR/macro-rules-derive-cfg.rs:18:25: 21:14 (#3), }, ], - span: $DIR/macro-rules-derive-cfg.rs:18:18: 21:15 (#4), + span: $DIR/macro-rules-derive-cfg.rs:18:18: 21:15 (#3), }, ], - span: $DIR/macro-rules-derive-cfg.rs:17:20: 22:10 (#4), + span: $DIR/macro-rules-derive-cfg.rs:17:20: 22:10 (#3), }, ] diff --git a/tests/ui/proc-macro/macro-use-attr.rs b/tests/ui/proc-macro/macro-use-attr.rs index b101c09ed..d275fb6a8 100644 --- a/tests/ui/proc-macro/macro-use-attr.rs +++ b/tests/ui/proc-macro/macro-use-attr.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use] diff --git a/tests/ui/proc-macro/macro-use-bang.rs b/tests/ui/proc-macro/macro-use-bang.rs index 4a0bf0b2f..e3174fd44 100644 --- a/tests/ui/proc-macro/macro-use-bang.rs +++ b/tests/ui/proc-macro/macro-use-bang.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use] diff --git a/tests/ui/proc-macro/meta-macro-hygiene.rs b/tests/ui/proc-macro/meta-macro-hygiene.rs index 70b8d8da1..72fd88e11 100644 --- a/tests/ui/proc-macro/meta-macro-hygiene.rs +++ b/tests/ui/proc-macro/meta-macro-hygiene.rs @@ -3,8 +3,10 @@ // edition:2018 // compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene -Z trim-diagnostic-paths=no // check-pass +// ignore-tidy-linelength // normalize-stdout-test "\d+#" -> "0#" // normalize-stdout-test "expn\d{3,}" -> "expnNNN" +// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */" // // We don't care about symbol ids, so we set them all to 0 // in the stdout @@ -22,7 +24,7 @@ macro_rules! produce_it { // the fact that `print_def_site` is produced by a // `macro_rules!` macro in `make_macro`). meta_macro::print_def_site!($crate::dummy!()); - } + }; } fn main() { diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout index 6b7b0c819..eeb7179e6 100644 --- a/tests/ui/proc-macro/meta-macro-hygiene.stdout +++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout @@ -1,14 +1,16 @@ -Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) -Input: TokenStream [Ident { ident: "$crate", span: $DIR/meta-macro-hygiene.rs:24:37: 24:43 (#4) }, Punct { ch: ':', spacing: Joint, span: $DIR/meta-macro-hygiene.rs:24:43: 24:44 (#4) }, Punct { ch: ':', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:24:44: 24:45 (#4) }, Ident { ident: "dummy", span: $DIR/meta-macro-hygiene.rs:24:45: 24:50 (#4) }, Punct { ch: '!', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:24:50: 24:51 (#4) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/meta-macro-hygiene.rs:24:51: 24:53 (#4) }] -Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Punct { ch: ':', spacing: Joint, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Punct { ch: ':', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Ident { ident: "dummy", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Punct { ch: '!', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#5) }] +Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) +Input: TokenStream [Ident { ident: "$crate", span: $DIR/meta-macro-hygiene.rs:26:37: 26:43 (#3) }, Punct { ch: ':', spacing: Joint, span: $DIR/meta-macro-hygiene.rs:26:43: 26:44 (#3) }, Punct { ch: ':', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:26:44: 26:45 (#3) }, Ident { ident: "dummy", span: $DIR/meta-macro-hygiene.rs:26:45: 26:50 (#3) }, Punct { ch: '!', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:26:50: 26:51 (#3) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/meta-macro-hygiene.rs:26:51: 26:53 (#3) }] +Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Punct { ch: ':', spacing: Joint, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Punct { ch: ':', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Ident { ident: "dummy", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Punct { ch: '!', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }] #![feature /* 0#0 */(prelude_import)] // aux-build:make-macro.rs // aux-build:meta-macro.rs // edition:2018 // compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene -Z trim-diagnostic-paths=no // check-pass +// ignore-tidy-linelength // normalize-stdout-test "\d+#" -> "0#" // normalize-stdout-test "expn\d{3,}" -> "expnNNN" +// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */" // // We don't care about symbol ids, so we set them all to 0 // in the stdout @@ -18,8 +20,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; #[macro_use /* 0#1 */] extern crate core /* 0#1 */; -#[macro_use /* 0#1 */] -extern crate compiler_builtins /* 0#1 */; +extern crate compiler_builtins /* NNN */ as _ /* 0#1 */; // Don't load unnecessary hygiene information from std extern crate std /* 0#0 */; @@ -37,7 +38,7 @@ macro_rules! produce_it // relative to `meta_macro`, *not* `make_macro` (despite // the fact that `print_def_site` is produced by a // `macro_rules!` macro in `make_macro`). - } + } ; } fn main /* 0#0 */() { ; } @@ -47,23 +48,21 @@ Expansions: crate0::{{expn0}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Root crate0::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports) crate0::{{expn2}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "produce_it") -crate0::{{expn3}}: parent: crate0::{{expn2}}, call_site_ctxt: #4, def_site_ctxt: #0, kind: Macro(Bang, "meta_macro::print_def_site") -crate0::{{expn4}}: parent: crate0::{{expn3}}, call_site_ctxt: #5, def_site_ctxt: #0, kind: Macro(Bang, "$crate::dummy") +crate0::{{expn3}}: parent: crate0::{{expn2}}, call_site_ctxt: #3, def_site_ctxt: #0, kind: Macro(Bang, "meta_macro::print_def_site") +crate0::{{expn4}}: parent: crate0::{{expn3}}, call_site_ctxt: #4, def_site_ctxt: #0, kind: Macro(Bang, "$crate::dummy") crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive") crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive") crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "include") -crate2::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports) SyntaxContexts: #0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque) #1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque) #2: parent: #0, outer_mark: (crate0::{{expn1}}, Transparent) -#3: parent: #0, outer_mark: (crate2::{{expn1}}, Opaque) -#4: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent) -#5: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque) -#6: parent: #4, outer_mark: (crate0::{{expn3}}, Transparent) -#7: parent: #0, outer_mark: (crate0::{{expn3}}, SemiTransparent) -#8: parent: #0, outer_mark: (crate0::{{expn4}}, Opaque) -#9: parent: #5, outer_mark: (crate0::{{expn4}}, Transparent) -#10: parent: #5, outer_mark: (crate0::{{expn4}}, SemiTransparent) +#3: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent) +#4: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque) +#5: parent: #3, outer_mark: (crate0::{{expn3}}, Transparent) +#6: parent: #0, outer_mark: (crate0::{{expn3}}, SemiTransparent) +#7: parent: #0, outer_mark: (crate0::{{expn4}}, Opaque) +#8: parent: #4, outer_mark: (crate0::{{expn4}}, Transparent) +#9: parent: #4, outer_mark: (crate0::{{expn4}}, SemiTransparent) */ diff --git a/tests/ui/proc-macro/meta-macro.stdout b/tests/ui/proc-macro/meta-macro.stdout index 662682d40..b2d20c237 100644 --- a/tests/ui/proc-macro/meta-macro.stdout +++ b/tests/ui/proc-macro/meta-macro.stdout @@ -1,3 +1,3 @@ -Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) +Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#3) Input: TokenStream [] Respanned: TokenStream [] diff --git a/tests/ui/proc-macro/nested-macro-rules.stdout b/tests/ui/proc-macro/nested-macro-rules.stdout index 311139040..829cfdc0c 100644 --- a/tests/ui/proc-macro/nested-macro-rules.stdout +++ b/tests/ui/proc-macro/nested-macro-rules.stdout @@ -2,45 +2,45 @@ PRINT-BANG INPUT (DISPLAY): FirstStruct PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "FirstStruct", - span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#7), + span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#6), }, ] PRINT-ATTR INPUT (DISPLAY): struct FirstAttrStruct {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#6), + span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#5), }, Ident { ident: "FirstAttrStruct", - span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#7), + span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#6), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#6), + span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#5), }, ] PRINT-BANG INPUT (DISPLAY): SecondStruct PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "SecondStruct", - span: $DIR/nested-macro-rules.rs:21:38: 21:50 (#16), + span: $DIR/nested-macro-rules.rs:21:38: 21:50 (#15), }, ] PRINT-ATTR INPUT (DISPLAY): struct SecondAttrStruct {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", - span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#15), + span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#14), }, Ident { ident: "SecondAttrStruct", - span: $DIR/nested-macro-rules.rs:21:52: 21:68 (#16), + span: $DIR/nested-macro-rules.rs:21:52: 21:68 (#15), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#15), + span: $DIR/auxiliary/nested-macro-rules.rs:10:57: 10:59 (#14), }, ] diff --git a/tests/ui/proc-macro/nested-nonterminal-tokens.stdout b/tests/ui/proc-macro/nested-nonterminal-tokens.stdout index a3d24dd26..4c5550bb0 100644 --- a/tests/ui/proc-macro/nested-nonterminal-tokens.stdout +++ b/tests/ui/proc-macro/nested-nonterminal-tokens.stdout @@ -16,45 +16,45 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/nested-nonterminal-tokens.rs:25:26: 25:27 (#0), }, ], - span: $DIR/nested-nonterminal-tokens.rs:17:41: 17:43 (#4), + span: $DIR/nested-nonterminal-tokens.rs:17:41: 17:43 (#3), }, Punct { ch: '+', spacing: Alone, - span: $DIR/nested-nonterminal-tokens.rs:17:44: 17:45 (#4), + span: $DIR/nested-nonterminal-tokens.rs:17:44: 17:45 (#3), }, Literal { kind: Integer, symbol: "1", suffix: None, - span: $DIR/nested-nonterminal-tokens.rs:17:46: 17:47 (#4), + span: $DIR/nested-nonterminal-tokens.rs:17:46: 17:47 (#3), }, ], - span: $DIR/nested-nonterminal-tokens.rs:18:41: 18:43 (#5), + span: $DIR/nested-nonterminal-tokens.rs:18:41: 18:43 (#4), }, Punct { ch: '+', spacing: Alone, - span: $DIR/nested-nonterminal-tokens.rs:18:44: 18:45 (#5), + span: $DIR/nested-nonterminal-tokens.rs:18:44: 18:45 (#4), }, Literal { kind: Integer, symbol: "2", suffix: None, - span: $DIR/nested-nonterminal-tokens.rs:18:46: 18:47 (#5), + span: $DIR/nested-nonterminal-tokens.rs:18:46: 18:47 (#4), }, ], - span: $DIR/nested-nonterminal-tokens.rs:20:21: 20:23 (#6), + span: $DIR/nested-nonterminal-tokens.rs:20:21: 20:23 (#5), }, Punct { ch: '+', spacing: Alone, - span: $DIR/nested-nonterminal-tokens.rs:20:24: 20:25 (#6), + span: $DIR/nested-nonterminal-tokens.rs:20:24: 20:25 (#5), }, Literal { kind: Integer, symbol: "3", suffix: None, - span: $DIR/nested-nonterminal-tokens.rs:20:26: 20:27 (#6), + span: $DIR/nested-nonterminal-tokens.rs:20:26: 20:27 (#5), }, ] diff --git a/tests/ui/proc-macro/nodelim-groups.stdout b/tests/ui/proc-macro/nodelim-groups.stdout index 6b410f0bf..cdf851b53 100644 --- a/tests/ui/proc-macro/nodelim-groups.stdout +++ b/tests/ui/proc-macro/nodelim-groups.stdout @@ -4,7 +4,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ kind: Str, symbol: "hi", suffix: None, - span: $DIR/nodelim-groups.rs:16:42: 16:46 (#4), + span: $DIR/nodelim-groups.rs:16:42: 16:46 (#3), }, Group { delimiter: None, @@ -44,7 +44,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/nodelim-groups.rs:20:27: 20:28 (#0), }, ], - span: $DIR/nodelim-groups.rs:16:47: 16:51 (#4), + span: $DIR/nodelim-groups.rs:16:47: 16:51 (#3), }, Group { delimiter: Parenthesis, @@ -53,21 +53,21 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ kind: Integer, symbol: "1", suffix: None, - span: $DIR/nodelim-groups.rs:16:53: 16:54 (#4), + span: $DIR/nodelim-groups.rs:16:53: 16:54 (#3), }, Punct { ch: '+', spacing: Alone, - span: $DIR/nodelim-groups.rs:16:55: 16:56 (#4), + span: $DIR/nodelim-groups.rs:16:55: 16:56 (#3), }, Literal { kind: Integer, symbol: "1", suffix: None, - span: $DIR/nodelim-groups.rs:16:57: 16:58 (#4), + span: $DIR/nodelim-groups.rs:16:57: 16:58 (#3), }, ], - span: $DIR/nodelim-groups.rs:16:52: 16:59 (#4), + span: $DIR/nodelim-groups.rs:16:52: 16:59 (#3), }, ] PRINT-BANG INPUT (DISPLAY): "hi" "hello".len() + "world".len() (1 + 1) @@ -76,7 +76,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ kind: Str, symbol: "hi", suffix: None, - span: $DIR/nodelim-groups.rs:16:42: 16:46 (#9), + span: $DIR/nodelim-groups.rs:16:42: 16:46 (#8), }, Group { delimiter: None, @@ -105,12 +105,12 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/nodelim-groups.rs:21:28: 21:30 (#0), }, ], - span: $DIR/nodelim-groups.rs:15:49: 15:54 (#8), + span: $DIR/nodelim-groups.rs:15:49: 15:54 (#7), }, Punct { ch: '+', spacing: Alone, - span: $DIR/nodelim-groups.rs:15:55: 15:56 (#8), + span: $DIR/nodelim-groups.rs:15:55: 15:56 (#7), }, Group { delimiter: None, @@ -136,10 +136,10 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/nodelim-groups.rs:21:44: 21:46 (#0), }, ], - span: $DIR/nodelim-groups.rs:15:57: 15:62 (#8), + span: $DIR/nodelim-groups.rs:15:57: 15:62 (#7), }, ], - span: $DIR/nodelim-groups.rs:16:47: 16:51 (#9), + span: $DIR/nodelim-groups.rs:16:47: 16:51 (#8), }, Group { delimiter: Parenthesis, @@ -148,20 +148,20 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ kind: Integer, symbol: "1", suffix: None, - span: $DIR/nodelim-groups.rs:16:53: 16:54 (#9), + span: $DIR/nodelim-groups.rs:16:53: 16:54 (#8), }, Punct { ch: '+', spacing: Alone, - span: $DIR/nodelim-groups.rs:16:55: 16:56 (#9), + span: $DIR/nodelim-groups.rs:16:55: 16:56 (#8), }, Literal { kind: Integer, symbol: "1", suffix: None, - span: $DIR/nodelim-groups.rs:16:57: 16:58 (#9), + span: $DIR/nodelim-groups.rs:16:57: 16:58 (#8), }, ], - span: $DIR/nodelim-groups.rs:16:52: 16:59 (#9), + span: $DIR/nodelim-groups.rs:16:52: 16:59 (#8), }, ] diff --git a/tests/ui/proc-macro/nonterminal-expansion.stdout b/tests/ui/proc-macro/nonterminal-expansion.stdout index 4d884348f..b2557af18 100644 --- a/tests/ui/proc-macro/nonterminal-expansion.stdout +++ b/tests/ui/proc-macro/nonterminal-expansion.stdout @@ -3,12 +3,12 @@ PRINT-ATTR_ARGS RE-COLLECTED (DISPLAY): a, line! (), b PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ Ident { ident: "a", - span: $DIR/nonterminal-expansion.rs:13:27: 13:28 (#4), + span: $DIR/nonterminal-expansion.rs:13:27: 13:28 (#3), }, Punct { ch: ',', spacing: Alone, - span: $DIR/nonterminal-expansion.rs:13:28: 13:29 (#4), + span: $DIR/nonterminal-expansion.rs:13:28: 13:29 (#3), }, Group { delimiter: None, @@ -28,15 +28,15 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/nonterminal-expansion.rs:19:24: 19:26 (#0), }, ], - span: $DIR/nonterminal-expansion.rs:13:30: 13:35 (#4), + span: $DIR/nonterminal-expansion.rs:13:30: 13:35 (#3), }, Punct { ch: ',', spacing: Alone, - span: $DIR/nonterminal-expansion.rs:13:35: 13:36 (#4), + span: $DIR/nonterminal-expansion.rs:13:35: 13:36 (#3), }, Ident { ident: "b", - span: $DIR/nonterminal-expansion.rs:13:37: 13:38 (#4), + span: $DIR/nonterminal-expansion.rs:13:37: 13:38 (#3), }, ] diff --git a/tests/ui/proc-macro/nonterminal-recollect-attr.stdout b/tests/ui/proc-macro/nonterminal-recollect-attr.stdout index 6824395ae..e722ee97d 100644 --- a/tests/ui/proc-macro/nonterminal-recollect-attr.stdout +++ b/tests/ui/proc-macro/nonterminal-recollect-attr.stdout @@ -5,30 +5,30 @@ First recollected: TokenStream [ }, Ident { ident: "struct", - span: $DIR/nonterminal-recollect-attr.rs:14:12: 14:18 (#4), + span: $DIR/nonterminal-recollect-attr.rs:14:12: 14:18 (#3), }, Ident { ident: "Foo", - span: $DIR/nonterminal-recollect-attr.rs:14:19: 14:22 (#4), + span: $DIR/nonterminal-recollect-attr.rs:14:19: 14:22 (#3), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "field", - span: $DIR/nonterminal-recollect-attr.rs:15:13: 15:18 (#4), + span: $DIR/nonterminal-recollect-attr.rs:15:13: 15:18 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/nonterminal-recollect-attr.rs:15:18: 15:19 (#4), + span: $DIR/nonterminal-recollect-attr.rs:15:18: 15:19 (#3), }, Ident { ident: "u8", - span: $DIR/nonterminal-recollect-attr.rs:15:20: 15:22 (#4), + span: $DIR/nonterminal-recollect-attr.rs:15:20: 15:22 (#3), }, ], - span: $DIR/nonterminal-recollect-attr.rs:14:23: 16:10 (#4), + span: $DIR/nonterminal-recollect-attr.rs:14:23: 16:10 (#3), }, ] Second recollected: TokenStream [ @@ -38,29 +38,29 @@ Second recollected: TokenStream [ }, Ident { ident: "struct", - span: $DIR/nonterminal-recollect-attr.rs:14:12: 14:18 (#4), + span: $DIR/nonterminal-recollect-attr.rs:14:12: 14:18 (#3), }, Ident { ident: "Foo", - span: $DIR/nonterminal-recollect-attr.rs:14:19: 14:22 (#4), + span: $DIR/nonterminal-recollect-attr.rs:14:19: 14:22 (#3), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "field", - span: $DIR/nonterminal-recollect-attr.rs:15:13: 15:18 (#4), + span: $DIR/nonterminal-recollect-attr.rs:15:13: 15:18 (#3), }, Punct { ch: ':', spacing: Alone, - span: $DIR/nonterminal-recollect-attr.rs:15:18: 15:19 (#4), + span: $DIR/nonterminal-recollect-attr.rs:15:18: 15:19 (#3), }, Ident { ident: "u8", - span: $DIR/nonterminal-recollect-attr.rs:15:20: 15:22 (#4), + span: $DIR/nonterminal-recollect-attr.rs:15:20: 15:22 (#3), }, ], - span: $DIR/nonterminal-recollect-attr.rs:14:23: 16:10 (#4), + span: $DIR/nonterminal-recollect-attr.rs:14:23: 16:10 (#3), }, ] diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.rs b/tests/ui/proc-macro/nonterminal-token-hygiene.rs index fa52a975b..1e9e90a6b 100644 --- a/tests/ui/proc-macro/nonterminal-token-hygiene.rs +++ b/tests/ui/proc-macro/nonterminal-token-hygiene.rs @@ -3,12 +3,13 @@ // check-pass // compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene // compile-flags: -Z trim-diagnostic-paths=no +// ignore-tidy-linelength // normalize-stdout-test "\d+#" -> "0#" // normalize-stdout-test "expn\d{3,}" -> "expnNNN" +// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */" // aux-build:test-macros.rs #![feature(decl_macro)] - #![no_std] // Don't load unnecessary hygiene information from std extern crate std; diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout index c08e53081..c437853ac 100644 --- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -6,19 +6,19 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ stream: TokenStream [ Ident { ident: "struct", - span: $DIR/nonterminal-token-hygiene.rs:31:5: 31:11 (#5), + span: $DIR/nonterminal-token-hygiene.rs:32:5: 32:11 (#4), }, Ident { ident: "S", - span: $DIR/nonterminal-token-hygiene.rs:31:12: 31:13 (#5), + span: $DIR/nonterminal-token-hygiene.rs:32:12: 32:13 (#4), }, Punct { ch: ';', spacing: Alone, - span: $DIR/nonterminal-token-hygiene.rs:31:13: 31:14 (#5), + span: $DIR/nonterminal-token-hygiene.rs:32:13: 32:14 (#4), }, ], - span: $DIR/nonterminal-token-hygiene.rs:21:27: 21:32 (#6), + span: $DIR/nonterminal-token-hygiene.rs:22:27: 22:32 (#5), }, ] #![feature /* 0#0 */(prelude_import)] @@ -28,19 +28,19 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ // check-pass // compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene // compile-flags: -Z trim-diagnostic-paths=no +// ignore-tidy-linelength // normalize-stdout-test "\d+#" -> "0#" // normalize-stdout-test "expn\d{3,}" -> "expnNNN" +// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */" // aux-build:test-macros.rs #![feature /* 0#0 */(decl_macro)] - #![no_std /* 0#0 */] #[prelude_import /* 0#1 */] use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; #[macro_use /* 0#1 */] extern crate core /* 0#2 */; -#[macro_use /* 0#1 */] -extern crate compiler_builtins /* 0#2 */; +extern crate compiler_builtins /* NNN */ as _ /* 0#2 */; // Don't load unnecessary hygiene information from std extern crate std /* 0#0 */; @@ -59,9 +59,9 @@ macro_rules! outer } struct S /* 0#0 */; -macro inner /* 0#4 */ { () => { print_bang! { struct S; } } } +macro inner /* 0#3 */ { () => { print_bang! { struct S; } } } -struct S /* 0#5 */; +struct S /* 0#4 */; // OK, not a duplicate definition of `S` fn main /* 0#0 */() {} @@ -71,22 +71,20 @@ Expansions: crate0::{{expn0}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Root crate0::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports) crate0::{{expn2}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "outer") -crate0::{{expn3}}: parent: crate0::{{expn2}}, call_site_ctxt: #4, def_site_ctxt: #4, kind: Macro(Bang, "inner") -crate0::{{expn4}}: parent: crate0::{{expn3}}, call_site_ctxt: #6, def_site_ctxt: #0, kind: Macro(Bang, "print_bang") +crate0::{{expn3}}: parent: crate0::{{expn2}}, call_site_ctxt: #3, def_site_ctxt: #3, kind: Macro(Bang, "inner") +crate0::{{expn4}}: parent: crate0::{{expn3}}, call_site_ctxt: #5, def_site_ctxt: #0, kind: Macro(Bang, "print_bang") crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive") crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive") crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "include") -crate2::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports) SyntaxContexts: #0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque) #1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque) #2: parent: #0, outer_mark: (crate0::{{expn1}}, Transparent) -#3: parent: #0, outer_mark: (crate2::{{expn1}}, Opaque) -#4: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent) -#5: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque) -#6: parent: #4, outer_mark: (crate0::{{expn3}}, Opaque) -#7: parent: #0, outer_mark: (crate0::{{expn4}}, Opaque) -#8: parent: #6, outer_mark: (crate0::{{expn4}}, Transparent) -#9: parent: #5, outer_mark: (crate0::{{expn4}}, SemiTransparent) +#3: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent) +#4: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque) +#5: parent: #3, outer_mark: (crate0::{{expn3}}, Opaque) +#6: parent: #0, outer_mark: (crate0::{{expn4}}, Opaque) +#7: parent: #5, outer_mark: (crate0::{{expn4}}, Transparent) +#8: parent: #4, outer_mark: (crate0::{{expn4}}, SemiTransparent) */ diff --git a/tests/ui/process/multi-panic.rs b/tests/ui/process/multi-panic.rs index a1887c218..c240dc18f 100644 --- a/tests/ui/process/multi-panic.rs +++ b/tests/ui/process/multi-panic.rs @@ -8,10 +8,12 @@ fn check_for_no_backtrace(test: std::process::Output) { let err = String::from_utf8_lossy(&test.stderr); let mut it = err.lines(); - assert_eq!(it.next().map(|l| l.starts_with("thread '' panicked at")), Some(true)); + assert_eq!(it.next().map(|l| l.starts_with("thread '' panicked")), Some(true)); + assert_eq!(it.next().is_some(), true); assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \ environment variable to display a backtrace")); assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true)); + assert_eq!(it.next().is_some(), true); assert_eq!(it.next(), None); } diff --git a/tests/ui/process/println-with-broken-pipe.rs b/tests/ui/process/println-with-broken-pipe.rs new file mode 100644 index 000000000..47c590ce2 --- /dev/null +++ b/tests/ui/process/println-with-broken-pipe.rs @@ -0,0 +1,44 @@ +// run-pass +// check-run-results +// ignore-windows +// ignore-emscripten +// ignore-fuchsia +// ignore-horizon +// ignore-android +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" + +// Test what the error message looks like when `println!()` panics because of +// `std::io::ErrorKind::BrokenPipe` + +#![feature(unix_sigpipe)] + +use std::env; +use std::process::{Command, Stdio}; + +#[unix_sigpipe = "sig_ign"] +fn main() { + let mut args = env::args(); + let me = args.next().unwrap(); + + if let Some(arg) = args.next() { + // More than enough iterations to fill any pipe buffer. Normally this + // loop will end with a panic more or less immediately. + for _ in 0..65536 * 64 { + println!("{arg}"); + } + unreachable!("should have panicked because of BrokenPipe"); + } + + // Set up a pipeline with a short-lived consumer and wait for it to finish. + // This will produce the `println!()` panic message on stderr. + let mut producer = Command::new(&me) + .arg("this line shall appear exactly once on stdout") + .env("RUST_BACKTRACE", "0") + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + let mut consumer = + Command::new("head").arg("-n1").stdin(producer.stdout.take().unwrap()).spawn().unwrap(); + consumer.wait().unwrap(); + producer.wait().unwrap(); +} diff --git a/tests/ui/process/println-with-broken-pipe.run.stderr b/tests/ui/process/println-with-broken-pipe.run.stderr new file mode 100644 index 000000000..a334c0ad2 --- /dev/null +++ b/tests/ui/process/println-with-broken-pipe.run.stderr @@ -0,0 +1,3 @@ +thread 'main' panicked at library/std/src/io/stdio.rs:LL:CC: +failed printing to stdout: Broken pipe (os error 32) +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/process/println-with-broken-pipe.run.stdout b/tests/ui/process/println-with-broken-pipe.run.stdout new file mode 100644 index 000000000..f55c39578 --- /dev/null +++ b/tests/ui/process/println-with-broken-pipe.run.stdout @@ -0,0 +1 @@ +this line shall appear exactly once on stdout diff --git a/tests/ui/recursion/issue-26548-recursion-via-normalize.rs b/tests/ui/recursion/issue-26548-recursion-via-normalize.rs index 91958dffc..6c7fc4beb 100644 --- a/tests/ui/recursion/issue-26548-recursion-via-normalize.rs +++ b/tests/ui/recursion/issue-26548-recursion-via-normalize.rs @@ -1,4 +1,5 @@ //~ ERROR cycle detected when computing layout of `core::option::Option` +//~| NOTE see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information //~| NOTE ...which requires computing layout of `S`... //~| NOTE ...which requires computing layout of `core::option::Option<::It>`... //~| NOTE ...which again requires computing layout of `core::option::Option`, completing the cycle diff --git a/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr b/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr index a75097cdb..514bed607 100644 --- a/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -4,6 +4,7 @@ error[E0391]: cycle detected when computing layout of `core::option::Option` = note: ...which requires computing layout of `core::option::Option<::It>`... = note: ...which again requires computing layout of `core::option::Option`, completing the cycle = note: cycle used when computing layout of `core::option::Option<::It>` + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index eae58771a..543b73084 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -14,8 +14,7 @@ error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) = note: required for `&mut Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:13:24: 13:27]>` to implement `Iterator` = note: 65 redundant requirements hidden - = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>, ...>, ...>, ...>` to implement `Iterator` - = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-83150/issue-83150.long-type-hash.txt' + = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>, [closure@$DIR/issue-83150.rs:13:24: 13:27]>` to implement `Iterator` error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/recursion/recursive-static-definition.stderr b/tests/ui/recursion/recursive-static-definition.stderr index 135976145..b112228d4 100644 --- a/tests/ui/recursion/recursive-static-definition.stderr +++ b/tests/ui/recursion/recursive-static-definition.stderr @@ -18,6 +18,7 @@ LL | | LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/regions/higher-ranked-implied.stderr b/tests/ui/regions/higher-ranked-implied.stderr index 9d80eacd7..8fa65f116 100644 --- a/tests/ui/regions/higher-ranked-implied.stderr +++ b/tests/ui/regions/higher-ranked-implied.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/higher-ranked-implied.rs:12:16 | LL | let y: B = x; - | ^ one type is more general than the other + | - ^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)` found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/higher-ranked-implied.rs:13:16 | LL | let _: A = y; - | ^ one type is more general than the other + | - ^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)` found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)` diff --git a/tests/ui/regions/issue-102374.stderr b/tests/ui/regions/issue-102374.stderr index af64b6867..a4230cf8b 100644 --- a/tests/ui/regions/issue-102374.stderr +++ b/tests/ui/regions/issue-102374.stderr @@ -7,8 +7,7 @@ LL | f | ^ expected `i32`, found fn pointer | = note: expected type `i32` - found fn pointer `fn(Cell<...>)` - the full type name has been written to '$TEST_BUILD_DIR/regions/issue-102374/issue-102374.long-type-hash.txt' + found fn pointer `for<'z1, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x, 'y, 'z, 'z0> fn(Cell<(&'z1 i32, &'a i32, &'b i32, &'c i32, &'d i32, &'e i32, &'f i32, &'g i32, &'h i32, &'i i32, &'j i32, &'k i32, &'l i32, &'m i32, &'n i32, &'o i32, &'p i32, &'q i32, &'r i32, &'s i32, &'t i32, &'u i32, &'v i32, &'w i32, &'x i32, &'y i32, &'z i32, &'z0 i32)>)` error: aborting due to previous error diff --git a/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr index bb5bc6f66..f2328cf3b 100644 --- a/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ b/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^ one type is more general than the other + | ---------------------------- ^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)` found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}` diff --git a/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr index dbe9e9b1a..9c5004981 100644 --- a/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ b/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^ one type is more general than the other + | ----------------------------------------- ^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b isize, &'c mut &'d isize, &'e mut &'f isize)` found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}` diff --git a/tests/ui/regions/region-object-lifetime-5.rs b/tests/ui/regions/region-object-lifetime-5.rs index ad3593671..307bbcbd5 100644 --- a/tests/ui/regions/region-object-lifetime-5.rs +++ b/tests/ui/regions/region-object-lifetime-5.rs @@ -8,7 +8,7 @@ trait Foo { // Here, the object is bounded by an anonymous lifetime and returned // as `&'static`, so you get an error. fn owned_receiver(x: Box) -> &'static () { - x.borrowed() //~ ERROR cannot return reference to local data `*x` + x.borrowed() //~ ERROR cannot return value referencing local data `*x` } fn main() {} diff --git a/tests/ui/regions/region-object-lifetime-5.stderr b/tests/ui/regions/region-object-lifetime-5.stderr index b82b58c7a..b86f6e3a2 100644 --- a/tests/ui/regions/region-object-lifetime-5.stderr +++ b/tests/ui/regions/region-object-lifetime-5.stderr @@ -1,8 +1,11 @@ -error[E0515]: cannot return reference to local data `*x` +error[E0515]: cannot return value referencing local data `*x` --> $DIR/region-object-lifetime-5.rs:11:5 | LL | x.borrowed() - | ^^^^^^^^^^^^ returns a reference to data owned by the current function + | -^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `*x` is borrowed here error: aborting due to previous error diff --git a/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr b/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr index df0fd069e..2fab29865 100644 --- a/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ b/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/regions-lifetime-bounds-on-fns.rs:20:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^ one type is more general than the other + | ---------------------------- ^ one type is more general than the other + | | + | expected due to this | = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)` found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}` diff --git a/tests/ui/repr/repr-transparent.stderr b/tests/ui/repr/repr-transparent.stderr index cb1e23377..028fc25db 100644 --- a/tests/ui/repr/repr-transparent.stderr +++ b/tests/ui/repr/repr-transparent.stderr @@ -20,13 +20,13 @@ error[E0691]: zero-sized field in transparent struct has alignment larger than 1 --> $DIR/repr-transparent.rs:36:32 | LL | struct NontrivialAlignZst(u32, [u16; 0]); - | ^^^^^^^^ has alignment larger than 1 + | ^^^^^^^^ has alignment of 2, which is larger than 1 error[E0691]: zero-sized field in transparent struct has alignment larger than 1 --> $DIR/repr-transparent.rs:42:24 | LL | struct GenericAlign(ZstAlign32, u32); - | ^^^^^^^^^^^^^ has alignment larger than 1 + | ^^^^^^^^^^^^^ has alignment of 32, which is larger than 1 error[E0084]: unsupported representation for zero-variant enum --> $DIR/repr-transparent.rs:44:1 @@ -66,13 +66,13 @@ error[E0691]: zero-sized field in transparent enum has alignment larger than 1 --> $DIR/repr-transparent.rs:71:14 | LL | Foo(u32, [u16; 0]), - | ^^^^^^^^ has alignment larger than 1 + | ^^^^^^^^ has alignment of 2, which is larger than 1 error[E0691]: zero-sized field in transparent enum has alignment larger than 1 --> $DIR/repr-transparent.rs:76:11 | LL | Foo { bar: ZstAlign32, baz: u32 } - | ^^^^^^^^^^^^^^^^^^ has alignment larger than 1 + | ^^^^^^^^^^^^^^^^^^ has alignment of 32, which is larger than 1 error[E0690]: transparent union needs at most one non-zero-sized field, but has 2 --> $DIR/repr-transparent.rs:85:1 diff --git a/tests/ui/resolve/112590-2.fixed b/tests/ui/resolve/112590-2.fixed new file mode 100644 index 000000000..3bfe81ae8 --- /dev/null +++ b/tests/ui/resolve/112590-2.fixed @@ -0,0 +1,34 @@ +// run-rustfix +use std::vec; + +use std::sync::atomic::AtomicBool; + +mod foo { + pub mod bar { + pub mod baz { + pub use std::vec::Vec as MyVec; + } + } +} + +mod u { + use foo::bar::baz::MyVec; + +fn _a() { + let _: Vec = MyVec::new(); //~ ERROR failed to resolve + } +} + +mod v { + use foo::bar::baz::MyVec; + +fn _b() { + let _: Vec = MyVec::new(); //~ ERROR failed to resolve + } +} + +fn main() { + let _t: Vec = Vec::new(); //~ ERROR failed to resolve + type _B = vec::Vec::; //~ ERROR failed to resolve + let _t = AtomicBool::new(true); //~ ERROR failed to resolve +} diff --git a/tests/ui/resolve/112590-2.rs b/tests/ui/resolve/112590-2.rs new file mode 100644 index 000000000..e5914cd67 --- /dev/null +++ b/tests/ui/resolve/112590-2.rs @@ -0,0 +1,26 @@ +// run-rustfix +mod foo { + pub mod bar { + pub mod baz { + pub use std::vec::Vec as MyVec; + } + } +} + +mod u { + fn _a() { + let _: Vec = super::foo::baf::baz::MyVec::new(); //~ ERROR failed to resolve + } +} + +mod v { + fn _b() { + let _: Vec = fox::bar::baz::MyVec::new(); //~ ERROR failed to resolve + } +} + +fn main() { + let _t: Vec = vec::new(); //~ ERROR failed to resolve + type _B = vec::Vec::; //~ ERROR failed to resolve + let _t = std::sync_error::atomic::AtomicBool::new(true); //~ ERROR failed to resolve +} diff --git a/tests/ui/resolve/112590-2.stderr b/tests/ui/resolve/112590-2.stderr new file mode 100644 index 000000000..0db20249d --- /dev/null +++ b/tests/ui/resolve/112590-2.stderr @@ -0,0 +1,71 @@ +error[E0433]: failed to resolve: could not find `baf` in `foo` + --> $DIR/112590-2.rs:12:39 + | +LL | let _: Vec = super::foo::baf::baz::MyVec::new(); + | ^^^ could not find `baf` in `foo` + | +help: consider importing this struct through its public re-export + | +LL + use foo::bar::baz::MyVec; + | +help: if you import `MyVec`, refer to it directly + | +LL - let _: Vec = super::foo::baf::baz::MyVec::new(); +LL + let _: Vec = MyVec::new(); + | + +error[E0433]: failed to resolve: use of undeclared crate or module `fox` + --> $DIR/112590-2.rs:18:27 + | +LL | let _: Vec = fox::bar::baz::MyVec::new(); + | ^^^ use of undeclared crate or module `fox` + | +help: consider importing this struct through its public re-export + | +LL + use foo::bar::baz::MyVec; + | +help: if you import `MyVec`, refer to it directly + | +LL - let _: Vec = fox::bar::baz::MyVec::new(); +LL + let _: Vec = MyVec::new(); + | + +error[E0433]: failed to resolve: use of undeclared crate or module `vec` + --> $DIR/112590-2.rs:24:15 + | +LL | type _B = vec::Vec::; + | ^^^ use of undeclared crate or module `vec` + | +help: consider importing this module + | +LL + use std::vec; + | + +error[E0433]: failed to resolve: could not find `sync_error` in `std` + --> $DIR/112590-2.rs:25:19 + | +LL | let _t = std::sync_error::atomic::AtomicBool::new(true); + | ^^^^^^^^^^ could not find `sync_error` in `std` + | +help: consider importing this struct + | +LL + use std::sync::atomic::AtomicBool; + | +help: if you import `AtomicBool`, refer to it directly + | +LL - let _t = std::sync_error::atomic::AtomicBool::new(true); +LL + let _t = AtomicBool::new(true); + | + +error[E0433]: failed to resolve: use of undeclared crate or module `vec` + --> $DIR/112590-2.rs:23:24 + | +LL | let _t: Vec = vec::new(); + | ^^^ + | | + | use of undeclared crate or module `vec` + | help: a struct with a similar name exists (notice the capitalization): `Vec` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/resolve/bad-expr-path.stderr b/tests/ui/resolve/bad-expr-path.stderr index 8261e8e53..411130913 100644 --- a/tests/ui/resolve/bad-expr-path.stderr +++ b/tests/ui/resolve/bad-expr-path.stderr @@ -10,12 +10,6 @@ error[E0425]: cannot find value `arguments` in module `m1` LL | log(debug, m1::arguments); | ^^^^^^^^^ not found in `m1` -error[E0425]: cannot find function `log` in this scope - --> $DIR/bad-expr-path.rs:4:5 - | -LL | log(debug, m1::arguments); - | ^^^ not found in this scope - error[E0580]: `main` function has wrong type --> $DIR/bad-expr-path.rs:3:1 | @@ -25,6 +19,12 @@ LL | fn main(arguments: Vec) { = note: expected fn pointer `fn()` found fn pointer `fn(Vec)` +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-expr-path.rs:4:5 + | +LL | log(debug, m1::arguments); + | ^^^ not found in this scope + error: aborting due to 4 previous errors Some errors have detailed explanations: E0425, E0580. diff --git a/tests/ui/resolve/bad-expr-path2.stderr b/tests/ui/resolve/bad-expr-path2.stderr index 6e11296d9..af3ca99c5 100644 --- a/tests/ui/resolve/bad-expr-path2.stderr +++ b/tests/ui/resolve/bad-expr-path2.stderr @@ -10,12 +10,6 @@ error[E0423]: expected value, found module `m1::arguments` LL | log(debug, m1::arguments); | ^^^^^^^^^^^^^ not a value -error[E0425]: cannot find function `log` in this scope - --> $DIR/bad-expr-path2.rs:6:5 - | -LL | log(debug, m1::arguments); - | ^^^ not found in this scope - error[E0580]: `main` function has wrong type --> $DIR/bad-expr-path2.rs:5:1 | @@ -25,6 +19,12 @@ LL | fn main(arguments: Vec) { = note: expected fn pointer `fn()` found fn pointer `fn(Vec)` +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-expr-path2.rs:6:5 + | +LL | log(debug, m1::arguments); + | ^^^ not found in this scope + error: aborting due to 4 previous errors Some errors have detailed explanations: E0423, E0425, E0580. diff --git a/tests/ui/resolve/derive-macro-1.rs b/tests/ui/resolve/derive-macro-1.rs new file mode 100644 index 000000000..90cbd903a --- /dev/null +++ b/tests/ui/resolve/derive-macro-1.rs @@ -0,0 +1,18 @@ +// check-pass +// aux-build:issue-112831-aux.rs + +mod z { + pub trait Zeroable {} +} + +use z::*; + +mod pod { + use super::*; + pub trait Pod: Zeroable {} +} + +extern crate issue_112831_aux; +use issue_112831_aux::Zeroable; + +fn main() {} diff --git a/tests/ui/resolve/derive-macro-2.rs b/tests/ui/resolve/derive-macro-2.rs new file mode 100644 index 000000000..7cecdd9e3 --- /dev/null +++ b/tests/ui/resolve/derive-macro-2.rs @@ -0,0 +1,18 @@ +// check-pass +// aux-build:issue-112831-aux.rs + +extern crate issue_112831_aux; +use issue_112831_aux::Zeroable; + +mod z { + pub trait Zeroable {} +} + +use z::*; + +mod pod { + use super::*; + pub trait Pod: Zeroable {} +} + +fn main() {} diff --git a/tests/ui/resolve/export-fully-qualified-2018.stderr b/tests/ui/resolve/export-fully-qualified-2018.stderr index 366ffd9bb..b724da930 100644 --- a/tests/ui/resolve/export-fully-qualified-2018.stderr +++ b/tests/ui/resolve/export-fully-qualified-2018.stderr @@ -3,11 +3,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` | LL | pub fn bar() { foo::baz(); } | ^^^ use of undeclared crate or module `foo` - | -help: consider importing this module - | -LL + use crate::foo; - | error: aborting due to previous error diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr index 0cd516ee1..a8af0c7c9 100644 --- a/tests/ui/resolve/export-fully-qualified.stderr +++ b/tests/ui/resolve/export-fully-qualified.stderr @@ -3,11 +3,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` | LL | pub fn bar() { foo::baz(); } | ^^^ use of undeclared crate or module `foo` - | -help: consider importing this module - | -LL + use foo; - | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-112831.rs b/tests/ui/resolve/issue-112831.rs deleted file mode 100644 index ffd83ea8b..000000000 --- a/tests/ui/resolve/issue-112831.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass -// aux-build:issue-112831-aux.rs - -mod zeroable { - pub trait Zeroable {} -} - -use zeroable::*; - -mod pod { - use super::*; - pub trait Pod: Zeroable {} -} - -use pod::*; - -extern crate issue_112831_aux; -use issue_112831_aux::Zeroable; - -fn main() {} diff --git a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed new file mode 100644 index 000000000..e730f9466 --- /dev/null +++ b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.fixed @@ -0,0 +1,31 @@ +// run-rustfix + +#![deny(unused_qualifications)] +#![feature(unsized_fn_params)] + +#[allow(unused_imports)] +use std::ops; +use std::ops::Index; + +pub struct A; + +impl Index for A { + //~^ ERROR unnecessary qualification + type Output = (); + fn index(&self, _: str) -> &Self::Output { + &() + } +} + +mod inner { + pub trait Trait {} +} + +// the import needs to be here for the lint to show up +#[allow(unused_imports)] +use inner::Trait; + +impl Trait for () {} +//~^ ERROR unnecessary qualification + +fn main() {} diff --git a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs new file mode 100644 index 000000000..641c892e3 --- /dev/null +++ b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs @@ -0,0 +1,31 @@ +// run-rustfix + +#![deny(unused_qualifications)] +#![feature(unsized_fn_params)] + +#[allow(unused_imports)] +use std::ops; +use std::ops::Index; + +pub struct A; + +impl ops::Index for A { + //~^ ERROR unnecessary qualification + type Output = (); + fn index(&self, _: str) -> &Self::Output { + &() + } +} + +mod inner { + pub trait Trait {} +} + +// the import needs to be here for the lint to show up +#[allow(unused_imports)] +use inner::Trait; + +impl inner::Trait for () {} +//~^ ERROR unnecessary qualification + +fn main() {} diff --git a/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr new file mode 100644 index 000000000..d9c7fd218 --- /dev/null +++ b/tests/ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.stderr @@ -0,0 +1,31 @@ +error: unnecessary qualification + --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:12:6 + | +LL | impl ops::Index for A { + | ^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:3:9 + | +LL | #![deny(unused_qualifications)] + | ^^^^^^^^^^^^^^^^^^^^^ +help: remove the unnecessary path segments + | +LL - impl ops::Index for A { +LL + impl Index for A { + | + +error: unnecessary qualification + --> $DIR/issue-113808-invalid-unused-qualifications-suggestion.rs:28:6 + | +LL | impl inner::Trait for () {} + | ^^^^^^^^^^^^^^^^ + | +help: remove the unnecessary path segments + | +LL - impl inner::Trait for () {} +LL + impl Trait for () {} + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs b/tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs new file mode 100644 index 000000000..83349dd33 --- /dev/null +++ b/tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs @@ -0,0 +1,10 @@ +#![deny(unused_qualifications)] +// check-pass +fn bar() { + match Option::>::None { + Some(v) => {} + None => {} + } +} + +fn main() {} diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr index 313b3e30d..30f5f0595 100644 --- a/tests/ui/resolve/issue-2356.stderr +++ b/tests/ui/resolve/issue-2356.stderr @@ -1,18 +1,3 @@ -error[E0425]: cannot find function `default` in this scope - --> $DIR/issue-2356.rs:31:5 - | -LL | default(); - | ^^^^^^^ - | -help: you might have meant to call the associated function - | -LL | Self::default(); - | ~~~~~~~~~~~~~ -help: consider importing this function - | -LL + use std::default::default; - | - error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:39:5 | @@ -64,6 +49,12 @@ error[E0425]: cannot find function `clone` in this scope LL | clone(); | ^^^^^ help: you might have meant to call the method: `self.clone` +error[E0425]: cannot find function `default` in this scope + --> $DIR/issue-2356.rs:31:5 + | +LL | default(); + | ^^^^^^^ help: you might have meant to call the associated function: `Self::default` + error[E0425]: cannot find function `shave` in this scope --> $DIR/issue-2356.rs:41:5 | diff --git a/tests/ui/resolve/resolve-inconsistent-names.stderr b/tests/ui/resolve/resolve-inconsistent-names.stderr index 023db303d..42b7281d7 100644 --- a/tests/ui/resolve/resolve-inconsistent-names.stderr +++ b/tests/ui/resolve/resolve-inconsistent-names.stderr @@ -14,6 +14,15 @@ LL | a | b => {} | | | pattern doesn't bind `b` +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/resolve-inconsistent-names.rs:19:9 + | +LL | (A, B) | (ref B, c) | (c, A) => () + | ^^^^^^ - - variable not in all patterns + | | | + | | variable not in all patterns + | pattern doesn't bind `c` + error[E0408]: variable `A` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:18 | @@ -37,15 +46,6 @@ LL | (A, B) | (ref B, c) | (c, A) => () | | variable not in all patterns | variable not in all patterns -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:19:9 - | -LL | (A, B) | (ref B, c) | (c, A) => () - | ^^^^^^ - - variable not in all patterns - | | | - | | variable not in all patterns - | pattern doesn't bind `c` - error[E0409]: variable `B` is bound inconsistently across alternatives separated by `|` --> $DIR/resolve-inconsistent-names.rs:19:23 | diff --git a/tests/ui/resolve/resolve-self-in-impl.stderr b/tests/ui/resolve/resolve-self-in-impl.stderr index 9f9ed6889..183a17171 100644 --- a/tests/ui/resolve/resolve-self-in-impl.stderr +++ b/tests/ui/resolve/resolve-self-in-impl.stderr @@ -56,6 +56,7 @@ LL | | trait Tr { LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 6 previous errors diff --git a/tests/ui/resolve/unresolved-segments-visibility.rs b/tests/ui/resolve/unresolved-segments-visibility.rs new file mode 100644 index 000000000..c26171f75 --- /dev/null +++ b/tests/ui/resolve/unresolved-segments-visibility.rs @@ -0,0 +1,11 @@ +// Check that we do not ICE due to unresolved segments in visibility path. +#![crate_type = "lib"] + +extern crate alloc as b; + +mod foo { + mod bar { + pub(in b::string::String::newy) extern crate alloc as e; + //~^ ERROR failed to resolve: `String` is a struct, not a module [E0433] + } +} diff --git a/tests/ui/resolve/unresolved-segments-visibility.stderr b/tests/ui/resolve/unresolved-segments-visibility.stderr new file mode 100644 index 000000000..0a11549cd --- /dev/null +++ b/tests/ui/resolve/unresolved-segments-visibility.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: `String` is a struct, not a module + --> $DIR/unresolved-segments-visibility.rs:8:27 + | +LL | pub(in b::string::String::newy) extern crate alloc as e; + | ^^^^^^ `String` is a struct, not a module + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/resolve/unused-qualifications-suggestion.fixed b/tests/ui/resolve/unused-qualifications-suggestion.fixed new file mode 100644 index 000000000..0d4b9007c --- /dev/null +++ b/tests/ui/resolve/unused-qualifications-suggestion.fixed @@ -0,0 +1,23 @@ +// run-rustfix + +#![deny(unused_qualifications)] + +mod foo { + pub fn bar() {} +} + +mod baz { + pub mod qux { + pub fn quux() {} + } +} + +fn main() { + use foo::bar; + bar(); + //~^ ERROR unnecessary qualification + + use baz::qux::quux; + quux(); + //~^ ERROR unnecessary qualification +} diff --git a/tests/ui/resolve/unused-qualifications-suggestion.rs b/tests/ui/resolve/unused-qualifications-suggestion.rs new file mode 100644 index 000000000..f6722e965 --- /dev/null +++ b/tests/ui/resolve/unused-qualifications-suggestion.rs @@ -0,0 +1,23 @@ +// run-rustfix + +#![deny(unused_qualifications)] + +mod foo { + pub fn bar() {} +} + +mod baz { + pub mod qux { + pub fn quux() {} + } +} + +fn main() { + use foo::bar; + foo::bar(); + //~^ ERROR unnecessary qualification + + use baz::qux::quux; + baz::qux::quux(); + //~^ ERROR unnecessary qualification +} diff --git a/tests/ui/resolve/unused-qualifications-suggestion.stderr b/tests/ui/resolve/unused-qualifications-suggestion.stderr new file mode 100644 index 000000000..e3dac37fc --- /dev/null +++ b/tests/ui/resolve/unused-qualifications-suggestion.stderr @@ -0,0 +1,31 @@ +error: unnecessary qualification + --> $DIR/unused-qualifications-suggestion.rs:17:5 + | +LL | foo::bar(); + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/unused-qualifications-suggestion.rs:3:9 + | +LL | #![deny(unused_qualifications)] + | ^^^^^^^^^^^^^^^^^^^^^ +help: remove the unnecessary path segments + | +LL - foo::bar(); +LL + bar(); + | + +error: unnecessary qualification + --> $DIR/unused-qualifications-suggestion.rs:21:5 + | +LL | baz::qux::quux(); + | ^^^^^^^^^^^^^^ + | +help: remove the unnecessary path segments + | +LL - baz::qux::quux(); +LL + quux(); + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/return/return-struct.rs b/tests/ui/return/return-struct.rs new file mode 100644 index 000000000..446445c17 --- /dev/null +++ b/tests/ui/return/return-struct.rs @@ -0,0 +1,24 @@ +struct S; + +enum Age { + Years(i64, i64) +} + +fn foo() { + let mut age = 29; + Age::Years({age += 1; age}, 55) + //~^ ERROR mismatched types +} + +fn bar() { + let mut age = 29; + Age::Years(age, 55) + //~^ ERROR mismatched types +} + +fn baz() { + S + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/return/return-struct.stderr b/tests/ui/return/return-struct.stderr new file mode 100644 index 000000000..e6c0363e3 --- /dev/null +++ b/tests/ui/return/return-struct.stderr @@ -0,0 +1,35 @@ +error[E0308]: mismatched types + --> $DIR/return-struct.rs:9:5 + | +LL | Age::Years({age += 1; age}, 55) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age` + | +help: consider using a semicolon here + | +LL | Age::Years({age += 1; age}, 55); + | + +help: try adding a return type + | +LL | fn foo() -> Age { + | ++++++ + +error[E0308]: mismatched types + --> $DIR/return-struct.rs:15:5 + | +LL | fn bar() { + | - help: try adding a return type: `-> Age` +LL | let mut age = 29; +LL | Age::Years(age, 55) + | ^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age` + +error[E0308]: mismatched types + --> $DIR/return-struct.rs:20:5 + | +LL | fn baz() { + | - help: try adding a return type: `-> S` +LL | S + | ^ expected `()`, found `S` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs index ca5fa6df2..77227ebd8 100644 --- a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs @@ -1,6 +1,3 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr new file mode 100644 index 000000000..c4371a002 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-2.rs:12:22 + | +LL | fn main() -> Something { + | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | +note: required by a bound in `Main::{opaque#0}` + --> $DIR/issue-103052-2.rs:6:27 + | +LL | fn main() -> impl std::process::Termination; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr index b7c0b0bb6..04572920e 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr @@ -2,7 +2,7 @@ error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immu --> $DIR/borrowck-issue-49631.rs:20:9 | LL | while let Some(Ok(string)) = foo.get() { - | --------- immutable borrow occurs here + | --- immutable borrow occurs here LL | foo.mutate(); | ^^^^^^^^^^^^ mutable borrow occurs here LL | diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs index 721890db4..c27e8c4b0 100644 --- a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs @@ -1,5 +1,7 @@ // Check that we can manually implement an object-unsafe trait for its trait object. +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next // run-pass #![feature(object_safe_for_dispatch)] diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs new file mode 100644 index 000000000..bc8864000 --- /dev/null +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs @@ -0,0 +1,18 @@ +// Tests #108655: closures in `#[target_feature]` functions can still be marked #[inline(always)] + +// check-pass +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck +// only-x86_64 + +#![feature(target_feature_11)] + +#[target_feature(enable = "avx")] +pub unsafe fn test() { + ({ + #[inline(always)] + move || {} + })(); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs index d7a418959..880907b24 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs @@ -6,6 +6,10 @@ // compile-flags: --crate-type lib --emit link // normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL" // normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE" +// normalize-stderr-test: "[^ ]*/foo.lib" -> "$$LIB_FILE" +// normalize-stderr-test: "-m [^ ]*" -> "$$TARGET_MACHINE" +// normalize-stderr-test: "-f [^ ]*" -> "$$ASM_FLAGS" +// normalize-stderr-test: "--temp-prefix [^ ]*/foo.dll" -> "$$TEMP_PREFIX" #[link(name = "foo", kind = "raw-dylib")] extern "C" { // `@1` is an invalid name to export, as it usually indicates that something diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr index 020ac6a2b..cc532ccc4 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr @@ -1,4 +1,5 @@ -error: Dlltool could not create import library: +error: Dlltool could not create import library with $DLLTOOL -d $DEF_FILE -D foo.dll -l $LIB_FILE $TARGET_MACHINE $ASM_FLAGS --no-leading-underscore $TEMP_PREFIX: + $DLLTOOL: Syntax error in def file $DEF_FILE:1 error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr index 510108405..dfd245669 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr @@ -2,7 +2,7 @@ error: multiple declarations of external function `f` from library `foo.dll` hav --> $DIR/multiple-declarations.rs:13:9 | LL | fn f(x: i32); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr index f8265ae69..f69275a01 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr @@ -2,7 +2,7 @@ error: ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture --> $DIR/unsupported-abi.rs:6:5 | LL | fn f(x: i32); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs index 780a510c5..f41c1051f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs @@ -1,5 +1,6 @@ -// check-pass -#![feature(const_trait_impl)] +// known-bug: #110395 +// FIXME check-pass +#![feature(const_trait_impl, effects)] #[const_trait] trait Foo { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr new file mode 100644 index 000000000..4fcfe9d47 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/assoc-type-const-bound-usage.rs:12:5 + | +LL | ::Assoc::foo(); + | ^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting this bound + | +LL | const fn foo() { + | +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs index e73082c11..f40dc27cb 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] pub trait MyTrait { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs index 589e3f024..687cb128b 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(staged_api)] #![stable(feature = "rust1", since = "1.0.0")] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs index dd9933974..771c35cf6 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] pub trait Plus { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr index 7350909ba..2d9c49af8 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr @@ -2,13 +2,9 @@ error[E0277]: the trait bound `u32: ~const Plus` is not satisfied --> $DIR/call-const-trait-method-fail.rs:25:7 | LL | a.plus(b) - | ^^^^ the trait `~const Plus` is not implemented for `u32` + | ^^^^ the trait `Plus` is not implemented for `u32` | -note: the trait `Plus` is implemented for `u32`, but that implementation is not `const` - --> $DIR/call-const-trait-method-fail.rs:25:7 - | -LL | a.plus(b) - | ^^^^ + = help: the trait `Plus` is implemented for `u32` error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr index ff53eea11..60cd000f2 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr @@ -1,20 +1,24 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/call-const-trait-method-pass.rs:7:12 +error[E0015]: cannot call non-const fn `::plus` in constant functions + --> $DIR/call-const-trait-method-pass.rs:36:7 | -LL | impl const std::ops::Add for Int { - | ^^^^^^^^^^^^^ +LL | a.plus(b) + | ^^^^^^^ | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-const-trait-method-pass.rs:15:12 +error[E0015]: cannot call non-const operator in constants + --> $DIR/call-const-trait-method-pass.rs:39:22 + | +LL | const ADD_INT: Int = Int(1i32) + Int(2i32); + | ^^^^^^^^^^^^^^^^^^^^^ | -LL | impl const PartialEq for Int { - | ^^^^^^^^^ +note: impl defined here, but it is not `const` + --> $DIR/call-const-trait-method-pass.rs:7:1 | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change +LL | impl const std::ops::Add for Int { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr index 529a472e0..37faa3f6b 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr @@ -1,12 +1,3 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-generic-method-chain.rs:9:12 - | -LL | impl const PartialEq for S { - | ^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - error: ~const can only be applied to `#[const_trait]` traits --> $DIR/call-generic-method-chain.rs:18:32 | @@ -19,5 +10,5 @@ error: ~const can only be applied to `#[const_trait]` traits LL | const fn equals_self_wrapper(t: &T) -> bool { | ^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr index bdc6ccc8a..90cfe04a9 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr @@ -1,12 +1,3 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-generic-method-dup-bound.rs:7:12 - | -LL | impl const PartialEq for S { - | ^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - error: ~const can only be applied to `#[const_trait]` traits --> $DIR/call-generic-method-dup-bound.rs:18:44 | @@ -19,5 +10,5 @@ error: ~const can only be applied to `#[const_trait]` traits LL | const fn equals_self2(t: &T) -> bool { | ^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs index fe1abbf42..53778b3af 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs @@ -1,5 +1,6 @@ -// known-bug: #110395 -#![feature(const_trait_impl)] +// FIXME(effects) +// check-pass +#![feature(const_trait_impl, effects)] pub const fn equals_self(t: &T) -> bool { *t == *t diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr deleted file mode 100644 index 3963f64ad..000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0277]: can't compare `T` with `T` in const contexts - --> $DIR/call-generic-method-fail.rs:5:5 - | -LL | *t == *t - | ^^^^^^^^ no implementation for `T == T` - | -note: the trait `PartialEq` is implemented for `T`, but that implementation is not `const` - --> $DIR/call-generic-method-fail.rs:5:5 - | -LL | *t == *t - | ^^^^^^^^ - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/call-generic-method-fail.rs:5:5 - | -LL | *t == *t - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -help: consider further restricting this bound - | -LL | pub const fn equals_self(t: &T) -> bool { - | ++++++++++++++++++++++++++++ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs index 414a8c87d..eada4ceaf 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs @@ -1,3 +1,6 @@ +// check-pass +// known-bug: #110395 + #![feature(const_trait_impl)] struct S; @@ -21,6 +24,6 @@ const fn equals_self(t: &T) -> bool { // it not using the impl. pub const EQ: bool = equals_self(&S); -//~^ ERROR +// FIXME(effects) ~^ ERROR fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr deleted file mode 100644 index a28d6ce05..000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `S: ~const Foo` is not satisfied - --> $DIR/call-generic-method-nonconst.rs:23:22 - | -LL | pub const EQ: bool = equals_self(&S); - | ^^^^^^^^^^^^^^^ the trait `~const Foo` is not implemented for `S` - | -note: the trait `Foo` is implemented for `S`, but that implementation is not `const` - --> $DIR/call-generic-method-nonconst.rs:23:22 - | -LL | pub const EQ: bool = equals_self(&S); - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr index 7fbe89dba..bea1846e7 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr @@ -1,17 +1,8 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-generic-method-pass.rs:9:12 - | -LL | impl const PartialEq for S { - | ^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - error: ~const can only be applied to `#[const_trait]` traits --> $DIR/call-generic-method-pass.rs:18:32 | LL | const fn equals_self(t: &T) -> bool { | ^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr index 4f858d61e..54bc43477 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr @@ -1,20 +1,25 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/const-and-non-const-impl.rs:7:12 +error[E0117]: only traits defined in the current crate can be implemented for primitive types + --> $DIR/const-and-non-const-impl.rs:7:1 | LL | impl const std::ops::Add for i32 { - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^-------------^^^^^--- + | | | | + | | | `i32` is not defined in the current crate + | | `i32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change + = note: define and implement a trait or new type instead -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/const-and-non-const-impl.rs:23:12 +error[E0119]: conflicting implementations of trait `Add` for type `Int` + --> $DIR/const-and-non-const-impl.rs:23:1 | +LL | impl std::ops::Add for Int { + | -------------------------- first implementation here +... LL | impl const std::ops::Add for Int { - | ^^^^^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` error: aborting due to 2 previous errors +Some errors have detailed explanations: E0117, E0119. +For more information about an error, try `rustc --explain E0117`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs index 52984fb6b..4854f41bf 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] struct S; #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr index 112416a35..96ffca651 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -1,16 +1,15 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied in `fn(()) -> i32 {<() as Tr>::a}` - --> $DIR/const-closure-trait-method-fail.rs:18:23 +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/const-closure-trait-method-fail.rs:15:5 | -LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` +LL | x(()) + | ^^^^^ | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/const-closure-trait-method-fail.rs:18:23 + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound | -LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it appears within the type `fn(()) -> i32 {<() as Tr>::a}` +LL | const fn need_const_closure i32 + ~const std::ops::FnOnce<((),)>>(x: T) -> i32 { + | ++++++++++++++++++++++++++++++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs index 3e6d19088..fd9f28725 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs @@ -1,4 +1,5 @@ -// check-pass +// known-bug: #110395 +// FIXME check-pass #![feature(const_trait_impl)] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr new file mode 100644 index 000000000..fd0c29118 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr @@ -0,0 +1,15 @@ +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/const-closure-trait-method.rs:15:5 + | +LL | x(()) + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | const fn need_const_closure i32 + ~const std::ops::FnOnce<((),)>>(x: T) -> i32 { + | ++++++++++++++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.rs index 7c55b51c8..1fe4044d5 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.rs @@ -1,4 +1,5 @@ -// check-pass +// known-bug: #110395 +// FIXME check-pass #![feature(const_trait_impl)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr new file mode 100644 index 000000000..abf2a2dc5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr @@ -0,0 +1,39 @@ +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/const-closures.rs:12:5 + | +LL | f() * 7 + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | F: ~const FnOnce() -> u8 + ~const std::ops::Fn<()>, + | +++++++++++++++++++++++++ + +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/const-closures.rs:24:5 + | +LL | f() + f() + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | const fn answer u8 + ~const std::ops::Fn<()>>(f: &F) -> u8 { + | +++++++++++++++++++++++++ + +error[E0015]: cannot call non-const closure in constant functions + --> $DIR/const-closures.rs:24:11 + | +LL | f() + f() + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | const fn answer u8 + ~const std::ops::Fn<()>>(f: &F) -> u8 { + | +++++++++++++++++++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs index 140a06a73..be668b4f1 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] trait ConstDefaultFn: Sized { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr index f9d0d1f78..7b558e3f7 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr @@ -2,13 +2,9 @@ error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satis --> $DIR/const-default-method-bodies.rs:24:18 | LL | NonConstImpl.a(); - | ^ the trait `~const ConstDefaultFn` is not implemented for `NonConstImpl` + | ^ the trait `ConstDefaultFn` is not implemented for `NonConstImpl` | -note: the trait `ConstDefaultFn` is implemented for `NonConstImpl`, but that implementation is not `const` - --> $DIR/const-default-method-bodies.rs:24:5 - | -LL | NonConstImpl.a(); - | ^^^^^^^^^^^^ + = help: the trait `ConstDefaultFn` is implemented for `NonConstImpl` error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs index 948f0efbc..7f89c1280 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs @@ -1,4 +1,5 @@ -// check-pass +// known-bug: #110395 +// FIXME check-pass #![feature(const_trait_impl)] #![feature(const_precise_live_drops)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr new file mode 100644 index 000000000..f5147dc74 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr @@ -0,0 +1,9 @@ +error[E0493]: destructor of `E` cannot be evaluated at compile-time + --> $DIR/const-drop-bound.rs:12:13 + | +LL | Err(_e) => None, + | ^^ the destructor for this type cannot be evaluated in constant functions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs index 3de9d37d4..747ccbf0f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs @@ -18,6 +18,10 @@ trait A { fn a() { } } impl A for NonTrivialDrop {} +const fn check(_: T) {} + + +/* FIXME(effects) struct ConstDropImplWithBounds(PhantomData); impl const Drop for ConstDropImplWithBounds { @@ -26,11 +30,10 @@ impl const Drop for ConstDropImplWithBounds { } } -const fn check(_: T) {} - const _: () = check::>( ConstDropImplWithBounds(PhantomData) ); +*/ struct ConstDropImplWithNonConstBounds(PhantomData); diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr index 375f5d2c5..100d1df87 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr @@ -1,50 +1,11 @@ -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop-fail-2.rs:21:36 | -LL | const _: () = check::>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:31:23 - | -LL | const _: () = check::>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds(PhantomData); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` - -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:32:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:32:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds(PhantomData); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` - -error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - --> $DIR/const-drop-fail-2.rs:37:9 - | -LL | impl const Drop for ConstDropImplWithNonConstBounds { - | ^^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/const-drop-fail-2.rs:35:1 - | -LL | struct ConstDropImplWithNonConstBounds(PhantomData); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const fn check(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index e745cbd24..dfa5ea8c4 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -1,58 +1,9 @@ -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop-fail.rs:24:36 | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation -note: required because it appears within the type `ConstImplWithDropGlue` - --> $DIR/const-drop-fail.rs:18:8 - | -LL | struct ConstImplWithDropGlue(NonTrivialDrop); - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | const fn check(_: T) {} + | ^ the destructor for this type cannot be evaluated in constant functions -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index e745cbd24..8af38b792 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -1,58 +1,11 @@ -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop-fail.rs:24:36 | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation -note: required because it appears within the type `ConstImplWithDropGlue` - --> $DIR/const-drop-fail.rs:18:8 - | -LL | struct ConstImplWithDropGlue(NonTrivialDrop); - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | const fn check(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr new file mode 100644 index 000000000..23e368870 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr @@ -0,0 +1,19 @@ +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 + | +LL | const fn a(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:24:13 + | +LL | let _ = S(&mut c); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs index b0fc3adf9..0a9cf638a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs @@ -1,9 +1,10 @@ -// run-pass +// FIXME run-pass +// known-bug: #110395 // revisions: stock precise #![feature(const_trait_impl)] #![feature(const_mut_refs)] #![feature(never_type)] -#![cfg_attr(precise, feature(const_precise_live_drops))] +// #![cfg_attr(precise, feature(const_precise_live_drops))] use std::marker::Destruct; @@ -16,10 +17,12 @@ impl<'a> const Drop for S<'a> { } const fn a(_: T) {} +//FIXME ~^ ERROR destructor of const fn b() -> u8 { let mut c = 0; let _ = S(&mut c); + //FIXME ~^ ERROR destructor of a(S(&mut c)); c } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr new file mode 100644 index 000000000..23e368870 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr @@ -0,0 +1,19 @@ +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 + | +LL | const fn a(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:24:13 + | +LL | let _ = S(&mut c); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs index 2b4963991..fc3a83876 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs @@ -1,9 +1,11 @@ -#![feature(const_trait_impl)] +// known-bug: #110395 + +#![feature(const_trait_impl, effects)] pub trait A {} -//~^ HELP: mark `A` as const +// FIXME ~^ HELP: mark `A` as const impl const A for () {} -//~^ ERROR: const `impl` for trait `A` which is not marked with `#[const_trait]` +// FIXME ~^ ERROR: const `impl` for trait `A` which is not marked with `#[const_trait]` fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr index 478adcf3e..c45af1a9f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `A` which is not marked with `#[const_trait]` - --> $DIR/const-impl-requires-const-trait.rs:6:12 + --> $DIR/const-impl-requires-const-trait.rs:8:12 | LL | pub trait A {} | - help: mark `A` as const: `#[const_trait]` diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs index dba3ad7f8..348ca0ab1 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs @@ -1,5 +1,4 @@ #[derive_const(Default)] //~ ERROR use of unstable library feature -//~^ ERROR not marked with `#[const_trait]` pub struct S; fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr index 6a81f96d8..cc9bdd271 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr @@ -6,16 +6,6 @@ LL | #[derive_const(Default)] | = help: add `#![feature(derive_const)]` to the crate attributes to enable -error: const `impl` for trait `Default` which is not marked with `#[const_trait]` - --> $DIR/derive-const-gate.rs:1:16 - | -LL | #[derive_const(Default)] - | ^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs index b575ea8da..ce39045d7 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs @@ -1,5 +1,5 @@ // known-bug: #110395 -#![feature(derive_const)] +#![feature(derive_const, effects)] pub struct A; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr index 88054096e..046dbae0e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr @@ -10,44 +10,6 @@ error[E0635]: unknown feature `const_default_impls` LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] | ^^^^^^^^^^^^^^^^^^^ -error: const `impl` for trait `Default` which is not marked with `#[const_trait]` - --> $DIR/derive-const-use.rs:6:12 - | -LL | impl const Default for A { - | ^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/derive-const-use.rs:10:12 - | -LL | impl const PartialEq for A { - | ^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: const `impl` for trait `Default` which is not marked with `#[const_trait]` - --> $DIR/derive-const-use.rs:14:16 - | -LL | #[derive_const(Default, PartialEq)] - | ^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/derive-const-use.rs:14:25 - | -LL | #[derive_const(Default, PartialEq)] - | ^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr index fa7832658..37d123e4c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr @@ -1,13 +1,3 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/derive-const-with-params.rs:6:16 - | -LL | #[derive_const(PartialEq)] - | ^^^^^^^^^ - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) - error: ~const can only be applied to `#[const_trait]` traits --> $DIR/derive-const-with-params.rs:6:16 | @@ -16,5 +6,5 @@ LL | #[derive_const(PartialEq)] | = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr index 633b7cc25..428286e0b 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr @@ -2,13 +2,9 @@ error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrai --> $DIR/cross-crate.rs:17:14 | LL | NonConst.func(); - | ^^^^ the trait `~const cross_crate::MyTrait` is not implemented for `cross_crate::NonConst` + | ^^^^ the trait `cross_crate::MyTrait` is not implemented for `cross_crate::NonConst` | -note: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst`, but that implementation is not `const` - --> $DIR/cross-crate.rs:17:5 - | -LL | NonConst.func(); - | ^^^^^^^^ + = help: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst` error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs index 6df47022c..95edbdc0e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs @@ -1,6 +1,6 @@ // revisions: stock gated stocknc gatednc // [gated] check-pass -#![cfg_attr(any(gated, gatednc), feature(const_trait_impl))] +#![cfg_attr(any(gated, gatednc), feature(const_trait_impl, effects))] // aux-build: cross-crate.rs extern crate cross_crate; @@ -15,10 +15,11 @@ fn non_const_context() { const fn const_context() { #[cfg(any(stocknc, gatednc))] NonConst.func(); - //[stocknc]~^ ERROR: the trait bound + //[stocknc]~^ ERROR: cannot call //[gatednc]~^^ ERROR: the trait bound Const.func(); //[stock]~^ ERROR: cannot call + //[stocknc]~^^ ERROR: cannot call } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr index 9e97d3f11..ebbe9aa22 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr @@ -1,15 +1,21 @@ -error[E0277]: the trait bound `cross_crate::NonConst: cross_crate::MyTrait` is not satisfied +error[E0015]: cannot call non-const fn `::func` in constant functions --> $DIR/cross-crate.rs:17:14 | LL | NonConst.func(); - | ^^^^ the trait `~const cross_crate::MyTrait` is not implemented for `cross_crate::NonConst` + | ^^^^^^ | -note: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst`, but that implementation is not `const` - --> $DIR/cross-crate.rs:17:5 + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error[E0015]: cannot call non-const fn `::func` in constant functions + --> $DIR/cross-crate.rs:20:11 | -LL | NonConst.func(); - | ^^^^^^^^ +LL | Const.func(); + | ^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs index 96acdc300..f5644c888 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs @@ -1,3 +1,6 @@ +// known-bug: #110395 +// check-pass + #![feature(const_trait_impl)] #[const_trait] @@ -10,7 +13,7 @@ const fn foo() where T: ~const Tr {} pub trait Foo { fn foo() { foo::<()>(); - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + //FIXME ~^ ERROR the trait bound `(): Tr` is not satisfied } } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr deleted file mode 100644 index 26644f72c..000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied - --> $DIR/default-method-body-is-const-body-checking.rs:12:9 - | -LL | foo::<()>(); - | ^^^^^^^^^^^ the trait `~const Tr` is not implemented for `()` - | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/default-method-body-is-const-body-checking.rs:12:9 - | -LL | foo::<()>(); - | ^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs index f70ecbc37..da2772400 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] pub trait Tr { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr index 21ecddaff..a6881b8fe 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr @@ -2,13 +2,9 @@ error[E0277]: the trait bound `(): ~const Tr` is not satisfied --> $DIR/default-method-body-is-const-same-trait-ck.rs:8:12 | LL | ().a() - | ^ the trait `~const Tr` is not implemented for `()` + | ^ the trait `Tr` is not implemented for `()` | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/default-method-body-is-const-same-trait-ck.rs:8:9 - | -LL | ().a() - | ^^ + = help: the trait `Tr` is implemented for `()` error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs index 730e268c0..5a0db816a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(const_trait_impl, rustc_attrs)] +#![feature(const_trait_impl, rustc_attrs, effects)] #[const_trait] trait Foo { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/helloworld.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/helloworld.rs index 49457354c..e7ba0505d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/helloworld.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/helloworld.rs @@ -7,7 +7,7 @@ // ensure we are passing in the correct host effect in always const contexts. -pub const fn hmm() -> usize { +pub const fn hmm() -> usize { if host { 1 } else { @@ -16,14 +16,12 @@ pub const fn hmm() -> usize { } const _: () = { - let x = hmm(); + let x = hmm::<()>(); assert!(0 == x); }; -/* FIXME(effects) pub const fn uwu(x: [u8; hmm::<()>()]) { let [] = x; } -*/ fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr index 1b21d7c0e..6a177592b 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr @@ -1,11 +1,16 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/generic-bound.rs:16:15 +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/generic-bound.rs:25:5 | -LL | impl const std::ops::Add for S { - | ^^^^^^^^^^^^^ +LL | arg + arg + | ^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $DIR/generic-bound.rs:16:1 | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change +LL | impl const std::ops::Add for S { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.rs index 337c73340..426534deb 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.rs @@ -1,6 +1,6 @@ // Regression test for #69615. -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] pub trait MyTrait { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs index 07d3f51ed..df242721b 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs @@ -1,11 +1,12 @@ +// known-bug: #110395 #![feature(const_trait_impl)] struct Bug { inner: [(); match || 1 { n => n(), - //~^ ERROR the trait bound - //~| ERROR the trait bound - //~| ERROR cannot call non-const closure in constants + //FIXME ~^ ERROR the trait bound + //FIXME ~| ERROR the trait bound + //FIXME ~| ERROR cannot call non-const closure in constants }], } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr index b98ccbe5d..f0c61cf9d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr @@ -1,41 +1,11 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-102985.rs:4:23: 4:25]: ~const Fn<()>` is not satisfied - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-102985.rs:4:23: 4:25]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-102985.rs:4:23: 4:25]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-102985.rs:4:23: 4:25]`, but that implementation is not `const` - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ - = note: wrap the `[closure@$DIR/issue-102985.rs:4:23: 4:25]` in a closure with no arguments: `|| { /* code */ }` - -error[E0277]: the trait bound `[closure@$DIR/issue-102985.rs:4:23: 4:25]: ~const Fn<()>` is not satisfied - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-102985.rs:4:23: 4:25]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-102985.rs:4:23: 4:25]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-102985.rs:4:23: 4:25]`, but that implementation is not `const` - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ - = note: wrap the `[closure@$DIR/issue-102985.rs:4:23: 4:25]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants - --> $DIR/issue-102985.rs:5:14 + --> $DIR/issue-102985.rs:6:14 | LL | n => n(), | ^^^ | - = note: closures need an RFC before allowed to be called in constants = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs index b132c395a..5127ec069 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + #![feature(const_trait_impl)] pub trait A { @@ -6,8 +8,8 @@ pub trait A { pub const fn foo() -> bool { T::assoc() - //~^ ERROR the trait bound - //~| ERROR cannot call non-const fn + //FIXME ~^ ERROR the trait bound + //FIXME ~| ERROR cannot call non-const fn } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr index 955923505..d8cb10c65 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr @@ -1,24 +1,11 @@ -error[E0277]: the trait bound `T: ~const A` is not satisfied - --> $DIR/issue-88155.rs:8:5 - | -LL | T::assoc() - | ^^^^^^^^^^ the trait `~const A` is not implemented for `T` - | -note: the trait `A` is implemented for `T`, but that implementation is not `const` - --> $DIR/issue-88155.rs:8:5 - | -LL | T::assoc() - | ^^^^^^^^^^ - error[E0015]: cannot call non-const fn `::assoc` in constant functions - --> $DIR/issue-88155.rs:8:5 + --> $DIR/issue-88155.rs:10:5 | LL | T::assoc() | ^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs index 96a3e386e..fdb422201 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs @@ -1,6 +1,7 @@ // Regression test for #92111. // -// check-pass +// known-bug: #110395 +// FIXME check-pass #![feature(const_trait_impl)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr new file mode 100644 index 000000000..b27f94f99 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr @@ -0,0 +1,11 @@ +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/issue-92111.rs:20:32 + | +LL | const fn a(t: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr index bd0dd126c..4fe8a372e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr @@ -1,26 +1,12 @@ -error[E0277]: can't compare `str` with `str` in const contexts - --> $DIR/match-non-const-eq.rs:6:9 - | -LL | "a" => (), - | ^^^ no implementation for `str == str` - | - = help: the trait `~const PartialEq` is not implemented for `str` -note: the trait `PartialEq` is implemented for `str`, but that implementation is not `const` - --> $DIR/match-non-const-eq.rs:6:9 - | -LL | "a" => (), - | ^^^ - error[E0015]: cannot match on `str` in constant functions - --> $DIR/match-non-const-eq.rs:6:9 + --> $DIR/match-non-const-eq.rs:7:9 | -LL | "a" => (), +LL | "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts | ^^^ | = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs index 0d04101a3..d06d0d6dd 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs @@ -1,10 +1,11 @@ +// known-bug: #110395 // revisions: stock gated #![cfg_attr(gated, feature(const_trait_impl))] const fn foo(input: &'static str) { match input { - "a" => (), //[gated]~ ERROR can't compare `str` with `str` in const contexts - //~^ ERROR cannot match on `str` in constant functions + "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts + //FIXME ~^ ERROR cannot match on `str` in constant functions _ => (), } } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr index dcb9b49ea..c36142dac 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr @@ -1,7 +1,7 @@ error[E0015]: cannot match on `str` in constant functions - --> $DIR/match-non-const-eq.rs:6:9 + --> $DIR/match-non-const-eq.rs:7:9 | -LL | "a" => (), +LL | "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts | ^^^ | = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs index f31123f16..3db59631e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs @@ -1,5 +1,7 @@ // Tests that trait bounds on specializing trait impls must be `~const` if the // same bound is present on the default impl and is `~const` there. +// check-pass +// FIXME(effects) ^ should error #![feature(const_trait_impl)] #![feature(rustc_attrs)] @@ -29,7 +31,7 @@ where impl Bar for T where - T: Foo, //~ ERROR missing `~const` qualifier + T: Foo, //FIXME ~ ERROR missing `~const` qualifier T: Specialize, { fn bar() {} @@ -47,7 +49,7 @@ where default fn baz() {} } -impl const Baz for T //~ ERROR conflicting implementations of trait `Baz` +impl const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz` where T: Foo, T: Specialize, diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr deleted file mode 100644 index 057cf4aea..000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: missing `~const` qualifier for specialization - --> $DIR/const-default-bound-non-const-specialized-bound.rs:32:8 - | -LL | T: Foo, - | ^^^ - -error[E0119]: conflicting implementations of trait `Baz` - --> $DIR/const-default-bound-non-const-specialized-bound.rs:50:1 - | -LL | impl const Baz for T - | ----------------------- first implementation here -... -LL | impl const Baz for T - | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs index 9ddea427c..b6cb24d15 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs @@ -3,7 +3,7 @@ // run-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(min_specialization)] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs index a3bb9b3f9..9a93d01ed 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs @@ -1,6 +1,6 @@ // Tests that specializing trait impls must be at least as const as the default impl. -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(min_specialization)] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs index 35aa52fbd..84c7926f4 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs @@ -1,9 +1,9 @@ // Tests that a non-const default impl can be specialized by a const trait impl, // but that the default impl cannot be used in a const context. +// known-bug: #110395 +// FIXME run-pass -// run-pass - -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(min_specialization)] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.stderr new file mode 100644 index 000000000..4734cee7f --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Value` for type `FortyTwo` + --> $DIR/non-const-default-const-specialized.rs:27:1 + | +LL | impl Value for T { + | ------------------- first implementation here +... +LL | impl const Value for FortyTwo { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `FortyTwo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs index 633543700..ada475909 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs @@ -1,5 +1,5 @@ #![feature(const_trait_impl, min_specialization, rustc_attrs)] - +// known-bug: #110395 #[rustc_specialization_trait] #[const_trait] pub trait Sup {} @@ -25,7 +25,7 @@ impl const A for T { const fn generic() { ::a(); - //~^ ERROR: the trait bound `T: ~const Sup` is not satisfied + //FIXME ~^ ERROR: the trait bound `T: ~const Sup` is not satisfied } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr index 8923416f4..92bc9815e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr @@ -1,21 +1,11 @@ -error[E0277]: the trait bound `T: ~const Sup` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/specializing-constness-2.rs:27:5 | LL | ::a(); - | ^^^^^^^^^^^^^ the trait `~const Sup` is not implemented for `T` + | ^^^^^^^^^^^^^ | -note: required for `T` to implement `~const A` - --> $DIR/specializing-constness-2.rs:20:37 - | -LL | impl const A for T { - | ---------- ^ ^ - | | - | unsatisfied trait bound introduced here -help: consider further restricting this bound - | -LL | const fn generic() { - | ++++++++++++ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs index 5c2a3f801..7206a89e5 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl, min_specialization, rustc_attrs)] +#![feature(const_trait_impl, effects, min_specialization, rustc_attrs)] #[rustc_specialization_trait] #[const_trait] @@ -22,7 +22,7 @@ impl const A for T { impl A for T { //~^ ERROR: cannot specialize -//~| ERROR: missing `~const` qualifier +//FIXME(effects) ~| ERROR: missing `~const` qualifier fn a() -> u32 { 3 } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.stderr index 1ffdc50e5..08258fd1a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.stderr @@ -4,11 +4,5 @@ error: cannot specialize on const impl with non-const impl LL | impl A for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing `~const` qualifier for specialization - --> $DIR/specializing-constness.rs:23:9 - | -LL | impl A for T { - | ^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.rs index 1d79f5adf..b3977e6ce 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.rs @@ -1,7 +1,7 @@ // revisions: stable unstable #![cfg_attr(unstable, feature(unstable))] // The feature from the ./auxiliary/staged-api.rs file. -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(staged_api)] #![stable(feature = "rust1", since = "1.0.0")] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs index ecb06271c..93fd96f8f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs @@ -1,5 +1,5 @@ #![feature(const_trait_impl)] - +// known-bug: #110395 // revisions: yy yn ny nn #[cfg_attr(any(yy, yn), const_trait)] @@ -9,12 +9,12 @@ trait Foo { #[cfg_attr(any(yy, ny), const_trait)] trait Bar: ~const Foo {} -//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` +// FIXME [ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` +// FIXME [ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` const fn foo(x: &T) { x.a(); - //[yn,yy]~^ ERROR the trait bound + // FIXME [yn,yy]~^ ERROR the trait bound } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr index c9fa19554..5d34156a5 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr @@ -1,19 +1,11 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/super-traits-fail-2.rs:16:7 | LL | x.a(); - | ^ the trait `~const Foo` is not implemented for `T` + | ^^^ | -note: the trait `Foo` is implemented for `T`, but that implementation is not `const` - --> $DIR/super-traits-fail-2.rs:16:5 - | -LL | x.a(); - | ^ -help: consider further restricting this bound - | -LL | const fn foo(x: &T) { - | ++++++++++++ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr index c9fa19554..5d34156a5 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr @@ -1,19 +1,11 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/super-traits-fail-2.rs:16:7 | LL | x.a(); - | ^ the trait `~const Foo` is not implemented for `T` + | ^^^ | -note: the trait `Foo` is implemented for `T`, but that implementation is not `const` - --> $DIR/super-traits-fail-2.rs:16:5 - | -LL | x.a(); - | ^ -help: consider further restricting this bound - | -LL | const fn foo(x: &T) { - | ++++++++++++ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr index fdc6b8058..2897eabb0 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr @@ -1,17 +1,17 @@ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 + --> $DIR/super-traits-fail-3.rs:13:19 | LL | trait Bar: ~const Foo {} | ^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 + --> $DIR/super-traits-fail-3.rs:13:19 | LL | trait Bar: ~const Foo {} | ^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:16:24 + --> $DIR/super-traits-fail-3.rs:17:24 | LL | const fn foo(x: &T) { | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr index 7375b8c81..9839a4f24 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr @@ -1,11 +1,11 @@ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 + --> $DIR/super-traits-fail-3.rs:13:19 | LL | trait Bar: ~const Foo {} | ^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 + --> $DIR/super-traits-fail-3.rs:13:19 | LL | trait Bar: ~const Foo {} | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs index 8cf64944a..16c592830 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs @@ -1,7 +1,8 @@ #![feature(const_trait_impl)] // revisions: yy yn ny nn -//[yy] check-pass +//[yy] known-bug: #110395 +//FIXME [yy] check-pass #[cfg_attr(any(yy, yn), const_trait)] trait Foo { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr index 7a152914b..58225b945 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr @@ -1,5 +1,5 @@ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:16:24 + --> $DIR/super-traits-fail-3.rs:17:24 | LL | const fn foo(x: &T) { | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr new file mode 100644 index 000000000..6bc643e68 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `::a` in constant functions + --> $DIR/super-traits-fail-3.rs:19:7 + | +LL | x.a(); + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs index 3e2b81368..b3853def7 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs @@ -1,3 +1,6 @@ +// check-pass +// known-bug: #110395 + #![feature(const_trait_impl)] #[const_trait] @@ -13,6 +16,6 @@ impl Foo for S { } impl const Bar for S {} -//~^ ERROR the trait bound +//FIXME ~^ ERROR the trait bound fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr deleted file mode 100644 index bf12ef1ca..000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0277]: the trait bound `S: ~const Foo` is not satisfied - --> $DIR/super-traits-fail.rs:15:20 - | -LL | impl const Bar for S {} - | ^ the trait `~const Foo` is not implemented for `S` - | -note: the trait `Foo` is implemented for `S`, but that implementation is not `const` - --> $DIR/super-traits-fail.rs:15:20 - | -LL | impl const Bar for S {} - | ^ -note: required by a bound in `Bar` - --> $DIR/super-traits-fail.rs:8:12 - | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^ required by this bound in `Bar` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits.rs index df96f6fb4..92becf7c4 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] trait Foo { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs index 78a64b901..89d74cecf 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(generic_arg_infer)] #![feature(generic_const_exprs)] #![allow(incomplete_features)] @@ -6,9 +6,10 @@ struct Foo; impl Foo { - fn add(self) -> Foo<{ A::add(N) }> { - Foo - } + fn add(self) -> Foo<{ A::add(N) }> { + //~^ ERROR mismatched types + Foo + } } #[const_trait] @@ -24,6 +25,7 @@ impl const Add42 for () { fn bar(_: Foo) -> Foo<{ A::add(N) }> { //~^ ERROR `~const` is not allowed here + //~| ERROR mismatched types Foo } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr index aae72f36e..ec5d21d33 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr @@ -1,14 +1,33 @@ error: `~const` is not allowed here - --> $DIR/tilde-const-and-const-params.rs:25:11 + --> $DIR/tilde-const-and-const-params.rs:26:11 | LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { | ^^^^^^^^^^^^ | note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-and-const-params.rs:25:4 + --> $DIR/tilde-const-and-const-params.rs:26:4 | LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { | ^^^ -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/tilde-const-and-const-params.rs:26:61 + | +LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { + | ^^^^^^^^^ expected `false`, found `true` + | + = note: expected constant `false` + found constant `true` + +error[E0308]: mismatched types + --> $DIR/tilde-const-and-const-params.rs:9:44 + | +LL | fn add(self) -> Foo<{ A::add(N) }> { + | ^^^^^^^^^ expected `false`, found `true` + | + = note: expected constant `false` + found constant `true` + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs index 285cef571..fbdc3a4f3 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs @@ -1,5 +1,6 @@ -// check-pass -#![feature(const_trait_impl)] +// known-bug: #110395 +// FIXME check-pass +#![feature(const_trait_impl, effects)] #[const_trait] trait Foo { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr new file mode 100644 index 000000000..f77672f3e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/tilde_const_on_impl_bound.rs:14:9 + | +LL | self.0.foo() + | ^^^^^^^^^^^^ expected `host`, found `true` + | + = note: expected constant `host` + found constant `true` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr index 35dc1ca12..deed05ae1 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr @@ -1,20 +1,29 @@ -error: const `impl` for trait `Try` which is not marked with `#[const_trait]` - --> $DIR/trait-default-body-stability.rs:18:12 +error[E0015]: `?` cannot determine the branch of `T` in constant functions + --> $DIR/trait-default-body-stability.rs:44:9 | -LL | impl const Try for T { - | ^^^ +LL | T? + | ^^ + | +note: impl defined here, but it is not `const` + --> $DIR/trait-default-body-stability.rs:18:1 | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change +LL | impl const Try for T { + | ^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` - --> $DIR/trait-default-body-stability.rs:33:12 +error[E0015]: `?` cannot convert from residual of `T` in constant functions + --> $DIR/trait-default-body-stability.rs:44:9 | -LL | impl const FromResidual for T { - | ^^^^^^^^^^^^ +LL | T? + | ^^ + | +note: impl defined here, but it is not `const` + --> $DIR/trait-default-body-stability.rs:33:1 | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change +LL | impl const FromResidual for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs index bfe98b98c..94be3ff46 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs @@ -2,7 +2,9 @@ // Checking the validity of traits' where clauses happen at a later stage. // (`rustc_const_eval` instead of `rustc_hir_analysis`) Therefore one file as a // test is not enough. -#![feature(const_trait_impl)] +// known-bug: #110395 +// FIXME check-pass +#![feature(const_trait_impl, effects)] #[const_trait] trait Bar {} @@ -17,9 +19,9 @@ trait Foo { const fn test1() { T::a(); T::b(); - //~^ ERROR the trait bound + //FIXME ~^ ERROR the trait bound T::c::(); - //~^ ERROR the trait bound + //FIXME ~^ ERROR the trait bound } const fn test2() { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr index f2846b6a6..e8d0eec02 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr @@ -1,34 +1,34 @@ error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:19:5 + --> $DIR/trait-where-clause-const.rs:21:5 | LL | T::b(); - | ^^^^^^ the trait `~const Bar` is not implemented for `T` + | ^^^^ the trait `Bar` is not implemented for `T` | -note: the trait `Bar` is implemented for `T`, but that implementation is not `const` - --> $DIR/trait-where-clause-const.rs:19:5 +note: required by a bound in `Foo::b` + --> $DIR/trait-where-clause-const.rs:15:24 | -LL | T::b(); - | ^^^^^^ +LL | fn b() where Self: ~const Bar; + | ^^^^^^^^^^ required by this bound in `Foo::b` help: consider further restricting this bound | -LL | const fn test1() { - | ++++++++++++ +LL | const fn test1() { + | +++++ error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:21:5 + --> $DIR/trait-where-clause-const.rs:23:12 | LL | T::c::(); - | ^^^^^^^^^^^ the trait `~const Bar` is not implemented for `T` + | ^ the trait `Bar` is not implemented for `T` | -note: the trait `Bar` is implemented for `T`, but that implementation is not `const` - --> $DIR/trait-where-clause-const.rs:21:5 +note: required by a bound in `Foo::c` + --> $DIR/trait-where-clause-const.rs:16:13 | -LL | T::c::(); - | ^^^^^^^^^^^ +LL | fn c(); + | ^^^^^^^^^^ required by this bound in `Foo::c` help: consider further restricting this bound | -LL | const fn test1() { - | ++++++++++++ +LL | const fn test1() { + | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs index 4b8b00406..5439f859a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs @@ -1,6 +1,6 @@ // run-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] trait Bar { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs index 3b028ac48..c578813b8 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] trait Foo { diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs new file mode 100644 index 000000000..0907061d6 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs @@ -0,0 +1,14 @@ +// force-host +// edition: 2018 +// no-prefer-dynamic +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; +use std::str::FromStr; + +#[proc_macro] +pub fn number_of_tokens(_: TokenStream) -> TokenStream { + TokenStream::from_str("c\"\"").unwrap().into_iter().count().to_string().parse().unwrap() +} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs index 3fc5fd481..503739600 100644 --- a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs @@ -1,5 +1,4 @@ -// FIXME(c_str_literals): This should be `run-pass` -// known-bug: #113333 +// run-pass // edition: 2021 #![feature(c_str_literals)] diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr deleted file mode 100644 index 571c319d8..000000000 --- a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: prefix `c` is unknown - --> $DIR/basic.rs:8:27 - | -LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul()); - | ^ unknown prefix - | - = note: prefixed identifiers and literals are reserved since Rust 2021 -help: consider inserting whitespace here - | -LL | assert_eq!(b"test\0", c "test".to_bytes_with_nul()); - | + - -error: no rules expected the token `"test"` - --> $DIR/basic.rs:8:28 - | -LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul()); - | -^^^^^ - | | - | no rules expected this token in macro call - | help: missing comma here - | - = note: while trying to match sequence start - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs new file mode 100644 index 000000000..b3557c71b --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs @@ -0,0 +1,16 @@ +// even if this crate is edition 2021, proc macros compiled using older +// editions should still be able to observe the pre-2021 token behavior +// +// adapted from tests/ui/rust-2021/reserved-prefixes-via-macro.rs + +// edition: 2021 +// check-pass + +// aux-build: count.rs +extern crate count; + +const _: () = { + assert!(count::number_of_tokens!() == 2); +}; + +fn main() {} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr index 8de36ca4a..ea666e433 100644 --- a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr @@ -1,32 +1,21 @@ -error: prefix `c` is unknown +error[E0658]: `c".."` literals are experimental --> $DIR/gate.rs:10:5 | LL | c"foo"; - | ^ unknown prefix + | ^^^^^^ | - = note: prefixed identifiers and literals are reserved since Rust 2021 -help: consider inserting whitespace here - | -LL | c "foo"; - | + + = note: see issue #105723 for more information + = help: add `#![feature(c_str_literals)]` to the crate attributes to enable -error: prefix `c` is unknown +error[E0658]: `c".."` literals are experimental --> $DIR/gate.rs:13:8 | LL | m!(c"test"); - | ^ unknown prefix - | - = note: prefixed identifiers and literals are reserved since Rust 2021 -help: consider inserting whitespace here + | ^^^^^^^ | -LL | m!(c "test"); - | + - -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"foo"` - --> $DIR/gate.rs:10:6 - | -LL | c"foo"; - | ^^^^^ expected one of 8 possible tokens + = note: see issue #105723 for more information + = help: add `#![feature(c_str_literals)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs index 96945f125..369173e23 100644 Binary files a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs and b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs differ diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr index 2226c7aa6..82d9f9cb3 100644 Binary files a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr and b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr differ diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs index 066505c23..380445d7a 100644 --- a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs @@ -1,5 +1,4 @@ -// FIXME(c_str_literals): This should be `run-pass` -// known-bug: #113333 +// run-pass // edition: 2021 #![feature(c_str_literals)] diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr deleted file mode 100644 index 47361fb61..000000000 --- a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: prefix `c` is unknown - --> $DIR/non-ascii.rs:9:9 - | -LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), - | ^ unknown prefix - | - = note: prefixed identifiers and literals are reserved since Rust 2021 -help: consider inserting whitespace here - | -LL | c "\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), - | + - -error: out of range hex escape - --> $DIR/non-ascii.rs:9:11 - | -LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), - | ^^^^ must be a character in the range [\x00-\x7f] - -error: out of range hex escape - --> $DIR/non-ascii.rs:9:15 - | -LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), - | ^^^^ must be a character in the range [\x00-\x7f] - -error: no rules expected the token `"\xEF\x80🦀\u{1F980}"` - --> $DIR/non-ascii.rs:9:10 - | -LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), - | -^^^^^^^^^^^^^^^^^^^^ - | | - | no rules expected this token in macro call - | help: missing comma here - | -note: while trying to match `,` - --> $SRC_DIR/core/src/macros/mod.rs:LL:COL - -error: aborting due to 4 previous errors - diff --git a/tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs b/tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs deleted file mode 100644 index f5e8c3d2a..000000000 --- a/tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs +++ /dev/null @@ -1,8 +0,0 @@ -// no-prefer-dynamic - -#![crate_type="rlib"] -#![crate_name="rmeta_aux"] - -pub struct Foo { - pub field: i32, -} diff --git a/tests/ui/rmeta/auxiliary/rmeta-rmeta.rs b/tests/ui/rmeta/auxiliary/rmeta-rmeta.rs deleted file mode 100644 index 4a6d055a8..000000000 --- a/tests/ui/rmeta/auxiliary/rmeta-rmeta.rs +++ /dev/null @@ -1,9 +0,0 @@ -// no-prefer-dynamic -// compile-flags: --emit=metadata - -#![crate_type="rlib"] -#![crate_name="rmeta_aux"] - -pub struct Foo { - pub field2: i32, -} diff --git a/tests/ui/rmeta/rmeta-rpass.rs b/tests/ui/rmeta/rmeta-rpass.rs deleted file mode 100644 index 173a6a394..000000000 --- a/tests/ui/rmeta/rmeta-rpass.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass -// Test that using rlibs and rmeta dep crates work together. Specifically, that -// there can be both an rmeta and an rlib file and rustc will prefer the rmeta -// file. -// -// This behavior is simply making sure this doesn't accidentally change; in this -// case we want to make sure that the rlib isn't being used as that would cause -// bugs in -Zbinary-dep-depinfo (see #68298). - -// aux-build:rmeta-rmeta.rs -// aux-build:rmeta-rlib-rpass.rs - -extern crate rmeta_aux; -use rmeta_aux::Foo; - -pub fn main() { - let _ = Foo { field2: 42 }; -} diff --git a/tests/ui/sanitize/address.rs b/tests/ui/sanitize/address.rs index 5b2cea875..1faab1fd2 100644 --- a/tests/ui/sanitize/address.rs +++ b/tests/ui/sanitize/address.rs @@ -1,11 +1,12 @@ // needs-sanitizer-support // needs-sanitizer-address +// ignore-cross-compile // // compile-flags: -Z sanitizer=address -O -g // // run-fail // error-pattern: AddressSanitizer: stack-buffer-overflow -// error-pattern: 'xs' (line 13) <== Memory access at offset +// error-pattern: 'xs' (line 14) <== Memory access at offset use std::hint::black_box; diff --git a/tests/ui/sanitize/badfree.rs b/tests/ui/sanitize/badfree.rs index 095a6f469..c8d1ce7df 100644 --- a/tests/ui/sanitize/badfree.rs +++ b/tests/ui/sanitize/badfree.rs @@ -1,5 +1,6 @@ // needs-sanitizer-support // needs-sanitizer-address +// ignore-cross-compile // // compile-flags: -Z sanitizer=address -O // diff --git a/tests/ui/sanitize/issue-111184-generator-witness.rs b/tests/ui/sanitize/issue-111184-generator-witness.rs index 8f4118057..d36d8bce5 100644 --- a/tests/ui/sanitize/issue-111184-generator-witness.rs +++ b/tests/ui/sanitize/issue-111184-generator-witness.rs @@ -2,10 +2,10 @@ // encode_ty and caused the compiler to ICE. // // needs-sanitizer-cfi -// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +// compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 // no-prefer-dynamic // only-x86_64-unknown-linux-gnu -// run-pass +// build-pass use std::future::Future; diff --git a/tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs b/tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs new file mode 100644 index 000000000..8f870be13 --- /dev/null +++ b/tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs @@ -0,0 +1,15 @@ +// Regression test for issue 114275 `typeid::typeid_itanium_cxx_abi::transform_ty` +// was expecting array type lengths to be evaluated, this was causing an ICE. +// +// build-pass +// compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static +// needs-sanitizer-cfi + +#![crate_type = "lib"] + +#[repr(transparent)] +pub struct Array([u8; 1 * 1]); + +pub extern "C" fn array() -> Array { + loop {} +} diff --git a/tests/ui/sanitize/issue-72154-lifetime-markers.rs b/tests/ui/sanitize/issue-72154-lifetime-markers.rs index b2e182238..3d9c51daa 100644 --- a/tests/ui/sanitize/issue-72154-lifetime-markers.rs +++ b/tests/ui/sanitize/issue-72154-lifetime-markers.rs @@ -5,6 +5,7 @@ // // needs-sanitizer-support // needs-sanitizer-address +// ignore-cross-compile // // compile-flags: -Copt-level=0 -Zsanitizer=address // run-pass diff --git a/tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs b/tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs index 33e18e355..052a40598 100644 --- a/tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs +++ b/tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs @@ -4,6 +4,7 @@ // // needs-sanitizer-support // needs-sanitizer-address +// ignore-cross-compile // // no-prefer-dynamic // revisions: opt0 opt1 diff --git a/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs b/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs index 29e32889f..e9a49dd3f 100644 --- a/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs +++ b/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs @@ -1,4 +1,4 @@ -// Verifies that `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`. +// Verifies that `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`. // // needs-sanitizer-cfi // compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi diff --git a/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr b/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr index 5e706b513..8cd9c5444 100644 --- a/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr +++ b/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto` +error: `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto` error: aborting due to previous error diff --git a/tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.rs b/tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.rs new file mode 100644 index 000000000..a13c12c17 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.rs @@ -0,0 +1,8 @@ +// Verifies that `-Zsanitizer=cfi` with `-Clto` or `-Clto=thin` requires `-Ccodegen-units=1`. +// +// needs-sanitizer-cfi +// compile-flags: -Ccodegen-units=2 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.stderr b/tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.stderr new file mode 100644 index 000000000..136f49360 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-with-rustc-lto-requires-single-codegen-unit.stderr @@ -0,0 +1,4 @@ +error: `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1` + +error: aborting due to previous error + diff --git a/tests/ui/sanitize/use-after-scope.rs b/tests/ui/sanitize/use-after-scope.rs index 30be2ae6f..de63eea19 100644 --- a/tests/ui/sanitize/use-after-scope.rs +++ b/tests/ui/sanitize/use-after-scope.rs @@ -1,5 +1,6 @@ // needs-sanitizer-support // needs-sanitizer-address +// ignore-cross-compile // // compile-flags: -Zsanitizer=address // run-fail diff --git a/tests/ui/self/arbitrary_self_type_mut_difference.rs b/tests/ui/self/arbitrary_self_type_mut_difference.rs new file mode 100644 index 000000000..e75c00ae9 --- /dev/null +++ b/tests/ui/self/arbitrary_self_type_mut_difference.rs @@ -0,0 +1,13 @@ +// Related to #57994. +use std::pin::Pin; +struct S; + +impl S { + fn x(self: Pin<&mut Self>) {} //~ NOTE method is available for `Pin<&mut S>` + fn y(self: Pin<&Self>) {} //~ NOTE method is available for `Pin<&S>` +} + +fn main() { + Pin::new(&S).x(); //~ ERROR no method named `x` found for struct `Pin<&S>` in the current scope + Pin::new(&mut S).y(); //~ ERROR no method named `y` found for struct `Pin<&mut S>` in the current scope +} diff --git a/tests/ui/self/arbitrary_self_type_mut_difference.stderr b/tests/ui/self/arbitrary_self_type_mut_difference.stderr new file mode 100644 index 000000000..a56d58694 --- /dev/null +++ b/tests/ui/self/arbitrary_self_type_mut_difference.stderr @@ -0,0 +1,27 @@ +error[E0599]: no method named `x` found for struct `Pin<&S>` in the current scope + --> $DIR/arbitrary_self_type_mut_difference.rs:11:18 + | +LL | Pin::new(&S).x(); + | ^ help: there is a method with a similar name: `y` + | +note: method is available for `Pin<&mut S>` + --> $DIR/arbitrary_self_type_mut_difference.rs:6:5 + | +LL | fn x(self: Pin<&mut Self>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0599]: no method named `y` found for struct `Pin<&mut S>` in the current scope + --> $DIR/arbitrary_self_type_mut_difference.rs:12:22 + | +LL | Pin::new(&mut S).y(); + | ^ help: there is a method with a similar name: `x` + | +note: method is available for `Pin<&S>` + --> $DIR/arbitrary_self_type_mut_difference.rs:7:5 + | +LL | fn y(self: Pin<&Self>) {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.fixed b/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.fixed new file mode 100644 index 000000000..6a94b85b9 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.fixed @@ -0,0 +1,17 @@ +// run-rustfix +#![allow(dead_code)] +mod first { + trait Foo { fn m(self: Box); } + fn foo(a: T) { + Box::new(a).m(); //~ ERROR no method named `m` found + } +} +mod second { + use std::sync::Arc; + trait Bar { fn m(self: Arc); } + fn bar(b: impl Bar) { + Arc::new(b).m(); //~ ERROR no method named `m` found + } +} + +fn main() {} diff --git a/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.rs b/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.rs new file mode 100644 index 000000000..fa480b1f7 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.rs @@ -0,0 +1,17 @@ +// run-rustfix +#![allow(dead_code)] +mod first { + trait Foo { fn m(self: Box); } + fn foo(a: T) { + a.m(); //~ ERROR no method named `m` found + } +} +mod second { + use std::sync::Arc; + trait Bar { fn m(self: Arc); } + fn bar(b: impl Bar) { + b.m(); //~ ERROR no method named `m` found + } +} + +fn main() {} diff --git a/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.stderr b/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.stderr new file mode 100644 index 000000000..2ab634ad3 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_needing_box_or_arc_wrapping.stderr @@ -0,0 +1,43 @@ +error[E0599]: no method named `m` found for type parameter `T` in the current scope + --> $DIR/arbitrary_self_types_needing_box_or_arc_wrapping.rs:6:11 + | +LL | trait Foo { fn m(self: Box); } + | - --------- the method might not be found because of this arbitrary self type + | | + | the method is available for `Box` here +LL | fn foo(a: T) { + | - method `m` not found for this type parameter +LL | a.m(); + | ^ method not found in `T` +... +LL | trait Bar { fn m(self: Arc); } + | --------- the method might not be found because of this arbitrary self type + | +help: consider wrapping the receiver expression with the appropriate type + | +LL | Box::new(a).m(); + | +++++++++ + + +error[E0599]: no method named `m` found for type parameter `impl Bar` in the current scope + --> $DIR/arbitrary_self_types_needing_box_or_arc_wrapping.rs:13:11 + | +LL | trait Foo { fn m(self: Box); } + | --------- the method might not be found because of this arbitrary self type +... +LL | trait Bar { fn m(self: Arc); } + | - --------- the method might not be found because of this arbitrary self type + | | + | the method is available for `Arc` here +LL | fn bar(b: impl Bar) { + | -------- method `m` not found for this type parameter +LL | b.m(); + | ^ method not found in `impl Bar` + | +help: consider wrapping the receiver expression with the appropriate type + | +LL | Arc::new(b).m(); + | +++++++++ + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed b/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed new file mode 100644 index 000000000..ccd65ff40 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed @@ -0,0 +1,12 @@ +// run-rustfix +use std::pin::Pin; +struct S; + +impl S { + fn x(self: Pin<&mut Self>) { + } +} + +fn main() { + Pin::new(&mut S).x(); //~ ERROR no method named `x` found +} diff --git a/tests/ui/self/arbitrary_self_types_needing_mut_pin.rs b/tests/ui/self/arbitrary_self_types_needing_mut_pin.rs new file mode 100644 index 000000000..d15676a62 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_needing_mut_pin.rs @@ -0,0 +1,12 @@ +// run-rustfix +use std::pin::Pin; +struct S; + +impl S { + fn x(self: Pin<&mut Self>) { + } +} + +fn main() { + S.x(); //~ ERROR no method named `x` found +} diff --git a/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr b/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr new file mode 100644 index 000000000..f34ce4dce --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr @@ -0,0 +1,20 @@ +error[E0599]: no method named `x` found for struct `S` in the current scope + --> $DIR/arbitrary_self_types_needing_mut_pin.rs:11:7 + | +LL | struct S; + | -------- method `x` not found for this struct +... +LL | fn x(self: Pin<&mut Self>) { + | - the method is available for `Pin<&mut S>` here +... +LL | S.x(); + | ^ method not found in `S` + | +help: consider wrapping the receiver expression with the appropriate type + | +LL | Pin::new(&mut S).x(); + | +++++++++++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs new file mode 100644 index 000000000..d877dbe60 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs @@ -0,0 +1,13 @@ +use std::pin::Pin; +struct S; + +impl S { + fn x(self: Pin<&mut Self>) { + } +} + +fn main() { + Pin::new(S).x(); + //~^ ERROR the trait bound `S: Deref` is not satisfied + //~| ERROR no method named `x` found for struct `Pin` in the current scope +} diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr new file mode 100644 index 000000000..ec985b254 --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr @@ -0,0 +1,33 @@ +error[E0277]: the trait bound `S: Deref` is not satisfied + --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:14 + | +LL | Pin::new(S).x(); + | -------- ^ the trait `Deref` is not implemented for `S` + | | + | required by a bound introduced by this call + | +note: required by a bound in `Pin::

::new` + --> $SRC_DIR/core/src/pin.rs:LL:COL +help: consider borrowing here + | +LL | Pin::new(&S).x(); + | + +LL | Pin::new(&mut S).x(); + | ++++ + +error[E0599]: no method named `x` found for struct `Pin` in the current scope + --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17 + | +LL | Pin::new(S).x(); + | ^ method not found in `Pin` + | +note: method is available for `Pin<&mut S>` + --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:5:5 + | +LL | fn x(self: Pin<&mut Self>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/simd/intrinsic/float-minmax-pass.rs b/tests/ui/simd/intrinsic/float-minmax-pass.rs index d79be61f9..968b074b6 100644 --- a/tests/ui/simd/intrinsic/float-minmax-pass.rs +++ b/tests/ui/simd/intrinsic/float-minmax-pass.rs @@ -21,7 +21,7 @@ fn main() { #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] let nan = f32::NAN; - // MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit. + // MIPS hardware except MIPS R6 treats f32::NAN as SNAN. Clear the signaling bit. // See https://github.com/rust-lang/rust/issues/52746. #[cfg(any(target_arch = "mips", target_arch = "mips64"))] let nan = f32::from_bits(f32::NAN.to_bits() - 1); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index 3576eed71..62fb5238b 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -27,6 +27,10 @@ extern "platform-intrinsic" { fn simd_xor(x: T, y: T) -> T; fn simd_neg(x: T) -> T; + fn simd_bswap(x: T) -> T; + fn simd_bitreverse(x: T) -> T; + fn simd_ctlz(x: T) -> T; + fn simd_cttz(x: T) -> T; } fn main() { @@ -64,6 +68,14 @@ fn main() { simd_neg(x); simd_neg(z); + simd_bswap(x); + simd_bswap(y); + simd_bitreverse(x); + simd_bitreverse(y); + simd_ctlz(x); + simd_ctlz(y); + simd_cttz(x); + simd_cttz(y); simd_add(0, 0); @@ -87,6 +99,14 @@ fn main() { simd_neg(0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_bswap(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_bitreverse(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_ctlz(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_cttz(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shl(z, z); @@ -98,6 +118,14 @@ fn main() { simd_or(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_xor(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_bswap(z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_bitreverse(z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_ctlz(z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_cttz(z); //~^ ERROR unsupported operation on `f32x4` with element `f32` } } diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index 0f0a7ea66..db26f3417 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,93 +1,141 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:69:9 + --> $DIR/generic-arithmetic-2.rs:81:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:71:9 + --> $DIR/generic-arithmetic-2.rs:83:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:73:9 + --> $DIR/generic-arithmetic-2.rs:85:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:75:9 + --> $DIR/generic-arithmetic-2.rs:87:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:77:9 + --> $DIR/generic-arithmetic-2.rs:89:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:79:9 + --> $DIR/generic-arithmetic-2.rs:91:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:81:9 + --> $DIR/generic-arithmetic-2.rs:93:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:83:9 + --> $DIR/generic-arithmetic-2.rs:95:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:85:9 + --> $DIR/generic-arithmetic-2.rs:97:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:88:9 + --> $DIR/generic-arithmetic-2.rs:100:9 | LL | simd_neg(0); | ^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:102:9 + | +LL | simd_bswap(0); + | ^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:104:9 + | +LL | simd_bitreverse(0); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:106:9 + | +LL | simd_ctlz(0); + | ^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:108:9 + | +LL | simd_cttz(0); + | ^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:92:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:94:9 + --> $DIR/generic-arithmetic-2.rs:114:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:96:9 + --> $DIR/generic-arithmetic-2.rs:116:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:98:9 + --> $DIR/generic-arithmetic-2.rs:118:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:100:9 + --> $DIR/generic-arithmetic-2.rs:120:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ -error: aborting due to 15 previous errors +error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:122:9 + | +LL | simd_bswap(z); + | ^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:124:9 + | +LL | simd_bitreverse(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:126:9 + | +LL | simd_ctlz(z); + | ^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:128:9 + | +LL | simd_cttz(z); + | ^^^^^^^^^^^^ + +error: aborting due to 23 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index c507b8d31..f021ee471 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -1,8 +1,6 @@ // run-pass #![allow(non_camel_case_types)] - // ignore-emscripten FIXME(#45351) hits an LLVM assert - #![feature(repr_simd, platform_intrinsics)] #[repr(simd)] @@ -22,7 +20,7 @@ macro_rules! all_eq { let a = $a; let b = $b; assert!(a.0 == b.0 && a.1 == b.1 && a.2 == b.2 && a.3 == b.3); - }} + }}; } macro_rules! all_eq_ { @@ -30,10 +28,9 @@ macro_rules! all_eq_ { let a = $a; let b = $b; assert!(a.0 == b.0); - }} + }}; } - extern "platform-intrinsic" { fn simd_add(x: T, y: T) -> T; fn simd_sub(x: T, y: T) -> T; @@ -47,6 +44,10 @@ extern "platform-intrinsic" { fn simd_xor(x: T, y: T) -> T; fn simd_neg(x: T) -> T; + fn simd_bswap(x: T) -> T; + fn simd_bitreverse(x: T) -> T; + fn simd_ctlz(x: T) -> T; + fn simd_cttz(x: T) -> T; } fn main() { @@ -84,8 +85,8 @@ fn main() { all_eq_!(simd_div(y1, y1), U32::<4>([1, 1, 1, 1])); all_eq_!(simd_div(U32::<4>([2, 4, 6, 8]), U32::<4>([2, 2, 2, 2])), y1); all_eq!(simd_div(z1, z1), f32x4(1.0, 1.0, 1.0, 1.0)); - all_eq!(simd_div(z1, z2), f32x4(1.0/2.0, 2.0/3.0, 3.0/4.0, 4.0/5.0)); - all_eq!(simd_div(z2, z1), f32x4(2.0/1.0, 3.0/2.0, 4.0/3.0, 5.0/4.0)); + all_eq!(simd_div(z1, z2), f32x4(1.0 / 2.0, 2.0 / 3.0, 3.0 / 4.0, 4.0 / 5.0)); + all_eq!(simd_div(z2, z1), f32x4(2.0 / 1.0, 3.0 / 2.0, 4.0 / 3.0, 5.0 / 4.0)); all_eq!(simd_rem(x1, x1), i32x4(0, 0, 0, 0)); all_eq!(simd_rem(x2, x1), i32x4(0, 1, 1, 1)); @@ -109,8 +110,10 @@ fn main() { // ensure we get logical vs. arithmetic shifts correct let (a, b, c, d) = (-12, -123, -1234, -12345); all_eq!(simd_shr(i32x4(a, b, c, d), x1), i32x4(a >> 1, b >> 2, c >> 3, d >> 4)); - all_eq_!(simd_shr(U32::<4>([a as u32, b as u32, c as u32, d as u32]), y1), - U32::<4>([(a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4])); + all_eq_!( + simd_shr(U32::<4>([a as u32, b as u32, c as u32, d as u32]), y1), + U32::<4>([(a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4]) + ); all_eq!(simd_and(x1, x2), i32x4(0, 2, 0, 4)); all_eq!(simd_and(x2, x1), i32x4(0, 2, 0, 4)); @@ -132,5 +135,19 @@ fn main() { all_eq!(simd_neg(z1), f32x4(-1.0, -2.0, -3.0, -4.0)); all_eq!(simd_neg(z2), f32x4(-2.0, -3.0, -4.0, -5.0)); + all_eq!(simd_bswap(x1), i32x4(0x01000000, 0x02000000, 0x03000000, 0x04000000)); + all_eq_!(simd_bswap(y1), U32::<4>([0x01000000, 0x02000000, 0x03000000, 0x04000000])); + + all_eq!( + simd_bitreverse(x1), + i32x4(0x80000000u32 as i32, 0x40000000, 0xc0000000u32 as i32, 0x20000000) + ); + all_eq_!(simd_bitreverse(y1), U32::<4>([0x80000000, 0x40000000, 0xc0000000, 0x20000000])); + + all_eq!(simd_ctlz(x1), i32x4(31, 30, 30, 29)); + all_eq_!(simd_ctlz(y1), U32::<4>([31, 30, 30, 29])); + + all_eq!(simd_cttz(x1), i32x4(0, 1, 0, 2)); + all_eq_!(simd_cttz(y1), U32::<4>([0, 1, 0, 2])); } } diff --git a/tests/ui/simd/intrinsic/generic-bswap-byte.rs b/tests/ui/simd/intrinsic/generic-bswap-byte.rs new file mode 100644 index 000000000..13fc942c2 --- /dev/null +++ b/tests/ui/simd/intrinsic/generic-bswap-byte.rs @@ -0,0 +1,22 @@ +// run-pass +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +struct i8x4([i8; 4]); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u8x4([u8; 4]); + +extern "platform-intrinsic" { + fn simd_bswap(x: T) -> T; +} + +fn main() { + unsafe { + assert_eq!(simd_bswap(i8x4([0, 1, 2, 3])).0, [0, 1, 2, 3]); + assert_eq!(simd_bswap(u8x4([0, 1, 2, 3])).0, [0, 1, 2, 3]); + } +} diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index 3c913c0ad..905c3b8d3 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -22,9 +22,7 @@ extern "platform-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; fn simd_extract(x: T, idx: u32) -> E; - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; - fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; - fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; + fn simd_shuffle(x: T, y: T, idx: I) -> U; } macro_rules! all_eq { @@ -83,19 +81,19 @@ fn main() { let y4 = i32x4(140, 141, 142, 143); let y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187); unsafe { - all_eq!(simd_shuffle2(x2, y2, const { [3u32, 0] }), i32x2(121, 20)); - all_eq!(simd_shuffle4(x2, y2, const { [3u32, 0, 1, 2] }), i32x4(121, 20, 21, 120)); - all_eq!(simd_shuffle8(x2, y2, const { [3u32, 0, 1, 2, 1, 2, 3, 0] }), + all_eq!(simd_shuffle(x2, y2, const { [3u32, 0] }), i32x2(121, 20)); + all_eq!(simd_shuffle(x2, y2, const { [3u32, 0, 1, 2] }), i32x4(121, 20, 21, 120)); + all_eq!(simd_shuffle(x2, y2, const { [3u32, 0, 1, 2, 1, 2, 3, 0] }), i32x8(121, 20, 21, 120, 21, 120, 121, 20)); - all_eq!(simd_shuffle2(x4, y4, const { [7u32, 2] }), i32x2(143, 42)); - all_eq!(simd_shuffle4(x4, y4, const { [7u32, 2, 5, 0] }), i32x4(143, 42, 141, 40)); - all_eq!(simd_shuffle8(x4, y4, const { [7u32, 2, 5, 0, 3, 6, 4, 1] }), + all_eq!(simd_shuffle(x4, y4, const { [7u32, 2] }), i32x2(143, 42)); + all_eq!(simd_shuffle(x4, y4, const { [7u32, 2, 5, 0] }), i32x4(143, 42, 141, 40)); + all_eq!(simd_shuffle(x4, y4, const { [7u32, 2, 5, 0, 3, 6, 4, 1] }), i32x8(143, 42, 141, 40, 43, 142, 140, 41)); - all_eq!(simd_shuffle2(x8, y8, const { [11u32, 5] }), i32x2(183, 85)); - all_eq!(simd_shuffle4(x8, y8, const { [11u32, 5, 15, 0] }), i32x4(183, 85, 187, 80)); - all_eq!(simd_shuffle8(x8, y8, const { [11u32, 5, 15, 0, 3, 8, 12, 1] }), + all_eq!(simd_shuffle(x8, y8, const { [11u32, 5] }), i32x2(183, 85)); + all_eq!(simd_shuffle(x8, y8, const { [11u32, 5, 15, 0] }), i32x4(183, 85, 187, 80)); + all_eq!(simd_shuffle(x8, y8, const { [11u32, 5, 15, 0, 3, 8, 12, 1] }), i32x8(183, 85, 187, 80, 83, 180, 184, 81)); } diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index abde69163..0ff2203ec 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -34,9 +34,7 @@ extern "platform-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; fn simd_extract(x: T, idx: u32) -> E; - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; - fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; - fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; + fn simd_shuffle(x: T, y: T, idx: I) -> U; } fn main() { @@ -51,27 +49,27 @@ fn main() { //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32` const IDX2: [u32; 2] = [0; 2]; - simd_shuffle2::(0, 0, IDX2); + simd_shuffle::(0, 0, IDX2); //~^ ERROR expected SIMD input type, found non-SIMD `i32` const IDX4: [u32; 4] = [0; 4]; - simd_shuffle4::(0, 0, IDX4); + simd_shuffle::(0, 0, IDX4); //~^ ERROR expected SIMD input type, found non-SIMD `i32` const IDX8: [u32; 8] = [0; 8]; - simd_shuffle8::(0, 0, IDX8); + simd_shuffle::(0, 0, IDX8); //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shuffle2::<_, f32x2>(x, x, IDX2); + simd_shuffle::<_, _, f32x2>(x, x, IDX2); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - simd_shuffle4::<_, f32x4>(x, x, IDX4); + simd_shuffle::<_, _, f32x4>(x, x, IDX4); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - simd_shuffle8::<_, f32x8>(x, x, IDX8); + simd_shuffle::<_, _, f32x8>(x, x, IDX8); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - simd_shuffle2::<_, i32x8>(x, x, IDX2); + simd_shuffle::<_, _, i32x8>(x, x, IDX2); //~^ ERROR expected return type of length 2, found `i32x8` with length 8 - simd_shuffle4::<_, i32x8>(x, x, IDX4); + simd_shuffle::<_, _, i32x8>(x, x, IDX4); //~^ ERROR expected return type of length 4, found `i32x8` with length 8 - simd_shuffle8::<_, i32x2>(x, x, IDX8); + simd_shuffle::<_, _, i32x2>(x, x, IDX8); //~^ ERROR expected return type of length 8, found `i32x2` with length 2 } } diff --git a/tests/ui/simd/intrinsic/generic-elements.stderr b/tests/ui/simd/intrinsic/generic-elements.stderr index 5b423f704..115d9d4b3 100644 --- a/tests/ui/simd/intrinsic/generic-elements.stderr +++ b/tests/ui/simd/intrinsic/generic-elements.stderr @@ -1,74 +1,74 @@ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:46:9 + --> $DIR/generic-elements.rs:44:9 | LL | simd_insert(0, 0, 0); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` - --> $DIR/generic-elements.rs:48:9 + --> $DIR/generic-elements.rs:46:9 | LL | simd_insert(x, 0, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` - --> $DIR/generic-elements.rs:50:9 + --> $DIR/generic-elements.rs:48:9 | LL | simd_extract::<_, f32>(x, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:54:9 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:52:9 | -LL | simd_shuffle2::(0, 0, IDX2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::(0, 0, IDX2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:57:9 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:55:9 | -LL | simd_shuffle4::(0, 0, IDX4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::(0, 0, IDX4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:60:9 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:58:9 | -LL | simd_shuffle8::(0, 0, IDX8); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::(0, 0, IDX8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + --> $DIR/generic-elements.rs:61:9 + | +LL | simd_shuffle::<_, _, f32x2>(x, x, IDX2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` --> $DIR/generic-elements.rs:63:9 | -LL | simd_shuffle2::<_, f32x2>(x, x, IDX2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::<_, _, f32x4>(x, x, IDX4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` --> $DIR/generic-elements.rs:65:9 | -LL | simd_shuffle4::<_, f32x4>(x, x, IDX4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::<_, _, f32x8>(x, x, IDX8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:67:9 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `i32x8` with length 8 + --> $DIR/generic-elements.rs:68:9 | -LL | simd_shuffle8::<_, f32x8>(x, x, IDX8); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::<_, _, i32x8>(x, x, IDX2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return type of length 2, found `i32x8` with length 8 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 4, found `i32x8` with length 8 --> $DIR/generic-elements.rs:70:9 | -LL | simd_shuffle2::<_, i32x8>(x, x, IDX2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::<_, _, i32x8>(x, x, IDX4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x8` with length 8 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 8, found `i32x2` with length 2 --> $DIR/generic-elements.rs:72:9 | -LL | simd_shuffle4::<_, i32x8>(x, x, IDX4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:74:9 - | -LL | simd_shuffle8::<_, i32x2>(x, x, IDX8); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs index 7221b3ab7..5ca684a9d 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs @@ -6,7 +6,7 @@ #![feature(platform_intrinsics, repr_simd)] extern "platform-intrinsic" { - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle(x: T, y: T, idx: I) -> U; } #[repr(simd)] @@ -22,5 +22,5 @@ fn main() { #[inline(always)] unsafe fn inline_me() -> Simd2 { const IDX: [u32; 2] = [0, 3]; - simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) + simd_shuffle(Simd2(10, 11), Simd2(12, 13), IDX) } diff --git a/tests/ui/simd/intrinsic/inlining-issue67557.rs b/tests/ui/simd/intrinsic/inlining-issue67557.rs index 0d1542709..5633ad70c 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557.rs @@ -6,7 +6,7 @@ #![feature(platform_intrinsics, repr_simd)] extern "platform-intrinsic" { - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle(x: T, y: T, idx: I) -> U; } #[repr(simd)] @@ -16,7 +16,7 @@ struct Simd2(u8, u8); fn main() { unsafe { const IDX: [u32; 2] = [0, 1]; - let p_res: Simd2 = simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX); + let p_res: Simd2 = simd_shuffle(Simd2(10, 11), Simd2(12, 13), IDX); let a_res: Simd2 = inline_me(); assert_10_11(p_res); @@ -38,5 +38,5 @@ fn assert_10_13(x: Simd2) { #[inline(always)] unsafe fn inline_me() -> Simd2 { const IDX: [u32; 2] = [0, 3]; - simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) + simd_shuffle(Simd2(10, 11), Simd2(12, 13), IDX) } diff --git a/tests/ui/simd/shuffle-not-out-of-bounds.rs b/tests/ui/simd/shuffle-not-out-of-bounds.rs index 0dee3a0e8..18939bcc5 100644 --- a/tests/ui/simd/shuffle-not-out-of-bounds.rs +++ b/tests/ui/simd/shuffle-not-out-of-bounds.rs @@ -29,12 +29,7 @@ struct u8x32([u8; 32]); struct u8x64([u8; 64]); extern "platform-intrinsic" { - pub fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; - pub fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; - pub fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; - pub fn simd_shuffle16(x: T, y: T, idx: [u32; 16]) -> U; - pub fn simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U; - pub fn simd_shuffle64(x: T, y: T, idx: [u32; 64]) -> U; + pub fn simd_shuffle(x: T, y: T, idx: I) -> U; } // Test vectors by lane size. Since LLVM does not distinguish between a shuffle @@ -58,22 +53,22 @@ macro_rules! test_shuffle_lanes { } } } -//~^^^^^ ERROR: invalid monomorphization of `simd_shuffle2` intrinsic -//~| ERROR: invalid monomorphization of `simd_shuffle4` intrinsic -//~| ERROR: invalid monomorphization of `simd_shuffle8` intrinsic -//~| ERROR: invalid monomorphization of `simd_shuffle16` intrinsic -//~| ERROR: invalid monomorphization of `simd_shuffle32` intrinsic -//~| ERROR: invalid monomorphization of `simd_shuffle64` intrinsic +//~^^^^^ ERROR: invalid monomorphization of `simd_shuffle` intrinsic +//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic +//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic +//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic +//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic +//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic // Because the test is mostly embedded in a macro, all the errors have the same origin point. // And unfortunately, standard comments, as in the UI test harness, disappear in macros! fn main() { - test_shuffle_lanes!(2, u8x2, simd_shuffle2); - test_shuffle_lanes!(4, u8x4, simd_shuffle4); - test_shuffle_lanes!(8, u8x8, simd_shuffle8); - test_shuffle_lanes!(16, u8x16, simd_shuffle16); - test_shuffle_lanes!(32, u8x32, simd_shuffle32); - test_shuffle_lanes!(64, u8x64, simd_shuffle64); + test_shuffle_lanes!(2, u8x2, simd_shuffle); + test_shuffle_lanes!(4, u8x4, simd_shuffle); + test_shuffle_lanes!(8, u8x8, simd_shuffle); + test_shuffle_lanes!(16, u8x16, simd_shuffle); + test_shuffle_lanes!(32, u8x32, simd_shuffle); + test_shuffle_lanes!(64, u8x64, simd_shuffle); extern "platform-intrinsic" { fn simd_shuffle(a: T, b: T, i: I) -> U; diff --git a/tests/ui/simd/shuffle-not-out-of-bounds.stderr b/tests/ui/simd/shuffle-not-out-of-bounds.stderr index 415f04d93..59e5ab858 100644 --- a/tests/ui/simd/shuffle-not-out-of-bounds.stderr +++ b/tests/ui/simd/shuffle-not-out-of-bounds.stderr @@ -1,71 +1,71 @@ -error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: shuffle index #0 is out of bounds (limit 4) - --> $DIR/shuffle-not-out-of-bounds.rs:56:21 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4) + --> $DIR/shuffle-not-out-of-bounds.rs:51:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(2, u8x2, simd_shuffle2); - | ------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(2, u8x2, simd_shuffle); + | ------------------------------------------ in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: shuffle index #0 is out of bounds (limit 8) - --> $DIR/shuffle-not-out-of-bounds.rs:56:21 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 8) + --> $DIR/shuffle-not-out-of-bounds.rs:51:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(4, u8x4, simd_shuffle4); - | ------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(4, u8x4, simd_shuffle); + | ------------------------------------------ in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: shuffle index #0 is out of bounds (limit 16) - --> $DIR/shuffle-not-out-of-bounds.rs:56:21 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 16) + --> $DIR/shuffle-not-out-of-bounds.rs:51:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(8, u8x8, simd_shuffle8); - | ------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(8, u8x8, simd_shuffle); + | ------------------------------------------ in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0511]: invalid monomorphization of `simd_shuffle16` intrinsic: shuffle index #0 is out of bounds (limit 32) - --> $DIR/shuffle-not-out-of-bounds.rs:56:21 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 32) + --> $DIR/shuffle-not-out-of-bounds.rs:51:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(16, u8x16, simd_shuffle16); - | ---------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(16, u8x16, simd_shuffle); + | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0511]: invalid monomorphization of `simd_shuffle32` intrinsic: shuffle index #0 is out of bounds (limit 64) - --> $DIR/shuffle-not-out-of-bounds.rs:56:21 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 64) + --> $DIR/shuffle-not-out-of-bounds.rs:51:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(32, u8x32, simd_shuffle32); - | ---------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(32, u8x32, simd_shuffle); + | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0511]: invalid monomorphization of `simd_shuffle64` intrinsic: shuffle index #0 is out of bounds (limit 128) - --> $DIR/shuffle-not-out-of-bounds.rs:56:21 +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 128) + --> $DIR/shuffle-not-out-of-bounds.rs:51:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(64, u8x64, simd_shuffle64); - | ---------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(64, u8x64, simd_shuffle); + | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4) - --> $DIR/shuffle-not-out-of-bounds.rs:84:23 + --> $DIR/shuffle-not-out-of-bounds.rs:79:23 | LL | let _: u8x2 = simd_shuffle(v, v, I); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/shuffle.rs b/tests/ui/simd/shuffle.rs index 461243d48..838e31f8e 100644 --- a/tests/ui/simd/shuffle.rs +++ b/tests/ui/simd/shuffle.rs @@ -8,7 +8,6 @@ extern "platform-intrinsic" { fn simd_shuffle(a: T, b: T, i: I) -> U; - fn simd_shuffle16(x: T, y: T, idx: [u32; 16]) -> U; } #[derive(Copy, Clone)] @@ -16,7 +15,7 @@ extern "platform-intrinsic" { struct Simd([T; N]); pub unsafe fn __shuffle_vector16(x: T, y: T) -> U { - simd_shuffle16(x, y, IDX) + simd_shuffle(x, y, IDX) } fn main() { diff --git a/tests/ui/sized/recursive-type-2.stderr b/tests/ui/sized/recursive-type-2.stderr index d0e6e9db0..0f72f7414 100644 --- a/tests/ui/sized/recursive-type-2.stderr +++ b/tests/ui/sized/recursive-type-2.stderr @@ -7,6 +7,7 @@ note: cycle used when elaborating drops for `main` | LL | fn main() { | ^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index 80c5f9da4..4aad88437 100644 --- a/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -66,7 +66,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5 | LL | x.set(0, 0); - | ^^^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -77,7 +77,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5 | LL | x.y_mut() - | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -88,7 +88,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6 | LL | *x.y_mut() = 3; - | ^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider changing this to be mutable | @@ -99,7 +99,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6 | LL | *x.y_mut() = 3; - | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 99c8fa1f9..ba8da2e75 100644 --- a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -25,7 +25,7 @@ error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5 | LL | f.f.call_mut(()) - | ^^^^^^^^^^^^^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr b/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr index 328197ae9..3f033f5e4 100644 --- a/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr +++ b/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5 | LL | x.h(); - | ^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-fn-in-const-b.stderr b/tests/ui/span/borrowck-fn-in-const-b.stderr index 17fdcc622..929878026 100644 --- a/tests/ui/span/borrowck-fn-in-const-b.stderr +++ b/tests/ui/span/borrowck-fn-in-const-b.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-fn-in-const-b.rs:7:9 | LL | x.push(format!("this is broken")); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-let-suggestion-suffixes.stderr b/tests/ui/span/borrowck-let-suggestion-suffixes.stderr index 545b235a5..78cadc8c6 100644 --- a/tests/ui/span/borrowck-let-suggestion-suffixes.stderr +++ b/tests/ui/span/borrowck-let-suggestion-suffixes.stderr @@ -39,7 +39,7 @@ LL | v4.push(&id('y')); | creates a temporary value which is freed while still in use ... LL | v4.use_ref(); - | ------------ borrow later used here + | -- borrow later used here | = note: consider using a `let` binding to create a longer lived value diff --git a/tests/ui/span/borrowck-object-mutability.stderr b/tests/ui/span/borrowck-object-mutability.stderr index 805a8034c..e4b5c8ce7 100644 --- a/tests/ui/span/borrowck-object-mutability.stderr +++ b/tests/ui/span/borrowck-object-mutability.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-object-mutability.rs:8:5 | LL | x.borrowed_mut(); - | ^^^^^^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-object-mutability.rs:18:5 | LL | x.borrowed_mut(); - | ^^^^^^^^^^^^^^^^ cannot borrow as mutable + | ^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/span/destructor-restrictions.stderr b/tests/ui/span/destructor-restrictions.stderr index 281248626..b923cee5f 100644 --- a/tests/ui/span/destructor-restrictions.stderr +++ b/tests/ui/span/destructor-restrictions.stderr @@ -4,7 +4,7 @@ error[E0597]: `*a` does not live long enough LL | let a = Box::new(RefCell::new(4)); | - binding `a` declared here LL | *a.borrow() + 1 - | ^^^^^^^^^^ + | ^--------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... diff --git a/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr b/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr index e1a377203..421c22566 100644 --- a/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr +++ b/tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr @@ -4,7 +4,7 @@ error[E0597]: `y` does not live long enough LL | let y = x; | - binding `y` declared here LL | y.borrow().clone() - | ^^^^^^^^^^ + | ^--------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... @@ -27,7 +27,7 @@ error[E0597]: `y` does not live long enough LL | let y = x; | - binding `y` declared here LL | y.borrow().clone() - | ^^^^^^^^^^ + | ^--------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... diff --git a/tests/ui/span/issue-36537.stderr b/tests/ui/span/issue-36537.stderr index 6c330c1a0..8dfee8d64 100644 --- a/tests/ui/span/issue-36537.stderr +++ b/tests/ui/span/issue-36537.stderr @@ -9,7 +9,7 @@ LL | p = &a; LL | } | - `a` dropped here while still borrowed LL | p.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to previous error diff --git a/tests/ui/span/issue-39698.stderr b/tests/ui/span/issue-39698.stderr index 25c35fd54..81211b20a 100644 --- a/tests/ui/span/issue-39698.stderr +++ b/tests/ui/span/issue-39698.stderr @@ -1,3 +1,13 @@ +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/issue-39698.rs:10:9 + | +LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } + | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern doesn't bind `c` + | | | | + | | | variable not in all patterns + | | pattern doesn't bind `c` + | pattern doesn't bind `c` + error[E0408]: variable `d` is not bound in all patterns --> $DIR/issue-39698.rs:10:37 | @@ -28,16 +38,6 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | variable not in all patterns | pattern doesn't bind `b` -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/issue-39698.rs:10:9 - | -LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } - | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern doesn't bind `c` - | | | | - | | | variable not in all patterns - | | pattern doesn't bind `c` - | pattern doesn't bind `c` - error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0408`. diff --git a/tests/ui/span/issue-40157.stderr b/tests/ui/span/issue-40157.stderr index a0afd33f7..216876717 100644 --- a/tests/ui/span/issue-40157.stderr +++ b/tests/ui/span/issue-40157.stderr @@ -2,7 +2,7 @@ error[E0597]: `foo` does not live long enough --> $DIR/issue-40157.rs:2:53 | LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | --- ^^^^^^^^^^ - `foo` dropped here while still borrowed + | --- ^^^ - `foo` dropped here while still borrowed | | | | | borrowed value does not live long enough | binding `foo` declared here diff --git a/tests/ui/span/mut-arg-hint.stderr b/tests/ui/span/mut-arg-hint.stderr index 06011eac6..df782280b 100644 --- a/tests/ui/span/mut-arg-hint.stderr +++ b/tests/ui/span/mut-arg-hint.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:3:9 | LL | a.push_str("bar"); - | ^^^^^^^^^^^^^^^^^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:8:5 | LL | a.push_str("foo"); - | ^^^^^^^^^^^^^^^^^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:15:9 | LL | a.push_str("foo"); - | ^^^^^^^^^^^^^^^^^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/mut-ptr-cant-outlive-ref.stderr b/tests/ui/span/mut-ptr-cant-outlive-ref.stderr index be56f9489..395b6ec67 100644 --- a/tests/ui/span/mut-ptr-cant-outlive-ref.stderr +++ b/tests/ui/span/mut-ptr-cant-outlive-ref.stderr @@ -9,7 +9,7 @@ LL | } | - `b` dropped here while still borrowed LL | LL | p.use_ref(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to previous error diff --git a/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr b/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr index fb3fad6ae..9b5ec8461 100644 --- a/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr +++ b/tests/ui/span/regionck-unboxed-closure-lifetimes.stderr @@ -9,7 +9,7 @@ LL | let c_ref = &c; LL | } | - `c` dropped here while still borrowed LL | f.use_mut(); - | ----------- borrow later used here + | - borrow later used here error: aborting due to previous error diff --git a/tests/ui/span/regions-escape-loop-via-vec.stderr b/tests/ui/span/regions-escape-loop-via-vec.stderr index 532ac3606..18c6cd480 100644 --- a/tests/ui/span/regions-escape-loop-via-vec.stderr +++ b/tests/ui/span/regions-escape-loop-via-vec.stderr @@ -7,7 +7,7 @@ LL | while x < 10 { | ^ use of borrowed `x` LL | let mut z = x; LL | _y.push(&mut z); - | --------------- borrow later used here + | -- borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:6:21 @@ -18,7 +18,7 @@ LL | while x < 10 { LL | let mut z = x; | ^ use of borrowed `x` LL | _y.push(&mut z); - | --------------- borrow later used here + | -- borrow later used here error[E0597]: `z` does not live long enough --> $DIR/regions-escape-loop-via-vec.rs:7:17 @@ -26,7 +26,9 @@ error[E0597]: `z` does not live long enough LL | let mut z = x; | ----- binding `z` declared here LL | _y.push(&mut z); - | ^^^^^^ borrowed value does not live long enough + | -- ^^^^^^ borrowed value does not live long enough + | | + | borrow later used here ... LL | } | - `z` dropped here while still borrowed @@ -38,7 +40,7 @@ LL | let mut _y = vec![&mut x]; | ------ `x` is borrowed here ... LL | _y.push(&mut z); - | --------------- borrow later used here + | -- borrow later used here LL | LL | x += 1; | ^^^^^^ use of borrowed `x` diff --git a/tests/ui/span/send-is-not-static-std-sync.stderr b/tests/ui/span/send-is-not-static-std-sync.stderr index 7dfe94bca..eaba415ad 100644 --- a/tests/ui/span/send-is-not-static-std-sync.stderr +++ b/tests/ui/span/send-is-not-static-std-sync.stderr @@ -10,7 +10,7 @@ LL | drop(y); | ^ move out of `y` occurs here ... LL | *lock.lock().unwrap() = &z; - | ----------- borrow later used here + | ---- borrow later used here error[E0597]: `z` does not live long enough --> $DIR/send-is-not-static-std-sync.rs:16:33 @@ -23,7 +23,7 @@ LL | } | - `z` dropped here while still borrowed LL | LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use) - | -------------- borrow later used here + | ---- borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:27:10 @@ -37,7 +37,7 @@ LL | drop(y); | ^ move out of `y` occurs here ... LL | *lock.write().unwrap() = &z; - | ------------ borrow later used here + | ---- borrow later used here error[E0597]: `z` does not live long enough --> $DIR/send-is-not-static-std-sync.rs:30:34 @@ -50,7 +50,7 @@ LL | } | - `z` dropped here while still borrowed LL | LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use) - | -------------- borrow later used here + | ---- borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:43:10 @@ -64,7 +64,7 @@ LL | drop(y); | ^ move out of `y` occurs here ... LL | tx.send(&z).unwrap(); - | ----------- borrow later used here + | -- borrow later used here error[E0597]: `z` does not live long enough --> $DIR/send-is-not-static-std-sync.rs:46:17 diff --git a/tests/ui/span/slice-borrow.stderr b/tests/ui/span/slice-borrow.stderr index b70bf69d6..b271c9ae6 100644 --- a/tests/ui/span/slice-borrow.stderr +++ b/tests/ui/span/slice-borrow.stderr @@ -7,7 +7,7 @@ LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; LL | } | - temporary value is freed at the end of this statement LL | y.use_ref(); - | ----------- borrow later used here + | - borrow later used here | = note: consider using a `let` binding to create a longer lived value = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/span/suggestion-non-ascii.stderr b/tests/ui/span/suggestion-non-ascii.stderr index b14632d4e..21f8bb62a 100644 --- a/tests/ui/span/suggestion-non-ascii.stderr +++ b/tests/ui/span/suggestion-non-ascii.stderr @@ -1,8 +1,8 @@ error[E0608]: cannot index into a value of type `({integer},)` - --> $DIR/suggestion-non-ascii.rs:3:21 + --> $DIR/suggestion-non-ascii.rs:3:24 | LL | println!("☃{}", tup[0]); - | ^^^^^^ help: to access tuple elements, use: `tup.0` + | ^^^ help: to access tuple elements, use: `.0` error: aborting due to previous error diff --git a/tests/ui/span/visibility-ty-params.rs b/tests/ui/span/visibility-ty-params.rs index d77febe0a..11c2cf44c 100644 --- a/tests/ui/span/visibility-ty-params.rs +++ b/tests/ui/span/visibility-ty-params.rs @@ -4,7 +4,7 @@ macro_rules! m { struct S(T); m!{ S } //~ ERROR unexpected generic arguments in path - //~| ERROR expected module, found struct `S` + //~| ERROR failed to resolve: `S` is a struct, not a module [E0433] mod m { m!{ m<> } //~ ERROR unexpected generic arguments in path diff --git a/tests/ui/span/visibility-ty-params.stderr b/tests/ui/span/visibility-ty-params.stderr index 067893fd2..97d05c464 100644 --- a/tests/ui/span/visibility-ty-params.stderr +++ b/tests/ui/span/visibility-ty-params.stderr @@ -4,11 +4,11 @@ error: unexpected generic arguments in path LL | m!{ S } | ^^^^ -error[E0577]: expected module, found struct `S` +error[E0433]: failed to resolve: `S` is a struct, not a module --> $DIR/visibility-ty-params.rs:6:5 | LL | m!{ S } - | ^^^^^ not a module + | ^ `S` is a struct, not a module error: unexpected generic arguments in path --> $DIR/visibility-ty-params.rs:10:10 @@ -18,4 +18,4 @@ LL | m!{ m<> } error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0577`. +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/specialization/min_specialization/issue-79224.stderr b/tests/ui/specialization/min_specialization/issue-79224.stderr index 505baa23c..9a4d557a1 100644 --- a/tests/ui/specialization/min_specialization/issue-79224.stderr +++ b/tests/ui/specialization/min_specialization/issue-79224.stderr @@ -11,10 +11,10 @@ LL | impl Display for Cow<'_, B> { | +++++++++++++++++++ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:20:12 + --> $DIR/issue-79224.rs:20:13 | LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - | ^^^^^ the trait `Clone` is not implemented for `B` + | ^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting this bound diff --git a/tests/ui/stability-attribute/missing-const-stability.rs b/tests/ui/stability-attribute/missing-const-stability.rs index 6eff899bf..621e85762 100644 --- a/tests/ui/stability-attribute/missing-const-stability.rs +++ b/tests/ui/stability-attribute/missing-const-stability.rs @@ -1,5 +1,5 @@ #![feature(staged_api)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![stable(feature = "stable", since = "1.0.0")] #[stable(feature = "stable", since = "1.0.0")] diff --git a/tests/ui/std/issue-15149.rs b/tests/ui/std/issue-15149.rs deleted file mode 100644 index 064472f57..000000000 --- a/tests/ui/std/issue-15149.rs +++ /dev/null @@ -1,57 +0,0 @@ -// run-pass - -#![allow(unused_variables)] -// no-prefer-dynamic -// ignore-cross-compile - -use std::env; -use std::ffi::OsStr; -use std::fs; -use std::path::PathBuf; -use std::process; -use std::str; - -fn main() { - // If we're the child, make sure we were invoked correctly - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - // FIXME: This should check the whole `args[0]` instead of just - // checking that it ends_with the executable name. This - // is needed because of Windows, which has a different behavior. - // See #15149 for more info. - let my_path = env::current_exe().unwrap(); - return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest"))); - } - - test(); -} - -fn test() { - // If we're the parent, copy our own binary to a new directory. - let my_path = env::current_exe().unwrap(); - let my_dir = my_path.parent().unwrap(); - - let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let child_dir = child_dir.join("issue-15140-child"); - fs::create_dir_all(&child_dir).unwrap(); - - let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX)); - fs::copy(&my_path, &child_path).unwrap(); - - // Append the new directory to our own PATH. - let path = { - let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect(); - paths.push(child_dir.to_path_buf()); - env::join_paths(paths).unwrap() - }; - - let child_output = - process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap(); - - assert!( - child_output.status.success(), - "child assertion failed\n child stdout:\n {}\n child stderr:\n {}", - str::from_utf8(&child_output.stdout).unwrap(), - str::from_utf8(&child_output.stderr).unwrap() - ); -} diff --git a/tests/ui/std/switch-stdout.rs b/tests/ui/std/switch-stdout.rs deleted file mode 100644 index 2d936d96b..000000000 --- a/tests/ui/std/switch-stdout.rs +++ /dev/null @@ -1,52 +0,0 @@ -// run-pass -// ignore-wasm (needs file descriptors and env variables) - -use std::env; -use std::fs::File; -use std::io::{Read, Write}; -use std::path::PathBuf; - -#[cfg(unix)] -fn switch_stdout_to(file: File) { - use std::os::unix::prelude::*; - - extern "C" { - fn dup2(old: i32, new: i32) -> i32; - } - - unsafe { - assert_eq!(dup2(file.as_raw_fd(), 1), 1); - } -} - -#[cfg(windows)] -fn switch_stdout_to(file: File) { - use std::os::windows::prelude::*; - - extern "system" { - fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32; - } - - const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; - - unsafe { - let rc = SetStdHandle(STD_OUTPUT_HANDLE, file.into_raw_handle() as *mut _); - assert!(rc != 0); - } -} - -fn main() { - let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let path = path.join("switch-stdout-output"); - let f = File::create(&path).unwrap(); - - println!("foo"); - std::io::stdout().flush().unwrap(); - switch_stdout_to(f); - println!("bar"); - std::io::stdout().flush().unwrap(); - - let mut contents = String::new(); - File::open(&path).unwrap().read_to_string(&mut contents).unwrap(); - assert_eq!(contents, "bar\n"); -} diff --git a/tests/ui/suggestions/copied-and-cloned.fixed b/tests/ui/suggestions/copied-and-cloned.fixed index f801403fe..4cecf9e26 100644 --- a/tests/ui/suggestions/copied-and-cloned.fixed +++ b/tests/ui/suggestions/copied-and-cloned.fixed @@ -2,6 +2,16 @@ fn expect(_: T) {} +struct Issue114925 { + x: Option, +} + +fn issue_114925(lol: &mut Issue114925, x: Option<&String>) { + lol.x = x.clone().cloned(); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` +} + fn main() { let x = Some(&()); expect::>(x.copied()); @@ -20,4 +30,28 @@ fn main() { expect::>(x.cloned()); //~^ ERROR mismatched types //~| HELP use `Result::cloned` to clone the value inside the `Result` + + let s = String::new(); + let x = Some(s.clone()); + let y = Some(&s); + println!("{}", x == y.cloned()); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` + //FIXME(#114050) ~| HELP use `Option::as_ref` to convert `Option` to `Option<&String>` + + let mut s = (); + let x = Some(s); + let y = Some(&mut s); + println!("{}", x == y.copied()); + //~^ ERROR mismatched types + //~| HELP use `Option::copied` to copy the value inside the `Option` + + let mut s = String::new(); + let x = Some(s.clone()); + let y = Some(&mut s); + println!("{}", x == y.cloned()); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` + + issue_114925(&mut Issue114925 { x: None }, None); } diff --git a/tests/ui/suggestions/copied-and-cloned.rs b/tests/ui/suggestions/copied-and-cloned.rs index 640450b76..a79928c50 100644 --- a/tests/ui/suggestions/copied-and-cloned.rs +++ b/tests/ui/suggestions/copied-and-cloned.rs @@ -2,6 +2,16 @@ fn expect(_: T) {} +struct Issue114925 { + x: Option, +} + +fn issue_114925(lol: &mut Issue114925, x: Option<&String>) { + lol.x = x.clone(); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` +} + fn main() { let x = Some(&()); expect::>(x); @@ -20,4 +30,28 @@ fn main() { expect::>(x); //~^ ERROR mismatched types //~| HELP use `Result::cloned` to clone the value inside the `Result` + + let s = String::new(); + let x = Some(s.clone()); + let y = Some(&s); + println!("{}", x == y); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` + //FIXME(#114050) ~| HELP use `Option::as_ref` to convert `Option` to `Option<&String>` + + let mut s = (); + let x = Some(s); + let y = Some(&mut s); + println!("{}", x == y); + //~^ ERROR mismatched types + //~| HELP use `Option::copied` to copy the value inside the `Option` + + let mut s = String::new(); + let x = Some(s.clone()); + let y = Some(&mut s); + println!("{}", x == y); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` + + issue_114925(&mut Issue114925 { x: None }, None); } diff --git a/tests/ui/suggestions/copied-and-cloned.stderr b/tests/ui/suggestions/copied-and-cloned.stderr index 067808141..87b0624d4 100644 --- a/tests/ui/suggestions/copied-and-cloned.stderr +++ b/tests/ui/suggestions/copied-and-cloned.stderr @@ -1,5 +1,20 @@ error[E0308]: mismatched types - --> $DIR/copied-and-cloned.rs:7:26 + --> $DIR/copied-and-cloned.rs:10:13 + | +LL | lol.x = x.clone(); + | ----- ^^^^^^^^^ expected `Option`, found `Option<&String>` + | | + | expected due to the type of this binding + | + = note: expected enum `Option` + found enum `Option<&String>` +help: use `Option::cloned` to clone the value inside the `Option` + | +LL | lol.x = x.clone().cloned(); + | +++++++++ + +error[E0308]: mismatched types + --> $DIR/copied-and-cloned.rs:17:26 | LL | expect::>(x); | -------------------- ^ expected `Option<()>`, found `Option<&()>` @@ -19,7 +34,7 @@ LL | expect::>(x.copied()); | +++++++++ error[E0308]: mismatched types - --> $DIR/copied-and-cloned.rs:11:30 + --> $DIR/copied-and-cloned.rs:21:30 | LL | expect::>(x); | ------------------------ ^ expected `Result<(), ()>`, found `Result<&(), _>` @@ -39,7 +54,7 @@ LL | expect::>(x.copied()); | +++++++++ error[E0308]: mismatched types - --> $DIR/copied-and-cloned.rs:16:30 + --> $DIR/copied-and-cloned.rs:26:30 | LL | expect::>(x); | ------------------------ ^ expected `Option`, found `Option<&String>` @@ -59,7 +74,7 @@ LL | expect::>(x.cloned()); | +++++++++ error[E0308]: mismatched types - --> $DIR/copied-and-cloned.rs:20:34 + --> $DIR/copied-and-cloned.rs:30:34 | LL | expect::>(x); | ---------------------------- ^ expected `Result`, found `Result<&String, _>` @@ -78,6 +93,45 @@ help: use `Result::cloned` to clone the value inside the `Result` LL | expect::>(x.cloned()); | +++++++++ -error: aborting due to 4 previous errors +error[E0308]: mismatched types + --> $DIR/copied-and-cloned.rs:37:25 + | +LL | println!("{}", x == y); + | ^ expected `Option`, found `Option<&String>` + | + = note: expected enum `Option` + found enum `Option<&String>` +help: use `Option::cloned` to clone the value inside the `Option` + | +LL | println!("{}", x == y.cloned()); + | +++++++++ + +error[E0308]: mismatched types + --> $DIR/copied-and-cloned.rs:45:25 + | +LL | println!("{}", x == y); + | ^ expected `Option<()>`, found `Option<&mut ()>` + | + = note: expected enum `Option<()>` + found enum `Option<&mut ()>` +help: use `Option::copied` to copy the value inside the `Option` + | +LL | println!("{}", x == y.copied()); + | +++++++++ + +error[E0308]: mismatched types + --> $DIR/copied-and-cloned.rs:52:25 + | +LL | println!("{}", x == y); + | ^ expected `Option`, found `Option<&mut String>` + | + = note: expected enum `Option` + found enum `Option<&mut String>` +help: use `Option::cloned` to clone the value inside the `Option` + | +LL | println!("{}", x == y.cloned()); + | +++++++++ + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/crate-or-module-typo.stderr b/tests/ui/suggestions/crate-or-module-typo.stderr index 5e7a7685a..9ece31e76 100644 --- a/tests/ui/suggestions/crate-or-module-typo.stderr +++ b/tests/ui/suggestions/crate-or-module-typo.stderr @@ -30,17 +30,23 @@ help: there is a crate or module with a similar name | LL | bar: std::cell::Cell | ~~~ +help: consider importing one of these items + | +LL + use core::cell; + | +LL + use std::cell; + | +help: if you import `cell`, refer to it directly + | +LL - bar: st::cell::Cell +LL + bar: cell::Cell + | error[E0433]: failed to resolve: use of undeclared crate or module `bar` --> $DIR/crate-or-module-typo.rs:6:20 | LL | pub fn bar() { bar::baz(); } | ^^^ use of undeclared crate or module `bar` - | -help: consider importing this module - | -LL + use crate::bar; - | error: aborting due to 4 previous errors diff --git a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs index 711cbbd38..255cab060 100644 --- a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs +++ b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs @@ -18,7 +18,7 @@ mod bav { impl Bar for i32 {} fn use_it<'a>(val: Box>) -> impl OtherTrait<'a> { - val.use_self() //~ ERROR cannot return reference to function parameter + val.use_self() //~ ERROR cannot return value referencing function parameter } } diff --git a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr index 2dc300ac7..a7e03f491 100644 --- a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr +++ b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr @@ -1,20 +1,29 @@ -error[E0515]: cannot return reference to function parameter `val` +error[E0515]: cannot return value referencing function parameter `val` --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 | LL | val.use_self() - | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function + | ---^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `val` is borrowed here -error[E0515]: cannot return reference to function parameter `val` +error[E0515]: cannot return value referencing function parameter `val` --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 | LL | val.use_self() - | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function + | ---^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `val` is borrowed here -error[E0515]: cannot return reference to function parameter `val` +error[E0515]: cannot return value referencing function parameter `val` --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 | LL | val.use_self() - | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function + | ---^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `val` is borrowed here error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/issue-102972.stderr b/tests/ui/suggestions/issue-102972.stderr index 03f9dbb6c..3303d6bbc 100644 --- a/tests/ui/suggestions/issue-102972.stderr +++ b/tests/ui/suggestions/issue-102972.stderr @@ -7,10 +7,7 @@ LL | for _c in chars.by_ref() { | first mutable borrow occurs here | first borrow later used here LL | chars.next(); - | ^^^^^^^^^^^^ second mutable borrow occurs here - | - = note: a for loop advances the iterator for you, the result is stored in `_c`. - = help: if you want to call `next` on a iterator within the loop, consider using `while let`. + | ^^^^^ second mutable borrow occurs here error[E0382]: borrow of moved value: `iter` --> $DIR/issue-102972.rs:12:9 @@ -20,10 +17,8 @@ LL | let mut iter = v.iter(); LL | for _i in iter { | ---- `iter` moved due to this implicit call to `.into_iter()` LL | iter.next(); - | ^^^^^^^^^^^ value borrowed here after move + | ^^^^ value borrowed here after move | - = note: a for loop advances the iterator for you, the result is stored in `_i`. - = help: if you want to call `next` on a iterator within the loop, consider using `while let`. note: `into_iter` takes ownership of the receiver `self`, which moves `iter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL diff --git a/tests/ui/suggestions/issue-114701.rs b/tests/ui/suggestions/issue-114701.rs new file mode 100644 index 000000000..81d7803ec --- /dev/null +++ b/tests/ui/suggestions/issue-114701.rs @@ -0,0 +1,15 @@ +enum Enum { SVariant { v: T }, UVariant } + +macro_rules! is_variant { + (TSVariant, ) => (!); + (SVariant, ) => (!); + (UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr)); + (@check $variant:ident, $matcher:tt, $expr:expr) => ( + assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false }, + ); + ); +} + +fn main() { + is_variant!(UVariant, Enum::<()>::UVariant); //~ ERROR expected function +} diff --git a/tests/ui/suggestions/issue-114701.stderr b/tests/ui/suggestions/issue-114701.stderr new file mode 100644 index 000000000..67462a09c --- /dev/null +++ b/tests/ui/suggestions/issue-114701.stderr @@ -0,0 +1,15 @@ +error[E0618]: expected function, found `Enum<()>` + --> $DIR/issue-114701.rs:14:27 + | +LL | enum Enum { SVariant { v: T }, UVariant } + | -------- `Enum::UVariant` defined here +... +LL | assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false }, + | -------- call expression requires function +... +LL | is_variant!(UVariant, Enum::<()>::UVariant); + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0618`. diff --git a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed new file mode 100644 index 000000000..57387936a --- /dev/null +++ b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed @@ -0,0 +1,17 @@ +//run-rustfix +#![allow(dead_code)] + +trait Trait {} + +fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) { + //~^ ERROR incorrect parentheses around trait bounds + ptr as _ +} + +fn foo2(_: &(dyn Trait + Send)) {} +//~^ ERROR incorrect parentheses around trait bounds + +fn foo3(_: &(dyn Trait + Send)) {} +//~^ ERROR incorrect parentheses around trait bounds + +fn main() {} diff --git a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs new file mode 100644 index 000000000..8a1939bcf --- /dev/null +++ b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs @@ -0,0 +1,17 @@ +//run-rustfix +#![allow(dead_code)] + +trait Trait {} + +fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) { + //~^ ERROR incorrect parentheses around trait bounds + ptr as _ +} + +fn foo2(_: &dyn (Trait + Send)) {} +//~^ ERROR incorrect parentheses around trait bounds + +fn foo3(_: &dyn(Trait + Send)) {} +//~^ ERROR incorrect parentheses around trait bounds + +fn main() {} diff --git a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr new file mode 100644 index 000000000..2d1abe91a --- /dev/null +++ b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr @@ -0,0 +1,38 @@ +error: incorrect parentheses around trait bounds + --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:49 + | +LL | fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) { + | ^ ^ + | +help: fix the parentheses + | +LL - fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) { +LL + fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) { + | + +error: incorrect parentheses around trait bounds + --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:11:17 + | +LL | fn foo2(_: &dyn (Trait + Send)) {} + | ^ ^ + | +help: fix the parentheses + | +LL - fn foo2(_: &dyn (Trait + Send)) {} +LL + fn foo2(_: &(dyn Trait + Send)) {} + | + +error: incorrect parentheses around trait bounds + --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:14:16 + | +LL | fn foo3(_: &dyn(Trait + Send)) {} + | ^ ^ + | +help: fix the parentheses + | +LL - fn foo3(_: &dyn(Trait + Send)) {} +LL + fn foo3(_: &(dyn Trait + Send)) {} + | + +error: aborting due to 3 previous errors + diff --git a/tests/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr b/tests/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr index 438075083..bb8b9b370 100644 --- a/tests/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr +++ b/tests/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr @@ -5,7 +5,7 @@ LL | fn vindictive() -> bool { true } | ----------------------- `vindictive` defined here returns `bool` ... LL | vindictive() - | -^^^^^^^^^^^- help: consider using a semicolon here: `;` + | -^^^^^^^^^^^- help: consider using a semicolon here to finish the statement: `;` | _____| | | LL | | (1, 2) diff --git a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr index 6820af1fd..a03d4e8ce 100644 --- a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr +++ b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr @@ -16,7 +16,7 @@ note: required by a bound in `Trader::<'a>::set_closure` | LL | pub fn set_closure(&mut self, function: impl Fn(&mut Trader) + 'a) { | ^^^^^^^^^^^^^^^ required by this bound in `Trader::<'a>::set_closure` -help: consider borrowing the argument +help: consider adjusting the signature so it borrows its argument | LL | let closure = |trader : &mut Trader| { | ++++ diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr new file mode 100644 index 000000000..24e2e0a0f --- /dev/null +++ b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr @@ -0,0 +1,57 @@ +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:6:14 + | +LL | const A: &str = ""; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ trait ZstAssert<'a>: Sized { +LL ~ const A: &'a str = ""; + | + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:7:14 + | +LL | const B: S = S { s: &() }; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ trait ZstAssert<'a>: Sized { +LL | const A: &str = ""; +LL ~ const B: S<'a> = S { s: &() }; + | + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:8:15 + | +LL | const C: &'_ str = ""; + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ trait ZstAssert<'a>: Sized { +LL | const A: &str = ""; +LL | const B: S = S { s: &() }; +LL ~ const C: &'a str = ""; + | + +error[E0106]: missing lifetime specifiers + --> $DIR/missing-lifetime-in-assoc-const-type.rs:9:14 + | +LL | const D: T = T { a: &(), b: &() }; + | ^ expected 2 lifetime parameters + | +help: consider introducing a named lifetime parameter + | +LL ~ trait ZstAssert<'a>: Sized { +LL | const A: &str = ""; +LL | const B: S = S { s: &() }; +LL | const C: &'_ str = ""; +LL ~ const D: T<'a, 'a> = T { a: &(), b: &() }; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr new file mode 100644 index 000000000..a97ffe7da --- /dev/null +++ b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr @@ -0,0 +1,47 @@ +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:6:14 + | +LL | const A: &str = ""; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | const A<'a>: &'a str = ""; + | ++++ ++ + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:7:14 + | +LL | const B: S = S { s: &() }; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | const B<'a>: S<'a> = S { s: &() }; + | ++++ ++++ + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:8:15 + | +LL | const C: &'_ str = ""; + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | const C<'a>: &'a str = ""; + | ++++ ~~ + +error[E0106]: missing lifetime specifiers + --> $DIR/missing-lifetime-in-assoc-const-type.rs:9:14 + | +LL | const D: T = T { a: &(), b: &() }; + | ^ expected 2 lifetime parameters + | +help: consider introducing a named lifetime parameter + | +LL | const D<'a>: T<'a, 'a> = T { a: &(), b: &() }; + | ++++ ++++++++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs index 38332627f..2a8b4c3c0 100644 --- a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs +++ b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs @@ -1,3 +1,7 @@ +// revisions: default generic_const_items + +#![cfg_attr(generic_const_items, feature(generic_const_items), allow(incomplete_features))] + trait ZstAssert: Sized { const A: &str = ""; //~ ERROR missing lifetime specifier const B: S = S { s: &() }; //~ ERROR missing lifetime specifier diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr deleted file mode 100644 index 233f1bc5a..000000000 --- a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-in-assoc-const-type.rs:2:14 - | -LL | const A: &str = ""; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL ~ trait ZstAssert<'a>: Sized { -LL ~ const A: &'a str = ""; - | - -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-in-assoc-const-type.rs:3:14 - | -LL | const B: S = S { s: &() }; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL ~ trait ZstAssert<'a>: Sized { -LL | const A: &str = ""; -LL ~ const B: S<'a> = S { s: &() }; - | - -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-in-assoc-const-type.rs:4:15 - | -LL | const C: &'_ str = ""; - | ^^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL ~ trait ZstAssert<'a>: Sized { -LL | const A: &str = ""; -LL | const B: S = S { s: &() }; -LL ~ const C: &'a str = ""; - | - -error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-in-assoc-const-type.rs:5:14 - | -LL | const D: T = T { a: &(), b: &() }; - | ^ expected 2 lifetime parameters - | -help: consider introducing a named lifetime parameter - | -LL ~ trait ZstAssert<'a>: Sized { -LL | const A: &str = ""; -LL | const B: S = S { s: &() }; -LL | const C: &'_ str = ""; -LL ~ const D: T<'a, 'a> = T { a: &(), b: &() }; - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/suggestions/missing-semicolon.fixed b/tests/ui/suggestions/missing-semicolon.fixed new file mode 100644 index 000000000..df355f0b0 --- /dev/null +++ b/tests/ui/suggestions/missing-semicolon.fixed @@ -0,0 +1,38 @@ +// run-rustfix +#![allow(dead_code, unused_variables, path_statements)] +fn a() { + let x = 5; + let y = x; //~ ERROR expected function + (); //~ ERROR expected `;`, found `}` +} + +fn b() { + let x = 5; + let y = x; //~ ERROR expected function + (); +} +fn c() { + let x = 5; + x; //~ ERROR expected function + () +} +fn d() { // ok + let x = || (); + x + () +} +fn e() { // ok + let x = || (); + x + (); +} +fn f() + { + let y = 5; //~ ERROR expected function + (); //~ ERROR expected `;`, found `}` +} +fn g() { + 5; //~ ERROR expected function + (); +} +fn main() {} diff --git a/tests/ui/suggestions/missing-semicolon.rs b/tests/ui/suggestions/missing-semicolon.rs new file mode 100644 index 000000000..12ef3d33e --- /dev/null +++ b/tests/ui/suggestions/missing-semicolon.rs @@ -0,0 +1,38 @@ +// run-rustfix +#![allow(dead_code, unused_variables, path_statements)] +fn a() { + let x = 5; + let y = x //~ ERROR expected function + () //~ ERROR expected `;`, found `}` +} + +fn b() { + let x = 5; + let y = x //~ ERROR expected function + (); +} +fn c() { + let x = 5; + x //~ ERROR expected function + () +} +fn d() { // ok + let x = || (); + x + () +} +fn e() { // ok + let x = || (); + x + (); +} +fn f() + { + let y = 5 //~ ERROR expected function + () //~ ERROR expected `;`, found `}` +} +fn g() { + 5 //~ ERROR expected function + (); +} +fn main() {} diff --git a/tests/ui/suggestions/missing-semicolon.stderr b/tests/ui/suggestions/missing-semicolon.stderr new file mode 100644 index 000000000..54a64f664 --- /dev/null +++ b/tests/ui/suggestions/missing-semicolon.stderr @@ -0,0 +1,75 @@ +error: expected `;`, found `}` + --> $DIR/missing-semicolon.rs:6:7 + | +LL | () + | ^ help: add `;` here +LL | } + | - unexpected token + +error: expected `;`, found `}` + --> $DIR/missing-semicolon.rs:32:7 + | +LL | () + | ^ help: add `;` here +LL | } + | - unexpected token + +error[E0618]: expected function, found `{integer}` + --> $DIR/missing-semicolon.rs:5:13 + | +LL | let x = 5; + | - `x` has type `{integer}` +LL | let y = x + | ^- help: consider using a semicolon here to finish the statement: `;` + | _____________| + | | +LL | | () + | |______- call expression requires function + +error[E0618]: expected function, found `{integer}` + --> $DIR/missing-semicolon.rs:11:13 + | +LL | let x = 5; + | - `x` has type `{integer}` +LL | let y = x + | ^- help: consider using a semicolon here to finish the statement: `;` + | _____________| + | | +LL | | (); + | |______- call expression requires function + +error[E0618]: expected function, found `{integer}` + --> $DIR/missing-semicolon.rs:16:5 + | +LL | let x = 5; + | - `x` has type `{integer}` +LL | x + | ^- help: consider using a semicolon here to finish the statement: `;` + | _____| + | | +LL | | () + | |______- call expression requires function + +error[E0618]: expected function, found `{integer}` + --> $DIR/missing-semicolon.rs:31:13 + | +LL | let y = 5 + | ^- help: consider using a semicolon here to finish the statement: `;` + | _____________| + | | +LL | | () + | |______- call expression requires function + +error[E0618]: expected function, found `{integer}` + --> $DIR/missing-semicolon.rs:35:5 + | +LL | 5 + | ^- help: consider using a semicolon here to finish the statement: `;` + | _____| + | | +LL | | (); + | |______- call expression requires function + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0618`. diff --git a/tests/ui/suggestions/option-content-move.stderr b/tests/ui/suggestions/option-content-move.stderr index 474a72093..5060606d8 100644 --- a/tests/ui/suggestions/option-content-move.stderr +++ b/tests/ui/suggestions/option-content-move.stderr @@ -12,7 +12,7 @@ note: `Option::::unwrap` takes ownership of the receiver `self`, which moves help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | if selection.1.clone().unwrap().contains(selection.0) { - | ++++++++ + | ++++++++ error[E0507]: cannot move out of `selection.1` which is behind a shared reference --> $DIR/option-content-move.rs:27:20 @@ -28,7 +28,7 @@ note: `Result::::unwrap` takes ownership of the receiver `self`, which mov help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | if selection.1.clone().unwrap().contains(selection.0) { - | ++++++++ + | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/remove-question-symbol-with-paren.rs b/tests/ui/suggestions/remove-question-symbol-with-paren.rs new file mode 100644 index 000000000..c522793db --- /dev/null +++ b/tests/ui/suggestions/remove-question-symbol-with-paren.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/114392 + +fn foo() -> Option<()> { + let x = Some(()); + (x?) + //~^ ERROR `?` operator has incompatible types +} + +fn main() {} diff --git a/tests/ui/suggestions/remove-question-symbol-with-paren.stderr b/tests/ui/suggestions/remove-question-symbol-with-paren.stderr new file mode 100644 index 000000000..40b9cf2dc --- /dev/null +++ b/tests/ui/suggestions/remove-question-symbol-with-paren.stderr @@ -0,0 +1,25 @@ +error[E0308]: `?` operator has incompatible types + --> $DIR/remove-question-symbol-with-paren.rs:5:6 + | +LL | fn foo() -> Option<()> { + | ---------- expected `Option<()>` because of return type +LL | let x = Some(()); +LL | (x?) + | ^^ expected `Option<()>`, found `()` + | + = note: `?` operator cannot convert from `()` to `Option<()>` + = note: expected enum `Option<()>` + found unit type `()` +help: try removing this `?` + | +LL - (x?) +LL + (x) + | +help: try wrapping the expression in `Some` + | +LL | (Some(x?)) + | +++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-closure.rs b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.rs new file mode 100644 index 000000000..e4721ba01 --- /dev/null +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.rs @@ -0,0 +1,19 @@ +use std::collections::HashMap; +struct X(usize); +struct Y { + v: u32, +} + +fn main() { + let _ = || { + let mut buzz = HashMap::new(); + buzz.insert("a", Y { v: 0 }); + + for mut t in buzz.values() { + //~^ HELP + //~| SUGGESTION values_mut() + t.v += 1; + //~^ ERROR cannot assign + } + }; +} diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr new file mode 100644 index 000000000..8a2df8d7c --- /dev/null +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr @@ -0,0 +1,15 @@ +error[E0594]: cannot assign to `t.v`, which is behind a `&` reference + --> $DIR/suggest-mut-method-for-loop-closure.rs:15:13 + | +LL | for mut t in buzz.values() { + | ------------- + | | | + | | help: use mutable method: `values_mut()` + | this iterator yields `&` references +... +LL | t.v += 1; + | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index 8d1765eb8..782444417 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -1,16 +1,5 @@ -// ignore-arm -// ignore-aarch64 -// ignore-wasm -// ignore-emscripten -// ignore-mips -// ignore-mips64 -// ignore-powerpc -// ignore-powerpc64 -// ignore-riscv64 -// ignore-sparc -// ignore-sparc64 -// ignore-s390x -// ignore-loongarch64 +// only-x86_64 +// // gate-test-sse4a_target_feature // gate-test-powerpc_target_feature // gate-test-avx512_target_feature @@ -28,6 +17,7 @@ // gate-test-ermsb_target_feature // gate-test-bpf_target_feature // gate-test-aarch64_ver_target_feature +// gate-test-csky_target_feature #[target_feature(enable = "avx512bw")] //~^ ERROR: currently unstable diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index ee542b60a..f56efb3bb 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable - --> $DIR/gate.rs:32:18 + --> $DIR/gate.rs:22:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index 77fd8b85f..d1b3cf71c 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -1,16 +1,4 @@ -// ignore-arm -// ignore-aarch64 -// ignore-wasm -// ignore-emscripten -// ignore-mips -// ignore-mips64 -// ignore-powerpc -// ignore-powerpc64 -// ignore-riscv64 -// ignore-s390x -// ignore-sparc -// ignore-sparc64 -// ignore-loongarch64 +// only-x86_64 #![warn(unused_attributes)] diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index 6d37d0917..29c73921c 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -1,11 +1,11 @@ error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:32:1 + --> $DIR/invalid-attribute.rs:20:1 | LL | #[target_feature = "+sse2"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]` error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:17:1 + --> $DIR/invalid-attribute.rs:5:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL | extern crate alloc; | ------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:22:1 + --> $DIR/invalid-attribute.rs:10:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | use alloc::alloc::alloc; | ------------------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:27:1 + --> $DIR/invalid-attribute.rs:15:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | extern "Rust" {} | ---------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:49:1 + --> $DIR/invalid-attribute.rs:37:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | mod another {} | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:54:1 + --> $DIR/invalid-attribute.rs:42:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | const FOO: usize = 7; | --------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:59:1 + --> $DIR/invalid-attribute.rs:47:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | struct Foo; | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:64:1 + --> $DIR/invalid-attribute.rs:52:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | enum Bar {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:69:1 + --> $DIR/invalid-attribute.rs:57:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | | } | |_- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:77:1 + --> $DIR/invalid-attribute.rs:65:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | type Uwu = (); | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:82:1 + --> $DIR/invalid-attribute.rs:70:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | trait Baz {} | ------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:92:1 + --> $DIR/invalid-attribute.rs:80:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | static A: () = (); | ------------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:97:1 + --> $DIR/invalid-attribute.rs:85:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,7 +117,7 @@ LL | impl Quux for u8 {} | ------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:102:1 + --> $DIR/invalid-attribute.rs:90:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL | impl Foo {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:120:5 + --> $DIR/invalid-attribute.rs:108:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL | | } | |_____- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:128:5 + --> $DIR/invalid-attribute.rs:116:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -147,25 +147,25 @@ LL | || {}; | ----- not a function definition error: the feature named `foo` is not valid for this target - --> $DIR/invalid-attribute.rs:34:18 + --> $DIR/invalid-attribute.rs:22:18 | LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:37:18 + --> $DIR/invalid-attribute.rs:25:18 | LL | #[target_feature(bar)] | ^^^ help: must be of the form: `enable = ".."` error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:39:18 + --> $DIR/invalid-attribute.rs:27:18 | LL | #[target_feature(disable = "baz")] | ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."` error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:43:1 + --> $DIR/invalid-attribute.rs:31:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,13 +177,13 @@ LL | fn bar() {} = help: add `#![feature(target_feature_11)]` to the crate attributes to enable error: cannot use `#[inline(always)]` with `#[target_feature]` - --> $DIR/invalid-attribute.rs:87:1 + --> $DIR/invalid-attribute.rs:75:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:112:5 + --> $DIR/invalid-attribute.rs:100:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr index 727e9691c..699783383 100644 --- a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr @@ -1,9 +1,11 @@ -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `2`, - right: `4`', $DIR/test-panic-abort-nocapture.rs:33:5 +thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:33:5: +assertion `left == right` failed + left: 2 + right: 4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `2`, - right: `4`', $DIR/test-panic-abort-nocapture.rs:27:5 +thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:27:5: +assertion `left == right` failed + left: 2 + right: 4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace testing321 diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout index b6b9c2560..0e27f6fb6 100644 --- a/tests/ui/test-attrs/test-panic-abort.run.stdout +++ b/tests/ui/test-attrs/test-panic-abort.run.stdout @@ -17,9 +17,10 @@ hello, world testing123 ---- it_fails stderr ---- testing321 -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `2`, - right: `5`', $DIR/test-panic-abort.rs:38:5 +thread 'main' panicked at $DIR/test-panic-abort.rs:38:5: +assertion `left == right` failed + left: 2 + right: 5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/test-attrs/test-thread-capture.run.stdout b/tests/ui/test-attrs/test-thread-capture.run.stdout index 513c8cf2a..31261aaa2 100644 --- a/tests/ui/test-attrs/test-thread-capture.run.stdout +++ b/tests/ui/test-attrs/test-thread-capture.run.stdout @@ -10,7 +10,8 @@ fee fie foe fum -thread 'thready_fail' panicked at 'explicit panic', $DIR/test-thread-capture.rs:32:5 +thread 'thready_fail' panicked at $DIR/test-thread-capture.rs:32:5: +explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/test-attrs/test-thread-nocapture.run.stderr b/tests/ui/test-attrs/test-thread-nocapture.run.stderr index 8c905d1af..9266fe841 100644 --- a/tests/ui/test-attrs/test-thread-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-thread-nocapture.run.stderr @@ -1,2 +1,3 @@ -thread 'thready_fail' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:32:5 +thread 'thready_fail' panicked at $DIR/test-thread-nocapture.rs:32:5: +explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/thir-print/thir-flat-const-variant.stdout b/tests/ui/thir-print/thir-flat-const-variant.stdout index 1b76f07c3..7bddc9259 100644 --- a/tests/ui/thir-print/thir-flat-const-variant.stdout +++ b/tests/ui/thir-print/thir-flat-const-variant.stdout @@ -35,7 +35,7 @@ Thir { AdtExpr { adt_def: Foo, variant_index: 0, - substs: [], + args: [], user_ty: None, fields: [ FieldExpr { @@ -120,7 +120,7 @@ Thir { AdtExpr { adt_def: Foo, variant_index: 0, - substs: [], + args: [], user_ty: None, fields: [ FieldExpr { @@ -205,7 +205,7 @@ Thir { AdtExpr { adt_def: Foo, variant_index: 0, - substs: [], + args: [], user_ty: None, fields: [ FieldExpr { @@ -290,7 +290,7 @@ Thir { AdtExpr { adt_def: Foo, variant_index: 0, - substs: [], + args: [], user_ty: None, fields: [ FieldExpr { diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout index eea04c095..3fc130f01 100644 --- a/tests/ui/thir-print/thir-tree-match.stdout +++ b/tests/ui/thir-print/thir-tree-match.stdout @@ -106,7 +106,7 @@ body: variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } - substs: [] + args: [] variant_index: 0 subpatterns: [ Pat: { @@ -120,7 +120,7 @@ body: variants: [VariantDef { def_id: DefId(0:4 ~ thir_tree_match[fcf8]::Bar::First), ctor: Some((Const, DefId(0:5 ~ thir_tree_match[fcf8]::Bar::First::{constructor#0}))), name: "First", discr: Relative(0), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:6 ~ thir_tree_match[fcf8]::Bar::Second), ctor: Some((Const, DefId(0:7 ~ thir_tree_match[fcf8]::Bar::Second::{constructor#0}))), name: "Second", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:8 ~ thir_tree_match[fcf8]::Bar::Third), ctor: Some((Const, DefId(0:9 ~ thir_tree_match[fcf8]::Bar::Third::{constructor#0}))), name: "Third", discr: Relative(2), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 10333377570083945360 } - substs: [] + args: [] variant_index: 0 subpatterns: [] } @@ -179,7 +179,7 @@ body: variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } - substs: [] + args: [] variant_index: 0 subpatterns: [ Pat: { @@ -242,7 +242,7 @@ body: variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } - substs: [] + args: [] variant_index: 1 subpatterns: [] } diff --git a/tests/ui/threads-sendsync/issue-24313.rs b/tests/ui/threads-sendsync/issue-24313.rs index c28b4ca96..6694bac0d 100644 --- a/tests/ui/threads-sendsync/issue-24313.rs +++ b/tests/ui/threads-sendsync/issue-24313.rs @@ -19,7 +19,7 @@ fn main() { if args.len() == 1 { let out = Command::new(&args[0]).arg("test").output().unwrap(); let stderr = std::str::from_utf8(&out.stderr).unwrap(); - assert!(stderr.contains("panicked at 'explicit panic'"), + assert!(stderr.contains("explicit panic"), "bad failure message:\n{}\n", stderr); } else { // TLS dtors are not always run on process exit diff --git a/tests/ui/traits/dont-autoderef-ty-with-escaping-var.rs b/tests/ui/traits/dont-autoderef-ty-with-escaping-var.rs new file mode 100644 index 000000000..d5ba3847a --- /dev/null +++ b/tests/ui/traits/dont-autoderef-ty-with-escaping-var.rs @@ -0,0 +1,22 @@ +// issue:113951 + +trait Foo<'x, T> {} + +trait RefFoo { + fn ref_foo(&self); +} + +impl RefFoo for T +where + for<'a> &'a mut Vec<&'a u32>: Foo<'static, T>, +{ + fn ref_foo(&self) {} +} + +fn coerce_lifetime2() { + >::ref_foo(unknown); + //~^ ERROR cannot find value `unknown` in this scope + //~| ERROR the trait bound `for<'a> &'a mut Vec<&'a u32>: Foo<'static, i32>` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr b/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr new file mode 100644 index 000000000..934d20b22 --- /dev/null +++ b/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr @@ -0,0 +1,27 @@ +error[E0425]: cannot find value `unknown` in this scope + --> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:35 + | +LL | >::ref_foo(unknown); + | ^^^^^^^ not found in this scope + +error[E0277]: the trait bound `for<'a> &'a mut Vec<&'a u32>: Foo<'static, i32>` is not satisfied + --> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:35 + | +LL | >::ref_foo(unknown); + | ----------------------------- ^^^^^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>` + | | + | required by a bound introduced by this call + | +note: required for `i32` to implement `RefFoo` + --> $DIR/dont-autoderef-ty-with-escaping-var.rs:9:9 + | +LL | impl RefFoo for T + | ^^^^^^^^^ ^ +LL | where +LL | for<'a> &'a mut Vec<&'a u32>: Foo<'static, T>, + | --------------- unsatisfied trait bound introduced here + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0425. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/issue-105231.rs b/tests/ui/traits/issue-105231.rs index 74c7afd6b..bb2b13664 100644 --- a/tests/ui/traits/issue-105231.rs +++ b/tests/ui/traits/issue-105231.rs @@ -1,9 +1,9 @@ -//~ ERROR overflow evaluating the requirement `A>>>>>>: Send` struct A(B); //~^ ERROR recursive types `A` and `B` have infinite size struct B(A>); trait Foo {} impl Foo for T where T: Send {} +//~^ ERROR overflow evaluating the requirement `A>>>>>>: Send` impl Foo for B {} fn main() {} diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr index fe20c47c5..76a710673 100644 --- a/tests/ui/traits/issue-105231.stderr +++ b/tests/ui/traits/issue-105231.stderr @@ -1,5 +1,5 @@ error[E0072]: recursive types `A` and `B` have infinite size - --> $DIR/issue-105231.rs:2:1 + --> $DIR/issue-105231.rs:1:1 | LL | struct A(B); | ^^^^^^^^^^^ ---- recursive without indirection @@ -15,10 +15,14 @@ LL ~ struct B(Box>>); | error[E0275]: overflow evaluating the requirement `A>>>>>>: Send` + --> $DIR/issue-105231.rs:5:28 + | +LL | impl Foo for T where T: Send {} + | ^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`) note: required because it appears within the type `B>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-105231.rs:4:8 + --> $DIR/issue-105231.rs:3:8 | LL | struct B(A>); | ^ diff --git a/tests/ui/traits/issue-24010.rs b/tests/ui/traits/issue-24010.rs index f18185334..fd7d6751d 100644 --- a/tests/ui/traits/issue-24010.rs +++ b/tests/ui/traits/issue-24010.rs @@ -1,4 +1,6 @@ // run-pass +// revisions: classic next +//[next] compile-flags: -Ztrait-solver=next trait Foo: Fn(i32) -> i32 + Send {} diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index c721dd41a..c6fc7bb12 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -23,8 +23,7 @@ LL | impl> Iterator for IteratorOfWrapped { | | | unsatisfied trait bound introduced here = note: 256 redundant requirements hidden - = note: required for `IteratorOfWrapped<(), Map>, ...>>, ...>>` to implement `Iterator` - = note: the full type name has been written to '$TEST_BUILD_DIR/traits/issue-91949-hangs-on-recursion/issue-91949-hangs-on-recursion.long-type-hash.txt' + = note: required for `IteratorOfWrapped<(), Map>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:28:45: 28:48]>>` to implement `Iterator` error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/traits/new-solver/alias-bound-preference.rs b/tests/ui/traits/new-solver/alias-bound-preference.rs new file mode 100644 index 000000000..e4e0f634e --- /dev/null +++ b/tests/ui/traits/new-solver/alias-bound-preference.rs @@ -0,0 +1,39 @@ +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next +// run-pass + +// A test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/45. + +trait Trait { + type Assoc: Into; +} +impl> Trait for T { + type Assoc = T; +} +fn prefer_alias_bound_projection(x: T::Assoc) { + // There are two possible types for `x`: + // - `u32` by using the "alias bound" of `::Assoc` + // - `::Assoc`, i.e. `u16`, by using `impl From for T` + // + // We infer the type of `x` to be `u32` here as it is highly likely + // that this is expected by the user. + let x = x.into(); + assert_eq!(std::mem::size_of_val(&x), 4); +} + +fn impl_trait() -> impl Into { + 0u16 +} + +fn main() { + // There are two possible types for `x`: + // - `u32` by using the "alias bound" of `impl Into` + // - `impl Into`, i.e. `u16`, by using `impl From for T` + // + // We infer the type of `x` to be `u32` here as it is highly likely + // that this is expected by the user. + let x = impl_trait().into(); + assert_eq!(std::mem::size_of_val(&x), 4); + + prefer_alias_bound_projection::(1); +} diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.rs b/tests/ui/traits/new-solver/alias-bound-unsound.rs index 959f1afa0..38d83d289 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.rs +++ b/tests/ui/traits/new-solver/alias-bound-unsound.rs @@ -16,12 +16,17 @@ trait Foo { impl Foo for () { type Item = String where String: Copy; + //~^ ERROR overflow evaluating the requirement `<() as Foo>::Item: Copy` } fn main() { let x = String::from("hello, world"); drop(<() as Foo>::copy_me(&x)); - //~^ ERROR the type `&<() as Foo>::Item` is not well-formed - //~| ERROR `<() as Foo>::Item` is not well-formed + //~^ ERROR overflow evaluating the requirement `<() as Foo>::Item: Sized` + //~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _` + //~| ERROR overflow evaluating the requirement `<() as Foo>::Item well-formed` + //~| ERROR overflow evaluating the requirement `String <: <() as Foo>::Item` + //~| ERROR overflow evaluating the requirement `&<() as Foo>::Item well-formed` + //~| ERROR type annotations needed println!("{x}"); } diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.stderr b/tests/ui/traits/new-solver/alias-bound-unsound.stderr index 5800e2c43..abc6677c1 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/new-solver/alias-bound-unsound.stderr @@ -1,14 +1,69 @@ -error: the type `&<() as Foo>::Item` is not well-formed - --> $DIR/alias-bound-unsound.rs:23:31 +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item: Copy` + --> $DIR/alias-bound-unsound.rs:18:17 + | +LL | type Item = String where String: Copy; + | ^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) +note: required by a bound in `Foo::Item` + --> $DIR/alias-bound-unsound.rs:8:16 + | +LL | type Item: Copy + | ^^^^ required by this bound in `Foo::Item` + +error[E0282]: type annotations needed + --> $DIR/alias-bound-unsound.rs:24:5 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^ cannot infer type of the type parameter `T` declared on the function `drop` + | +help: consider specifying the generic argument + | +LL | drop::(<() as Foo>::copy_me(&x)); + | +++++ + +error[E0275]: overflow evaluating the requirement `&<() as Foo>::Item well-formed` + --> $DIR/alias-bound-unsound.rs:24:31 | LL | drop(<() as Foo>::copy_me(&x)); | ^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) -error: the type `<() as Foo>::Item` is not well-formed - --> $DIR/alias-bound-unsound.rs:23:10 +error[E0275]: overflow evaluating the requirement `String <: <() as Foo>::Item` + --> $DIR/alias-bound-unsound.rs:24:31 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) + +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item well-formed` + --> $DIR/alias-bound-unsound.rs:24:10 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) + +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` + --> $DIR/alias-bound-unsound.rs:24:10 | LL | drop(<() as Foo>::copy_me(&x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) + +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item: Sized` + --> $DIR/alias-bound-unsound.rs:24:10 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) + = note: the return type of a function must have a statically known size -error: aborting due to 2 previous errors +error: aborting due to 7 previous errors +Some errors have detailed explanations: E0275, E0282. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs b/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs new file mode 100644 index 000000000..826e8c1e0 --- /dev/null +++ b/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs @@ -0,0 +1,27 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// Checks that we do not get ambiguity by considering an impl +// multiple times if we're able to normalize the self type. + +trait Trait<'a> {} + +impl<'a, T: 'a> Trait<'a> for T {} + +fn impls_trait<'a, T: Trait<'a>>() {} + +trait Id { + type Assoc; +} +impl Id for T { + type Assoc = T; +} + +fn call() { + impls_trait::<::Assoc>(); +} + +fn main() { + call::<()>(); + impls_trait::<<<() as Id>::Assoc as Id>::Assoc>(); +} diff --git a/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.rs b/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.rs new file mode 100644 index 000000000..1dca86d36 --- /dev/null +++ b/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.rs @@ -0,0 +1,15 @@ +// compile-flags: -Ztrait-solver=next + +// In the new solver, we are trying to select `::Item: Debug`, +// which, naively can be unified with every impl of `Debug` if we're not careful. +// This test makes sure that we treat projections with inference var substs as +// placeholders during fast reject. + +fn iter() -> ::Item { + todo!() +} + +fn main() { + println!("{:?}", iter::<_>()); + //~^ ERROR type annotations needed +} diff --git a/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.stderr b/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.stderr new file mode 100644 index 000000000..47004821a --- /dev/null +++ b/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/runaway-impl-candidate-selection.rs:13:22 + | +LL | println!("{:?}", iter::<_>()); + | ^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `iter` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.rs b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.rs new file mode 100644 index 000000000..b39ae0333 --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.rs @@ -0,0 +1,20 @@ +// compile-flags: -Ztrait-solver=next + +// Coherence should handle overflow while normalizing for +// `trait_ref_is_knowable` correctly. + +trait Overflow { + type Assoc; +} +impl Overflow for T { + type Assoc = ::Assoc; +} + + +trait Trait {} +impl Trait for T {} +struct LocalTy; +impl Trait for ::Assoc {} +//~^ ERROR conflicting implementations of trait `Trait` for type `::Assoc` + +fn main() {} diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr new file mode 100644 index 000000000..5d5f325e4 --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Trait` for type `::Assoc` + --> $DIR/trait_ref_is_knowable-norm-overflow.rs:17:1 + | +LL | impl Trait for T {} + | ------------------------- first implementation here +LL | struct LocalTy; +LL | impl Trait for ::Assoc {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `::Assoc` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-1.rs b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-1.rs new file mode 100644 index 000000000..c38e3baf5 --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-1.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Id { + type Assoc; +} +impl Id for T { + type Assoc = T; +} + + +// Coherence should be able to reason that `::Assoc: Copy` +// does not hold. +// +// See https://github.com/rust-lang/trait-system-refactor-initiative/issues/51 +// for more details. +trait Trait {} +impl Trait for T {} +struct LocalTy; +impl Trait for ::Assoc {} + +fn main() {} diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-2.rs b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-2.rs new file mode 100644 index 000000000..2d53266db --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-2.rs @@ -0,0 +1,25 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +use std::future::{Future, IntoFuture}; +use std::pin::Pin; + +// We check that this does not overlap with the following impl from std: +// impl

Future for Pin

where P: DerefMut,

::Target: Future { .. } +// This should fail because we know ` <&mut Value as Deref>::Target: Future` not to hold. +// For this to work we have to normalize in the `trait_ref_is_knowable` check as we +// otherwise add an ambiguous candidate here. +// +// See https://github.com/rust-lang/trait-system-refactor-initiative/issues/51 +// for more details. +struct Value; +impl<'a> IntoFuture for Pin<&'a mut Value> { + type Output = (); + type IntoFuture = Pin + Send>>; + + fn into_future(self) -> Self::IntoFuture { + todo!() + } +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-3.rs b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-3.rs new file mode 100644 index 000000000..2f27de4e4 --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-3.rs @@ -0,0 +1,24 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Id { + type Assoc; +} +impl Id for T { + type Assoc = T; +} + + +// Coherence should be able to reason that `(): PartialEq<::Assoc>>` +// does not hold. +// +// See https://github.com/rust-lang/trait-system-refactor-initiative/issues/51 +// for more details. +trait Trait {} +impl Trait for T +where + (): PartialEq {} +struct LocalTy; +impl Trait for ::Assoc {} + +fn main() {} diff --git a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs b/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs new file mode 100644 index 000000000..fcafdcf63 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs @@ -0,0 +1,32 @@ +// compile-flags: -Ztrait-solver=next + +// Proving `W: Trait` instantiates `?0` with `(W, W)` and then +// proves `W: Trait` and `W: Trait`, resulting in a coinductive cycle. +// +// Proving coinductive cycles runs until we reach a fixpoint. This fixpoint is +// never reached here and each step doubles the amount of nested obligations. +// +// This previously caused a hang in the trait solver, see +// https://github.com/rust-lang/trait-system-refactor-initiative/issues/13. + +#![feature(rustc_attrs)] + +#[rustc_coinductive] +trait Trait {} + +struct W(T); + +impl Trait for W<(W, W)> +where + W: Trait, + W: Trait, +{ +} + +fn impls() {} + +fn main() { + impls::>(); + //~^ ERROR type annotations needed + //~| ERROR overflow evaluating the requirement +} diff --git a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr b/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr new file mode 100644 index 000000000..7d3535e1f --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr @@ -0,0 +1,23 @@ +error[E0282]: type annotations needed + --> $DIR/fixpoint-exponential-growth.rs:29:5 + | +LL | impls::>(); + | ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls` + +error[E0275]: overflow evaluating the requirement `W<_>: Trait` + --> $DIR/fixpoint-exponential-growth.rs:29:5 + | +LL | impls::>(); + | ^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`fixpoint_exponential_growth`) +note: required by a bound in `impls` + --> $DIR/fixpoint-exponential-growth.rs:26:13 + | +LL | fn impls() {} + | ^^^^^ required by this bound in `impls` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0275, E0282. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs b/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs new file mode 100644 index 000000000..0cd14f05c --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs @@ -0,0 +1,69 @@ +// compile-flags: -Ztrait-solver=next +#![feature(rustc_attrs)] + +// This test is incredibly subtle. At its core the goal is to get a coinductive cycle, +// which, depending on its root goal, either holds or errors. We achieve this by getting +// incomplete inference via a `ParamEnv` candidate in the `A` impl and required +// inference from an `Impl` candidate in the `B` impl. +// +// To make global cache accesses stronger than the guidance from the where-bounds, we add +// another coinductive cycle from `A: Trait` to `A: Trait` and only +// constrain `D` directly. This means that any candidates which rely on `V` only make +// progress in the second iteration, allowing a cache access in the first iteration to take +// precedence. +// +// tl;dr: our caching of coinductive cycles was broken and this is a regression +// test for that. + +#[rustc_coinductive] +trait Trait {} +struct A(*const T); +struct B(*const T); + +trait IncompleteGuidance {} +impl IncompleteGuidance for T {} +impl IncompleteGuidance for T {} +impl IncompleteGuidance for T {} + +trait ImplGuidance {} +impl ImplGuidance for T {} +impl ImplGuidance for T {} + +impl Trait for A +where + T: IncompleteGuidance, + A: Trait, + B: Trait, + (): ToU8, +{ +} + +trait ToU8 {} +impl ToU8 for () {} + +impl Trait for B +where + T: ImplGuidance, + A: Trait, +{ +} + +fn impls_trait, U: ?Sized, V: ?Sized, D: ?Sized>() {} + +fn with_bound() +where + X: IncompleteGuidance, + X: IncompleteGuidance, + X: IncompleteGuidance, +{ + impls_trait::, _, _, _>(); // entering the cycle from `B` works + + // entering the cycle from `A` fails, but would work if we were to use the cache + // result of `B`. + impls_trait::, _, _, _>(); + //~^ ERROR the trait bound `A: Trait<_, _, _>` is not satisfied +} + +fn main() { + with_bound::(); +} diff --git a/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.stderr b/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.stderr new file mode 100644 index 000000000..f1871ff05 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `A: Trait<_, _, _>` is not satisfied + --> $DIR/incompleteness-unstable-result.rs:63:19 + | +LL | impls_trait::, _, _, _>(); + | ^^^^ the trait `Trait<_, _, _>` is not implemented for `A` + | + = help: the trait `Trait` is implemented for `A` +note: required by a bound in `impls_trait` + --> $DIR/incompleteness-unstable-result.rs:51:28 + | +LL | fn impls_trait, U: ?Sized, V: ?Sized, D: ?Sized>() {} + | ^^^^^^^^^^^^^^ required by this bound in `impls_trait` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.rs b/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.rs new file mode 100644 index 000000000..5617e45ad --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.rs @@ -0,0 +1,37 @@ +// compile-flags: -Ztrait-solver=next +#![feature(rustc_attrs)] + +// Test that having both an inductive and a coinductive cycle +// is handled correctly. + +#[rustc_coinductive] +trait Trait {} +impl Trait for T {} + +trait Inductive {} +impl Inductive for T {} +#[rustc_coinductive] +trait Coinductive {} +impl Coinductive for T {} + +fn impls_trait() {} + +#[rustc_coinductive] +trait TraitRev {} +impl TraitRev for T {} + +trait InductiveRev {} +impl InductiveRev for T {} +#[rustc_coinductive] +trait CoinductiveRev {} +impl CoinductiveRev for T {} + +fn impls_trait_rev() {} + +fn main() { + impls_trait::<()>(); + //~^ ERROR overflow evaluating the requirement + + impls_trait_rev::<()>(); + //~^ ERROR overflow evaluating the requirement +} diff --git a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr b/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr new file mode 100644 index 000000000..4b8846da5 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr @@ -0,0 +1,29 @@ +error[E0275]: overflow evaluating the requirement `(): Trait` + --> $DIR/double-cycle-inductive-coinductive.rs:32:5 + | +LL | impls_trait::<()>(); + | ^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`double_cycle_inductive_coinductive`) +note: required by a bound in `impls_trait` + --> $DIR/double-cycle-inductive-coinductive.rs:17:19 + | +LL | fn impls_trait() {} + | ^^^^^ required by this bound in `impls_trait` + +error[E0275]: overflow evaluating the requirement `(): TraitRev` + --> $DIR/double-cycle-inductive-coinductive.rs:35:5 + | +LL | impls_trait_rev::<()>(); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`double_cycle_inductive_coinductive`) +note: required by a bound in `impls_trait_rev` + --> $DIR/double-cycle-inductive-coinductive.rs:29:23 + | +LL | fn impls_trait_rev() {} + | ^^^^^^^^ required by this bound in `impls_trait_rev` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.rs b/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.rs new file mode 100644 index 000000000..cda987898 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.rs @@ -0,0 +1,48 @@ +// compile-flags: -Ztrait-solver=next +#![feature(trivial_bounds, marker_trait_attr)] +#![allow(trivial_bounds)] +// This previously triggered a bug in the provisional cache. +// +// This has the proof tree +// - `MultipleCandidates: Trait` proven via impl-one +// - `MultipleNested: Trait` via impl +// - `MultipleCandidates: Trait` (inductive cycle ~> OVERFLOW) +// - `DoesNotImpl: Trait` (ERR) +// - `MultipleCandidates: Trait` proven via impl-two +// - `MultipleNested: Trait` (in provisional cache ~> OVERFLOW) +// +// We previously incorrectly treated the `MultipleCandidates: Trait` as +// overflow because it was in the cache and reached via an inductive cycle. +// It should be `NoSolution`. + +struct MultipleCandidates; +struct MultipleNested; +struct DoesNotImpl; + +#[marker] +trait Trait {} + +// impl-one +impl Trait for MultipleCandidates +where + MultipleNested: Trait +{} + +// impl-two +impl Trait for MultipleCandidates +where + MultipleNested: Trait, +{} + +impl Trait for MultipleNested +where + MultipleCandidates: Trait, + DoesNotImpl: Trait, +{} + +fn impls_trait() {} + +fn main() { + impls_trait::(); + //~^ ERROR the trait bound `MultipleCandidates: Trait` is not satisfied +} diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.stderr b/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.stderr new file mode 100644 index 000000000..57227321a --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `MultipleCandidates: Trait` is not satisfied + --> $DIR/inductive-cycle-but-err.rs:46:19 + | +LL | impls_trait::(); + | ^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `MultipleCandidates` + | + = help: the trait `Trait` is implemented for `MultipleCandidates` +note: required by a bound in `impls_trait` + --> $DIR/inductive-cycle-but-err.rs:43:19 + | +LL | fn impls_trait() {} + | ^^^^^ required by this bound in `impls_trait` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-ok.rs b/tests/ui/traits/new-solver/cycles/inductive-cycle-but-ok.rs new file mode 100644 index 000000000..d4851eb69 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/inductive-cycle-but-ok.rs @@ -0,0 +1,44 @@ +// compile-flags: -Ztrait-solver=next +// check-pass +#![feature(trivial_bounds, marker_trait_attr)] +#![allow(trivial_bounds)] + +// This previously triggered a bug in the provisional cache. +// +// This has the proof tree +// - `Root: Trait` proven via impl +// - `MultipleCandidates: Trait` +// - candidate: overflow-impl +// - `Root: Trait` (inductive cycle ~> OVERFLOW) +// - candidate: trivial-impl ~> YES +// - merge respones ~> YES +// - `MultipleCandidates: Trait` (in provisional cache ~> OVERFLOW) +// +// We previously incorrectly treated the `MultipleCandidates: Trait` as +// overflow because it was in the cache and reached via an inductive cycle. +// It should be `YES`. + +struct Root; +struct MultipleCandidates; + +#[marker] +trait Trait {} +impl Trait for Root +where + MultipleCandidates: Trait, + MultipleCandidates: Trait, +{} + +// overflow-impl +impl Trait for MultipleCandidates +where + Root: Trait, +{} +// trivial-impl +impl Trait for MultipleCandidates {} + +fn impls_trait() {} + +fn main() { + impls_trait::(); +} diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs b/tests/ui/traits/new-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs new file mode 100644 index 000000000..530e6d0ec --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs @@ -0,0 +1,36 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +#![feature(rustc_attrs, marker_trait_attr)] +#[rustc_coinductive] +trait Trait {} + +impl Trait for (T, U) +where + (U, T): Trait, + (T, U): Inductive, + (): ConstrainToU32, +{} + +trait ConstrainToU32 {} +impl ConstrainToU32 for () {} + +// We only prefer the candidate without an inductive cycle +// once the inductive cycle has the same constraints as the +// other goal. +#[marker] +trait Inductive {} +impl Inductive for (T, U) +where + (T, U): Trait, +{} + +impl Inductive for (u32, u32) {} + +fn impls_trait() +where + (T, U): Trait, +{} + +fn main() { + impls_trait::<_, _>(); +} diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs new file mode 100644 index 000000000..3cfe7ab87 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs @@ -0,0 +1,46 @@ +// compile-flags: -Ztrait-solver=next +#![feature(rustc_attrs, trivial_bounds)] + +// We have to be careful here: +// +// We either have the provisional result of `A -> B -> A` on the +// stack, which is a fully coinductive cycle. Accessing the +// provisional result for `B` as part of the `A -> C -> B -> A` cycle +// has to make sure we don't just use the result of `A -> B -> A` as the +// new cycle is inductive. +// +// Alternatively, if we have `A -> C -> A` first, then `A -> B -> A` has +// a purely inductive stack, so something could also go wrong here. + +#[rustc_coinductive] +trait A {} +#[rustc_coinductive] +trait B {} +trait C {} + +impl A for T {} +impl B for T {} +impl C for T {} + +fn impls_a() {} + +// The same test with reordered where clauses to make sure we're actually testing anything. +#[rustc_coinductive] +trait AR {} +#[rustc_coinductive] +trait BR {} +trait CR {} + +impl AR for T {} +impl BR for T {} +impl CR for T {} + +fn impls_ar() {} + +fn main() { + impls_a::<()>(); + // FIXME(-Ztrait-solver=next): This is broken and should error. + + impls_ar::<()>(); + //~^ ERROR overflow evaluating the requirement `(): AR` +} diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr new file mode 100644 index 000000000..0e1c86c1b --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr @@ -0,0 +1,16 @@ +error[E0275]: overflow evaluating the requirement `(): AR` + --> $DIR/inductive-not-on-stack.rs:44:5 + | +LL | impls_ar::<()>(); + | ^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`) +note: required by a bound in `impls_ar` + --> $DIR/inductive-not-on-stack.rs:38:16 + | +LL | fn impls_ar() {} + | ^^ required by this bound in `impls_ar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/cycles/leak-check-coinductive-cycle.rs b/tests/ui/traits/new-solver/cycles/leak-check-coinductive-cycle.rs new file mode 100644 index 000000000..a6d318726 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/leak-check-coinductive-cycle.rs @@ -0,0 +1,33 @@ +// compile-flags: -Ztrait-solver=next +// check-pass +#![feature(rustc_attrs)] + +#[rustc_coinductive] +trait Trait {} +impl<'a, 'b, T> Trait for (&'a (), &'b ()) +where + 'b: 'a, + &'a (): Trait, +{} + +impl Trait for &'static () {} +impl<'a> Trait for &'a () +where + for<'b> (&'a (), &'b ()): Trait, +{} + + +fn impls_trait, U>() {} + +fn main() { + // This infers to `impls_trait::<(&'static (), &'static ()), i32>();` + // + // In the first attempt we have 2 candidates for `&'a (): Trait<_>` + // and we get ambiguity. The result is therefore ambiguity with a `'b: 'a` + // constraint. The next attempt then uses that provisional result when + // trying to apply `impl<'a> Trait for &'a ()`. This means we get a + // `for<'b> 'b: 'a` bound which fails the leak check. Because of this we + // end up with a single impl for `&'a (): Trait<_>` which infers `_` to `i32` + // and succeeds. + impls_trait::<(&(), &()), _>(); +} diff --git a/tests/ui/traits/new-solver/cycles/provisional-result-done.rs b/tests/ui/traits/new-solver/cycles/provisional-result-done.rs new file mode 100644 index 000000000..589d34dd7 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/provisional-result-done.rs @@ -0,0 +1,33 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// This tests checks that we update results in the provisional cache when +// we pop a goal from the stack. +#![feature(auto_traits)] +auto trait Coinductive {} +struct Foo(T); +struct Bar(T); + +impl Coinductive for Foo +where + Bar: Coinductive +{} + +impl Coinductive for Bar +where + Foo: Coinductive, + Bar: ConstrainInfer, +{} + +trait ConstrainInfer {} +impl ConstrainInfer for Bar {} +impl ConstrainInfer for Foo {} + +fn impls() -> T { todo!() } + +fn constrain(_: T) {} + +fn main() { + // This should constrain `_` to `u8`. + impls::>(); +} diff --git a/tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs b/tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs new file mode 100644 index 000000000..c2ac80459 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs @@ -0,0 +1,17 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +use std::fmt::Display; +use std::rc::Rc; + +fn mk(t: Option<&T>) -> Rc { + todo!() +} + +fn main() { + let mut x = None; + let y = mk(x); + // Don't treat the line below as a unsize coercion `Rc ~> Rc` + let z: Rc = y; + x = Some(&1 as &dyn Display); +} diff --git a/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs b/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs new file mode 100644 index 000000000..b241e3bf8 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs @@ -0,0 +1,32 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Eq<'a, 'b, T> {} + +trait Ambig {} +impl Ambig for () {} + +impl<'a, T> Eq<'a, 'a, T> for () where T: Ambig {} + +fn eq<'a, 'b, T>(t: T) +where + (): Eq<'a, 'b, T>, +{ +} + +fn test<'r>() { + let mut x = Default::default(); + + // When we evaluate `(): Eq<'r, 'r, ?0>` we uniquify the regions. + // That leads us to evaluate `(): Eq<'?0, '?1, ?0>`. The response of this + // will be ambiguous (because `?0: Ambig` is ambig) and also not an "identity" + // response, since the region constraints will contain `'?0 == '?1` (so + // `is_changed` will return true). Since it's both ambig and changed, + // fulfillment will both re-register the goal AND loop again. This hits the + // overflow limit. This should neither be considered overflow, nor ICE. + eq::<'r, 'r, _>(x); + + x = (); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs b/tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs new file mode 100644 index 000000000..19a6fa990 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next + +// Test that we don't incorrectly leak unconstrained inference variables +// if the projection contained an error. This caused an ICE in writeback. + +trait Mirror { + type Assoc: ?Sized; +} + +struct Wrapper(T); +impl Mirror for Wrapper { + type Assoc = T; +} + +fn mirror(_: W) -> Box { todo!() } + +fn type_error() -> TypeError { todo!() } +//~^ ERROR cannot find type `TypeError` in this scope + +fn main() { + let x = mirror(type_error()); +} diff --git a/tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr b/tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr new file mode 100644 index 000000000..5a7459ec1 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `TypeError` in this scope + --> $DIR/dont-normalize-proj-with-error.rs:17:20 + | +LL | fn type_error() -> TypeError { todo!() } + | ^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs b/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs index 7d15b8c63..af35a6195 100644 --- a/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs +++ b/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs @@ -1,6 +1,10 @@ // compile-flags: -Ztrait-solver=next // check-pass +// Test that selection prefers the builtin trait object impl for `Any` +// instead of the user defined impl. Both impls apply to the trait +// object. + use std::any::Any; fn needs_usize(_: &usize) {} diff --git a/tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs b/tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs new file mode 100644 index 000000000..29784c32a --- /dev/null +++ b/tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs @@ -0,0 +1,18 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Trivial { + type Assoc; +} + +impl Trivial for T { + type Assoc = (); +} + +fn main() { + // During writeback, we call `normalize_erasing_regions`, which will walk past + // the `for<'a>` binder and try to normalize `<&'a () as Trivial>::Assoc` directly. + // We need to handle this case in the new deep normalizer similarly to how it + // is handled in the old solver. + let x: Option fn(<&'a () as Trivial>::Assoc)> = None; +} diff --git a/tests/ui/traits/new-solver/exponential-trait-goals.rs b/tests/ui/traits/new-solver/exponential-trait-goals.rs deleted file mode 100644 index b37f09ee1..000000000 --- a/tests/ui/traits/new-solver/exponential-trait-goals.rs +++ /dev/null @@ -1,20 +0,0 @@ -// compile-flags: -Ztrait-solver=next - -trait Trait {} - -struct W(T); - -impl Trait for W<(W, W)> -where - W: Trait, - W: Trait, -{ -} - -fn impls() {} - -fn main() { - impls::>(); - //~^ ERROR type annotations needed - //~| ERROR overflow evaluating the requirement `W<_>: Trait` -} diff --git a/tests/ui/traits/new-solver/exponential-trait-goals.stderr b/tests/ui/traits/new-solver/exponential-trait-goals.stderr deleted file mode 100644 index 28a99cbbc..000000000 --- a/tests/ui/traits/new-solver/exponential-trait-goals.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/exponential-trait-goals.rs:17:5 - | -LL | impls::>(); - | ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls` - -error[E0275]: overflow evaluating the requirement `W<_>: Trait` - --> $DIR/exponential-trait-goals.rs:17:5 - | -LL | impls::>(); - | ^^^^^^^^^^^^^ - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`exponential_trait_goals`) -note: required by a bound in `impls` - --> $DIR/exponential-trait-goals.rs:14:13 - | -LL | fn impls() {} - | ^^^^^ required by this bound in `impls` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0275, E0282. -For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs new file mode 100644 index 000000000..b0b9b6bbd --- /dev/null +++ b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs @@ -0,0 +1,73 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// A minimization of an ambiguity when using typenum. See +// https://github.com/rust-lang/trait-system-refactor-initiative/issues/55 +// for more details. +trait Id { + type Assoc: ?Sized; +} +impl Id for T { + type Assoc = T; +} + +trait WithAssoc { + type Assoc: ?Sized; +} + + +struct Leaf; +struct Wrapper(U); + +impl WithAssoc for Leaf { + type Assoc = U; +} + +impl WithAssoc> for Wrapper